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

formList组件修改

上级 d9521816
...@@ -71,8 +71,7 @@ const CreateForm = Form.create()((props) => { ...@@ -71,8 +71,7 @@ const CreateForm = Form.create()((props) => {
//处理日期何时入库问题 //处理日期何时入库问题
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;
} }
} }
...@@ -119,12 +118,7 @@ const CreateForm = Form.create()((props) => { ...@@ -119,12 +118,7 @@ const CreateForm = Form.create()((props) => {
); );
}); });
@connect(({ @connect(({ formList, DataColumn, DataObj, loading }) => ({
formList,
DataColumn,
DataObj,
loading,
}) => ({
formList, formList,
DataColumn, DataColumn,
DataObj, DataObj,
...@@ -289,19 +283,12 @@ class FormList extends React.Component { ...@@ -289,19 +283,12 @@ class FormList extends React.Component {
//渲染值 //渲染值
componentDidMount() { componentDidMount() {
const { const { dispatch } = this.props;
dispatch,
} = this.props;
window.addEventListener('resize', this.resize); window.addEventListener('resize', this.resize);
// console.log('componentDidMount'); // console.log('componentDidMount');
if (this.props.objCode) { if (this.props.objCode) {
const { const { dispatch, objCode, sql } = this.props;
dispatch,
objCode,
sql
} = this.props;
if (Number(objCode) === 1) { if (Number(objCode) === 1) {
this.initColumn(); this.initColumn();
...@@ -413,15 +400,8 @@ class FormList extends React.Component { ...@@ -413,15 +400,8 @@ class FormList extends React.Component {
} }
initColumn = () => { initColumn = () => {
const { const { dispatch, value, objCode } = this.props;
dispatch, const { rights, columnRights } = this.state;
value,
objCode
} = this.props;
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 = [];
...@@ -540,11 +520,9 @@ class FormList extends React.Component { ...@@ -540,11 +520,9 @@ class FormList extends React.Component {
return val; return val;
} }
if (datas[t].dataFormatStrWeb != null) { if (datas[t].dataFormatStrWeb != null) {
return moment(val) return moment(val).format(datas[t].dataFormatStrWeb);
.format(datas[t].dataFormatStrWeb);
} else { } else {
return moment(val) return moment(val).format('YYYY-MM-DD HH:mm:ss');
.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) {
...@@ -560,7 +538,7 @@ class FormList extends React.Component { ...@@ -560,7 +538,7 @@ class FormList extends React.Component {
{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>
); );
})} })}
...@@ -693,9 +671,13 @@ class FormList extends React.Component { ...@@ -693,9 +671,13 @@ class FormList extends React.Component {
this.setState({ this.setState({
data, data,
isReady: true, isReady: true,
selectedRows: [], // 姚鑫国说的 调了分页接口以后需要 把这个选择的行数据 清空
}); });
} else { } else {
this.setState({ data }); this.setState({
data,
selectedRows: [], // 姚鑫国说的 调了分页接口以后需要 把这个选择的行数据 清空
});
} }
}, },
}); });
...@@ -703,8 +685,7 @@ class FormList extends React.Component { ...@@ -703,8 +685,7 @@ class FormList extends React.Component {
}; };
handleStandardTableChange = (pagination, filtersArg, sorter) => { handleStandardTableChange = (pagination, filtersArg, sorter) => {
const filters = Object.keys(filtersArg) const filters = Object.keys(filtersArg).reduce((obj, key) => {
.reduce((obj, key) => {
const newObj = { ...obj }; const newObj = { ...obj };
newObj[key] = getValue(filtersArg[key]); newObj[key] = getValue(filtersArg[key]);
return newObj; return newObj;
...@@ -791,8 +772,7 @@ class FormList extends React.Component { ...@@ -791,8 +772,7 @@ class FormList extends React.Component {
for (let i in columns) { for (let i in columns) {
if (columns[i].isPrimaryKey) { if (columns[i].isPrimaryKey) {
//key //key
Keys[columns[i].name] = selectedRows.map((row) => row[columns[i].name]) Keys[columns[i].name] = selectedRows.map((row) => row[columns[i].name]).join(',');
.join(',');
} }
} }
this.props.dispatch({ this.props.dispatch({
...@@ -817,10 +797,7 @@ class FormList extends React.Component { ...@@ -817,10 +797,7 @@ class FormList extends React.Component {
handleSearch = (e) => { handleSearch = (e) => {
e.preventDefault(); e.preventDefault();
const { const { dispatch, form } = this.props;
dispatch,
form
} = this.props;
const { formValues } = this.state; const { formValues } = this.state;
...@@ -871,10 +848,7 @@ class FormList extends React.Component { ...@@ -871,10 +848,7 @@ class FormList extends React.Component {
this.getPage(params); this.getPage(params);
}; };
handleFormReset = () => { handleFormReset = () => {
const { const { form, dispatch } = this.props;
form,
dispatch
} = this.props;
form.resetFields(); form.resetFields();
this.setState( this.setState(
{ {
...@@ -886,17 +860,14 @@ class FormList extends React.Component { ...@@ -886,17 +860,14 @@ class FormList extends React.Component {
); );
}; };
getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => { getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => {
const { const { groups, isView } = this.state;
groups,
isView
} = this.state;
//如果隐藏的话 就用隐藏域放置 //如果隐藏的话 就用隐藏域放置
if (item.isHidden) { if (item.isHidden) {
return ( return (
<FormItem className={styles.hidden} key={item.id}> <FormItem className={styles.hidden} key={item.id}>
{form.getFieldDecorator(item.name, { {form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name], initialValue: formData == null ? '' : formData[item.name],
})(<Input type="hidden" placeholder="请输入"/>)} })(<Input type="hidden" placeholder="请输入" />)}
</FormItem> </FormItem>
); );
} }
...@@ -910,7 +881,7 @@ class FormList extends React.Component { ...@@ -910,7 +881,7 @@ class FormList extends React.Component {
{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: [{ required: !item.isNull }],
})(<Input style={{ width: '70%' }} readOnly={!isAdd} placeholder="请输入"/>)} })(<Input style={{ width: '70%' }} readOnly={!isAdd} placeholder="请输入" />)}
</FormItem> </FormItem>
); );
} }
...@@ -930,8 +901,7 @@ class FormList extends React.Component { ...@@ -930,8 +901,7 @@ class FormList extends React.Component {
showSearch showSearch
filterOption={(input, option) => filterOption={(input, option) =>
option option
? option.props.children.toLowerCase() ? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
.indexOf(input.toLowerCase()) >= 0
: false : false
} }
placeholder="请选择" placeholder="请选择"
...@@ -976,7 +946,7 @@ class FormList extends React.Component { ...@@ -976,7 +946,7 @@ class FormList extends React.Component {
? JSON.parse(formData[item.name]) ? JSON.parse(formData[item.name])
: null, : null,
rules: [{ required: !item.isNull }], rules: [{ required: !item.isNull }],
})(<UploadCom disabled={isView}/>)} })(<UploadCom disabled={isView} />)}
</FormItem> </FormItem>
); );
} else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) { } else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) {
...@@ -997,8 +967,7 @@ class FormList extends React.Component { ...@@ -997,8 +967,7 @@ class FormList extends React.Component {
showSearch showSearch
filterOption={(input, option) => filterOption={(input, option) =>
option option
? option.props.children.toLowerCase() ? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
.indexOf(input.toLowerCase()) >= 0
: false : false
} }
allowClear> allowClear>
...@@ -1017,7 +986,7 @@ class FormList extends React.Component { ...@@ -1017,7 +986,7 @@ class FormList extends React.Component {
{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: [{ required: !item.isNull }],
})(<Input disabled={isView} style={{ width: '70%' }} placeholder="请输入"/>)} })(<Input disabled={isView} style={{ width: '70%' }} placeholder="请输入" />)}
</FormItem> </FormItem>
); );
} else if (number.indexOf(item.type) > -1) { } else if (number.indexOf(item.type) > -1) {
...@@ -1036,7 +1005,7 @@ class FormList extends React.Component { ...@@ -1036,7 +1005,7 @@ class FormList extends React.Component {
callback(errors); callback(errors);
}, },
], ],
})(<Input disabled={isView} placeholder="请输入"/>)} })(<Input disabled={isView} placeholder="请输入" />)}
</FormItem> </FormItem>
); );
} else if (isQuery && date.indexOf(item.type) > -1) { } else if (isQuery && date.indexOf(item.type) > -1) {
...@@ -1081,17 +1050,14 @@ class FormList extends React.Component { ...@@ -1081,17 +1050,14 @@ class FormList extends React.Component {
{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: [{ required: !item.isNull }],
})(<Input disabled={isView} style={{ width: '70%' }} placeholder="请输入"/>)} })(<Input disabled={isView} style={{ width: '70%' }} placeholder="请输入" />)}
</FormItem> </FormItem>
); );
} }
}; };
renderForm() { renderForm() {
const { const { form, get } = this.props;
form,
get
} = this.props;
const { querys } = this.state; const { querys } = this.state;
if (querys.length == 0) { if (querys.length == 0) {
...@@ -1164,13 +1130,7 @@ class FormList extends React.Component { ...@@ -1164,13 +1130,7 @@ class FormList extends React.Component {
}; };
render() { render() {
const { const { modalVisible, selectedRows, rights, data, isReady } = this.state;
modalVisible,
selectedRows,
rights,
data,
isReady,
} = this.state;
if (!isReady) { if (!isReady) {
return ( return (
...@@ -1179,7 +1139,7 @@ class FormList extends React.Component { ...@@ -1179,7 +1139,7 @@ class FormList extends React.Component {
width: 20, width: 20,
margin: 'auto', margin: 'auto',
}}> }}>
<Spin/> <Spin />
</div> </div>
); );
} }
...@@ -1196,10 +1156,7 @@ class FormList extends React.Component { ...@@ -1196,10 +1156,7 @@ class FormList extends React.Component {
loading, loading,
uuid, uuid,
} = this.props; } = this.props;
const { const { showMobileDiv, isView } = this.state;
showMobileDiv,
isView
} = this.state;
let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度 let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
let isMobile = scrollWidth < 1000; let isMobile = scrollWidth < 1000;
...@@ -1207,7 +1164,10 @@ class FormList extends React.Component { ...@@ -1207,7 +1164,10 @@ class FormList extends React.Component {
isMobile = true; isMobile = true;
} }
const showDiv = countWidth({json, uuid}); const showDiv = countWidth({
json,
uuid,
});
const parentMethods = { const parentMethods = {
handleAdd: this.handleAdd, handleAdd: this.handleAdd,
handleModalVisible: this.handleModalVisible, handleModalVisible: this.handleModalVisible,
...@@ -1287,7 +1247,7 @@ class FormList extends React.Component { ...@@ -1287,7 +1247,7 @@ class FormList extends React.Component {
Dom.map((x, index) => ( Dom.map((x, index) => (
<Fragment key={Math.random()}> <Fragment key={Math.random()}>
{x} {x}
{index > 0 && index !== Dom.length - 1 && <Divider type="vertical"/>} {index > 0 && index !== Dom.length - 1 && <Divider type="vertical" />}
</Fragment> </Fragment>
))} ))}
</div> </div>
...@@ -1408,13 +1368,13 @@ class FormList extends React.Component { ...@@ -1408,13 +1368,13 @@ class FormList extends React.Component {
{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') ? (
...@@ -1431,12 +1391,12 @@ class FormList extends React.Component { ...@@ -1431,12 +1391,12 @@ class FormList extends React.Component {
{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')
? '' ? ''
...@@ -1478,7 +1438,7 @@ class FormList extends React.Component { ...@@ -1478,7 +1438,7 @@ class FormList extends React.Component {
</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 &&
...@@ -1548,7 +1508,7 @@ class FormList extends React.Component { ...@@ -1548,7 +1508,7 @@ class FormList extends React.Component {
)} )}
</div> </div>
</Card> </Card>
<CreateForm {...parentMethods} modalVisible={modalVisible}/> <CreateForm {...parentMethods} modalVisible={modalVisible} />
</> </>
); );
if (isFormCom) { if (isFormCom) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论