Browse Source

增加工程弹窗

release_0.0.1
xingyongchun 3 years ago
parent
commit
23bbec827e
  1. 222
      web/client/src/sections/fillion/components/project/project.js

222
web/client/src/sections/fillion/components/project/project.js

@ -0,0 +1,222 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { Form, Spin, Table } from 'antd';
import { DrawerForm, ProForm, ProFormText,ProFormSelect } from '@ant-design/pro-form';
import { putProject } from "../../actions/infor"
const data = {
"entryName": "项目名称",
"projectMileage": "工程里程",
"investment": "投资",
"buildUnit": "建设单位",
"constructionControlUnit": "监理单位",
"designUnit": "设计单位",
"constructionUnit": "施工单位",
"supervisorAndSupervisor": "监督负责人及监督人员",
"projectProgress": "项目进展情况"
}
const ProjectModal = (props) => {
const { visible, onVisibleChange, typecard, rewkeys, recortd, sitename, dispatch, setRecortd, engineering } = props
const [newlys, setNewlys] = useState() //必填数据
const [newlysay, setNewlysay] = useState() //处理hou
const [records, setRecords] = useState()//处理
const [recordsay, setRecordsay] = useState()//必填数据
const [success, setSuccess] = useState() //状态
const [flage, setFlage] = useState() //xiangmujinzhan
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) => {
if (rewkeys === 'road') {
if (typecard == '111') {
console.log(values)
const query = { ...values, type:rewkeys }
dispatch(putProject(query)).then((res) => {
setSuccess(res.success)
})
return success
} else {
const query = { ...values, type:rewkeys }
dispatch(putProject(query)).then((res) => {
setSuccess(res.success)
})
return success
}
}
if (rewkeys === 'bridge') {
if (typecard == '111') {
console.log(values)
const query = { ...values, type:rewkeys }
dispatch(putProject(query)).then((res) => {
setSuccess(res.success)
})
return success
} else {
const query = { ...values, type:rewkeys }
dispatch(putProject(query)).then((res) => {
setSuccess(res.success)
})
return success
}
}
}}
initialValues={recortd}
>
{typecard == '111' ?
<ProForm.Group
>
<ProFormText
name={newlys?.[0]?.type}
width="md"
label={newlys?.[0]?.name}
tooltip="最长为 24 位"
placeholder="请输入名称"
value={recordsay?.[0]?.value}
rules={[{ required: true, message: "必填" }]}
/><ProFormText
name={newlys?.[1]?.type}
width="md"
label={newlys?.[1]?.name}
tooltip="最长为 24 位"
placeholder="请输入名称"
value={recordsay?.[1]?.value}
rules={[{ required: true, message: "必填" }]}
/>
<ProFormSelect
options={[
{
value: 'true',
label: '是',
},{
value: 'false',
label: '否',
},
]}
width="xs"
name='done'
label='是否已完成'
/>
{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}
tooltip="最长为 24 位"
placeholder="请输入名称"
// value={recordssy?.[0]?.value}
rules={[{ required: true, message: "必填" }]}
/><ProFormText
name={newlys?.[1]?.type}
width="md"
label={newlys?.[1]?.name}
tooltip="最长为 24 位"
placeholder="请输入名称"
// value={recordssy?.[1]?.value}
rules={[{ required: true, message: "必填" }]}
/>
<ProFormSelect
options={[
{
value: 'true',
label: '是',
},{
value: 'false',
label: '否',
},
]}
width="xs"
name='done'
label='是否已完成'
/>
{newlysay?.map((item, index) => {
return <ProFormText width="md"
name={item?.type} label={newlysay[index]?.name} placeholder="请输入名称" key={index}
tooltip="最长为 24 位"
/>
})}
</ProForm.Group>}
</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);
Loading…
Cancel
Save