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

自定义导入bug

上级 ca6a992d
...@@ -459,7 +459,7 @@ export default class StatisticsInfo extends React.Component { ...@@ -459,7 +459,7 @@ export default class StatisticsInfo extends React.Component {
}; };
componentDidMount() { componentDidMount() {
this.open(); // this.open();
} }
pageConfig = (item = 0) => { pageConfig = (item = 0) => {
......
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import { import {
Button, Button,
Card, Card,
DatePicker, DatePicker,
Divider, Divider,
Table, Table,
Form, Form,
Row, Row,
Col, Col,
Input, Input,
InputNumber, InputNumber,
message, message,
Modal, Modal,
Select, Select,
Tree, Tree,
Popconfirm, Popconfirm,
Tooltip, Tooltip,
Spin, Spin,
} from 'antd'; } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import PageHeaderWrapper from './PageHeaderWrapper'; import PageHeaderWrapper from './PageHeaderWrapper';
...@@ -35,1377 +35,1385 @@ import { isEmpty } from 'lodash'; ...@@ -35,1377 +35,1385 @@ import { isEmpty } from 'lodash';
import FilePreview from '@/webPublic/one_stop_public/filePreview'; import FilePreview from '@/webPublic/one_stop_public/filePreview';
import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig'; import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
import UploadCom from '@/webPublic/one_stop_public/libs/UploadCom'; import UploadCom from '@/webPublic/one_stop_public/libs/UploadCom';
const FormItem = Form.Item; const FormItem = Form.Item;
let AllWidth = 0; // 表格总长度 let AllWidth = 0; // 表格总长度
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const TreeNode = Tree.TreeNode; const TreeNode = Tree.TreeNode;
const text = [ const text = [
'BINARY', 'BINARY',
'BIT', 'BIT',
'BLOB', 'BLOB',
'CHAR', 'CHAR',
'GEOMETRY', 'GEOMETRY',
'GEOMETRYCOLLECTION', 'GEOMETRYCOLLECTION',
'JSON', 'JSON',
'LINESTRING', 'LINESTRING',
'LONGBLOB', 'LONGBLOB',
'LONGTEXT', 'LONGTEXT',
'MEDIUMBLOB', 'MEDIUMBLOB',
'MEDIUMINT', 'MEDIUMINT',
'MEDIUMTEXT', 'MEDIUMTEXT',
'MULTILINESTRING', 'MULTILINESTRING',
'MULTIPOINT', 'MULTIPOINT',
'MULTIPOLYGON', 'MULTIPOLYGON',
'POINT', 'POINT',
'POLYGON', 'POLYGON',
'REAL', 'REAL',
'DECIMAL', 'DECIMAL',
'ENUM', 'ENUM',
'SET', 'SET',
'TEXT', 'TEXT',
'TINYBLOB', 'TINYBLOB',
'TIBYTEXT', 'TIBYTEXT',
'VARBINARY', 'VARBINARY',
'VARCHAR', 'VARCHAR',
]; ];
const number = ['BIGINT', 'DOUBLE', 'FLOAT', 'INT', 'INTEGER', 'NUMERIC', 'SMALLINT', 'TINYINT']; const number = ['BIGINT', 'DOUBLE', 'FLOAT', 'INT', 'INTEGER', 'NUMERIC', 'SMALLINT', 'TINYINT'];
const data = ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR']; const data = ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'];
const CreateForm = Form.create()(props => { const CreateForm = Form.create()((props) => {
const { const {
modalVisible, modalVisible,
form, form,
handleAdd, handleAdd,
formLoading, formLoading,
formData, formData,
isAdd, isAdd,
handleModalVisible, handleModalVisible,
formItem, formItem,
getItem, getItem,
isView, isView,
} = props; } = props;
//通过回调 //通过回调
const okHandle = () => { const okHandle = () => {
form.validateFields((err, fieldsValue) => { form.validateFields((err, fieldsValue) => {
if (err) return; if (err) return;
if (isView) { if (isView) {
handleModalVisible(); handleModalVisible();
return; return;
} }
formItem.map((item, index) => { formItem.map((item, index) => {
if (item.type.indexOf('DATE') > -1) { if (item.type.indexOf('DATE') > -1) {
for (let d in fieldsValue) { for (let d in fieldsValue) {
if (item.name === d && fieldsValue[d]) { if (item.name === d && fieldsValue[d]) {
fieldsValue[d] = fieldsValue[d].format('YYYY-MM-DD HH:mm:ss'); fieldsValue[d] = fieldsValue[d].format('YYYY-MM-DD HH:mm:ss');
} }
} }
} }
}); });
let params = { ...fieldsValue }; let params = { ...fieldsValue };
handleAdd(params, isAdd); handleAdd(params, isAdd);
}); });
}; };
//需要获取动态表单 //需要获取动态表单
return ( return (
<Modal <Modal
width="700px" width="700px"
maskClosable={false} maskClosable={false}
destroyOnClose destroyOnClose
title={isView ? '查看详情' : isAdd ? '新增' : '编辑'} title={isView ? '查看详情' : isAdd ? '新增' : '编辑'}
visible={modalVisible} visible={modalVisible}
footer={ footer={
isView isView
? null ? null
: [ : [
<Button key="back" onClick={() => handleModalVisible()}> <Button key="back" onClick={() => handleModalVisible()}>
取消 取消
</Button>, </Button>,
<Button key="submit" type="primary" onClick={okHandle}> <Button key="submit" type="primary" onClick={okHandle}>
确定 确定
</Button>, </Button>,
] ]
} }
onOk={okHandle} onOk={okHandle}
onCancel={() => handleModalVisible()} onCancel={() => handleModalVisible()}>
> {formItem.map((item, index) =>
{formItem.map((item, index) => getItem(false, form, item, isAdd, formData, { span: 5 }, { span: 15 }),
getItem(false, form, item, isAdd, formData, { span: 5 }, { span: 15 }), )}
)} </Modal>
</Modal> );
);
}); });
@connect(({ formList, loading }) => ({ @connect(({ formList, loading }) => ({
formList, formList,
loading: loading.models.formList, loading: loading.models.formList,
})) }))
@Form.create() @Form.create()
class TreeList extends React.Component { class TreeList extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
const { const {
json: { treeTitleName, treeKeyName }, json: { treeTitleName, treeKeyName },
} = this.props; } = this.props;
const root = {}; const root = {};
root[treeTitleName] = '根目录'; root[treeTitleName] = '根目录';
root[treeKeyName] = '0-0'; root[treeKeyName] = '0-0';
this.state = { this.state = {
data: { data: {
list: [], list: [],
pagination: {}, pagination: {},
}, },
treeData: [root], treeData: [root],
isReady: false, isReady: false,
parentName: '根节点', parentName: '根节点',
parentId: null, parentId: null,
selects: [], selects: [],
modalVisible: false, modalVisible: false,
formData: null, formData: null,
formValues: {}, formValues: {},
formItem: [], formItem: [],
objId: this.props.objId || (this.props.location ? this.props.location.state.id : null), objId: this.props.objId || (this.props.location ? this.props.location.state.id : null),
isAdd: false, isAdd: false,
querys: [], querys: [],
selectedRows: [], selectedRows: [],
primaryKey: null, primaryKey: null,
options: {}, options: {},
isTable: true, isTable: true,
tableWidth: 500, tableWidth: 500,
rights: this.props.rights || [], rights: this.props.rights || [],
columnRights: [], columnRights: [],
isReady: false, isReady: false,
groups: {}, groups: {},
showDiv: '', showDiv: '',
showMobileDiv: '', showMobileDiv: '',
isView: false, isView: false,
}; };
} }
columns = []; columns = [];
getOptions = () => { getOptions = () => {
const refIds = []; const refIds = [];
for (var i = 0; i < this.state.formItem.length; i++) { for (var i = 0; i < this.state.formItem.length; i++) {
if ( if (
this.state.formItem[i].referenceObjId != null && this.state.formItem[i].referenceObjId != null &&
this.state.options[this.state.formItem[i].id + ''] == null this.state.options[this.state.formItem[i].id + ''] == null
) { ) {
refIds.push(datas[t].id); refIds.push(datas[t].id);
} }
} }
if (refIds.length > 0) { if (refIds.length > 0) {
dispatch({ dispatch({
type: 'formList/getBatchOptions', type: 'formList/getBatchOptions',
payload: { ids: refIds }, payload: { ids: refIds },
callback: options => { callback: (options) => {
this.setState({ options: { ...this.state.options, ...options } }); this.setState({ options: { ...this.state.options, ...options } });
}, },
}); });
} }
}; };
getList = (values, callback,isFirst) => { getList = (values, callback, isFirst) => {
const { const {
dispatch, dispatch,
json: { treeParentIdName,ctgFilterSql}, json: { treeParentIdName, ctgFilterSql },
} = this.props; } = this.props;
if (!values) { if (!values) {
values = this.state.formValues; values = this.state.formValues;
} }
dispatch({ dispatch({
type: 'formList/tree', type: 'formList/tree',
payload: { ...values,ctgFilterSql:ctgFilterSql, parentIdName: treeParentIdName, dataObjId: this.state.objId }, payload: {
callback: callback, ...values,
}); ctgFilterSql: ctgFilterSql,
}; parentIdName: treeParentIdName,
modify = record => { dataObjId: this.state.objId,
// if (this.state.formItem.length < 10) { },
this.getOptions(); callback: callback,
this.setState({ });
formData: record, };
modalVisible: true, modify = (record) => {
isAdd: false, // if (this.state.formItem.length < 10) {
isView: false, this.getOptions();
}); this.setState({
// } else { formData: record,
// router.push({ modalVisible: true,
// pathname: '/admin/ddl/dataObj/formEdit', isAdd: false,
// state: { isView: false,
// id: this.state.objId, });
// recordId: record[this.state.primaryKey], // } else {
// recordKey: this.state.primaryKey, // router.push({
// isAdd: false, // pathname: '/admin/ddl/dataObj/formEdit',
// isView:false // state: {
// }, // id: this.state.objId,
// }); // recordId: record[this.state.primaryKey],
// } // recordKey: this.state.primaryKey,
}; // isAdd: false,
// isView:false
view = record => { // },
// if (this.state.formItem.length < 10) { // });
this.getOptions(); // }
this.setState({ };
formData: record,
modalVisible: true, view = (record) => {
isAdd: false, // if (this.state.formItem.length < 10) {
isView: true, this.getOptions();
}); this.setState({
// } else { formData: record,
// router.push({ modalVisible: true,
// pathname: '/admin/ddl/dataObj/formEdit', isAdd: false,
// state: { isView: true,
// id: this.state.objId, });
// recordId: record[this.state.primaryKey], // } else {
// recordKey: this.state.primaryKey, // router.push({
// isAdd: false, // pathname: '/admin/ddl/dataObj/formEdit',
// isView:true // state: {
// }, // id: this.state.objId,
// }); // recordId: record[this.state.primaryKey],
// } // recordKey: this.state.primaryKey,
}; // isAdd: false,
// isView:true
isJSON = str => { // },
if (typeof str == 'string') { // });
try { // }
var obj = JSON.parse(str); };
if (typeof obj == 'object' && obj) {
return true; isJSON = (str) => {
} else { if (typeof str == 'string') {
return false; try {
} var obj = JSON.parse(str);
} catch (e) { if (typeof obj == 'object' && obj) {
console.log('error:' + str + '!!!' + e); return true;
return false; } else {
} return false;
} }
console.log('这不是个字符串'); } catch (e) {
}; console.log('error:' + str + '!!!' + e);
return false;
delete = record => { }
//找出主键 }
let Keys = {}; console.log('这不是个字符串');
Keys[this.state.primaryKey] = record[this.state.primaryKey]; };
this.props.dispatch({
type: 'formList/delete', delete = (record) => {
payload: { //找出主键
keys: JSON.stringify(Keys), let Keys = {};
objId: this.state.objId, Keys[this.state.primaryKey] = record[this.state.primaryKey];
}, this.props.dispatch({
callback: () => { type: 'formList/delete',
this.getPage({ parentId: this.state.parentId }, null, null, list => { payload: {
const treeData = this.refesh(this.state.parentId, list, this.state.treeData); keys: JSON.stringify(Keys),
this.setState({ objId: this.state.objId,
modalVisible: false, },
treeData, callback: () => {
}); this.getPage({ parentId: this.state.parentId }, null, null, (list) => {
}); const treeData = this.refesh(this.state.parentId, list, this.state.treeData);
}, this.setState({
}); modalVisible: false,
}; treeData,
});
viewProcess = record => { });
const { dispatch } = this.props; },
dispatch({ });
type: 'formList/getAppId', };
payload: {
code: record.process_biz_key, viewProcess = (record) => {
}, const { dispatch } = this.props;
callback: data => { dispatch({
router.push({ pathname: '/portal/serviceCentre/getdetail', state: { id: data.id } }); type: 'formList/getAppId',
}, payload: {
}); code: record.process_biz_key,
}; },
callback: (data) => {
/** router.push({ pathname: '/portal/serviceCentre/getdetail', state: { id: data.id } });
* 宽度自适应函数 },
*/ });
resize = e => { };
let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
let showMobileDiv = scrollWidth - 77; /**
if (document.querySelector('#previewDiv')) { * 宽度自适应函数
// 预览模式 */
this.setState({ resize = (e) => {
showMobileDiv: document.querySelector('#previewDiv').clientWidth - 77, let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
}); let showMobileDiv = scrollWidth - 77;
} else { if (document.querySelector('#previewDiv')) {
this.setState({ // 预览模式
showMobileDiv, this.setState({
}); showMobileDiv: document.querySelector('#previewDiv').clientWidth - 77,
} });
}; } else {
//渲染值 this.setState({
componentDidMount() { showMobileDiv,
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props; });
window.addEventListener('resize', this.resize); }
if (this.props.objCode) { };
const { dispatch, objCode, sql } = this.props;
//渲染值
if (objCode == 1 || objCode == '1') { componentDidMount() {
this.initColumn(); const { dispatch, isFormCom, isSelect, callback, valueName } = this.props;
} else { window.addEventListener('resize', this.resize);
dispatch({ if (this.props.objCode) {
type: 'DataObj/findByCode', const { dispatch, objCode, sql } = this.props;
payload: { objCode: this.props.objCode },
callback: dataObj => { if (objCode == 1 || objCode == '1') {
this.setState({ objId: dataObj.id, isTable: data.isTable }, () => { this.initColumn();
dispatch({ } else {
type: 'DataRight/getUserRight', dispatch({
payload: { objId: this.state.objId }, type: 'DataObj/findByCode',
callback: data => { payload: { objCode: this.props.objCode },
if (!this.props.rights) { callback: (dataObj) => {
this.setState({ rights: data }); this.setState({ objId: dataObj.id, isTable: data.isTable }, () => {
} dispatch({
dispatch({ type: 'DataRight/getUserRight',
type: 'DataRight/getUserColumnRight', payload: { objId: this.state.objId },
payload: { objId: this.state.objId }, callback: (data) => {
callback: data => { if (!this.props.rights) {
this.setState({ columnRights: data }); this.setState({ rights: data });
this.initColumn(); }
}, dispatch({
}); type: 'DataRight/getUserColumnRight',
}, payload: { objId: this.state.objId },
}); callback: (data) => {
}); this.setState({ columnRights: data });
}, this.initColumn();
}); },
} });
} else { },
dispatch({ });
type: 'formList/getObjDetail', });
payload: { id: this.state.objId }, },
callback: data => { });
this.setState({ isTable: data.isTable }); }
}, } else {
}); dispatch({
dispatch({ type: 'formList/getObjDetail',
type: 'DataRight/getUserRight', payload: { id: this.state.objId },
payload: { objId: this.state.objId }, callback: (data) => {
callback: data => { this.setState({ isTable: data.isTable });
if (!this.props.rights) { },
this.setState({ rights: data }); });
} dispatch({
dispatch({ type: 'DataRight/getUserRight',
type: 'DataRight/getUserColumnRight', payload: { objId: this.state.objId },
payload: { objId: this.state.objId }, callback: (data) => {
callback: data => { if (!this.props.rights) {
this.setState({ columnRights: data }); this.setState({ rights: data });
this.initColumn(); }
}, dispatch({
}); type: 'DataRight/getUserColumnRight',
}, payload: { objId: this.state.objId },
}); callback: (data) => {
} this.setState({ columnRights: data });
} this.initColumn();
/** },
* 移除监听器 });
*/ },
componentWillUnmount() { });
window.removeEventListener('resize', this.resize); }
} }
custom = this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null;
componentWillReceiveProps(nextProps) { /**
const b = nextProps.value || {}; * 移除监听器
const a = this.props.value || {}; */
componentWillUnmount() {
if (JSON.stringify(a) != JSON.stringify(b)) { window.removeEventListener('resize', this.resize);
const params = { }
pageNo: 1,
pageSize: this.props.pageSize || 10, custom = this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null;
query: JSON.stringify(this.state.formValues),
}; componentWillReceiveProps(nextProps) {
if (nextProps.value.columns != null && nextProps.value.columns.length > 0) { const b = nextProps.value || {};
this.columns = nextProps.value.columns; const a = this.props.value || {};
}
if (JSON.stringify(a) != JSON.stringify(b)) {
this.custom = Base16Encode(JSON.stringify(b)); const params = {
if (nextProps.value.getPage) { pageNo: 1,
this.getPage(params, null, nextProps.value.getPage); pageSize: this.props.pageSize || 10,
} else { query: JSON.stringify(this.state.formValues),
if (this.state.objId) this.getPage(params); };
} if (nextProps.value.columns != null && nextProps.value.columns.length > 0) {
} this.columns = nextProps.value.columns;
const x = nextProps.selects; }
const y = this.props.selects;
if (JSON.stringify(x) != JSON.stringify(y)) { this.custom = Base16Encode(JSON.stringify(b));
this.setState({ selects: x }); if (nextProps.value.getPage) {
} this.getPage(params, null, nextProps.value.getPage);
} } else {
initColumn = () => { if (this.state.objId) this.getPage(params);
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props; }
}
const { rights, columnRights } = this.state; const x = nextProps.selects;
if (this.props.value && this.props.value.columns) { const y = this.props.selects;
this.columns = this.props.value.columns; if (JSON.stringify(x) != JSON.stringify(y)) {
this.getPage(); this.setState({ selects: x });
return; }
} }
if (this.props.objCode == 1 || this.props.objCode == '1') {
} else { initColumn = () => {
dispatch({ const { dispatch, isFormCom, isSelect, callback, valueName } = this.props;
type: 'formList/getHead',
payload: { dataObjId: this.state.objId }, const { rights, columnRights } = this.state;
callback: datas => { if (this.props.value && this.props.value.columns) {
const querys = []; this.columns = this.props.value.columns;
const refIds = []; this.getPage();
const groups = {}; return;
if (datas) { }
this.state.formItem = datas; if (this.props.objCode == 1 || this.props.objCode == '1') {
let i = 0; } else {
dispatch({
for (let t in datas) { type: 'formList/getHead',
if (datas[t].isPrimaryKey) this.state.primaryKey = datas[t].name; payload: { dataObjId: this.state.objId },
if (datas[t].isHidden) { callback: (datas) => {
continue; const querys = [];
} const refIds = [];
let column = {}; const groups = {};
column.title = datas[t].title; if (datas) {
column.dataIndex = datas[t].name; this.state.formItem = datas;
column.width = datas[t].width; let i = 0;
if (i == 0) column.fixed = 'left';
for (let t in datas) {
if (columnRights.length > 0 && !columnRights.includes(datas[t].id)) { if (datas[t].isPrimaryKey) this.state.primaryKey = datas[t].name;
continue; if (datas[t].isHidden) {
} continue;
if (data.includes(datas[t].type)) { }
column.render = val => { let column = {};
if (val == null) { column.title = datas[t].title;
return val; column.dataIndex = datas[t].name;
} column.width = datas[t].width;
if (datas[t].dataFormatStrWeb != null) { if (i == 0) column.fixed = 'left';
return moment(val).format(datas[t].dataFormatStrWeb);
} else { if (columnRights.length > 0 && !columnRights.includes(datas[t].id)) {
return moment(val).format('YYYY-MM-DD HH:mm:ss'); continue;
} }
}; if (data.includes(datas[t].type)) {
} else if (datas[t].name.indexOf('process_status') > -1) { column.render = (val) => {
column.render = val => (val ? (val === '0' ? '审核通过' : '审核未通过') : null); if (val == null) {
} else if (datas[t].extendTypeId && datas[t].extendTypeId.indexOf('file') > -1) { return val;
//特殊处理附件 }
column.render = val => { if (datas[t].dataFormatStrWeb != null) {
if (this.isJSON(val)) { return moment(val).format(datas[t].dataFormatStrWeb);
val = JSON.parse(val); } else {
let files = val.files; return moment(val).format('YYYY-MM-DD HH:mm:ss');
let xx = ( }
<ul> };
{files.map((f, index2) => { } else if (datas[t].name.indexOf('process_status') > -1) {
return ( column.render = (val) => (val ? (val === '0' ? '审核通过' : '审核未通过') : null);
<li key={index2}> } else if (datas[t].extendTypeId && datas[t].extendTypeId.indexOf('file') > -1) {
<FilePreview path={queryApiActionPath() + f.path} pathName={f.name} /> //特殊处理附件
</li> column.render = (val) => {
); if (this.isJSON(val)) {
})} val = JSON.parse(val);
</ul> let files = val.files;
); let xx = (
return xx; <ul>
} else { {files.map((f, index2) => {
return val; return (
} <li key={index2}>
}; <FilePreview path={queryApiActionPath() + f.path} pathName={f.name} />
} else { </li>
column.render = val => );
val && val.length > 100 ? ( })}
<Tooltip title={val} overlayStyle={{ width: 1000 }}> </ul>
<span );
style={{ return xx;
width: column.width || 200, } else {
display: 'block', return val;
wordBreak: 'keep-all', }
whiteSpace: 'nowrap', };
overflow: 'hidden', } else {
textOverflow: 'ellipsis', column.render = (val) =>
}} val && val.length > 100 ? (
> <Tooltip title={val} overlayStyle={{ width: 1000 }}>
{val} <span
</span> style={{
</Tooltip> width: column.width || 200,
) : ( display: 'block',
val wordBreak: 'keep-all',
); whiteSpace: 'nowrap',
} overflow: 'hidden',
textOverflow: 'ellipsis',
this.setState({ tableWidth: (datas.length - 1) * 200 }); }}>
this.columns.push(column); {val}
</span>
if (datas[t].isShowQuery) { </Tooltip>
querys.push(datas[t]); ) : (
if (datas[t].referenceObjId != null) { val
refIds.push(datas[t].id); );
} }
if (datas[t].isGroupQuery != null) {
dispatch({ this.setState({ tableWidth: (datas.length - 1) * 200 });
type: 'formList/getGroupList', this.columns.push(column);
payload: { columnId: datas[t].id },
callback: gourp => { if (datas[t].isShowQuery) {
groups[datas[t].id] = gourp; querys.push(datas[t]);
this.setState({ groups }); if (datas[t].referenceObjId != null) {
}, refIds.push(datas[t].id);
}); }
} if (datas[t].isGroupQuery != null) {
} dispatch({
i++; type: 'formList/getGroupList',
} payload: { columnId: datas[t].id },
if (querys.length > 0) { callback: (gourp) => {
this.setState({ querys }); groups[datas[t].id] = gourp;
if (refIds.length > 0) { this.setState({ groups });
dispatch({ },
type: 'formList/getBatchOptions', });
payload: { ids: refIds }, }
callback: options => { }
this.setState({ options }); i++;
}, }
}); if (querys.length > 0) {
} this.setState({ querys });
} if (refIds.length > 0) {
dispatch({
this.getPage(); type: 'formList/getBatchOptions',
} payload: { ids: refIds },
}, callback: (options) => {
}); this.setState({ options });
} },
}; });
sqlBs16 = Base16Encode(this.props.sql); }
getPage = (params, values, callPage, callback) => { }
if (this.columns == null || this.columns.length == 0) {
return; this.getPage();
} }
const { },
dispatch, });
json: { treeParentIdName }, }
} = this.props; };
const pagination = this.state.data.pagination; sqlBs16 = Base16Encode(this.props.sql);
getPage = (params, values, callPage, callback) => {
if (params == null) { if (this.columns == null || this.columns.length == 0) {
params = { return;
// pageNo: pagination.current ? pagination.current : 1, }
//pageSize: pagination.pageSize ? pagination.pageSize : (this.props.pageSize||10), const {
query: JSON.stringify(values != null ? values : this.state.formValues), dispatch,
}; json: { treeParentIdName },
} } = this.props;
const pagination = this.state.data.pagination;
if (this.props.objCode && (this.props.objCode == '1' || this.props.objCode == 1)) {
if (callPage) { if (params == null) {
callPage(params, data => { params = {
if (!this.state.isReady) { // pageNo: pagination.current ? pagination.current : 1,
this.setState({ data, isReady: true }); //pageSize: pagination.pageSize ? pagination.pageSize : (this.props.pageSize||10),
} else { query: JSON.stringify(values != null ? values : this.state.formValues),
this.setState({ data }); };
} }
});
} else if (this.props.value && this.props.value.getPage) { if (this.props.objCode && (this.props.objCode == '1' || this.props.objCode == 1)) {
this.props.value.getPage(params, data => { if (callPage) {
if (!this.state.isReady) { callPage(params, (data) => {
this.setState({ data, isReady: true }); if (!this.state.isReady) {
} else { this.setState({ data, isReady: true });
this.setState({ data }); } else {
} this.setState({ data });
}); }
} });
} else { } else if (this.props.value && this.props.value.getPage) {
dispatch({ this.props.value.getPage(params, (data) => {
type: 'formList/tree', if (!this.state.isReady) {
payload: { this.setState({ data, isReady: true });
custom: this.custom, } else {
...params, this.setState({ data });
parentIdName: treeParentIdName, }
sql: this.sqlBs16, });
dataObjId: this.state.objId, }
}, } else {
callback: list => { dispatch({
const data = { type: 'formList/tree',
list: list, payload: {
pagination: false, custom: this.custom,
}; ...params,
parentIdName: treeParentIdName,
if (!this.state.isReady) { sql: this.sqlBs16,
this.setState({ data, parentId: params.parentId, isReady: true }, () => { dataObjId: this.state.objId,
if (callback) callback(list); },
}); callback: (list) => {
} else { const data = {
this.setState({ data, parentId: params.parentId }, () => { list: list,
if (callback) callback(list); pagination: false,
}); };
}
}, if (!this.state.isReady) {
}); this.setState({ data, parentId: params.parentId, isReady: true }, () => {
} if (callback) callback(list);
}; });
} else {
handleStandardTableChange = (pagination, filtersArg, sorter) => { this.setState({ data, parentId: params.parentId }, () => {
const filters = Object.keys(filtersArg).reduce((obj, key) => { if (callback) callback(list);
const newObj = { ...obj }; });
newObj[key] = getValue(filtersArg[key]); }
return newObj; },
}, {}); });
}
const params = { };
pageNo: pagination.current,
pageSize: pagination.pageSize, handleStandardTableChange = (pagination, filtersArg, sorter) => {
...filters, const filters = Object.keys(filtersArg).reduce((obj, key) => {
query: JSON.stringify(this.state.formValues), const newObj = { ...obj };
}; newObj[key] = getValue(filtersArg[key]);
if (sorter.field) { return newObj;
params.sorter = `${sorter.field}_${sorter.order}`; }, {});
}
this.getPage(params); const params = {
}; pageNo: pagination.current,
pageSize: pagination.pageSize,
handleAdd = (fields, isAdd) => { ...filters,
const { query: JSON.stringify(this.state.formValues),
json: { treeParentIdName }, };
} = this.props; if (sorter.field) {
let params = { params.sorter = `${sorter.field}_${sorter.order}`;
...fields, }
}; this.getPage(params);
params[treeParentIdName] = this.state.parentId; };
this.props.dispatch({
type: 'formList/add', handleAdd = (fields, isAdd) => {
payload: { const {
params: params, json: { treeParentIdName },
objId: this.state.objId, } = this.props;
isAdd: isAdd, let params = {
isSelf: true, ...fields,
isView: false, };
}, params[treeParentIdName] = this.state.parentId;
callback: () => { this.props.dispatch({
message.success('操作成功'); type: 'formList/add',
payload: {
this.getPage({ parentId: this.state.parentId }, null, null, list => { params: params,
const treeData = this.refesh(this.state.parentId, list, this.state.treeData); objId: this.state.objId,
this.setState({ isAdd: isAdd,
modalVisible: false, isSelf: true,
treeData, isView: false,
}); },
}); callback: () => {
}, message.success('操作成功');
});
}; this.getPage({ parentId: this.state.parentId }, null, null, (list) => {
const treeData = this.refesh(this.state.parentId, list, this.state.treeData);
handleModalVisible = () => { this.setState({
this.setState({ modalVisible: false,
modalVisible: this.state.modalVisible ? false : true, treeData,
formData: {}, });
}); });
}; },
});
add = () => { };
// if (this.state.formItem.length < 10) {
this.getOptions(); handleModalVisible = () => {
this.setState({ this.setState({
modalVisible: true, modalVisible: this.state.modalVisible ? false : true,
formData: {}, formData: {},
isAdd: true, });
isView: false, };
});
// } else { add = () => {
// router.push({ // if (this.state.formItem.length < 10) {
// pathname: '/admin/ddl/dataObj/formEdit', this.getOptions();
// state: { id: this.state.objId,isAdd: true,isView:false } this.setState({
// }); modalVisible: true,
// } formData: {},
}; isAdd: true,
isView: false,
handleSelectRows = rows => { });
if (this.props.onSelectRow) { };
this.props.onSelectRow(rows);
} handleSelectRows = (rows) => {
this.setState({ if (this.props.onSelectRow) {
selectedRows: rows, this.props.onSelectRow(rows);
}); }
}; this.setState({
selectedRows: rows,
batchDelete = e => { });
const { dispatch } = this.props; };
const { selectedRows } = this.state;
batchDelete = (e) => {
if (!selectedRows) return; const { dispatch } = this.props;
const { selectedRows } = this.state;
let columns = this.state.formItem;
let Keys = {}; if (!selectedRows) return;
for (let i in columns) { let columns = this.state.formItem;
if (columns[i].isPrimaryKey) { let Keys = {};
//key
Keys[columns[i].name] = selectedRows.map(row => row[columns[i].name]).join(','); for (let i in columns) {
} if (columns[i].isPrimaryKey) {
} //key
this.props.dispatch({ Keys[columns[i].name] = selectedRows.map((row) => row[columns[i].name]).join(',');
type: 'formList/delete', }
payload: { }
keys: JSON.stringify(Keys), this.props.dispatch({
objId: this.state.objId, type: 'formList/delete',
isSelf: true, payload: {
}, keys: JSON.stringify(Keys),
callback: () => { objId: this.state.objId,
this.setState({ isSelf: true,
selectedRows: [], },
}); callback: () => {
this.getPage(); this.setState({
}, selectedRows: [],
}); });
}; this.getPage();
},
goBack = () => { });
router.goBack(); };
};
handleSearch = e => { goBack = () => {
e.preventDefault(); router.goBack();
};
const { dispatch, form } = this.props; handleSearch = (e) => {
e.preventDefault();
const { formValues } = this.state;
const { dispatch, form } = this.props;
form.validateFields((err, fieldsValue) => {
if (err) return; const { formValues } = this.state;
const formItem = this.state.formItem; form.validateFields((err, fieldsValue) => {
formItem.map((item, index) => { if (err) return;
if (item.type.indexOf('DATE') > -1) {
for (let d in fieldsValue) { const formItem = this.state.formItem;
if (item.name === d && fieldsValue[d]) { formItem.map((item, index) => {
if (fieldsValue[d] != null && fieldsValue[d].length > 0) { if (item.type.indexOf('DATE') > -1) {
fieldsValue[d] = [ for (let d in fieldsValue) {
fieldsValue[d][0].format('YYYY-MM-DD HH:mm:ss'), if (item.name === d && fieldsValue[d]) {
fieldsValue[d][1].format('YYYY-MM-DD HH:mm:ss'), if (fieldsValue[d] != null && fieldsValue[d].length > 0) {
]; fieldsValue[d] = [
} else { fieldsValue[d][0].format('YYYY-MM-DD HH:mm:ss'),
fieldsValue[d] = ''; fieldsValue[d][1].format('YYYY-MM-DD HH:mm:ss'),
} ];
} } else {
} fieldsValue[d] = '';
} }
}); }
const values = { }
...this.state.formValues, }
...fieldsValue, });
}; const values = {
this.setState({ ...this.state.formValues,
formValues: fieldsValue, ...fieldsValue,
}); };
this.setState({
this.getPage(null, values); formValues: fieldsValue,
}); });
};
this.getPage(null, values);
hanldeHighSearch = e => { });
const pagination = this.props.formList.data.pagination; };
let params = {
pageNo: pagination.current ? pagination.current : 1, hanldeHighSearch = (e) => {
pageSize: pagination.pageSize ? pagination.pageSize : this.props.pageSize || 10, const pagination = this.props.formList.data.pagination;
...e, let params = {
}; pageNo: pagination.current ? pagination.current : 1,
this.setState({ formValues: { ...e, ...this.state.formValues } }); pageSize: pagination.pageSize ? pagination.pageSize : this.props.pageSize || 10,
this.getPage(params); ...e,
}; };
handleFormReset = () => { this.setState({ formValues: { ...e, ...this.state.formValues } });
const { form, dispatch } = this.props; this.getPage(params);
form.resetFields(); };
this.setState( handleFormReset = () => {
{ const { form, dispatch } = this.props;
formValues: {}, form.resetFields();
}, this.setState(
() => { {
this.getPage(); formValues: {},
}, },
); () => {
}; this.getPage();
getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => { },
const { groups } = this.state; );
if (item.isPrimaryKey) { };
if (isAdd) { getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => {
return <></>; const { groups } = this.state;
} else { if (item.isPrimaryKey) {
return ( if (isAdd) {
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> return <></>;
{form.getFieldDecorator(item.name, { } else {
initialValue: formData == null ? '' : formData[item.name], return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})(<Input style={{ width: '70%' }} readOnly={!isAdd} placeholder="请输入" />)} {form.getFieldDecorator(item.name, {
</FormItem> initialValue: formData == null ? '' : formData[item.name],
); rules: [{ required: !item.isNull }],
} })(<Input style={{ width: '70%' }} readOnly={!isAdd} placeholder="请输入" />)}
} else if (item.referenceObjId != null) { </FormItem>
const { options } = this.state; );
const ops = options[item.id + ''] || []; }
} else if (item.referenceObjId != null) {
return ( const { options } = this.state;
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> const ops = options[item.id + ''] || [];
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name], return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})( {form.getFieldDecorator(item.name, {
<Select style={{ width: '70%' }} placeholder="请选择" allowClear> initialValue: formData == null ? '' : formData[item.name],
{ops.map(r => ( rules: [{ required: !item.isNull }],
<Option value={r[item.referenceCodeName]} key={r[item.referenceCodeName]}> })(
{r[item.referenceNameName]} <Select style={{ width: '70%' }} placeholder="请选择" allowClear>
</Option> {ops.map((r) => (
))} <Option value={r[item.referenceCodeName]} key={r[item.referenceCodeName]}>
</Select>, {r[item.referenceNameName]}
)} </Option>
</FormItem> ))}
); </Select>,
} else if (item.name.indexOf('process_status') > -1) { )}
return ( </FormItem>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> );
{form.getFieldDecorator(item.name, { } else if (item.name.indexOf('process_status') > -1) {
initialValue: formData == null ? '' : formData[item.name], return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})( {form.getFieldDecorator(item.name, {
<Select style={{ width: '70%' }} placeholder="请选择" allowClear> initialValue: formData == null ? '' : formData[item.name],
<Option value={'0'} key={'0'}> rules: [{ required: !item.isNull }],
审核通过 })(
</Option> <Select style={{ width: '70%' }} placeholder="请选择" allowClear>
<Option value={'2'} key={'2'}> <Option value={'0'} key={'0'}>
审核未通过 审核通过
</Option> </Option>
</Select>, <Option value={'2'} key={'2'}>
)} 审核未通过
</FormItem> </Option>
); </Select>,
} else if (item.extendTypeId && item.extendTypeId.indexOf('file') > -1) { )}
//特殊处理附件 如果是查询就 跳过 </FormItem>
if (isQuery) return; );
return ( } else if (item.extendTypeId && item.extendTypeId.indexOf('file') > -1) {
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> //特殊处理附件 如果是查询就 跳过
{form.getFieldDecorator(item.name, { if (isQuery) return;
initialValue: return (
formData == null <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
? '' {form.getFieldDecorator(item.name, {
: formData[item.name] && this.isJSON(formData[item.name]) initialValue:
? JSON.parse(formData[item.name]) formData == null
: null, ? ''
rules: [{ required: !item.isNull }], : formData[item.name] && this.isJSON(formData[item.name])
})(<UploadCom />)} ? JSON.parse(formData[item.name])
</FormItem> : null,
); rules: [{ required: !item.isNull }],
} else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) { })(<UploadCom />)}
//如果是查询 并且是组合查询 </FormItem>
);
const ops = groups[item.id + ''] || []; } else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) {
return ( //如果是查询 并且是组合查询
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, { const ops = groups[item.id + ''] || [];
initialValue: formData == null ? '' : formData[item.name], return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})( {form.getFieldDecorator(item.name, {
<Select style={{ width: '70%' }} placeholder="请选择" allowClear> initialValue: formData == null ? '' : formData[item.name],
{ops.map(r => ( rules: [{ required: !item.isNull }],
<Option value={r.value} key={r.value}> })(
{r.value} <Select style={{ width: '70%' }} placeholder="请选择" allowClear>
</Option> {ops.map((r) => (
))} <Option value={r.value} key={r.value}>
</Select>, {r.value}
)} </Option>
</FormItem> ))}
); </Select>,
} else if (text.indexOf(item.type) > -1) { )}
return ( </FormItem>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> );
{form.getFieldDecorator(item.name, { } else if (text.indexOf(item.type) > -1) {
initialValue: formData == null ? '' : formData[item.name], return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})(<Input style={{ width: '70%' }} placeholder="请输入" />)} {form.getFieldDecorator(item.name, {
</FormItem> initialValue: formData == null ? '' : formData[item.name],
); rules: [{ required: !item.isNull }],
} else if (number.indexOf(item.type) > -1) { })(<Input style={{ width: '70%' }} placeholder="请输入" />)}
return ( </FormItem>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> );
{form.getFieldDecorator(item.name, { } else if (number.indexOf(item.type) > -1) {
initialValue: formData == null ? '' : formData[item.name], return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})(<InputNumber placeholder="请输入" min={0} />)} {form.getFieldDecorator(item.name, {
</FormItem> initialValue: formData == null ? '' : formData[item.name],
); rules: [{ required: !item.isNull }],
} else if (isQuery && data.indexOf(item.type) > -1) { })(<InputNumber placeholder="请输入" min={0} />)}
return ( </FormItem>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> );
{form.getFieldDecorator(item.name, { } else if (isQuery && data.indexOf(item.type) > -1) {
initialValue: formData == null ? null : moment(formData[item.name]), return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})( {form.getFieldDecorator(item.name, {
<RangePicker initialValue: formData == null ? null : moment(formData[item.name]),
format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb} rules: [{ required: !item.isNull }],
style={{ width: '95%' }} })(
/>, <RangePicker
)} format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb}
</FormItem> style={{ width: '95%' }}
); />,
} else if (data.indexOf(item.type) > -1) { )}
return ( </FormItem>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> );
{form.getFieldDecorator(item.name, { } else if (data.indexOf(item.type) > -1) {
initialValue: return (
formData == null <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
? moment() {form.getFieldDecorator(item.name, {
: formData[item.name] initialValue:
? moment(formData[item.name]) formData == null
: null, ? moment()
rules: [{ required: !item.isNull }], : formData[item.name]
})( ? moment(formData[item.name])
<DatePicker : null,
format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb} rules: [{ required: !item.isNull }],
style={{ width: '100%' }} })(
placeholder="请输入" <DatePicker
/>, format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb}
)} style={{ width: '100%' }}
</FormItem> placeholder="请输入"
); />,
} else { )}
return ( </FormItem>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> );
{form.getFieldDecorator(item.name, { } else {
initialValue: formData == null ? '' : formData[item.name], return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})(<Input style={{ width: '70%' }} placeholder="请输入" />)} {form.getFieldDecorator(item.name, {
</FormItem> initialValue: formData == null ? '' : formData[item.name],
); rules: [{ required: !item.isNull }],
} })(<Input style={{ width: '70%' }} placeholder="请输入" />)}
}; </FormItem>
);
renderForm() { }
const { form, get } = this.props; };
const { querys } = this.state; renderForm() {
if (querys.length == 0) { const { form, get } = this.props;
return '';
} const { querys } = this.state;
if (querys.length == 0) {
return ( return '';
<Form layout="inline"> }
<Row style={{ padding: '15px' }}>
{querys.map(item => ( return (
<Col style={{ height: 58 }} span={get === 'mobile' ? 24 : 8} key={item.id}> <Form layout="inline">
{this.getItem( <Row style={{ padding: '15px' }}>
true, {querys.map((item) => (
form, <Col style={{ height: 58 }} span={get === 'mobile' ? 24 : 8} key={item.id}>
{ {this.getItem(
...item, true,
isNull: true, form,
}, {
true, ...item,
)} isNull: true,
</Col> },
))} true,
)}
<Col </Col>
span={get === 'mobile' ? 24 : 8} ))}
style={{
textAlign: get === 'mobile' ? 'right' : '', <Col
paddingRight: get === 'mobile' ? 12 : '', span={get === 'mobile' ? 24 : 8}
}} style={{
> textAlign: get === 'mobile' ? 'right' : '',
<span className={styles.submitButtons}> paddingRight: get === 'mobile' ? 12 : '',
<Button type="primary" loading={this.props.loading} onClick={this.handleSearch}> }}>
查询 <span className={styles.submitButtons}>
</Button> <Button type="primary" loading={this.props.loading} onClick={this.handleSearch}>
<Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}> 查询
重置 </Button>
</Button> <Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>
{/* <a style={{ marginLeft: 8 }} onClick={this.toggleForm}> 重置
</Button>
{/* <a style={{ marginLeft: 8 }} onClick={this.toggleForm}>
展开 <Icon type="down" /> 展开 <Icon type="down" />
</a> */} </a> */}
</span> </span>
</Col> </Col>
</Row> </Row>
</Form> </Form>
); );
} }
onSelect = (selectedKeys, info) => {
if (info.selectedNodes.length > 0) { onSelect = (selectedKeys, info) => {
const parentId = selectedKeys[0] != '0-0' ? selectedKeys[0] : null; if (info.selectedNodes.length > 0) {
this.setState({ parentName: info.selectedNodes[0].props.title, parentId }); const parentId = selectedKeys[0] != '0-0' ? selectedKeys[0] : null;
this.getPage({ parentId: parentId }); this.setState({ parentName: info.selectedNodes[0].props.title, parentId });
} this.getPage({ parentId: parentId });
}; }
onLoadData = treeNode => { };
return new Promise(resolve => { onLoadData = (treeNode) => {
if (treeNode.props.childs) { return new Promise((resolve) => {
resolve(); if (treeNode.props.childs) {
return; resolve();
} return;
const parentId = treeNode.props.eventKey != '0-0' ? treeNode.props.eventKey : null; }
this.getList({ parentId: parentId }, list => { const parentId = treeNode.props.eventKey != '0-0' ? treeNode.props.eventKey : null;
treeNode.props.dataRef.childs = list; this.getList(
this.setState({ { parentId: parentId },
treeData: [...this.state.treeData], (list) => {
}); treeNode.props.dataRef.childs = list;
resolve(); this.setState({
},true); treeData: [...this.state.treeData],
}); });
}; resolve();
},
renderTreeNodes = list => { true,
const { );
json: { treeTitleName, treeKeyName }, });
} = this.props; };
return list.map(item => { renderTreeNodes = (list) => {
item.title = item[treeTitleName]; const {
item.key = item[treeKeyName]; json: { treeTitleName, treeKeyName },
if (item.childs) { } = this.props;
return (
<TreeNode title={item[treeTitleName]} key={item.key} dataRef={item}> return list.map((item) => {
{this.renderTreeNodes(item.childs)} item.title = item[treeTitleName];
</TreeNode> item.key = item[treeKeyName];
); if (item.childs) {
} return (
return <TreeNode {...item} dataRef={item} />; <TreeNode title={item[treeTitleName]} key={item.key} dataRef={item}>
}); {this.renderTreeNodes(item.childs)}
}; </TreeNode>
refesh = (parentId, list, data) => { );
if (parentId == null) { }
data[0].childs = list; return <TreeNode {...item} dataRef={item} />;
return data; });
} };
for (var i = 0; i < data.length; i++) { refesh = (parentId, list, data) => {
if (data[i].key == parentId) { if (parentId == null) {
data[i].childs = list; data[0].childs = list;
break; return data;
} else { }
if (data[i].childs) { for (var i = 0; i < data.length; i++) {
this.refesh(parentId, list, data[i].childs); if (data[i].key == parentId) {
} data[i].childs = list;
} break;
} } else {
if (data[i].childs) {
return data; this.refesh(parentId, list, data[i].childs);
}; }
render() { }
const { modalVisible, selectedRows, querys, tableWidth, rights, data, isReady } = this.state; }
if (!isReady) {
return ( return data;
<div style={{ width: 20, margin: 'auto' }}> };
<Spin />
</div> render() {
); const { modalVisible, selectedRows, querys, tableWidth, rights, data, isReady } = this.state;
} if (!isReady) {
const { return (
isFormCom, <div style={{ width: 20, margin: 'auto' }}>
isSelect, <Spin />
get, </div>
callback, );
valueName, }
notShowBack, const {
istableCom, // 是否有模板设计器调用 isFormCom,
value: { btns }, isSelect,
json: { treeSpan }, get,
loading, callback,
} = this.props; valueName,
const { showMobileDiv, isView } = this.state; notShowBack,
istableCom, // 是否有模板设计器调用
let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度 value: { btns },
let isMobile = scrollWidth < 1200; json: { treeSpan },
if (document.querySelector('#previewDiv')) { loading,
isMobile = true; } = this.props;
} const { showMobileDiv, isView } = this.state;
let showDiv =
document.querySelector('#mobelDiv') && let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
document.querySelector('#mobelDiv')?.parentNode.clientWidth; let isMobile = scrollWidth < 1200;
const parentMethods = { if (document.querySelector('#previewDiv')) {
handleAdd: this.handleAdd, isMobile = true;
handleModalVisible: this.handleModalVisible, }
formData: this.state.formData, let showDiv =
formItem: this.state.formItem, document.querySelector('#mobelDiv') &&
isAdd: this.state.isAdd, document.querySelector('#mobelDiv')?.parentNode.clientWidth;
getItem: this.getItem, const parentMethods = {
isView: isView, handleAdd: this.handleAdd,
}; handleModalVisible: this.handleModalVisible,
formData: this.state.formData,
if ( formItem: this.state.formItem,
!isSelect && isAdd: this.state.isAdd,
!rights.includes('edit') && getItem: this.getItem,
!rights.includes('delete') && isView: isView,
!rights.includes('view') && };
!rights.includes('viewProcess')
) { if (
} else { !isSelect &&
let width = 0; !rights.includes('edit') &&
if (rights && rights.includes('viewProcess')) { !rights.includes('delete') &&
width = width + 75; !rights.includes('view') &&
} !rights.includes('viewProcess')
if (rights && rights.includes('view')) { ) {
width = width + 75; } else {
} let width = 0;
if (rights && rights.includes('edit')) { if (rights && rights.includes('viewProcess')) {
width = width + 40; width = width + 75;
} }
if (rights && rights.includes('delete')) { if (rights && rights.includes('view')) {
width = width + 40; width = width + 75;
} }
const column = { if (rights && rights.includes('edit')) {
title: '操作', width = width + 40;
fixed: 'right', }
width: width, if (rights && rights.includes('delete')) {
render: (text, record) => { width = width + 40;
return ( }
<Fragment> const column = {
<div style={{ textAlign: 'center' }}> title: '操作',
{isSelect ? ( fixed: 'right',
this.state.selects.includes(record[valueName]) ? ( width: width,
<> render: (text, record) => {
<span>已选择</span> return (
<Divider type="vertical" /> <Fragment>
</> <div style={{ textAlign: 'center' }}>
) : ( {isSelect ? (
<> this.state.selects.includes(record[valueName]) ? (
<a onClick={callback.bind(this, record, this.columns)}>选择</a> <>
<Divider type="vertical" /> <span>已选择</span>
</> <Divider type="vertical" />
) </>
) : ( ) : (
'' <>
)} <a onClick={callback.bind(this, record, this.columns)}>选择</a>
{rights && !rights.includes('view') ? ( <Divider type="vertical" />
'' </>
) : ( )
<> ) : (
<a onClick={this.view.bind(this, record)}>查看详情</a> ''
<Divider type="vertical" /> )}
</> {rights && !rights.includes('view') ? (
)} ''
{rights && !rights.includes('edit') ? ( ) : (
'' <>
) : ( <a onClick={this.view.bind(this, record)}>查看详情</a>
<> <Divider type="vertical" />
<a onClick={this.modify.bind(this, record)}>编辑</a> </>
<Divider type="vertical" /> )}
</> {rights && !rights.includes('edit') ? (
)} ''
{rights && rights.includes('viewProcess') && record.process_biz_key ? ( ) : (
<> <>
<a onClick={this.viewProcess.bind(this, record)}>查看流程详情</a> <a onClick={this.modify.bind(this, record)}>编辑</a>
<Divider type="vertical" /> <Divider type="vertical" />
</> </>
) : ( )}
'' {rights && rights.includes('viewProcess') && record.process_biz_key ? (
)} <>
{rights && !rights.includes('delete') ? ( <a onClick={this.viewProcess.bind(this, record)}>查看流程详情</a>
'' <Divider type="vertical" />
) : ( </>
<> ) : (
{' '} ''
<Popconfirm )}
title="确定删除该数据?" {rights && !rights.includes('delete') ? (
onConfirm={this.delete.bind(this, record)} ''
okText="确定" ) : (
cancelText="取消" <>
> {' '}
<a>删除</a> <Popconfirm
</Popconfirm> title="确定删除该数据?"
</> onConfirm={this.delete.bind(this, record)}
)} okText="确定"
</div> cancelText="取消">
</Fragment> <a>删除</a>
); </Popconfirm>
}, </>
}; )}
if (this.columns.length > 0 && this.columns[this.columns.length - 1].title == '操作') { </div>
this.columns[this.columns.length - 1] = column; </Fragment>
} else { );
this.columns.push(column); },
} };
} if (this.columns.length > 0 && this.columns[this.columns.length - 1].title == '操作') {
this.columns[this.columns.length - 1] = column;
if (this.columns) { } else {
/** this.columns.push(column);
* 计算总长度 }
*/ }
AllWidth = 0;
this.columns = this.columns.map((item, index) => { if (this.columns) {
if (isEmpty(item)) { /**
return item; * 计算总长度
} */
if ( AllWidth = 0;
index === this.columns.length - 1 && this.columns = this.columns.map((item, index) => {
this.columns[this.columns.length - 1].title !== '操作' if (isEmpty(item)) {
) { return item;
AllWidth += 150; }
item.width = ''; if (
return item; index === this.columns.length - 1 &&
} this.columns[this.columns.length - 1].title !== '操作'
let width = item.width ? item.width : 150; ) {
if (!item.width) { AllWidth += 150;
item.width = 150; item.width = '';
} return item;
AllWidth += width; }
return item; let width = item.width ? item.width : 150;
}); if (!item.width) {
if ( item.width = 150;
!isEmpty(this.columns[this.columns.length - 1]) && }
this.columns[this.columns.length - 1].title === '操作' AllWidth += width;
) { return item;
this.columns[this.columns.length - 2].width = ''; });
AllWidth += 100; if (
} !isEmpty(this.columns[this.columns.length - 1]) &&
} this.columns[this.columns.length - 1].title === '操作'
const xxxx = ( ) {
<> this.columns[this.columns.length - 2].width = '';
<Row gutter={16}> AllWidth += 100;
<Col span={treeSpan}> }
<Card bordered={false} style={{ minHeight: 500 }}> }
<Tree const xxxx = (
showLine <>
defaultExpandedKeys={['0-0']} <Row gutter={16}>
onSelect={this.onSelect} <Col span={treeSpan}>
loadData={this.onLoadData} <Card bordered={false} style={{ minHeight: 500 }}>
> <Tree
{this.renderTreeNodes(this.state.treeData)} showLine
</Tree> defaultExpandedKeys={['0-0']}
</Card> onSelect={this.onSelect}
</Col> loadData={this.onLoadData}>
<Col span={24 - treeSpan}> {this.renderTreeNodes(this.state.treeData)}
<Card bordered={false} bodyStyle={{ padding: 0 }}> </Tree>
<div className={styles.tableList}> </Card>
<div className={styles.tableListForm}>{this.renderForm()}</div> </Col>
<div className={styles.tableListOperator}> <Col span={24 - treeSpan}>
{notShowBack ? ( <Card bordered={false} bodyStyle={{ padding: 0 }}>
notShowBack <div className={styles.tableList}>
) : ( <div className={styles.tableListForm}>{this.renderForm()}</div>
<Button icon="rollback" type="primary" onClick={this.goBack}> <div className={styles.tableListOperator}>
返回 {notShowBack ? (
</Button> notShowBack
)} ) : (
{btns && btns.before && btns.before.length > 0 <Button icon="rollback" type="primary" onClick={this.goBack}>
? btns.before.map(r => <Button {...r} />) 返回
: ''} </Button>
{rights && !rights.includes('add') ? ( )}
'' {btns && btns.before && btns.before.length > 0
) : ( ? btns.before.map((r) => <Button {...r} />)
<Button icon="plus" type="primary" onClick={this.add}> : ''}
新建 {rights && !rights.includes('add') ? (
</Button> ''
)} ) : (
{rights && !rights.includes('searchData') ? ( <Button icon="plus" type="primary" onClick={this.add}>
'' 新建
) : ( </Button>
<SearchInfo hanldeHighSearch={this.hanldeHighSearch} objId={this.state.objId} /> )}
)} {rights && !rights.includes('searchData') ? (
''
{rights && !rights.includes('importData') ? ( ) : (
'' <SearchInfo hanldeHighSearch={this.hanldeHighSearch} objId={this.state.objId} />
) : ( )}
<ImportUtil objId={this.state.objId} />
)} {rights && !rights.includes('importData') ? (
{rights && !rights.includes('exportCurrent') ? ( ''
'' ) : (
) : ( <ImportUtil objId={this.state.objId} />
<ExportCurrentInfo )}
objId={this.state.objId} {rights && !rights.includes('exportCurrent') ? (
query={JSON.stringify(this.state.formValues)} ''
custom={ ) : (
this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null <ExportCurrentInfo
} objId={this.state.objId}
sql={Base16Encode(this.props.sql)} query={JSON.stringify(this.state.formValues)}
/> custom={
)} this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null
}
{this.props.value &&this.props.value.exportConfig? sql={Base16Encode(this.props.sql)}
/>
this.props.value.exportConfig.map((r,i)=> <ExportCurrentInfo )}
objId={this.state.objId}
query={JSON.stringify(this.state.formValues)} {this.props.value && this.props.value.exportConfig
custom={this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null} ? this.props.value.exportConfig.map((r, i) => (
index={i} <ExportCurrentInfo
btn={r.btn} objId={this.state.objId}
ext={r.ext?r.ext:"xlsx"} query={JSON.stringify(this.state.formValues)}
sql={Base16Encode(this.props.sql)} custom={
/>):""} this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null
{rights && !rights.includes('exportData') ? ( }
'' index={i}
) : ( btn={r.btn}
<ExportInfo objId={this.state.objId} /> ext={r.ext ? r.ext : 'xlsx'}
)} sql={Base16Encode(this.props.sql)}
{rights && !rights.includes('statistics') ? ( />
'' ))
) : ( : ''}
<StatisticsInfo objId={this.state.objId} /> {rights && !rights.includes('exportData') ? (
)} ''
{rights && !rights.includes('delete') ) : (
? '' <ExportInfo objId={this.state.objId} />
: selectedRows.length > 0 && ( )}
<span> {rights && !rights.includes('statistics') ? (
<Popconfirm ''
title="确定删除该数据?" ) : (
onConfirm={this.batchDelete} <StatisticsInfo objId={this.state.objId} />
okText="确定" )}
cancelText="取消" {rights && !rights.includes('delete')
> ? ''
<Button>批量删除</Button> : selectedRows.length > 0 && (
</Popconfirm> <span>
</span> <Popconfirm
)} title="确定删除该数据?"
{btns && btns.after && btns.after.length > 0 onConfirm={this.batchDelete}
? btns.after.map(r => <Button {...r} loading={loading} />) okText="确定"
: ''} cancelText="取消">
</div> <Button>批量删除</Button>
{!istableCom || (this.props.value && this.props.value.columns) ? ( </Popconfirm>
<StandardTable </span>
showHeader={this.props.showHeader != null ? this.props.showHeader : true} )}
noSelectRow={ {btns && btns.after && btns.after.length > 0
this.props.onSelectRow == null && ? btns.after.map((r) => <Button {...r} loading={loading} />)
(rights == null || !rights.includes('delete')) : ''}
} </div>
rowKey="id" {!istableCom || (this.props.value && this.props.value.columns) ? (
data={data} <StandardTable
isHiddenPage={this.props.isHiddenPage != null ? this.props.isHiddenPage : false} showHeader={this.props.showHeader != null ? this.props.showHeader : true}
columns={this.columns} noSelectRow={
scroll={this.props.value && this.props.value.columns ? {} : { x: AllWidth }} this.props.onSelectRow == null &&
selectedRows={selectedRows} (rights == null || !rights.includes('delete'))
onSelectRow={this.handleSelectRows} }
onChange={this.handleStandardTableChange} rowKey="id"
loading={this.props.loading} data={data}
/> isHiddenPage={this.props.isHiddenPage != null ? this.props.isHiddenPage : false}
) : ( columns={this.columns}
<div scroll={this.props.value && this.props.value.columns ? {} : { x: AllWidth }}
id="mobelDiv" selectedRows={selectedRows}
style={{ onSelectRow={this.handleSelectRows}
overflow: 'hidden', onChange={this.handleStandardTableChange}
width: isMobile ? showMobileDiv : showDiv, loading={this.props.loading}
height: '100%', />
}} ) : (
> <div
<div> id="mobelDiv"
{get === 'mobile' ? <div>手机端,请将手机横屏查看</div> : null} style={{
{showDiv && ( overflow: 'hidden',
<StandardTable width: isMobile ? showMobileDiv : showDiv,
showHeader={this.props.showHeader != null ? this.props.showHeader : true} height: '100%',
noSelectRow={ }}>
this.props.onSelectRow == null && <div>
(rights == null || !rights.includes('delete')) {get === 'mobile' ? <div>手机端,请将手机横屏查看</div> : null}
} {showDiv && (
rowKey="id" <StandardTable
data={data} showHeader={this.props.showHeader != null ? this.props.showHeader : true}
columns={this.columns} noSelectRow={
scroll={ this.props.onSelectRow == null &&
this.props.value && this.props.value.columns ? {} : { x: AllWidth } (rights == null || !rights.includes('delete'))
} }
selectedRows={selectedRows} rowKey="id"
isHiddenPage={ data={data}
this.props.isHiddenPage != null ? this.props.isHiddenPage : false columns={this.columns}
} scroll={
onSelectRow={this.handleSelectRows} this.props.value && this.props.value.columns ? {} : { x: AllWidth }
onChange={this.handleStandardTableChange} }
loading={this.props.loading} selectedRows={selectedRows}
/> isHiddenPage={
)} this.props.isHiddenPage != null ? this.props.isHiddenPage : false
</div> }
</div> onSelectRow={this.handleSelectRows}
)} onChange={this.handleStandardTableChange}
</div> loading={this.props.loading}
</Card> />
</Col> )}
</Row> </div>
<CreateForm {...parentMethods} modalVisible={modalVisible} /> </div>
</> )}
); </div>
if (isFormCom) { </Card>
return xxxx; </Col>
} </Row>
return <PageHeaderWrapper title="">{xxxx}</PageHeaderWrapper>; <CreateForm {...parentMethods} modalVisible={modalVisible} />
} </>
);
if (isFormCom) {
return xxxx;
}
return <PageHeaderWrapper title="">{xxxx}</PageHeaderWrapper>;
}
} }
export default TreeList; export default TreeList;
...@@ -111,4 +111,6 @@ const getFormArrayConfig = (header,isAdd,options) => { ...@@ -111,4 +111,6 @@ const getFormArrayConfig = (header,isAdd,options) => {
return config; return config;
}; };
export { text, number, date, getFormArrayConfig }; export { text, number, date, getFormArrayConfig };
...@@ -4,12 +4,10 @@ import { ...@@ -4,12 +4,10 @@ import {
Card, Card,
DatePicker, DatePicker,
Divider, Divider,
Table,
Form, Form,
Row, Row,
Col, Col,
Input, Input,
InputNumber,
message, message,
Modal, Modal,
Select, Select,
...@@ -1341,7 +1339,7 @@ this.props.value.importConfig.map((r,i)=> <ImportUtil btn={r.btn} ext={r.ext?r.e ...@@ -1341,7 +1339,7 @@ this.props.value.importConfig.map((r,i)=> <ImportUtil btn={r.btn} ext={r.ext?r.e
this.getPage() this.getPage()
if(r.callback) r.callback(); if(r.callback) r.callback();
} }
}/> }/>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论