提交 54d13dd5 authored 作者: 钟是志's avatar 钟是志

元数据管理

上级 158b70e9
// import fetch from 'dva/fetch'; import fetch from 'dva/fetch';
// import React from 'react'; import React from 'react';
// import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
// import { Select, Button, Modal, Input, Transfer, Row, Col, Form, message, notification } from 'antd'; import { Select, Button, Modal, Input, Transfer, Row, Col, Form, message, notification } from 'antd';
// import { connect } from 'dva'; import { connect } from 'dva';
// import { getToken } from '@/utils/authority'; import { getToken } from '@/utils/authority';
// import config from '@/config/config'; import config from '@/config/config';
// import QueryItem from './QueryItem'; import QueryItem from './QueryItem';
// import OrderItem from './OrderItem'; import OrderItem from './OrderItem';
//
// import FormdataWrapper from '@/utils/object-to-formdata-custom'; import FormdataWrapper from '@/utils/object-to-formdata-custom';
//
// const Option = Select.Option; const Option = Select.Option;
// let keyX = 1; let keyX = 1;
// function swapArray(arr, index1, index2) { function swapArray(arr, index1, index2) {
// arr[index1] = arr.splice(index2, 1, arr[index1])[0]; arr[index1] = arr.splice(index2, 1, arr[index1])[0];
// return arr; return arr;
// } }
// const FormItem = Form.Item; const FormItem = Form.Item;
//
// @connect(({ DataObj, loading }) => ({ @connect(({ DataObj, loading }) => ({
// DataObj, DataObj,
// loading: loading.models.DataObj, loading: loading.models.DataObj,
// })) }))
// @Form.create() @Form.create()
// export default class Index extends React.Component { export default class Index extends React.Component {
// constructor(props) { constructor(props) {
// super(props); super(props);
// this.state = { this.state = {
// visiable: false, visiable: false,
//
// queryVisiable: false, queryVisiable: false,
// groupVisiable: false, groupVisiable: false,
// sortVisiable: false, sortVisiable: false,
// currentQueryKey: null, currentQueryKey: null,
// currentGroupKey: null, currentGroupKey: null,
// orderVisiable: false, orderVisiable: false,
// currentOrderKey: null, currentOrderKey: null,
// querys: [], querys: [],
// orders: [], orders: [],
// groups: [], groups: [],
// gs: [], gs: [],
// os: [], os: [],
// qs: [], qs: [],
// mockData: [], mockData: [],
// targetKeys: [], targetKeys: [],
// sourceSelectedKeys: [], sourceSelectedKeys: [],
// targetSelectedKeys: [], targetSelectedKeys: [],
// infos: {}, infos: {},
// confirmLoading: false, confirmLoading: false,
// }; };
// } }
//
// onSelectChange = (sourceSelectedKeys, targetSelectedKeys) => { onSelectChange = (sourceSelectedKeys, targetSelectedKeys) => {
// this.setState({ sourceSelectedKeys, targetSelectedKeys }); this.setState({ sourceSelectedKeys, targetSelectedKeys });
// }; };
// deleteQuery = (i) => { deleteQuery = (i) => {
// const querys = this.state.querys; const querys = this.state.querys;
// querys.splice(i, 1); querys.splice(i, 1);
// this.setState({ querys }); this.setState({ querys });
// }; };
// deleteOrder = (i) => { deleteOrder = (i) => {
// const orders = this.state.orders; const orders = this.state.orders;
// orders.splice(i, 1); orders.splice(i, 1);
// this.setState({ orders }); this.setState({ orders });
// }; };
// deleteGroup = (i) => { deleteGroup = (i) => {
// const groups = this.state.groups; const groups = this.state.groups;
// groups.splice(i, 1); groups.splice(i, 1);
// this.setState({ groups }); this.setState({ groups });
// }; };
// open = () => { open = () => {
// const { dispatch } = this.props; const { dispatch } = this.props;
// dispatch({ dispatch({
// type: 'DataObj/getExportInfo', type: 'DataObj/getExportInfo',
// payload: { payload: {
// objId: this.props.objId, objId: this.props.objId,
// }, },
// callback: (infos) => { callback: (infos) => {
//
// const mockData = []; const mockData = [];
// const qs = []; const qs = [];
// const gs = []; const gs = [];
// const os = []; const os = [];
// for (var key in infos) { for (var key in infos) {
// const x = infos[key]; const x = infos[key];
// mockData.push({ mockData.push({
// key: x.field, key: x.field,
// title: x.name, title: x.name,
// chosen: false, chosen: false,
// }); });
// if (x.canQuery) { if (x.canQuery) {
// qs.push(x); qs.push(x);
// } }
// if (x.canGroup) { if (x.canGroup) {
// gs.push(x); gs.push(x);
// } }
// if (x.canOrder) { if (x.canOrder) {
// os.push(x); os.push(x);
// } }
// } }
//
// this.setState({ this.setState({
// mockData, infos, visiable: true, qs, gs, os, mockData, infos, visiable: true, qs, gs, os,
// }); });
//
// }, },
// }); });
// }; };
// onCancle = () => { onCancle = () => {
// this.setState({ visiable: false }); this.setState({ visiable: false });
// }; };
// handleChange = (targetKeys, direction, moveKeys) => { handleChange = (targetKeys, direction, moveKeys) => {
//
// this.setState({ targetKeys }); this.setState({ targetKeys });
// }; };
//
// up = () => { up = () => {
// keyX = keyX + 1; keyX = keyX + 1;
// var { targetKeys, targetSelectedKeys } = this.state; var { targetKeys, targetSelectedKeys } = this.state;
// for (var i = 0; i < targetKeys.length; i++) { for (var i = 0; i < targetKeys.length; i++) {
// if (targetKeys[i] === targetSelectedKeys[0]) { if (targetKeys[i] === targetSelectedKeys[0]) {
// if (i === 0) return; if (i === 0) return;
// targetKeys = swapArray(targetKeys, i, i - 1); targetKeys = swapArray(targetKeys, i, i - 1);
//
// break; break;
// } }
// } }
//
// this.setState({ targetKeys }); this.setState({ targetKeys });
// }; };
// down = () => { down = () => {
// keyX = keyX + 1; keyX = keyX + 1;
// var { targetKeys, targetSelectedKeys } = this.state; var { targetKeys, targetSelectedKeys } = this.state;
// for (var i = 0; i < targetKeys.length; i++) { for (var i = 0; i < targetKeys.length; i++) {
// if (targetKeys[i] === targetSelectedKeys[0]) { if (targetKeys[i] === targetSelectedKeys[0]) {
// if (i === targetKeys.length - 1) return; if (i === targetKeys.length - 1) return;
// targetKeys = swapArray(targetKeys, i, i + 1); targetKeys = swapArray(targetKeys, i, i + 1);
//
// break; break;
// } }
// } }
//
// this.setState({ targetKeys }); this.setState({ targetKeys });
// }; };
// bottom = () => { bottom = () => {
// keyX = keyX + 1; keyX = keyX + 1;
// const { targetKeys, targetSelectedKeys } = this.state; const { targetKeys, targetSelectedKeys } = this.state;
// var x = []; var x = [];
// for (var i = 0; i < targetKeys.length; i++) { for (var i = 0; i < targetKeys.length; i++) {
// if (!targetSelectedKeys.includes(targetKeys[i])) { if (!targetSelectedKeys.includes(targetKeys[i])) {
// x.push(targetKeys[i]); x.push(targetKeys[i]);
// } }
// } }
// x = [...x, ...targetSelectedKeys]; x = [...x, ...targetSelectedKeys];
// this.setState({ targetKeys: x }); this.setState({ targetKeys: x });
// }; };
// top = () => { top = () => {
// keyX = keyX + 1; keyX = keyX + 1;
// const { targetKeys, targetSelectedKeys } = this.state; const { targetKeys, targetSelectedKeys } = this.state;
// const x = [...targetSelectedKeys]; const x = [...targetSelectedKeys];
// for (var i = 0; i < targetKeys.length; i++) { for (var i = 0; i < targetKeys.length; i++) {
// if (!targetSelectedKeys.includes(targetKeys[i])) { if (!targetSelectedKeys.includes(targetKeys[i])) {
// x.push(targetKeys[i]); x.push(targetKeys[i]);
// } }
// } }
//
//
// this.setState({ targetKeys: x }); this.setState({ targetKeys: x });
// }; };
// renderItem = (item) => { renderItem = (item) => {
// if (this.state.targetKeys.includes(item.key)) { if (this.state.targetKeys.includes(item.key)) {
// const customLabel = ( const customLabel = (
// <span className="custom-item" key={item.key}> <span className="custom-item" key={item.key}>
// {item.title} {item.title}
//
// </span> </span>
// ); );
// return { return {
// label: customLabel, // for displayed item label: customLabel, // for displayed item
// value: item.title, // for title and filter matching value: item.title, // for title and filter matching
// }; };
//
// } else { } else {
// const customLabel = ( const customLabel = (
// <span className="custom-item" key={item.key}> <span className="custom-item" key={item.key}>
// {item.title} {item.title}
// </span> </span>
// ); );
// return { return {
// label: customLabel, // for displayed item label: customLabel, // for displayed item
// value: item.title, // for title and filter matching value: item.title, // for title and filter matching
// }; };
// } }
// }; };
// addOrder = () => { addOrder = () => {
//
// this.setState({ orderVisiable: true }); this.setState({ orderVisiable: true });
//
// }; };
// okOrder = () => { okOrder = () => {
// const orders = this.state.orders; const orders = this.state.orders;
// orders.push(this.state.infos[this.state.currentOrderKey]); orders.push(this.state.infos[this.state.currentOrderKey]);
// this.setState({ orders, orderVisiable: false, currentOrderKey: null }); this.setState({ orders, orderVisiable: false, currentOrderKey: null });
//
// }; };
// okGroup = () => { okGroup = () => {
// const groups = this.state.groups; const groups = this.state.groups;
// groups.push(this.state.infos[this.state.currentGroupKey]); groups.push(this.state.infos[this.state.currentGroupKey]);
// this.setState({ groups, groupVisiable: false, currentGroupKey: null }); this.setState({ groups, groupVisiable: false, currentGroupKey: null });
// }; };
// addGroup = () => { addGroup = () => {
// this.setState({ groupVisiable: true }); this.setState({ groupVisiable: true });
// }; };
//
// addQuery = () => { addQuery = () => {
// this.setState({ queryVisiable: true }); this.setState({ queryVisiable: true });
// }; };
// okQuery = () => { okQuery = () => {
// const querys = this.state.querys; const querys = this.state.querys;
// querys.push(this.state.infos[this.state.currentQueryKey]); querys.push(this.state.infos[this.state.currentQueryKey]);
// this.setState({ querys, queryVisiable: false, currentQueryKey: null }); this.setState({ querys, queryVisiable: false, currentQueryKey: null });
//
// }; };
// export = () => { export = () => {
// this.props.form.validateFields((err, fieldsValue) => { this.props.form.validateFields((err, fieldsValue) => {
// if (err) return; if (err) return;
// //form.resetFields(); //form.resetFields();
// var qqs; var qqs;
// if (this.props.mustQuerys != null) { if (this.props.mustQuerys != null) {
// qqs = [...this.props.mustQuerys]; qqs = [...this.props.mustQuerys];
// } else { } else {
// qqs = []; qqs = [];
// } }
//
// const oos = []; const oos = [];
// const ggs = []; const ggs = [];
// for (let key in fieldsValue) { for (let key in fieldsValue) {
// var x = key.indexOf('__'); var x = key.indexOf('__');
// let kk = key.substr(x + 2); let kk = key.substr(x + 2);
// if (key.indexOf('q__') > -1) { if (key.indexOf('q__') > -1) {
// qqs.push({ qqs.push({
// notes: this.state.infos[kk].notes, notes: this.state.infos[kk].notes,
// hql: this.state.infos[kk].hql, hql: this.state.infos[kk].hql,
// c: this.state.infos[kk].type, c: this.state.infos[kk].type,
// x: fieldsValue[key].stringX, x: fieldsValue[key].stringX,
// v: fieldsValue[key].string, v: fieldsValue[key].string,
// }); });
//
// } else if (key.indexOf('o__') > -1) { } else if (key.indexOf('o__') > -1) {
// oos.push({ hql: this.state.infos[kk].hql, x: fieldsValue[key].stringX }); oos.push({ hql: this.state.infos[kk].hql, x: fieldsValue[key].stringX });
// } else if (key.indexOf('g__') > -1) { } else if (key.indexOf('g__') > -1) {
// ggs.push({ hql: this.state.infos[kk].hql }); ggs.push({ hql: this.state.infos[kk].hql });
// } }
// } }
//
// if (this.props.voClass && ggs.length === 0) { if (this.props.voClass && ggs.length === 0) {
// message.error('请至少选择一个聚合条件'); message.error('请至少选择一个聚合条件');
// return; return;
// } }
// if (this.state.targetKeys.length === 0) { if (this.state.targetKeys.length === 0) {
// message.error('请至少选择一个导出字段'); message.error('请至少选择一个导出字段');
// return; return;
// } }
// const names = []; const names = [];
// for (let i = 0; i < this.state.targetKeys.length; i++) { for (let i = 0; i < this.state.targetKeys.length; i++) {
// names.push(this.state.infos[this.state.targetKeys[i]].name); names.push(this.state.infos[this.state.targetKeys[i]].name);
// } }
// let divElement = document.getElementById('downloadDiv'); let divElement = document.getElementById('downloadDiv');
// console.log(config.sqlFormsServer); console.log(config.sqlFormsServer);
// let downloadUrl = config.sqlFormsServer + '/DataObjApi/exportFormData?'; let downloadUrl = config.sqlFormsServer + '/DataObjApi/exportFormData?';
// const token = getToken() != null && getToken() != 'null' ? getToken() : '0000'; const token = getToken() != null && getToken() != 'null' ? getToken() : '0000';
// downloadUrl = `${downloadUrl}token=${token}`; downloadUrl = `${downloadUrl}token=${token}`;
// let param = { let param = {
// fields: this.state.targetKeys, fields: this.state.targetKeys,
// names: names, names: names,
// beanName: this.props.beanName, beanName: this.props.beanName,
// querys: JSON.stringify(qqs), querys: JSON.stringify(qqs),
// orders: JSON.stringify(oos), orders: JSON.stringify(oos),
// groups: JSON.stringify(ggs), groups: JSON.stringify(ggs),
// voClass: this.props.voClass, voClass: this.props.voClass,
// objId:this.props.objId, objId:this.props.objId,
// modelClass: this.props.modelClass, modelClass: this.props.modelClass,
// preHandleClass: this.props.preHandleClass, preHandleClass: this.props.preHandleClass,
// hqlHandleClass: this.props.hqlHandleClass, hqlHandleClass: this.props.hqlHandleClass,
//
// }; };
// param = {...param, ...this.props.params || {}} param = {...param, ...this.props.params || {}}
// this.downloadFile(downloadUrl, param); this.downloadFile(downloadUrl, param);
// }); });
//
// }; };
//
// downloadFile(url, params) { downloadFile(url, params) {
// this.setState({ confirmLoading: true }); this.setState({ confirmLoading: true });
//
// fetch(url, { fetch(url, {
// method: 'POST', method: 'POST',
// body: FormdataWrapper(params), body: FormdataWrapper(params),
// }).then(res => { }).then(res => {
// if (res.status != '200') { if (res.status != '200') {
// return res.json(); return res.json();
// } else { } else {
// return res.blob(); return res.blob();
// } }
// }).then(data => { }).then(data => {
// if (data instanceof Blob) { if (data instanceof Blob) {
// let a = document.createElement('a'); let a = document.createElement('a');
// let url = window.URL.createObjectURL(data); let url = window.URL.createObjectURL(data);
// let filename = (this.props.fileName ? this.props.fileName : '导出文件') + '.xlsx'; let filename = (this.props.fileName ? this.props.fileName : '导出文件') + '.xlsx';
// a.href = url; a.href = url;
// a.download = filename; a.download = filename;
// a.click(); a.click();
// window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
// a = null; a = null;
// } else { } else {
// notification.error({ notification.error({
// message: `文件导出错误`, message: `文件导出错误`,
// description: data.errMsg, description: data.errMsg,
// }); });
// } }
//
// }).catch(err => { }).catch(err => {
// notification.error({ notification.error({
// message: `网络请求超时`, message: `网络请求超时`,
// }); });
// }).finally(() => { }).finally(() => {
// this.setState({ confirmLoading: false }); this.setState({ confirmLoading: false });
// }); });
// } }
//
// cancelGroup = () => { cancelGroup = () => {
// this.setState({ currentGroupKey: null, groupVisiable: false }); this.setState({ currentGroupKey: null, groupVisiable: false });
// }; };
// cancelQuery = () => { cancelQuery = () => {
// this.setState({ currentQueryKey: null, queryVisiable: false }); this.setState({ currentQueryKey: null, queryVisiable: false });
// }; };
// cancelOrder = () => { cancelOrder = () => {
// this.setState({ currentOrderKey: null, orderVisiable: false }); this.setState({ currentOrderKey: null, orderVisiable: false });
// }; };
// selectOrder = (e) => { selectOrder = (e) => {
//
// this.setState({ currentOrderKey: e }); this.setState({ currentOrderKey: e });
// }; };
// selectQuery = (e) => { selectQuery = (e) => {
//
// this.setState({ currentQueryKey: e }); this.setState({ currentQueryKey: e });
// }; };
// selectGroup = (e) => { selectGroup = (e) => {
//
// this.setState({ currentGroupKey: e }); this.setState({ currentGroupKey: e });
// }; };
//
// render() { render() {
// const { form } = this.props; const { form } = this.props;
// const { const {
// visiable, targetKeys, sourceSelectedKeys, queryVisiable, querys, orders, groups, confirmLoading, visiable, targetKeys, sourceSelectedKeys, queryVisiable, querys, orders, groups, confirmLoading,
// targetSelectedKeys, mockData, qs, os, gs, currentQueryKey, currentOrderKey, orderVisiable, currentGroupKey, groupVisiable, targetSelectedKeys, mockData, qs, os, gs, currentQueryKey, currentOrderKey, orderVisiable, currentGroupKey, groupVisiable,
// } = this.state; } = this.state;
// return ( return (
// <span> <span>
// <Button shape='round' onClick={this.open}>自定义导出</Button> <Button shape='round' onClick={this.open}>自定义导出</Button>
// <div id='downloadDiv' style={{ display: 'none' }}></div> <div id='downloadDiv' style={{ display: 'none' }}></div>
// <Modal <Modal
// width={670} width={670}
// maskClosable={false} maskClosable={false}
// destroyOnClose destroyOnClose
// title="自定义查询、排序、导出" title="自定义查询、排序、导出"
// style={{ textAlign: 'center' }} style={{ textAlign: 'center' }}
// visible={visiable} visible={visiable}
//
// onOk={this.export} onOk={this.export}
// onCancel={this.onCancle} onCancel={this.onCancle}
// confirmLoading={confirmLoading} confirmLoading={confirmLoading}
// > >
// <div style={{ overflowY: 'auto', maxHeight: '500px', height: '500px' }}> <div style={{ overflowY: 'auto', maxHeight: '500px', height: '500px' }}>
// <div style={{ textAlign: 'left' }}> <div style={{ textAlign: 'left' }}>
// <Button type="primary">新增查询条件</Button> <Button type="primary">新增查询条件</Button>
//
//
// <Select style={{ width: 200, paddingRight: '10px' }} <Select style={{ width: 200, paddingRight: '10px' }}
// value={currentQueryKey} value={currentQueryKey}
// onChange={this.selectQuery}> onChange={this.selectQuery}>
// {qs.map((r) => { {qs.map((r) => {
// return <Option key={r.field} return <Option key={r.field}
// value={r.field}> value={r.field}>
// {r.name} {r.name}
// </Option>; </Option>;
// }, },
// )} )}
//
// </Select> </Select>
// {currentQueryKey ? {currentQueryKey ?
// <span style={{ paddingLeft: '0' }}> <span style={{ paddingLeft: '0' }}>
// <Button type="primary" onClick={this.okQuery}>确定</Button> <Button type="primary" onClick={this.okQuery}>确定</Button>
// </span> </span>
// : ''} : ''}
// <div style={{ height: '12px' }}> <div style={{ height: '12px' }}>
//
// </div> </div>
// {querys.map((r, i) => {querys.map((r, i) =>
// <FormItem key={r.name + i} <FormItem key={r.name + i}
// labelCol={{ span: 4 }} labelCol={{ span: 4 }}
// wrapperCol={{ span: 20 }} wrapperCol={{ span: 20 }}
// colon={false} colon={false}
// label={r.name}> label={r.name}>
// {form.getFieldDecorator(i + 'q__' + r.field, { {form.getFieldDecorator(i + 'q__' + r.field, {
// initialValue: { stringX: '=' }, initialValue: { stringX: '=' },
// rules: [{ rules: [{
// validator: (rule, value, callback) => { validator: (rule, value, callback) => {
// var errors = []; var errors = [];
// if (value == null) { if (value == null) {
// errors.push(new Error('请输入查询值!', rule.field)); errors.push(new Error('请输入查询值!', rule.field));
//
// } else { } else {
// if (value.stringX != 'IS NOT NULL' && value.stringX != 'IS NULL' && value.string == null) { if (value.stringX != 'IS NOT NULL' && value.stringX != 'IS NULL' && value.string == null) {
// errors.push(new Error('请输入查询值!', rule.field)); errors.push(new Error('请输入查询值!', rule.field));
// } }
// } }
// callback(errors); callback(errors);
//
// }, },
// }], }],
// })( })(
// <QueryItem obj={r} <QueryItem obj={r}
// key={r.name + i} key={r.name + i}
// deleteQuery={this.deleteQuery.bind(this, i)}/>)} deleteQuery={this.deleteQuery.bind(this, i)}/>)}
// </FormItem>) </FormItem>)
// } }
// </div> </div>
// <div style={{ textAlign: 'left', paddingTop: '15px' }}> <div style={{ textAlign: 'left', paddingTop: '15px' }}>
// <Button type="primary">新增排序条件</Button> <Button type="primary">新增排序条件</Button>
// <Select style={{ width: 200, paddingRight: '10px' }} <Select style={{ width: 200, paddingRight: '10px' }}
// value={currentOrderKey} value={currentOrderKey}
// onChange={this.selectOrder}> onChange={this.selectOrder}>
// {os.map((r) => { {os.map((r) => {
// for (let j = 0; j < orders.length; j++) { for (let j = 0; j < orders.length; j++) {
// if (orders[j].field === r.field) return; if (orders[j].field === r.field) return;
//
// } }
// return <Option key={r.field} value={r.field}>{r.name}</Option>; return <Option key={r.field} value={r.field}>{r.name}</Option>;
// }, },
// )} )}
//
// </Select> </Select>
// {currentOrderKey ? {currentOrderKey ?
// <span style={{ paddingLeft: '0' }}> <span style={{ paddingLeft: '0' }}>
// <Button type="primary" onClick={this.okOrder}>确定</Button> <Button type="primary" onClick={this.okOrder}>确定</Button>
//
// </span> </span>
// : ''} : ''}
// <div style={{ height: '12px' }}> <div style={{ height: '12px' }}>
//
// </div> </div>
// {orders.map((r, i) => {orders.map((r, i) =>
// <FormItem key={r.name + i} <FormItem key={r.name + i}
// labelCol={{ span: 4 }} labelCol={{ span: 4 }}
// wrapperCol={{ span: 20 }} wrapperCol={{ span: 20 }}
// colon={false} colon={false}
// label={'按' + r.name}> label={'按' + r.name}>
// {form.getFieldDecorator(i + 'o__' + r.field, { {form.getFieldDecorator(i + 'o__' + r.field, {
// initialValue: { stringX: 'desc' }, initialValue: { stringX: 'desc' },
// })( })(
// <OrderItem deleteOrder={this.deleteOrder.bind(this, i)}/>)} <OrderItem deleteOrder={this.deleteOrder.bind(this, i)}/>)}
// </FormItem>)} </FormItem>)}
// </div> </div>
// {this.props.voClass ? {this.props.voClass ?
// <div style={{ textAlign: 'left', paddingTop: '15px' }}> <div style={{ textAlign: 'left', paddingTop: '15px' }}>
// <span style={{ paddingRight: '10px' }}>聚合条件:</span> <span style={{ paddingRight: '10px' }}>聚合条件:</span>
// {!groupVisiable ? {!groupVisiable ?
// <Button type="primary" onClick={this.addGroup}>新增</Button> <Button type="primary" onClick={this.addGroup}>新增</Button>
//
// : :
// <span> <span>
// <Select style={{ width: 100 }} <Select style={{ width: 100 }}
// value={currentGroupKey} value={currentGroupKey}
// onChange={this.selectGroup}> onChange={this.selectGroup}>
// {gs.map((r) => { {gs.map((r) => {
// for (var j = 0; j < groups.length; j++) { for (var j = 0; j < groups.length; j++) {
// if (groups[j].field == r.field) return; if (groups[j].field == r.field) return;
//
// } }
// return <Option key={r.field} return <Option key={r.field}
// value={r.field}> value={r.field}>
// {r.name} {r.name}
// </Option>; </Option>;
// }, },
// )} )}
// </Select> </Select>
// {currentGroupKey ? {currentGroupKey ?
// <Button type="primary" onClick={this.okGroup}>确定</Button> <Button type="primary" onClick={this.okGroup}>确定</Button>
//
//
// : ''} : ''}
// <Button type="primary" onClick={this.cancelGroup}>取消</Button> <Button type="primary" onClick={this.cancelGroup}>取消</Button>
//
// </span>} </span>}
// {groups.map((r, i) => {groups.map((r, i) =>
// <FormItem key={i + r.name} <FormItem key={i + r.name}
// labelCol={{ span: 5 }} labelCol={{ span: 5 }}
// wrapperCol={{ span: 15 }} wrapperCol={{ span: 15 }}
// label={'按' + r.name + '聚合'}> label={'按' + r.name + '聚合'}>
// {form.getFieldDecorator(i + 'g__' + r.field)( {form.getFieldDecorator(i + 'g__' + r.field)(
// <Input style={{ display: 'none' }} <Input style={{ display: 'none' }}
// value=""/>)} value=""/>)}
// <Button type="danger" onClick={this.deleteGroup.bind(this, i)}>删除</Button> <Button type="danger" onClick={this.deleteGroup.bind(this, i)}>删除</Button>
//
//
// </FormItem>)} </FormItem>)}
// </div> : ''} </div> : ''}
// <Row> <Row>
// <Col span={24} <Col span={24}
// style={{ textAlign: 'left', paddingTop: '15px' }}> style={{ textAlign: 'left', paddingTop: '15px' }}>
// <span style={{ paddingRight: '10px' }}>导出项:</span> <span style={{ paddingRight: '10px' }}>导出项:</span>
// {/*<Select>*/} </Col>
// {/*{*/} <Col span={18}>
// <Transfer key={keyX}
// {/*}*/} style={{ textAlign: 'left' }}
// {/*</Select>*/} dataSource={mockData}
// </Col> listStyle={{
// <Col span={18}> width: 200,
// <Transfer key={keyX} height: 300,
// style={{ textAlign: 'left' }} }}
// dataSource={mockData} onSelectChange={this.onSelectChange}
// listStyle={{ selectedKeys={[...sourceSelectedKeys, ...targetSelectedKeys]}
// width: 200, rowKey={record => record.key}
// height: 300, targetKeys={targetKeys}
// }} onChange={this.handleChange}
// onSelectChange={this.onSelectChange} render={this.renderItem}
// selectedKeys={[...sourceSelectedKeys, ...targetSelectedKeys]} />
// rowKey={record => record.key} </Col>
// targetKeys={targetKeys} <Col span={2}>
// onChange={this.handleChange} <div style={{ marginTop: 100 }}>
// render={this.renderItem} <Button size="small"
// /> disabled={targetSelectedKeys.length === 0}
// </Col> onClick={this.top}>
// <Col span={2}> 批量置顶
// <div style={{ marginTop: 100 }}> </Button>
// <Button size="small" <Button size="small"
// disabled={targetSelectedKeys.length === 0} style={{ marginTop: 10 }}
// onClick={this.top}> disabled={targetSelectedKeys.length !== 1}
// 批量置顶 onClick={this.up}>
// </Button> 单项上移
// <Button size="small" </Button>
// style={{ marginTop: 10 }} <Button size="small"
// disabled={targetSelectedKeys.length !== 1} style={{ marginTop: 10 }}
// onClick={this.up}> disabled={targetSelectedKeys.length !== 1}
// 单项上移 onClick={this.down}>
// </Button> 单项下移
// <Button size="small" </Button>
// style={{ marginTop: 10 }} <Button size="small"
// disabled={targetSelectedKeys.length !== 1} style={{ marginTop: 10 }}
// onClick={this.down}> disabled={targetSelectedKeys.length === 0}
// 单项下移 onClick={this.bottom}>
// </Button> 批量置底
// <Button size="small" </Button>
// style={{ marginTop: 10 }} </div>
// disabled={targetSelectedKeys.length === 0} </Col>
// onClick={this.bottom}>
// 批量置底 </Row>
// </Button> </div>
// </div> </Modal>
// </Col> </span>
// );
// </Row> }
// </div> }
// </Modal>
// </span>
// );
// }
// }
import React from 'react';
import List from './index';
import GetIdByPath from './GetIdByPath';
const ExportAndDetail = (props) => {
const Authority = {
add: false, // 新增
delete: false, // 删除
detail: true, // 详情
exportUtil: true, // 导出
importUtil: false, // 导入
};
return <GetIdByPath {...props}
Authority={Authority}
/>;
};
export default ExportAndDetail;
...@@ -2,7 +2,7 @@ import React, { Fragment } from 'react'; ...@@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
import { Divider, message, Modal, Popconfirm } from 'antd'; import { Divider, message, Modal, Popconfirm } from 'antd';
import moment from 'moment'; import moment from 'moment';
import router from 'umi/router'; import router from 'umi/router';
// import ExportInfo from '../Export/index'; import ExportInfo from '../Export/index';
import { text, number, date, getFormArrayConfig } from '../config/index'; import { text, number, date, getFormArrayConfig } from '../config/index';
import ButtonDiy from '@/baseComponent/ButtonDiy'; import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '../Shell'; import Shell from '../Shell';
...@@ -50,7 +50,7 @@ const CreateForm = props => { ...@@ -50,7 +50,7 @@ const CreateForm = props => {
fileSpan={{ big: 2, small: 2 }} fileSpan={{ big: 2, small: 2 }}
changeValue={changeFormData} changeValue={changeFormData}
/> />
<div style={{ clear: 'both' }} /> <div style={{ clear: 'both' }}/>
</Modal> </Modal>
); );
}; };
...@@ -79,7 +79,7 @@ class FormList extends React.Component { ...@@ -79,7 +79,7 @@ class FormList extends React.Component {
// 渲染值 // 渲染值
componentDidMount() { componentDidMount() {
const { objId } = this.props; const { objId, Authority } = this.props;
getHead({ dataObjId: objId }, datas => { getHead({ dataObjId: objId }, datas => {
if (!datas) return; if (!datas) return;
this.setState({ formItem: datas }); this.setState({ formItem: datas });
...@@ -116,26 +116,19 @@ class FormList extends React.Component { ...@@ -116,26 +116,19 @@ class FormList extends React.Component {
this.setState({ this.setState({
searchConfig, searchConfig,
}); });
let opt = { /*let opt = {
title: '操作', title: '操作',
render: (text, record) => ( render: (text, record) => (
<Fragment> <Fragment>
<div> <div>
<a onClick={this.modify.bind(this, record)}>编辑</a> <a onClick={this.modify.bind(this, record)}>
<Divider type="vertical" /> 编辑
<Popconfirm </a>
title="确定删除该数据?"
onConfirm={this.delete.bind(this, record)}
okText="确定"
cancelText="取消"
>
<a>删除</a>
</Popconfirm>
</div> </div>
</Fragment> </Fragment>
), ),
}; };
this.columns.push(opt); this.columns.push(opt);*/
this.getPage(); this.getPage();
}); });
} }
...@@ -263,13 +256,12 @@ class FormList extends React.Component { ...@@ -263,13 +256,12 @@ class FormList extends React.Component {
}; };
batchDelete = e => { batchDelete = e => {
const { selectedRows, formItem, objId } = this.state; const { objId } = this.props;
const { selectedRows, formItem } = this.state;
if (!selectedRows) return; if (!selectedRows) return;
const Keys = formItem.filter(i => i.isPrimaryKey).reduce((acc, i) => { const Keys = formItem.filter(i => i.isPrimaryKey).reduce((acc, i) => {
return { ...acc, [i.name]: selectedRows.map(row => row[i.name]).join(',') }; return { ...acc, [i.name]: selectedRows.map(row => row[i.name]).join(',') };
}); });
deleteItem({ keys: JSON.stringify(Keys), objId }, () => { deleteItem({ keys: JSON.stringify(Keys), objId }, () => {
this.setState({ this.setState({
selectedRows: [], selectedRows: [],
...@@ -294,20 +286,11 @@ class FormList extends React.Component { ...@@ -294,20 +286,11 @@ class FormList extends React.Component {
render() { render() {
const { const {
modalVisible, modalVisible, selectedRows, formItem, isAdd,
selectedRows, pageData, showEdit, formData, primaryKey,
formItem, formValues, searchConfig,
isAdd,
objId,
pageData,
showEdit,
formData,
primaryKey,
formValues,
searchConfig,
} = this.state; } = this.state;
const { hasExport, hasImport } = this.props; const { objId, Authority } = this.props;
const parentMethods = { const parentMethods = {
handleAdd: this.handleAdd, handleAdd: this.handleAdd,
handleModalVisible: this.handleModalVisible, handleModalVisible: this.handleModalVisible,
...@@ -343,10 +326,25 @@ class FormList extends React.Component { ...@@ -343,10 +326,25 @@ class FormList extends React.Component {
) : null} ) : null}
<Shell> <Shell>
<div style={{ paddingLeft: '10px', marginTop: '20px' }}> <div style={{ paddingLeft: '10px', marginTop: '20px' }}>
<ButtonDiy icon="plus" className="primaryBlue" handleClick={this.add} name="新建" /> {
{/* {hasImport && <ImportUtil objId={objId} />} Authority && Authority.add === false ? null :
{hasExport && <ExportInfo objId={objId} />}*/} <ButtonDiy icon="plus"
<ButtonDiy handleClick={this.batchDelete} name="批量删除" /> className="primaryBlue"
handleClick={this.add}
name="新建"/>
}
{
Authority && Authority.delete === false ? null :
<ButtonDiy handleClick={this.batchDelete}
name="批量删除"/>
}
{
Authority && Authority.exportUtil === false ? null :
<ExportInfo objId={objId}/>
}
{/* <ImportUtil objId={objId} />*/}
</div> </div>
<StandardTable <StandardTable
rowKey="row_id" rowKey="row_id"
...@@ -360,7 +358,7 @@ class FormList extends React.Component { ...@@ -360,7 +358,7 @@ class FormList extends React.Component {
</Fragment> </Fragment>
)} )}
<CreateForm {...parentMethods} modalVisible={modalVisible} /> <CreateForm {...parentMethods} modalVisible={modalVisible}/>
</> </>
); );
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论