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 { putRoadway, putSpecificVehicle, putHouseholds, putCircuit, putVehicle, putPurchase } from "../../actions/infor" import { putBridge } from "../../actions/infor" import _ from 'lodash' const UserModal = (props) => { const { visible, onVisibleChange, typecard, rewkeys, data, recortd, sitename, dispatch, setRecortd, setMonitor,setDelet,whichofits } = props const [newlys, setNewlys] = useState() //必填数据 const [newlysay, setNewlysay] = useState() //处理hou const [records, setRecords] = useState()//处理 const [recordsay, setRecordsay] = useState()//必填数据 // const [success, setSuccess] = useState() //状态 // const [establishment, setEstablishment] = useState() //业户类型 console.log(recortd) useEffect(() => { const array = [] if (rewkeys === 'transportation') { const xindata = [...data] setNewlys(xindata?.splice(0, 2)) setNewlysay(xindata) } if (rewkeys === 'bridge') { _.forIn(data, function (value, key) { array.push({ name: value, type: key }) }); setNewlys(array?.splice(0, 2)) setNewlysay(array) // console.log(array) } if (rewkeys === 'weihuo') { _.forIn(data, function (value, key) { array.push({ name: value, type: key }) }); setNewlys(array?.splice(0, 2)) setNewlysay(array) // console.log(array) } if (rewkeys === 'chuzu') { _.forIn(data, function (value, key) { array.push({ name: value, type: key }) }); array?.splice(1, 1) setNewlys(array?.splice(0, 2)) setNewlysay(array) } if (rewkeys === 'yehu') { _.forIn(data, function (value, key) { array.push({ name: value, type: key }) }); setNewlys(array?.splice(0, 2)) setNewlysay(array) // console.log(array) } if (rewkeys === 'xianlu') { _.forIn(data, function (value, key) { array.push({ name: value, type: key }) }); setNewlys(array?.splice(0, 2)) setNewlysay(array) } if (rewkeys === 'cheliang') { _.forIn(data, function (value, key) { array.push({ name: value, type: key }) }); setNewlys(array?.splice(0, 2)) setNewlysay(array) } if (rewkeys === 'zhichao') { _.forIn(data, function (value, key) { array.push({ name: value, type: key }) }); setNewlys(array?.splice(0, 2)) setNewlysay(array) } }, []) useEffect(() => { const arr = [] if (rewkeys === 'transportation') { _.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) } if (rewkeys === 'weihuo') { _.forIn(recortd, function (value, key) { arr.push({ value: value, type: key }) }); setRecordsay(arr.splice(1, 2)) setRecords(arr) } if (rewkeys === 'chuzu') { _.forIn(recortd, function (value, key) { arr.push({ value: value, type: key }) }); setRecordsay(arr.splice(1, 2)) setRecords(arr) } if (rewkeys === 'yehu') { _.forIn(recortd, function (value, key) { arr.push({ value: value, type: key }) }); setRecordsay(arr.splice(1, 2)) // setEstablishment(arr.splice(-1, 1)) setRecords(arr) } if (rewkeys === 'xianlu') { _.forIn(recortd, function (value, key) { arr.push({ value: value, type: key }) }); setRecordsay(arr.splice(1, 2)) // setEstablishment(arr.splice(-1, 1)) setRecords(arr) } if (rewkeys === 'cheliang') { _.forIn(recortd, function (value, key) { arr.push({ value: value, type: key }) }); setRecordsay(arr.splice(1, 2)) // setEstablishment(arr.splice(-1, 1)) setRecords(arr) } if (rewkeys === 'zhichao') { _.forIn(recortd, function (value, key) { arr.push({ value: value, type: key }) }); setRecordsay(arr.splice(1, 2)) // setEstablishment(arr.splice(-1, 1)) setRecords(arr) } }, [recortd]) useEffect(() => { return () => { setRecortd() } }, [setRecortd]) // console.log(recortd) return ( {/* { newlysay ? */} { if (Object.values(values).length > 0) { if (rewkeys === 'transportation') { if (typecard == '111') { setDelet(values) const query = { ...values, level: whichofits, roadId: records?.[0]?.value || '' } dispatch(putRoadway(query)).then((res) => { }) return true } else { setDelet(values) const query = { ...values, level: whichofits } dispatch(putRoadway(query)).then((res) => { }) return true } } if (rewkeys === 'bridge') { if (typecard == '111') { setDelet(values) const query = { ...values, roadId: records?.[0]?.value || '' } dispatch(putBridge(query)).then((res) => { }) return true } else { setDelet(values) const query = { ...values } dispatch(putBridge(query)).then((res) => { }) return true } } if (rewkeys === 'weihuo' || rewkeys === 'chuzu') { if (typecard == '111') { setDelet(values) const query = { ...values, vehicleId: records?.[0]?.value || '', type: rewkeys == 'chuzu' ? '出租车' : '危货' } dispatch(putSpecificVehicle(query)).then((res) => { }) return true } else { setDelet(values) const query = { ...values, type: rewkeys == 'chuzu' ? '出租车' : '危货' } dispatch(putSpecificVehicle(query)).then((res) => { }) return true } } if (rewkeys === 'yehu') { if (typecard == '111') { setDelet(values) const query = { ...values, businessId: records?.[0]?.value, type: rewkeys == 'chuzu' ? '出租车' : '危货' } dispatch(putHouseholds(query)).then((res) => { }) return true } else { setDelet(values) const query = { ...values, type: rewkeys === 'chuzu' ? '出租车' : '危货' } dispatch(putHouseholds(query)).then((res) => { }) return true } } if (rewkeys === 'xianlu') { if (typecard == '111') { setDelet(values) const query = { ...values, lineId: records?.[0]?.value || '' } dispatch(putCircuit(query)).then((res) => { }) return true } else { setDelet(values) const query = { ...values } dispatch(putCircuit(query)).then((res) => { }) return true } } if (rewkeys === 'cheliang') { if (typecard == '111') { setDelet(values) const query = { ...values, carId: records?.[0]?.value || '' } dispatch(putVehicle(query)).then((res) => { }) return true } else { setDelet(values) const query = { ...values } dispatch(putVehicle(query)).then((res) => { }) return true } } if (rewkeys === 'zhichao') { if (typecard == '111') { setDelet(values) const query = { ...values, overspeedId: records?.[0]?.value || '' } dispatch(putPurchase(query)).then((res) => { setMonitor(res) }) return true } else { setDelet(values) const query = { ...values } dispatch(putPurchase(query)).then((res) => { setMonitor(res) }) return true } } } else { return false } }} initialValues={recortd} > {typecard == '111' ? {rewkeys === 'yehu' ? : null } {newlysay?.map((item, index) => { return })} : {rewkeys === 'yehu' ? : null } {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)(UserModal);