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 ( {/* { newlysay ? */} { // 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' ? {newlysay?.map((item, index) => { return })} : [ { value: 'true', label: '是', }, { value: 'false', label: '否', }, ]} name='done' label='是否已完成' rules={[{ required: true, message: "必填" }]} /> {newlysay?.map((item, index) => { return })} } {/* : '' } */} ) } 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);