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

27867 就业市场/线上招聘管理/职位信息审核,胡林那 hulinnaAdmin 马上审核通过的职位直接发布 发布不了

上级 7a83785f
...@@ -25,7 +25,7 @@ export default function prepareShow(postData = {}, content = '') { ...@@ -25,7 +25,7 @@ export default function prepareShow(postData = {}, content = '') {
window.moment = moment; window.moment = moment;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log(agg?.unifiedServicePatternModel?.id); // 表单id; console.log(agg?.unifiedServicePatternModel?.id); // 表单id;
if (agg?.unifiedServicePatternModel?.id && (window.location.href.indexOf('localhost') > -1 || test === 'true')) { if (agg?.unifiedServicePatternModel?.id && (window.location.href.indexOf('localhost') > -1 || test)) {
const SystemConfig = window.specialImportantSystemConfig || {}; const SystemConfig = window.specialImportantSystemConfig || {};
console.log('%c' + `${SystemConfig?.gateWayPort}/onestop/#/admin/processServices/modelConfig/templateDetail/designById?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px'); console.log('%c' + `${SystemConfig?.gateWayPort}/onestop/#/admin/processServices/modelConfig/templateDetail/designById?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px');
console.log('%c' + `${SystemConfig?.gateWayPort}/wisdomSchool/#/designFormByUrl?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px'); console.log('%c' + `${SystemConfig?.gateWayPort}/wisdomSchool/#/designFormByUrl?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px');
......
...@@ -43,9 +43,9 @@ export default class TableList extends React.Component { ...@@ -43,9 +43,9 @@ export default class TableList extends React.Component {
static getDerivedStateFromProps(nextProps, prevState) { static getDerivedStateFromProps(nextProps, prevState) {
// ... // ...
if('value' in nextProps){ if('value' in nextProps){
return {...nextProps.value}; return {...nextProps.value}; // 更新state
} }
return null; return null; //不需要更新任何state
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
......
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import { import {
Button, Button,
Card, Card,
DatePicker, DatePicker,
Divider, Divider,
Form, Form,
Row, Row,
Col, Col,
Input, Input,
message, message,
Select, Select,
Tooltip, Tooltip,
Spin, Spin,
Popover, Popover,
Checkbox, Checkbox,
} from 'antd'; } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import PageHeaderWrapper from './PageHeaderWrapper'; import PageHeaderWrapper from './PageHeaderWrapper';
...@@ -43,1270 +43,1294 @@ let AllWidth = 0; // 表格总长度 ...@@ -43,1270 +43,1294 @@ let AllWidth = 0; // 表格总长度
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const CreateForm = Form.create()((props) => { const CreateForm = Form.create()((props) => {
const { const {
modalVisible, modalVisible,
form, form,
handleAdd, handleAdd,
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]) {
//处理日期何时入库问题 //处理日期何时入库问题
try { try {
fieldsValue[d] = fieldsValue[d].format('YYYY-MM-DD HH:mm:ss'); fieldsValue[d] = fieldsValue[d].format('YYYY-MM-DD HH:mm:ss');
} catch (e) { } catch (e) {}
} break;
break; }
} }
} } else if (number.includes(item.type)) {
} else if (number.includes(item.type)) { for (let d in fieldsValue) {
for (let d in fieldsValue) { if (item.name === d && fieldsValue[d] == '') {
if (item.name === d && fieldsValue[d] == '') { fieldsValue[d] = null;
fieldsValue[d] = null; break;
break; }
} }
} }
} });
}); 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, DataColumn, DataObj, loading }) => ({ @connect(({ formList, DataColumn, DataObj, loading }) => ({
formList, formList,
DataColumn, DataColumn,
DataObj, DataObj,
loading: loading.models.formList || loading.models.DataColumn || loading.models.DataObj, loading: loading.models.formList || loading.models.DataColumn || loading.models.DataObj,
})) }))
@Form.create() @Form.create()
class FormList extends React.Component { class FormList extends React.Component {
state = { state = {
data: { data: {
list: [], list: [],
pagination: {}, pagination: {},
}, },
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,
checkedList: [], // 复选框默认选中 checkedList: [], // 复选框默认选中
cacheColumns: '', // 初始表头缓存数据 后续不做增删改查 cacheColumns: '', // 初始表头缓存数据 后续不做增删改查
}; };
columns = []; columns = [];
checkList = []; // 复选框内容 checkList = []; // 复选框内容
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(this.state.formItem[i].id); refIds.push(this.state.formItem[i].id);
} }
} }
if (refIds.length > 0) { if (refIds.length > 0) {
this.props.dispatch({ this.props.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 } });
}, },
}); });
} }
}; };
modify = (record) => { modify = (record) => {
// if (this.state.formItem.length < 10) { // if (this.state.formItem.length < 10) {
this.getOptions(); this.getOptions();
this.props.dispatch({ this.props.dispatch({
type: 'formList/getDetail', type: 'formList/getDetail',
payload: { payload: {
dataObjId: this.state.objId, dataObjId: this.state.objId,
key: this.state.primaryKey, key: this.state.primaryKey,
value: record[this.state.primaryKey], value: record[this.state.primaryKey],
isBase: false, isBase: false,
}, },
callback: (record2) => { callback: (record2) => {
this.setState({ this.setState({
formData: record2, formData: record2,
modalVisible: true, modalVisible: true,
isAdd: false, isAdd: false,
isView: false, isView: false,
});
},
});
};
view = (record) => {
this.getOptions();
this.setState({
formData: record,
modalVisible: true,
isAdd: false,
isView: true,
});
};
isJSON = (str) => {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} catch (e) {
console.log('error:' + str + '!!!' + e);
return false;
}
}
console.log('这不是个字符串');
};
delete = (record) => {
//找出主键
let Keys = {};
Keys[this.state.primaryKey] = record[this.state.primaryKey];
this.props.dispatch({
type: 'formList/delete',
payload: {
keys: JSON.stringify(Keys),
objId: this.state.objId,
},
callback: () => {
this.getPage();
},
});
};
viewProcess = (record) => {
const { dispatch } = this.props;
dispatch({
type: 'formList/getAppId',
payload: {
code: record.process_biz_key,
},
callback: (data) => {
const domainName = sessionStorage.getItem('domainName')
? sessionStorage.getItem('domainName')
: '';
window.open(domainName + '/portal/serviceCentre/getdetail?id=' + data.id, '_blank');
//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({
showMobileDiv: document.querySelector('#previewDiv').clientWidth - 77,
});
} else {
this.setState({
showMobileDiv,
});
}
};
//渲染值
componentDidMount() {
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props;
window.addEventListener('resize', this.resize);
// console.log('componentDidMount');
if (this.props.objCode) {
const { dispatch, objCode, sql } = this.props;
if (Number(objCode) === 1) {
this.initColumn();
} else {
dispatch({
type: 'DataObj/findByCode',
payload: { objCode: this.props.objCode },
callback: (dataObj) => {
this.setState(
{
objId: dataObj.id,
isTable: dataObj.isTable,
},
() => {
dispatch({
type: 'DataRight/getUserRight',
payload: { objId: this.state.objId },
callback: (data) => {
if (!this.props.rights) {
this.setState({ rights: data });
}
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 });
},
});
dispatch({
type: 'DataRight/getUserRight',
payload: { objId: this.state.objId },
callback: (data) => {
if (!this.props.rights) {
this.setState({ rights: data });
}
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 ? JSON.stringify(this.props.value) : null;
componentWillReceiveProps(nextProps) {
const b = nextProps.value || {};
const a = this.props.value || {};
const jsonb = JSON.stringify(b);
const jsona = JSON.stringify(a);
this.custom = jsonb;
if (jsona != jsonb) {
let params = {
pageNo: b.pageNo ? b.pageNo : 1,
pageSize: b.pageSize ? b.pageSize : this.state.data.pagination.pageSize,
query: JSON.stringify(this.state.formValues),
};
if (nextProps.value.columns != null && nextProps.value.columns.length > 0) {
this.columns = nextProps.value.columns;
}
if(nextProps.value.selectedRows && Array.isArray(nextProps.value.selectedRows)){
// 27867 就业市场/线上招聘管理/职位信息审核,胡林那 hulinnaAdmin 马上审核通过的职位直接发布 发布不了
this.setState({
selectedRows: nextProps.value.selectedRows,
}); });
},
});
};
view = (record) => {
this.getOptions();
this.setState({
formData: record,
modalVisible: true,
isAdd: false,
isView: true,
});
};
isJSON = (str) => {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} catch (e) {
console.log('error:' + str + '!!!' + e);
return false;
}
}
console.log('这不是个字符串');
};
delete = (record) => {
//找出主键
let Keys = {};
Keys[this.state.primaryKey] = record[this.state.primaryKey];
this.props.dispatch({
type: 'formList/delete',
payload: {
keys: JSON.stringify(Keys),
objId: this.state.objId,
},
callback: () => {
this.getPage();
},
});
};
viewProcess = (record) => {
const { dispatch } = this.props;
dispatch({
type: 'formList/getAppId',
payload: {
code: record.process_biz_key,
},
callback: (data) => {
const domainName = sessionStorage.getItem('domainName')
? sessionStorage.getItem('domainName')
: '';
window.open(domainName + '/portal/serviceCentre/getdetail?id=' + data.id, '_blank');
//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({
showMobileDiv: document.querySelector('#previewDiv').clientWidth - 77,
});
} else {
this.setState({
showMobileDiv,
});
}
};
//渲染值
componentDidMount() {
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props;
window.addEventListener('resize', this.resize);
// console.log('componentDidMount');
if (this.props.objCode) {
const { dispatch, objCode, sql } = this.props;
if (Number(objCode) === 1) {
this.initColumn();
} else {
dispatch({
type: 'DataObj/findByCode',
payload: { objCode: this.props.objCode },
callback: (dataObj) => {
this.setState({ objId: dataObj.id, isTable: dataObj.isTable }, () => {
dispatch({
type: 'DataRight/getUserRight',
payload: { objId: this.state.objId },
callback: (data) => {
if (!this.props.rights) {
this.setState({ rights: data });
}
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 });
},
});
dispatch({
type: 'DataRight/getUserRight',
payload: { objId: this.state.objId },
callback: (data) => {
if (!this.props.rights) {
this.setState({ rights: data });
}
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 ? JSON.stringify(this.props.value) : null;
componentWillReceiveProps(nextProps) {
const b = nextProps.value || {};
const a = this.props.value || {};
const jsonb = JSON.stringify(b);
const jsona = JSON.stringify(a);
this.custom = jsonb;
if (jsona != jsonb) {
let params = {
pageNo: b.pageNo ? b.pageNo : 1,
pageSize: b.pageSize ? b.pageSize : this.state.data.pagination.pageSize,
query: JSON.stringify(this.state.formValues),
};
if (nextProps.value.columns != null && nextProps.value.columns.length > 0) {
this.columns = nextProps.value.columns;
} }
if (nextProps.value.getPage) { if (nextProps.value.getPage) {
this.getPage(params, null, nextProps.value.getPage); this.getPage(params, null, nextProps.value.getPage);
} else { } else {
if (this.state.objId) this.getPage(params); if (this.state.objId) this.getPage(params);
} }
} }
const x = nextProps.selects; const x = nextProps.selects;
const y = this.props.selects; const y = this.props.selects;
if (JSON.stringify(x) != JSON.stringify(y)) { if (JSON.stringify(x) != JSON.stringify(y)) {
this.setState({ selects: x }); this.setState({ selects: x });
} }
} }
initColumn = () => { initColumn = () => {
const { dispatch, value, objCode } = this.props; const { dispatch, value, objCode } = this.props;
const { rights, columnRights } = this.state; const { rights, columnRights } = this.state;
if (value && value.columns) { if (value && value.columns) {
this.columns = value.columns; this.columns = value.columns;
let cacheList = []; let cacheList = [];
let cacheChecked = []; let cacheChecked = [];
// 表头筛选逻辑 // 表头筛选逻辑
Array.isArray(value.columns) && Array.isArray(value.columns) &&
value.columns.map((item) => { value.columns.map((item) => {
if (item.dataIndex != null) { if (item.dataIndex != null) {
cacheList.push({ cacheList.push({
label: item.title, label: item.title,
value: item.dataIndex, value: item.dataIndex,
}); });
cacheChecked.push(item.dataIndex); cacheChecked.push(item.dataIndex);
} }
}); });
this.checkList = cacheList; this.checkList = cacheList;
this.setState({ this.setState({
checkedList: cacheChecked, checkedList: cacheChecked,
cacheColumns: cloneDeep(value.columns), cacheColumns: cloneDeep(value.columns),
}); });
if (Number(objCode) === 1) { if (Number(objCode) === 1) {
this.getPage(); this.getPage();
} else { } else {
dispatch({ dispatch({
type: 'formList/getHead', type: 'formList/getHead',
payload: { dataObjId: this.state.objId }, payload: { dataObjId: this.state.objId },
callback: (datas) => { callback: (datas) => {
this.state.formItem = datas; this.state.formItem = datas;
const querys = []; const querys = [];
const groups = {}; const groups = {};
const refIds = []; const refIds = [];
for (let t in datas) { for (let t in datas) {
if (datas[t].isPrimaryKey) this.state.primaryKey = datas[t].name; if (datas[t].isPrimaryKey) this.state.primaryKey = datas[t].name;
if (datas[t].isShowQuery) { if (datas[t].isShowQuery) {
querys.push(datas[t]); querys.push(datas[t]);
if (datas[t].referenceObjId != null) { if (datas[t].referenceObjId != null) {
refIds.push(datas[t].id); refIds.push(datas[t].id);
} }
if (datas[t].isGroupQuery != null) { if (datas[t].isGroupQuery != null) {
dispatch({ dispatch({
type: 'formList/getGroupList', type: 'formList/getGroupList',
payload: { columnId: datas[t].id }, payload: { columnId: datas[t].id },
callback: (gourp) => { callback: (gourp) => {
groups[datas[t].id] = gourp; groups[datas[t].id] = gourp;
this.setState({ groups }); this.setState({ groups });
}, },
}); });
} }
} }
} }
if (querys.length > 0) { if (querys.length > 0) {
this.setState({ querys }); this.setState({ querys });
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.setState({ options });
}, },
}); });
} }
} }
this.getPage(); this.getPage();
}, },
}); });
} }
return; return;
} }
if (Number(objCode) === 1) { if (Number(objCode) === 1) {
} else { } else {
dispatch({ dispatch({
type: 'formList/getHead', type: 'formList/getHead',
payload: { dataObjId: this.state.objId }, payload: { dataObjId: this.state.objId },
callback: (datas) => { callback: (datas) => {
const querys = []; const querys = [];
const refIds = []; const refIds = [];
const groups = {}; const groups = {};
if (datas) { if (datas) {
this.state.formItem = datas; this.state.formItem = datas;
let i = 0; let i = 0;
let cacheList = []; let cacheList = [];
let cacheChecked = []; let cacheChecked = [];
// 表头筛选逻辑 // 表头筛选逻辑
datas.map((item) => { datas.map((item) => {
if (item.name != null) { if (item.name != null) {
cacheList.push({ cacheList.push({
label: item.title, label: item.title,
value: item.name, value: item.name,
}); });
cacheChecked.push(item.name); cacheChecked.push(item.name);
} }
}); });
this.checkList = cacheList; this.checkList = cacheList;
this.setState({ this.setState({
checkedList: cacheChecked, checkedList: cacheChecked,
}); });
for (let t in datas) { for (let t in datas) {
if (datas[t].isPrimaryKey) this.state.primaryKey = datas[t].name; if (datas[t].isPrimaryKey) this.state.primaryKey = datas[t].name;
if (datas[t].isHidden) { if (datas[t].isHidden) {
continue; continue;
} }
let column = {}; let column = {};
column.title = datas[t].title; column.title = datas[t].title;
column.dataIndex = datas[t].name; column.dataIndex = datas[t].name;
column.width = datas[t].width; column.width = datas[t].width;
if (i == 0) column.fixed = 'left'; if (i == 0) column.fixed = 'left';
if (columnRights.length > 0 && !columnRights.includes(datas[t].id)) { if (columnRights.length > 0 && !columnRights.includes(datas[t].id)) {
continue; continue;
} }
if (date.includes(datas[t].type)) { if (date.includes(datas[t].type)) {
column.render = (val) => { column.render = (val) => {
if (val == null) { if (val == null) {
return val; return val;
} }
if (datas[t].dataFormatStrWeb != null) { if (datas[t].dataFormatStrWeb != null) {
return moment(val).format(datas[t].dataFormatStrWeb); return moment(val).format(datas[t].dataFormatStrWeb);
} else { } else {
return moment(val).format('YYYY-MM-DD HH:mm:ss'); return moment(val).format('YYYY-MM-DD HH:mm:ss');
} }
}; };
} else if (datas[t].name.indexOf('process_status') > -1) { } else if (datas[t].name.indexOf('process_status') > -1) {
column.render = (val) => (val ? (val === '0' ? '审核通过' : '审核未通过') : null); column.render = (val) => (val ? (val === '0' ? '审核通过' : '审核未通过') : null);
} else if (datas[t].extendTypeId && datas[t].extendTypeId.indexOf('file') > -1) { } else if (datas[t].extendTypeId && datas[t].extendTypeId.indexOf('file') > -1) {
//特殊处理附件 //特殊处理附件
column.render = (val) => { column.render = (val) => {
if (this.isJSON(val)) { if (this.isJSON(val)) {
val = JSON.parse(val); val = JSON.parse(val);
let files = val.files; let files = val.files;
let xx = ( let xx = (
<ul> <ul>
{files.map((f, index2) => { {files.map((f, index2) => {
return ( return (
<li key={index2}> <li key={index2}>
<FilePreview path={queryApiActionPath() + f.path} pathName={f.name} /> <FilePreview path={queryApiActionPath() + f.path} pathName={f.name} />
</li> </li>
); );
})} })}
</ul> </ul>
); );
return xx; return xx;
} else { } else {
return val; return val;
} }
}; };
} else { } else {
column.render = (val) => column.render = (val) =>
val && val.length > 100 ? ( val && val.length > 100 ? (
<Tooltip title={val} overlayStyle={{ width: 1000 }}> <Tooltip title={val} overlayStyle={{ width: 1000 }}>
<span <span
style={{ style={{
width: column.width || 200, width: column.width || 200,
display: 'block', display: 'block',
wordBreak: 'keep-all', wordBreak: 'keep-all',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
overflow: 'hidden', overflow: 'hidden',
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
}}> }}>
{val} {val}
</span> </span>
</Tooltip> </Tooltip>
) : ( ) : (
val val
); );
} }
this.setState({ tableWidth: (datas.length - 1) * 200 }); this.setState({ tableWidth: (datas.length - 1) * 200 });
this.columns.push(column); this.columns.push(column);
this.setState({ this.setState({
cacheColumns: cloneDeep(this.columns), cacheColumns: cloneDeep(this.columns),
}); });
if (datas[t].isShowQuery) { if (datas[t].isShowQuery) {
querys.push(datas[t]); querys.push(datas[t]);
if (datas[t].referenceObjId != null) { if (datas[t].referenceObjId != null) {
refIds.push(datas[t].id); refIds.push(datas[t].id);
} }
if (datas[t].isGroupQuery != null) { if (datas[t].isGroupQuery != null) {
dispatch({ dispatch({
type: 'formList/getGroupList', type: 'formList/getGroupList',
payload: { columnId: datas[t].id }, payload: { columnId: datas[t].id },
callback: (gourp) => { callback: (gourp) => {
groups[datas[t].id] = gourp; groups[datas[t].id] = gourp;
this.setState({ groups }); this.setState({ groups });
}, },
}); });
} }
} }
i++; i++;
} }
if (querys.length > 0) { if (querys.length > 0) {
this.setState({ querys }); this.setState({ querys });
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.setState({ options });
}, },
}); });
} }
} }
this.getPage(); this.getPage();
} }
}, },
}); });
} }
}; };
sqlBs16 = this.props.sql; sqlBs16 = this.props.sql;
getPage = (params, values, callPage, pageNo) => {
getPage = (params, values, callPage, pageNo) => { const { objCode } = this.props;
const { objCode } = this.props; if (this.columns == null || this.columns.length == 0) {
if (this.columns == null || this.columns.length == 0) { return;
return; }
} const { dispatch } = this.props;
const { dispatch } = this.props; const pagination = this.state.data.pagination;
const pagination = this.state.data.pagination;
if (params == null) {
if (params == null) { params = {
params = { pageNo: pageNo != null ? pageNo : pagination.current ? pagination.current : 1,
pageNo: pageNo != null ? pageNo : pagination.current ? pagination.current : 1, pageSize: pagination.pageSize ? pagination.pageSize : this.props.pageSize || 10,
pageSize: pagination.pageSize ? pagination.pageSize : this.props.pageSize || 10, query: JSON.stringify(values != null ? values : this.state.formValues),
query: JSON.stringify(values != null ? values : this.state.formValues), };
}; } else {
} else { if (params.pageNo == null && callPage == null && this.props.value.getPage == null) return;
if (params.pageNo == null && callPage == null && this.props.value.getPage == null) return; }
}
if (Number(objCode) === 1) {
if (Number(objCode) === 1) { if (callPage) {
if (callPage) { callPage(params, (data) => {
callPage(params, (data) => { if (!this.state.isReady) {
if (!this.state.isReady) { this.setState({
this.setState({ data, isReady: true }); data,
} else { isReady: true,
this.setState({ data }); });
} } else {
}); this.setState({ data });
} else if (this.props.value && this.props.value.getPage) { }
this.props.value.getPage(params, (data) => { });
if (!this.state.isReady) { } else if (this.props.value && this.props.value.getPage) {
this.setState({ data, isReady: true }); this.props.value.getPage(params, (data) => {
} else { if (!this.state.isReady) {
this.setState({ data }); this.setState({
} data,
}); isReady: true,
} });
} else { } else {
dispatch({ this.setState({ data });
type: 'formList/fetch', }
payload: { });
custom: this.custom, }
...params, } else {
dispatch({
sql: this.sqlBs16, type: 'formList/fetch',
dataObjId: this.state.objId, payload: {
}, custom: this.custom,
callback: (data) => { ...params,
if (!this.state.isReady) {
this.setState({ data, isReady: true }); sql: this.sqlBs16,
} else { dataObjId: this.state.objId,
this.setState({ data }); },
} callback: (data) => {
}, if (!this.state.isReady) {
}); this.setState({
} data,
}; isReady: true,
});
handleStandardTableChange = (pagination, filtersArg, sorter) => { } else {
const filters = Object.keys(filtersArg).reduce((obj, key) => { this.setState({ data });
const newObj = { ...obj }; }
newObj[key] = getValue(filtersArg[key]); },
return newObj; });
}, {}); }
};
const params = {
pageNo: pagination.current, handleStandardTableChange = (pagination, filtersArg, sorter) => {
pageSize: pagination.pageSize, const filters = Object.keys(filtersArg).reduce((obj, key) => {
...filters, const newObj = { ...obj };
query: JSON.stringify(this.state.formValues), newObj[key] = getValue(filtersArg[key]);
}; return newObj;
if (sorter.field) { }, {});
params.sorter = `${sorter.field}_${sorter.order}`;
} const params = {
this.getPage(params); pageNo: pagination.current,
}; pageSize: pagination.pageSize,
...filters,
handleAdd = (fields, isAdd) => { query: JSON.stringify(this.state.formValues),
let params = { };
...fields, if (sorter.field) {
}; params.sorter = `${sorter.field}_${sorter.order}`;
this.props.dispatch({ }
type: 'formList/add', this.getPage(params);
payload: { };
params: params,
objId: this.state.objId, handleAdd = (fields, isAdd) => {
isAdd: isAdd, let params = {
isSelf: true, ...fields,
isView: false, };
}, this.props.dispatch({
callback: () => { type: 'formList/add',
message.success('操作成功'); payload: {
this.setState({ params: params,
modalVisible: false, objId: this.state.objId,
}); isAdd: isAdd,
this.getPage(); isSelf: true,
}, isView: false,
}); },
}; callback: () => {
message.success('操作成功');
handleModalVisible = () => { this.setState({
this.setState({ modalVisible: false,
modalVisible: this.state.modalVisible ? false : true, });
formData: {}, this.getPage();
isView: false, },
}); });
}; };
add = () => { handleModalVisible = () => {
// if (this.state.formItem.length < 10) { this.setState({
this.getOptions(); modalVisible: this.state.modalVisible ? false : true,
this.setState({ formData: {},
modalVisible: true, isView: false,
formData: {}, });
isAdd: true, };
isView: false,
}); add = () => {
// } else { // if (this.state.formItem.length < 10) {
// router.push({ this.getOptions();
// pathname: '/admin/ddl/dataObj/formEdit', this.setState({
// state: { id: this.state.objId,isAdd: true,isView:false } modalVisible: true,
// }); formData: {},
// } isAdd: true,
}; isView: false,
});
handleSelectRows = (rows) => { // } else {
if (this.props.onSelectRow) { // router.push({
this.props.onSelectRow(rows); // pathname: '/admin/ddl/dataObj/formEdit',
} // state: { id: this.state.objId,isAdd: true,isView:false }
this.setState({ // });
selectedRows: rows, // }
}); };
};
handleSelectRows = (rows) => {
batchDelete = (e) => { if (this.props.onSelectRow) {
const { dispatch } = this.props; this.props.onSelectRow(rows);
const { selectedRows } = this.state; }
this.setState({
if (!selectedRows) return; selectedRows: rows,
});
let columns = this.state.formItem; };
let Keys = {};
batchDelete = (e) => {
for (let i in columns) { const { dispatch } = this.props;
if (columns[i].isPrimaryKey) { const { selectedRows } = this.state;
//key
Keys[columns[i].name] = selectedRows.map((row) => row[columns[i].name]).join(','); if (!selectedRows) return;
}
} let columns = this.state.formItem;
this.props.dispatch({ let Keys = {};
type: 'formList/delete',
payload: { for (let i in columns) {
keys: JSON.stringify(Keys), if (columns[i].isPrimaryKey) {
objId: this.state.objId, //key
// isSelf: true, Keys[columns[i].name] = selectedRows.map((row) => row[columns[i].name]).join(',');
}, }
callback: () => { }
this.setState({ this.props.dispatch({
selectedRows: [], type: 'formList/delete',
}); payload: {
this.getPage(); keys: JSON.stringify(Keys),
}, objId: this.state.objId,
}); // isSelf: true,
}; },
callback: () => {
goBack = () => { this.setState({
router.goBack(); selectedRows: [],
}; });
handleSearch = (e) => { this.getPage();
e.preventDefault(); },
});
const { dispatch, form } = this.props; };
const { formValues } = this.state; goBack = () => {
router.goBack();
form.validateFields((err, fieldsValue) => { };
if (err) return; handleSearch = (e) => {
e.preventDefault();
const formItem = this.state.formItem;
formItem.map((item, index) => { const { dispatch, form } = this.props;
if (item.type.indexOf('DATE') > -1) {
for (let d in fieldsValue) { const { formValues } = this.state;
if (item.name === d && fieldsValue[d]) {
if (fieldsValue[d] != null && fieldsValue[d].length > 0) { form.validateFields((err, fieldsValue) => {
fieldsValue[d] = [ if (err) return;
fieldsValue[d][0].format('YYYY-MM-DD HH:mm:ss'),
fieldsValue[d][1].format('YYYY-MM-DD HH:mm:ss'), const formItem = this.state.formItem;
]; formItem.map((item, index) => {
} else { if (item.type.indexOf('DATE') > -1) {
fieldsValue[d] = ''; for (let d in fieldsValue) {
} if (item.name === d && fieldsValue[d]) {
} if (fieldsValue[d] != null && fieldsValue[d].length > 0) {
} fieldsValue[d] = [
} fieldsValue[d][0].format('YYYY-MM-DD HH:mm:ss'),
}); fieldsValue[d][1].format('YYYY-MM-DD HH:mm:ss'),
const values = { ];
...this.state.formValues, } else {
...fieldsValue, fieldsValue[d] = '';
}; }
this.setState({ }
formValues: fieldsValue, }
}); }
const params = { });
pageNo: 1, const values = {
pageSize: this.props.pageSize || 10, ...this.state.formValues,
query: JSON.stringify(values), ...fieldsValue,
}; };
this.getPage(params, values, null, 1); this.setState({
}); formValues: fieldsValue,
}; });
const params = {
hanldeHighSearch = (e) => { pageNo: 1,
const pagination = this.props.formList.data.pagination; pageSize: this.props.pageSize || 10,
let params = { query: JSON.stringify(values),
pageNo: pagination.current ? pagination.current : 1, };
pageSize: pagination.pageSize ? pagination.pageSize : this.props.pageSize || 10, this.getPage(params, values, null, 1);
...e, });
}; };
this.setState({ formValues: { ...e, ...this.state.formValues } });
this.getPage(params); hanldeHighSearch = (e) => {
}; const pagination = this.props.formList.data.pagination;
handleFormReset = () => { let params = {
const { form, dispatch } = this.props; pageNo: pagination.current ? pagination.current : 1,
form.resetFields(); pageSize: pagination.pageSize ? pagination.pageSize : this.props.pageSize || 10,
this.setState( ...e,
{ };
formValues: {}, this.setState({ formValues: { ...e, ...this.state.formValues } });
}, this.getPage(params);
() => { };
this.getPage(); handleFormReset = () => {
}, const { form, dispatch } = this.props;
); form.resetFields();
}; this.setState(
getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => { {
const { groups, isView } = this.state; formValues: {},
//如果隐藏的话 就用隐藏域放置 },
if (item.isHidden) { () => {
return ( this.getPage();
<FormItem className={styles.hidden} key={item.id}> },
{form.getFieldDecorator(item.name, { );
initialValue: formData == null ? '' : formData[item.name], };
})(<Input type='hidden' placeholder='请输入' />)} getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => {
</FormItem> const { groups, isView } = this.state;
); //如果隐藏的话 就用隐藏域放置
} if (item.isHidden) {
return (
if (item.isPrimaryKey) { <FormItem className={styles.hidden} key={item.id}>
if (isAdd) { {form.getFieldDecorator(item.name, {
return <></>; initialValue: formData == null ? '' : formData[item.name],
} else { })(<Input type="hidden" placeholder="请输入" />)}
return ( </FormItem>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> );
{form.getFieldDecorator(item.name, { }
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }], if (item.isPrimaryKey) {
})(<Input style={{ width: '70%' }} readOnly={!isAdd} placeholder='请输入' />)} if (isAdd) {
</FormItem> return <></>;
); } else {
} return (
} else if (item.referenceObjId != null) { <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
const { options } = this.state; {form.getFieldDecorator(item.name, {
const ops = options[item.id + ''] || []; 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 }], }
})( } else if (item.referenceObjId != null) {
<Select const { options } = this.state;
disabled={isView} const ops = options[item.id + ''] || [];
style={{ width: '70%' }} return (
optionFilterProp='children' <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
showSearch {form.getFieldDecorator(item.name, {
filterOption={(input, option) => initialValue: formData == null ? '' : formData[item.name],
option rules: [{ required: !item.isNull }],
? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 })(
: false <Select
} disabled={isView}
placeholder='请选择' style={{ width: '70%' }}
allowClear> optionFilterProp="children"
{ops.map((r) => ( showSearch
<Option value={r[item.referenceCodeName]} key={r[item.referenceCodeName]}> filterOption={(input, option) =>
{r[item.referenceNameName]} option
</Option> ? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
))} : false
</Select>, }
)} placeholder="请选择"
</FormItem> allowClear>
); {ops.map((r) => (
} else if (item.name.indexOf('process_status') > -1) { <Option value={r[item.referenceCodeName]} key={r[item.referenceCodeName]}>
return ( {r[item.referenceNameName]}
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> </Option>
{form.getFieldDecorator(item.name, { ))}
initialValue: formData == null ? '' : formData[item.name], </Select>,
rules: [{ required: !item.isNull }], )}
})( </FormItem>
<Select disabled={isView} style={{ width: '70%' }} placeholder='请选择' allowClear> );
<Option value={'0'} key={'0'}> } else if (item.name.indexOf('process_status') > -1) {
审核通过 return (
</Option> <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
<Option value={'2'} key={'2'}> {form.getFieldDecorator(item.name, {
审核未通过 initialValue: formData == null ? '' : formData[item.name],
</Option> rules: [{ required: !item.isNull }],
</Select>, })(
)} <Select disabled={isView} style={{ width: '70%' }} placeholder="请选择" allowClear>
</FormItem> <Option value={'0'} key={'0'}>
); 审核通过
} else if (item.extendTypeId && item.extendTypeId.indexOf('file') > -1) { </Option>
//特殊处理附件 如果是查询就 跳过 <Option value={'2'} key={'2'}>
if (isQuery) return; 审核未通过
return ( </Option>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> </Select>,
{form.getFieldDecorator(item.name, { )}
initialValue: </FormItem>
formData == null );
? '' } else if (item.extendTypeId && item.extendTypeId.indexOf('file') > -1) {
: formData[item.name] && this.isJSON(formData[item.name]) //特殊处理附件 如果是查询就 跳过
? JSON.parse(formData[item.name]) if (isQuery) return;
: null, return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})(<UploadCom disabled={isView} />)} {form.getFieldDecorator(item.name, {
</FormItem> initialValue:
); formData == null
} else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) { ? ''
//如果是查询 并且是组合查询 : formData[item.name] && this.isJSON(formData[item.name])
? JSON.parse(formData[item.name])
const ops = groups[item.id + ''] || []; : null,
return ( rules: [{ required: !item.isNull }],
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> })(<UploadCom disabled={isView} />)}
{form.getFieldDecorator(item.name, { </FormItem>
initialValue: formData == null ? '' : formData[item.name], );
rules: [{ required: !item.isNull }], } else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) {
})( //如果是查询 并且是组合查询
<Select
disabled={isView} const ops = groups[item.id + ''] || [];
style={{ width: 200 }} return (
placeholder='请选择' <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
optionFilterProp='children' {form.getFieldDecorator(item.name, {
showSearch initialValue: formData == null ? '' : formData[item.name],
filterOption={(input, option) => rules: [{ required: !item.isNull }],
option })(
? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 <Select
: false disabled={isView}
} style={{ width: 200 }}
allowClear> placeholder="请选择"
{ops.map((r) => ( optionFilterProp="children"
<Option value={r.value} key={r.value}> showSearch
{r.value} filterOption={(input, option) =>
</Option> option
))} ? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
</Select>, : false
)} }
</FormItem> allowClear>
); {ops.map((r) => (
} else if (text.indexOf(item.type) > -1) { <Option value={r.value} key={r.value}>
return ( {r.value}
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> </Option>
{form.getFieldDecorator(item.name, { ))}
initialValue: formData == null ? '' : formData[item.name], </Select>,
rules: [{ required: !item.isNull }], )}
})(<Input disabled={isView} style={{ width: '70%' }} placeholder='请输入' />)} </FormItem>
</FormItem> );
); } else if (text.indexOf(item.type) > -1) {
} else if (number.indexOf(item.type) > -1) { return (
return ( <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> {form.getFieldDecorator(item.name, {
{form.getFieldDecorator(item.name, { initialValue: formData == null ? '' : formData[item.name],
initialValue: formData == null ? '' : formData[item.name], rules: [{ required: !item.isNull }],
rules: [ })(<Input disabled={isView} style={{ width: '70%' }} placeholder="请输入" />)}
{ required: !item.isNull }, </FormItem>
(rule, value, callback) => { );
var errors = []; } else if (number.indexOf(item.type) > -1) {
var reg = new RegExp(/(^-?[0-9][0-9]*(.[0-9]+)?)$/); return (
if (value != null && value != '' && !reg.test(value)) { <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
errors.push(new Error('请输入'), rule.field); {form.getFieldDecorator(item.name, {
} initialValue: formData == null ? '' : formData[item.name],
callback(errors); rules: [
}, { required: !item.isNull },
], (rule, value, callback) => {
})(<Input disabled={isView} placeholder='请输入' />)} var errors = [];
</FormItem> var reg = new RegExp(/(^-?[0-9][0-9]*(.[0-9]+)?)$/);
); if (value != null && value != '' && !reg.test(value)) {
} else if (isQuery && date.indexOf(item.type) > -1) { errors.push(new Error('请输入'), rule.field);
return ( }
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> callback(errors);
{form.getFieldDecorator(item.name, { },
initialValue: formData == null ? null : moment(formData[item.name]), ],
rules: [{ required: !item.isNull }], })(<Input disabled={isView} placeholder="请输入" />)}
})( </FormItem>
<RangePicker );
disabled={isView} } else if (isQuery && date.indexOf(item.type) > -1) {
format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb} return (
style={{ width: '95%' }} <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
/>, {form.getFieldDecorator(item.name, {
)} initialValue: formData == null ? null : moment(formData[item.name]),
</FormItem> rules: [{ required: !item.isNull }],
); })(
} else if (date.indexOf(item.type) > -1) { <RangePicker
return ( disabled={isView}
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb}
{form.getFieldDecorator(item.name, { style={{ width: '95%' }}
initialValue: />,
formData == null )}
? moment() </FormItem>
: formData[item.name] );
? moment(formData[item.name]) } else if (date.indexOf(item.type) > -1) {
: null, return (
rules: [{ required: !item.isNull }], <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
})( {form.getFieldDecorator(item.name, {
<DatePicker initialValue:
format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb} formData == null
style={{ width: '100%' }} ? moment()
placeholder='请输入' : formData[item.name]
disabled={isView} ? moment(formData[item.name])
/>, : null,
)} rules: [{ required: !item.isNull }],
</FormItem> })(
); <DatePicker
} else { format={item.dataFormatStrWeb == null ? 'YYYY-MM-DD HH:mm:ss' : item.dataFormatStrWeb}
return ( style={{ width: '100%' }}
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}> placeholder="请输入"
{form.getFieldDecorator(item.name, { disabled={isView}
initialValue: formData == null ? '' : formData[item.name], />,
rules: [{ required: !item.isNull }], )}
})(<Input disabled={isView} style={{ width: '70%' }} placeholder='请输入' />)} </FormItem>
</FormItem> );
); } else {
} return (
}; <FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
renderForm() { initialValue: formData == null ? '' : formData[item.name],
const { form, get } = this.props; rules: [{ required: !item.isNull }],
})(<Input disabled={isView} style={{ width: '70%' }} placeholder="请输入" />)}
const { querys } = this.state; </FormItem>
if (querys.length == 0) { );
return ''; }
} };
return ( renderForm() {
<Form layout='inline'> const { form, get } = this.props;
<Row style={{ padding: '15px' }}>
{querys.map((item) => ( const { querys } = this.state;
<Col style={{ height: 58 }} span={get === 'mobile' ? 24 : 8} key={item.id}> if (querys.length == 0) {
{this.getItem( return '';
true, }
form,
{ return (
...item, <Form layout="inline">
isNull: true, <Row style={{ padding: '15px' }}>
}, {querys.map((item) => (
true, <Col style={{ height: 58 }} span={get === 'mobile' ? 24 : 8} key={item.id}>
)} {this.getItem(
</Col> true,
))} form,
{
<Col ...item,
span={get === 'mobile' ? 24 : 8} isNull: true,
style={{ },
textAlign: get === 'mobile' ? 'right' : '', true,
paddingRight: get === 'mobile' ? 12 : '', )}
}}> </Col>
))}
<Col
span={get === 'mobile' ? 24 : 8}
style={{
textAlign: get === 'mobile' ? 'right' : '',
paddingRight: get === 'mobile' ? 12 : '',
}}>
<span className={styles.submitButtons}> <span className={styles.submitButtons}>
<Button type='primary' loading={this.props.loading} onClick={this.handleSearch}> <Button type="primary" loading={this.props.loading} onClick={this.handleSearch}>
查询 查询
</Button> </Button>
<Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}> <Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>
重置 重置
</Button> </Button>
{/* <a style={{ marginLeft: 8 }} onClick={this.toggleForm}> {/* <a style={{ marginLeft: 8 }} onClick={this.toggleForm}>
展开 <Icon type="down" /> 展开 <Icon type="down" />
</a> */} </a> */}
</span> </span>
</Col> </Col>
</Row> </Row>
</Form> </Form>
); );
} }
/** /**
* @description: 表头筛选复选框 根据用户筛选将表头内容重置 * @description: 表头筛选复选框 根据用户筛选将表头内容重置
* @param { Array<string> } 用户选择参数 * @param { Array<string> } 用户选择参数
* @return: * @return:
*/ */
CheckboxChange = (checkedValues) => { CheckboxChange = (checkedValues) => {
if (checkedValues.length === 0) { if (checkedValues.length === 0) {
message.error('至少选择一项'); message.error('至少选择一项');
return; return;
} }
const { cacheColumns } = this.state; const { cacheColumns } = this.state;
let initList = []; let initList = [];
checkedValues.map((item) => { checkedValues.map((item) => {
let ary = cacheColumns.filter((data) => data.dataIndex === item); let ary = cacheColumns.filter((data) => data.dataIndex === item);
if (ary.length !== 0) { if (ary.length !== 0) {
initList.push(ary[0]); initList.push(ary[0]);
} }
}); });
this.columns = initList; this.columns = initList;
this.setState({ this.setState({
checkedList: checkedValues, checkedList: checkedValues,
}); });
}; };
render() {
const { modalVisible, selectedRows, rights, data, isReady } = this.state;
render() {
const { modalVisible, selectedRows, rights, data, isReady } = this.state; if (!isReady) {
return (
if (!isReady) { <div
return ( style={{
<div style={{ width: 20, margin: 'auto' }}> width: 20,
<Spin /> margin: 'auto',
</div> }}>
); <Spin />
} </div>
const { );
isFormCom, }
isSelect, const {
get, isFormCom,
callback, isSelect,
valueName, get,
notShowBack, callback,
json, valueName,
istableCom, // 是否有模板设计器调用 notShowBack,
value: { btns }, json,
loading, istableCom, // 是否有模板设计器调用
} = this.props; value: { btns },
const { showMobileDiv, isView } = this.state; loading,
} = this.props;
let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度 const { showMobileDiv, isView } = this.state;
let isMobile = scrollWidth < 1000;
if (document.querySelector('#previewDiv')) { let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
isMobile = true; let isMobile = scrollWidth < 1000;
} if (document.querySelector('#previewDiv')) {
// console.log(json); isMobile = true;
let showDiv = 500; }
if (document.getElementsByClassName('ant-layout-content')?.length) { // 这是大学工项目 容器元素的宽度 // console.log(json);
showDiv = document.getElementsByClassName('ant-layout-content')[0].clientWidth - 100; let showDiv = 500;
} if (document.getElementsByClassName('ant-layout-content')?.length) {
// 这是大学工项目 容器元素的宽度
if (document.querySelector('#mobelDiv')) { // 这个是一站式的元素的宽度 showDiv = document.getElementsByClassName('ant-layout-content')[0].clientWidth - 100;
showDiv = document.querySelector('#mobelDiv')?.parentNode.clientWidth; }
}
if (json.twidth) { // 列表宽度配置项 在 组件的 扩展的配置里面 if (document.querySelector('#mobelDiv')) {
showDiv = json.twidth; // 这个是一站式的元素的宽度
} showDiv = document.querySelector('#mobelDiv')?.parentNode.clientWidth;
// console.log(showDiv); }
if (json.twidth) {
// 列表宽度配置项 在 组件的 扩展的配置里面
const parentMethods = { showDiv = json.twidth;
handleAdd: this.handleAdd, }
handleModalVisible: this.handleModalVisible, // console.log(showDiv);
formData: this.state.formData,
formItem: this.state.formItem, const parentMethods = {
isAdd: this.state.isAdd, handleAdd: this.handleAdd,
getItem: this.getItem, handleModalVisible: this.handleModalVisible,
isView: isView, formData: this.state.formData,
}; formItem: this.state.formItem,
isAdd: this.state.isAdd,
if ( getItem: this.getItem,
!isSelect && isView: isView,
!rights.includes('edit') && };
!rights.includes('delete') &&
!rights.includes('view') && if (
!rights.includes('viewProcess') !isSelect &&
) { !rights.includes('edit') &&
} else { !rights.includes('delete') &&
let width = 0; !rights.includes('view') &&
if (rights && rights.includes('viewProcess')) { !rights.includes('viewProcess')
width = width + 120; ) {
} } else {
if (rights && rights.includes('view')) { let width = 0;
width = width + 120; if (rights && rights.includes('viewProcess')) {
} width = width + 120;
if (rights && rights.includes('edit')) { }
width = width + 70; if (rights && rights.includes('view')) {
} width = width + 120;
if (rights && rights.includes('delete')) { }
width = width + 70; if (rights && rights.includes('edit')) {
} width = width + 70;
const column = { }
title: '操作', if (rights && rights.includes('delete')) {
fixed: 'right', width = width + 70;
width: width, }
render: (text, record) => { const column = {
let Dom = []; title: '操作',
if (isSelect) { fixed: 'right',
if (this.state.selects.includes(record[valueName])) { width: width,
Dom.push(<span>已选择</span>); render: (text, record) => {
} else { let Dom = [];
Dom.push(<a onClick={callback.bind(this, record, this.columns)}>选择</a>); if (isSelect) {
} if (this.state.selects.includes(record[valueName])) {
} Dom.push(<span>已选择</span>);
if (rights) { } else {
if (rights.includes('view')) { Dom.push(<a onClick={callback.bind(this, record, this.columns)}>选择</a>);
Dom.push(<a onClick={this.view.bind(this, record)}>查看详情</a>); }
} }
if (rights.includes('edit')) { if (rights) {
Dom.push(<a onClick={this.modify.bind(this, record)}>编辑</a>); if (rights.includes('view')) {
} Dom.push(<a onClick={this.view.bind(this, record)}>查看详情</a>);
if (rights.includes('viewProcess') && record.process_biz_key) { }
Dom.push(<a onClick={this.viewProcess.bind(this, record)}>流程详情</a>); if (rights.includes('edit')) {
} Dom.push(<a onClick={this.modify.bind(this, record)}>编辑</a>);
if (rights.includes('delete')) { }
Dom.push( if (rights.includes('viewProcess') && record.process_biz_key) {
<Popconfirm Dom.push(<a onClick={this.viewProcess.bind(this, record)}>流程详情</a>);
title='确定删除该数据?' }
onConfirm={this.delete.bind(this, record)} if (rights.includes('delete')) {
okText='确定' Dom.push(
cancelText='取消'> <Popconfirm
<a>删除</a> title="确定删除该数据?"
</Popconfirm>, onConfirm={this.delete.bind(this, record)}
); okText="确定"
} cancelText="取消">
} <a>删除</a>
return ( </Popconfirm>,
<Fragment> );
<div style={{ textAlign: 'center', paddingLeft: '0px', paddingRight: '0px' }}> }
{Dom && }
Dom.length && return (
Dom.map((x, index) => ( <Fragment>
<Fragment key={Math.random()}> <div
{x} style={{
{index > 0 && index !== Dom.length - 1 && <Divider type='vertical' />} textAlign: 'center',
</Fragment> paddingLeft: '0px',
))} paddingRight: '0px',
</div> }}>
</Fragment> {Dom &&
); Dom.length &&
}, Dom.map((x, index) => (
}; <Fragment key={Math.random()}>
if (this.columns.length > 0 && this.columns[this.columns.length - 1].title == '操作') { {x}
this.columns[this.columns.length - 1] = column; {index > 0 && index !== Dom.length - 1 && <Divider type="vertical" />}
} else { </Fragment>
this.columns.push(column); ))}
} </div>
} </Fragment>
// console.log(this.columns); );
if (this.columns) { },
/** };
* 计算总长度 if (this.columns.length > 0 && this.columns[this.columns.length - 1].title == '操作') {
*/ this.columns[this.columns.length - 1] = column;
AllWidth = 0; } else {
this.columns = this.columns.map((item, index) => { this.columns.push(column);
if (isEmpty(item)) { }
return item; }
} // console.log(this.columns);
if ( if (this.columns) {
index === this.columns.length - 1 && /**
this.columns[this.columns.length - 1].title !== '操作' * 计算总长度
) { */
AllWidth += 150; AllWidth = 0;
item.width = ''; this.columns = this.columns.map((item, index) => {
return item; if (isEmpty(item)) {
} return item;
let width = item.width ? item.width : 150; }
if (!item.width) { if (
item.width = 150; index === this.columns.length - 1 &&
} this.columns[this.columns.length - 1].title !== '操作'
AllWidth += width; ) {
return item; AllWidth += 150;
}); item.width = '';
if ( return item;
!isEmpty(this.columns[this.columns.length - 1]) && }
this.columns[this.columns.length - 1].title === '操作' let width = item.width ? item.width : 150;
) { if (!item.width) {
if (this.columns[this.columns.length - 2]) { item.width = 150;
this.columns[this.columns.length - 2].width = ''; }
AllWidth += 100; AllWidth += width;
} return item;
} });
} if (
!isEmpty(this.columns[this.columns.length - 1]) &&
const xxxx = ( this.columns[this.columns.length - 1].title === '操作'
<> ) {
<Card if (this.columns[this.columns.length - 2]) {
bordered={false} this.columns[this.columns.length - 2].width = '';
bodyStyle={{ padding: 0, width: json.twidth ? json.twidth : '100%' }}> AllWidth += 100;
<div className={styles.tableList}> }
<div className={styles.tableListForm}>{this.renderForm()}</div> }
<div className={styles.tableListOperator}> }
{notShowBack ? (
notShowBack const xxxx = (
) : ( <>
<Button icon='rollback' type='primary' onClick={this.goBack}> <Card
返回 bordered={false}
</Button> bodyStyle={{
)} padding: 0,
width: json.twidth ? json.twidth : '100%',
<FormListButtons btns={btns} }}>
loading={loading} <div className={styles.tableList}>
importConfig={(this.props.value && this.props.value.importConfig) || []} <div className={styles.tableListForm}>{this.renderForm()}</div>
exportConfig={(this.props.value && this.props.value.exportConfig) || []} <div className={styles.tableListOperator}>
getPage={this.getPage} {notShowBack ? (
objId={this.state.objId} notShowBack
query={JSON.stringify(this.state.formValues)} ) : (
custom={ <Button icon="rollback" type="primary" onClick={this.goBack}>
this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null 返回
} </Button>
sql={Base16Encode(this.props.sql)} )}
<FormListButtons
btns={btns}
/> loading={loading}
{/* {this.props.value && this.props.value.importConfig // 导入配置项 importConfig={(this.props.value && this.props.value.importConfig) || []}
exportConfig={(this.props.value && this.props.value.exportConfig) || []}
getPage={this.getPage}
objId={this.state.objId}
query={JSON.stringify(this.state.formValues)}
custom={this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null}
sql={Base16Encode(this.props.sql)}
/>
{/* {this.props.value && this.props.value.importConfig // 导入配置项
? this.props.value.importConfig.map((r, i) => ( ? this.props.value.importConfig.map((r, i) => (
<ImportUtil <ImportUtil
btn={r.btn} btn={r.btn}
...@@ -1321,7 +1345,7 @@ class FormList extends React.Component { ...@@ -1321,7 +1345,7 @@ class FormList extends React.Component {
)) ))
: ''}*/} : ''}*/}
{/* {this.props.value && this.props.value.exportConfig // 导出配置项 {/* {this.props.value && this.props.value.exportConfig // 导出配置项
? this.props.value.exportConfig.map((r, i) => ( ? this.props.value.exportConfig.map((r, i) => (
<ExportCurrentInfo <ExportCurrentInfo
objId={this.state.objId} objId={this.state.objId}
...@@ -1337,167 +1361,164 @@ class FormList extends React.Component { ...@@ -1337,167 +1361,164 @@ class FormList extends React.Component {
)) ))
: ''} : ''}
*/} */}
{rights && !rights.includes('add') ? ( {rights && !rights.includes('add') ? (
'' ''
) : ( ) : (
<Button icon='plus' type='primary' onClick={this.add}> <Button icon="plus" type="primary" onClick={this.add}>
新建 新建
</Button> </Button>
)} )}
{rights && !rights.includes('searchData') ? ( {rights && !rights.includes('searchData') ? (
'' ''
) : ( ) : (
<SearchInfo hanldeHighSearch={this.hanldeHighSearch} objId={this.state.objId} /> <SearchInfo hanldeHighSearch={this.hanldeHighSearch} objId={this.state.objId} />
)} )}
{rights && !rights.includes('importData') ? ( {rights && !rights.includes('importData') ? (
'' ''
) : ( ) : (
<ImportUtil objId={this.state.objId} callback={() => this.getPage()} /> <ImportUtil objId={this.state.objId} callback={() => this.getPage()} />
)} )}
{rights && !rights.includes('exportCurrent') ? ( {rights && !rights.includes('exportCurrent') ? (
'' ''
) : ( ) : (
<ExportCurrentInfo <ExportCurrentInfo
objId={this.state.objId} objId={this.state.objId}
query={JSON.stringify(this.state.formValues)} query={JSON.stringify(this.state.formValues)}
custom={this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null} custom={this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null}
sql={Base16Encode(this.props.sql)} sql={Base16Encode(this.props.sql)}
/> />
)} )}
{rights && !rights.includes('exportData') ? (
{rights && !rights.includes('exportData') ? ( ''
'' ) : (
) : ( <ExportInfo objId={this.state.objId} />
<ExportInfo objId={this.state.objId} /> )}
)} {rights && !rights.includes('statistics') ? (
{rights && !rights.includes('statistics') ? ( ''
'' ) : (
) : ( <StatisticsInfo objId={this.state.objId} />
<StatisticsInfo objId={this.state.objId} /> )}
)} {rights && !rights.includes('delete')
{rights && !rights.includes('delete') ? ''
? '' : selectedRows.length > 0 && (
: selectedRows.length > 0 && ( <span>
<span>
<Popconfirm <Popconfirm
title='确定删除该数据?' title="确定删除该数据?"
onConfirm={this.batchDelete} onConfirm={this.batchDelete}
okText='确定' okText="确定"
cancelText='取消'> cancelText="取消">
<Button>批量删除</Button> <Button>批量删除</Button>
</Popconfirm> </Popconfirm>
</span> </span>
)} )}
{rights && !rights.includes('headerFilter') ? ( {rights && !rights.includes('headerFilter') ? (
'' ''
) : ( ) : (
<Popover // 划入选择栏 <Popover // 划入选择栏
content={ content={
<div <div
style={{ style={{
width: 150, width: 150,
}}> }}>
<Checkbox.Group <Checkbox.Group
onChange={this.CheckboxChange} onChange={this.CheckboxChange}
value={this.state.checkedList} value={this.state.checkedList}
options={this.checkList} options={this.checkList}
/> />
</div> </div>
} }
title='请选择表头展示' title="请选择表头展示"
trigger='click' trigger="click"
placement='bottom'> placement="bottom">
<Button // 表头筛选控件 <Button // 表头筛选控件
className={styles.filter_btn} className={styles.filter_btn}
icon='filter'> icon="filter">
表头筛选 表头筛选
</Button> </Button>
</Popover> </Popover>
)} )}
{btns && btns.after && btns.after.length > 0 {btns && btns.after && btns.after.length > 0
? btns.after.map((r) => <Button {...r} loading={loading} />) ? btns.after.map((r) => <Button {...r} loading={loading} />)
: ''} : ''}
{ {!!this.props.otherProps &&
!!this.props.otherProps && !!this.props.otherProps.showRightTips && !!this.props.otherProps.showRightTips &&
this.props.otherProps.RightTipsComponent this.props.otherProps.RightTipsComponent}
} </div>
{!istableCom || (this.props.value && this.props.value.columns) ? (
</div> <div
{!istableCom || (this.props.value && this.props.value.columns) ? ( id="mobelDiv"
<div className={'mobelDivClassName'}
id='mobelDiv' style={{
className={'mobelDivClassName'} overflow: 'hidden',
style={{ width: isMobile ? showMobileDiv : showDiv,
overflow: 'hidden', height: '100%',
width: isMobile ? showMobileDiv : showDiv, }}>
height: '100%', {showDiv && (
}}> <StandardTable
{showDiv && ( showHeader={this.props.showHeader != null ? this.props.showHeader : true}
<StandardTable noSelectRow={
showHeader={this.props.showHeader != null ? this.props.showHeader : true} this.props.onSelectRow == null &&
noSelectRow={ (rights == null || !rights.includes('delete'))
this.props.onSelectRow == null && }
(rights == null || !rights.includes('delete')) rowKey={this.props.value?.rowKey ? this.props.value.rowKey : 'row_id'}
} data={data}
rowKey={this.props.value?.rowKey ? this.props.value.rowKey : 'row_id'} isHiddenPage={this.props.isHiddenPage != null ? this.props.isHiddenPage : false}
data={data} columns={this.columns}
isHiddenPage={this.props.isHiddenPage != null ? this.props.isHiddenPage : false} scroll={{ x: AllWidth }}
columns={this.columns} selectedRows={selectedRows}
scroll={{ x: AllWidth }} onSelectRow={this.handleSelectRows}
selectedRows={selectedRows} onChange={this.handleStandardTableChange}
onSelectRow={this.handleSelectRows} loading={this.props.loading}
onChange={this.handleStandardTableChange} />
loading={this.props.loading} )}
/> </div>
)} ) : (
</div> <div
) : ( id="mobelDiv"
<div style={{
id='mobelDiv' overflow: 'hidden',
style={{ width: isMobile ? showMobileDiv : showDiv,
overflow: 'hidden', height: '100%',
width: isMobile ? showMobileDiv : showDiv, }}>
height: '100%', <div>
}}> {get === 'mobile' ? <div>手机端,请使用浏览器将手机横屏查看</div> : null}
<div> {showDiv && (
{get === 'mobile' ? <div>手机端,请使用浏览器将手机横屏查看</div> : null} <StandardTable
{showDiv && ( showHeader={this.props.showHeader != null ? this.props.showHeader : true}
<StandardTable noSelectRow={
showHeader={this.props.showHeader != null ? this.props.showHeader : true} this.props.onSelectRow == null &&
noSelectRow={ (rights == null || !rights.includes('delete'))
this.props.onSelectRow == null && }
(rights == null || !rights.includes('delete')) rowKey={this.props.value?.rowKey ? this.props.value.rowKey : 'row_id'}
} data={data}
rowKey={this.props.value?.rowKey ? this.props.value.rowKey : 'row_id'} columns={this.columns}
data={data} scroll={this.props.value && this.props.value.columns ? {} : { x: AllWidth }}
columns={this.columns} selectedRows={selectedRows}
scroll={this.props.value && this.props.value.columns ? {} : { x: AllWidth }} isHiddenPage={
selectedRows={selectedRows} this.props.isHiddenPage != null ? this.props.isHiddenPage : false
isHiddenPage={ }
this.props.isHiddenPage != null ? this.props.isHiddenPage : false onSelectRow={this.handleSelectRows}
} onChange={this.handleStandardTableChange}
onSelectRow={this.handleSelectRows} loading={this.props.loading}
onChange={this.handleStandardTableChange} />
loading={this.props.loading} )}
/> </div>
)} </div>
</div> )}
</div> </div>
)} </Card>
</div> <CreateForm {...parentMethods} modalVisible={modalVisible} />
</Card> </>
<CreateForm {...parentMethods} modalVisible={modalVisible} /> );
</> if (isFormCom) {
); return xxxx;
if (isFormCom) { }
return xxxx; return <PageHeaderWrapper title="">{xxxx}</PageHeaderWrapper>;
} }
return <PageHeaderWrapper title=''>{xxxx}</PageHeaderWrapper>;
}
} }
export default FormList; export default FormList;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论