You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
235 lines
9.0 KiB
235 lines
9.0 KiB
import React, { useEffect, useState } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { Form, Spin, Table } from 'antd';
|
|
import { DrawerForm, ProForm, ProFormText, ProFormSelect, ProFormDatePicker, ProFormTextArea } from '@ant-design/pro-form';
|
|
import { putProject } from "../../actions/infor"
|
|
import _ from 'lodash'
|
|
|
|
const data = {
|
|
"entryName": "项目名称",
|
|
"projectMileage": "项目规模(公里)",
|
|
"investment": " 项目投资(万元)",
|
|
"buildUnit": "业主单位",
|
|
"qutityUnit": "质量监督单位",
|
|
"constructionUnit": "施工单位",
|
|
"designUnit": "设计单位",
|
|
"constructionControlUnit": "监理单位",
|
|
//"startTime": "开工时间",
|
|
//"remark": "备注",
|
|
"roadCodeStart": "起点路段编码",
|
|
}
|
|
const ProjectModal = (props) => {
|
|
const { visible, onVisibleChange, typecard, rewkeys, recortd, dispatch, setRecortd, setDelet, getData } = props
|
|
//console.log('typecard', newlysay)
|
|
const [newlys, setNewlys] = useState() //必填数据
|
|
|
|
const [newlysay, setNewlysay] = useState() //处理hou
|
|
const [records, setRecords] = useState()//处理
|
|
const [recordsay, setRecordsay] = useState()//必填数据
|
|
const [success, setSuccess] = useState() //状态
|
|
useEffect(() => {
|
|
const array = []
|
|
if (rewkeys === 'road') {
|
|
_.forIn(data, function (value, key) {
|
|
array.push({ name: value, type: key })
|
|
});
|
|
setNewlys(array?.splice(0, 2))
|
|
setNewlysay(array)
|
|
// console.log()
|
|
|
|
}
|
|
if (rewkeys === 'bridge') {
|
|
_.forIn(data, function (value, key) {
|
|
array.push({ name: value, type: key })
|
|
});
|
|
setNewlys(array?.splice(0, 2))
|
|
setNewlysay(array)
|
|
// console.log()
|
|
|
|
}
|
|
}, [])
|
|
useEffect(() => {
|
|
const arr = []
|
|
if (rewkeys === 'road') {
|
|
_.forIn(recortd, function (value, key) {
|
|
arr.push({ value: value, type: key })
|
|
});
|
|
setRecordsay(arr.splice(1, 2))
|
|
|
|
setRecords(arr)
|
|
}
|
|
if (rewkeys === 'bridge') {
|
|
_.forIn(recortd, function (value, key) {
|
|
arr.push({ value: value, type: key })
|
|
});
|
|
setRecordsay(arr.splice(1, 2))
|
|
setRecords(arr)
|
|
}
|
|
}, [recortd])
|
|
useEffect(() => {
|
|
return () => {
|
|
setRecortd()
|
|
}
|
|
}, [])
|
|
// console.log(recortd)
|
|
return (
|
|
<Spin spinning={false}>
|
|
{/* {
|
|
newlysay ? */}
|
|
<DrawerForm
|
|
width={'90rem'}
|
|
visible={visible}
|
|
onVisibleChange={onVisibleChange}
|
|
onFinish={(values) => {
|
|
// console.log(values)
|
|
if (rewkeys === 'road') {
|
|
if (typecard == 'compile') {
|
|
setDelet(values)
|
|
const query = { ...values, type: rewkeys, projectId: records?.[0]?.value || '', done: values.done === 'true' ? true : false }
|
|
dispatch(putProject(query)).then((res) => {
|
|
})
|
|
getData()
|
|
return true
|
|
} else {
|
|
setDelet(values)
|
|
const query = { ...values, type: rewkeys, done: values.done === 'true' ? true : false }
|
|
dispatch(putProject(query)).then((res) => {
|
|
})
|
|
getData()
|
|
return true
|
|
}
|
|
}
|
|
if (rewkeys === 'bridge') {
|
|
if (typecard == 'compile') {
|
|
setDelet(values)
|
|
const query = { ...values, type: rewkeys, projectId: records?.[0]?.value || '', done: values.done === 'true' ? true : false }
|
|
dispatch(putProject(query)).then((res) => {
|
|
|
|
})
|
|
getData()
|
|
return true
|
|
} else {
|
|
setDelet(values)
|
|
const query = { ...values, type: rewkeys, done: values.done === 'true' ? true : false }
|
|
dispatch(putProject(query)).then((res) => {
|
|
|
|
})
|
|
getData()
|
|
return true
|
|
}
|
|
}
|
|
}}
|
|
initialValues={{ ...recortd, done: typecard == 'compile' ? recortd?.done ? 'true' : 'false' : '' }}
|
|
>
|
|
{typecard == 'compile' ?
|
|
<ProForm.Group
|
|
>
|
|
<ProFormText
|
|
name={newlys?.[0]?.type}
|
|
width="md"
|
|
label={newlys?.[0]?.name}
|
|
|
|
placeholder="请输入名称"
|
|
// value={recordsay?.[0]?.value}
|
|
// rules={[{ required: true, message: "必填" }]}
|
|
/><ProFormText
|
|
name={newlys?.[1]?.type}
|
|
width="md"
|
|
label={newlys?.[1]?.name}
|
|
|
|
placeholder="请输入名称"
|
|
// value={recordsay?.[1]?.value}
|
|
// rules={[{ required: true, message: "必填" }]}
|
|
/>
|
|
<ProFormSelect
|
|
options={[
|
|
{
|
|
value: 'true',
|
|
label: '是',
|
|
}, {
|
|
value: 'false',
|
|
label: '否',
|
|
},
|
|
]}
|
|
name='done'
|
|
label='是否已完成'
|
|
rules={[{ required: true, message: "必填" }]}
|
|
/>
|
|
{newlysay?.map((item, index) => {
|
|
return <ProFormText width="md"
|
|
name={item?.type} label={newlysay[index]?.name} placeholder="请输入名称"
|
|
key={index}
|
|
/>
|
|
})}
|
|
|
|
</ProForm.Group>
|
|
: <ProForm.Group>
|
|
<ProFormText
|
|
name={newlys?.[0]?.type}
|
|
width="md"
|
|
label={newlys?.[0]?.name}
|
|
|
|
placeholder="请输入名称"
|
|
// value={recordssy?.[0]?.value}
|
|
// rules={[{ required: true, message: "必填" }]}
|
|
/><ProFormText
|
|
name={newlys?.[1]?.type}
|
|
width="md"
|
|
label={newlys?.[1]?.name}
|
|
|
|
placeholder="请输入名称"
|
|
// value={recordssy?.[1]?.value}
|
|
// rules={[{ required: true, message: "必填" }]}
|
|
/>
|
|
<ProFormSelect
|
|
request={async () => [
|
|
{
|
|
value: 'true',
|
|
label: '是',
|
|
}, {
|
|
value: 'false',
|
|
label: '否',
|
|
},
|
|
]}
|
|
|
|
name='done'
|
|
label='是否已完成'
|
|
rules={[{ required: true, message: "必填" }]}
|
|
/>
|
|
{newlysay?.map((item, index) => {
|
|
return <ProFormText width="md"
|
|
name={item?.type} label={newlysay[index]?.name} placeholder="请输入名称" key={index}
|
|
|
|
|
|
/>
|
|
})}
|
|
|
|
|
|
</ProForm.Group>}
|
|
<ProFormDatePicker width="md" name='startTime' label='开工时间' ></ProFormDatePicker>
|
|
<ProFormTextArea width="md" name='remark' label='备注' ></ProFormTextArea>
|
|
</DrawerForm>
|
|
{/* : ''
|
|
} */}
|
|
|
|
</Spin>
|
|
)
|
|
}
|
|
function mapStateToProps (state) {
|
|
const { depMessage } = state;
|
|
const pakData = (dep) => {
|
|
return dep.map((d) => {
|
|
return {
|
|
title: d.name,
|
|
value: d.id,
|
|
children: pakData(d.subordinate)
|
|
}
|
|
})
|
|
}
|
|
let depData = pakData(depMessage.data || [])
|
|
return {
|
|
loading: depMessage.isRequesting,
|
|
depData,
|
|
};
|
|
}
|
|
export default connect(mapStateToProps)(ProjectModal);
|