diff --git a/src/components/crud/BasicCrudModal2.js b/src/components/crud/BasicCrudModal2.js new file mode 100644 index 000000000..53ca425fb --- /dev/null +++ b/src/components/crud/BasicCrudModal2.js @@ -0,0 +1,217 @@ +import React from 'react'; +import { Modal, message } from 'antd'; +import { createCrudService } from './_'; +import apiurl from '../../service/apiurl'; + +class BasicCrudModal extends React.Component { + constructor(props) { + super(props); + + this.state = { + record: null, + open: false, + mode: null, + }; + } + + showEdit(record) { + this.setState({ record, open: true, mode: 'edit' }); + } + + showSave(record) { + record = record || {}; + this.setState({ record, open: true, mode: 'save' }); + } + showSimilarSave(record) { + record = record || {}; + this.setState({ record, open: true, mode: 'similarSave' }); + } + show(record) { + record = record || {}; + this.setState({ record, open: true, mode: 'show' }); + } + + showView(record) { + record = record || {}; + this.setState({ record, open: true, mode: 'view' }); + + } + + showReView(record) { + record = record || {}; + this.setState({ record, open: true, mode: 'review' }); + + } + + showAdd(record) { + record = record || {}; + this.setState({ record, open: true, mode: 'add' }); + } + + showImp() { + this.setState({ open: true, mode: 'imp' }); + } + + onEdit = (path,values) => { + createCrudService(path).edit1(values).then((result) => { + if (result?.code === 200) { + message.success('修改成功'); + this.setState({ open: false }); + + if (this.props.onCrudSuccess) { + this.props.onCrudSuccess(); + } + if (this.props.extraFun) { + this.props.extraFun(); + } + } else { + message.error(result?.msg||'修改失败'); + } + }) + } + + onSave = (path,values) => { + createCrudService(path).save(values).then((result) => { + if (result?.code === 200) { + message.success('保存成功'); + this.setState({ open: false }); + if (this.props.onCrudSuccess) { + this.props.onCrudSuccess(); + } + if (this.props.extraFun) { + this.props.extraFun(); + } + } else { + message.error(result?.msg||'保存失败'); + } + }) + } + + + onDelete = (path, values) => { + createCrudService(path).del(values).then((result) => { + if (result?.code === 200) { + message.success('删除成功'); + this.setState({ open: false }); + if (this.props.onCrudSuccess) { + this.props.onCrudSuccess(); + } + } else { + message.error(result?.msg||'删除失败'); + } + }) + } + + onDeleteGet = (path,values) => { + createCrudService(path).delGet(values).then((result) => { + if (result?.code === 200) { + message.success('删除成功'); + this.setState({ open: false }); + if (this.props.onCrudSuccess) { + this.props.onCrudSuccess(); + } + if (this.props.extraFun) { + this.props.extraFun(); + } + } else { + message.error(result?.msg||'删除失败'); + } + }) + } + + onDeletePost= (path,values) => { + createCrudService(path).edit1(values).then((result) => { + if (result?.code === 200) { + message.success('删除成功'); + this.setState({ open: false }); + if (this.props.onCrudSuccess) { + this.props.onCrudSuccess(); + } + if (this.props.extraFun) { + this.props.extraFun(); + } + } else { + message.error(result?.msg||'删除失败'); + } + }) + } + onSimilarSave = (path, values) => { + createCrudService(path).delGet(values).then((result) => { + if (result?.code === 200) { + message.success('类似新增成功'); + this.setState({ open: false }); + if (this.props.onCrudSuccess) { + this.props.onCrudSuccess(); + } + } else { + message.error(result?.msg||'类似新增失败'); + } + }) + } + onFileGet = (path,values) => { + createCrudService(path).delGet(values).then((result) => { + if (result?.code === 200) { + message.success('删除成功'); + this.setState({ open: false }); + if (this.props.onCrudSuccess) { + this.props.onCrudSuccess(); + } + + + } else { + message.error(result?.msg||'删除失败'); + } + }) + } + + + whichMod = (value) => { + if(value === 'save'){ + return '新增' + }else if (value === 'add' || value === ''){ + return '新增' + }else if (value === 'edit'){ + return '修改' + }else if (value === 'view'){ + return '查看' + }else if (value === 'show' || value === 'review'){ + return '' + } else { + return '新增' + } + } + + render() { + const { record, open, mode } = this.state; + const { width, title, style, wrapClassName, formProps, component: Component,extraFun } = this.props; + if (!record || !open) { + return null; + } + + return ( + { this.setState({ open: false }) }} + > + {this.setState({ open: false })}} + onCrudSuccess={this.props.onCrudSuccess} + record={record} + onEdit={this.onEdit} + onSave={this.onSave} + onSimilarSave={this.onSimilarSave} + formProps={formProps} + /> + + ); + } +} + +export default BasicCrudModal; diff --git a/src/models/auth/_.ts b/src/models/auth/_.ts index e0ef8d364..259968102 100644 --- a/src/models/auth/_.ts +++ b/src/models/auth/_.ts @@ -193,46 +193,133 @@ export async function loadMenu(): Promise { const id = idgen() return [ { id: id(), title: '水库一张图', path: '/mgr/home', icon: 'jbqk' }, - - { id: id(), title: '四预', redirect: '/mgr/sy/fhxzfx', icon: 'fxzb', + { + id: id(), title: '四制', redirect: '/mgr/sz/gltx/zzjgck', icon: 'jbqk', children: [ - { id: id(), title: '防洪现状分析', path: '/mgr/sy/fhxzfx'}, - { id: id(), title: '天气预报', path: '/mgr/sy/tqyb'}, { - id: id(), title: '洪水预报', redirect: '/mgr/sy/hsyb/hyybjs', + id: id(), title: '管理体系', redirect: '/mgr/sz/gltx/zzjgck', children: [ - { id: id(), title: '洪水预报计算', path: '/mgr/sy/hsyb/hyybjs' }, - { id: id(), title: '预报方案管理', path: '/mgr/sy/hsyb/ybfagl' }, - { id: id(), title: '参数管理', path: '/mgr/sy/hsyb/csgl' }, + { + id: id(), title: '管理体系', path: '/mgr/sz/gltx/zzjgck', + }, + { + id: id(), title: '责任人管理', path: '/mgr/sz/gltx/zrrgl', + } ] }, - { id: id(), title: '调度规程', path: '/mgr/fxzb/ddgc'}, - { id: id(), title: '防汛预案', path: '/mgr/fxzb/fxya'}, + { + id: id(), title: '监督考核', redirect: '/mgr/sz/jdkh/khtj', + children: [ + { + id: id(), title: '考核统计', path: '/mgr/sz/jdkh/khtj', + }, + { + id: id(), title: '考核任务管理', path: '/mgr/sz/jdkh/khrwgl', + }, + { + id: id(), title: '考核问题整改', path: '/mgr/sz/jdkh/khwtzg', + }, + { + id: id(), title: '考核指标管理', path: '/mgr/sz/jdkh/khzbgl', + }, + { + id: id(), title: '考核模板管理', path: '/mgr/sz/jdkh/khmbgl', + } + ] + } + ] + }, + { id: id(), title: '四预', redirect: '/mgr/sy/fhxzfx', icon: 'fxzb', + children: [ + { id: id(), title: '防洪形势', path: '/mgr/sy/fhxzfx'}, + // { id: id(), title: '天气预报', path: '/mgr/fxzb/tqyb'}, + // { + // id: id(), title: '洪水预报', redirect: '/mgr/fxzb/hsyb/hyybjs', + // children: [ + // { id: id(), title: '洪水预报计算', path: '/mgr/fxzb/hsyb/hyybjs' }, + // { id: id(), title: '预报方案管理', path: '/mgr/fxzb/hsyb/ybfagl' }, + // { id: id(), title: '参数管理', path: '/mgr/fxzb/hsyb/csgl' }, + // ] + // }, + { id: id(), title: '防汛预案', path: '/mgr/sy/fxya'}, + { id: id(), title: '调度规程', path: '/mgr/sy/ddgc'}, { id: id(), title: '抢险物料', - path: '/mgr/fxzb/qxwl', + path: '/mgr/sy/qxwl', }, { id: id(), title: '抢险队伍', - path: '/mgr/fxzb/qxdw', + path: '/mgr/sy/qxdw', }, ], }, - - { - id: id(), - title: '工程安全监测', - redirect: '/mgr/gcaqjc/gcaqyj/bzt', - icon: 'fxzb', + { id: id(), title: '四管', redirect: '/mgr/sg/xcxj/xcrw', icon: 'fxzb', children: [ - { id: id(), title: '布置图', path: '/mgr/gcaqjc/gcaqyj/bzt' }, + { + id: id(), title: '巡查巡检', redirect: '/mgr/sg/xcxj/xcrw', + children: [ + { id: id(), title: '巡检任务', path: '/mgr/sg/xcxj/xcrw' }, + { id: id(), title: '巡检问题处理', path: '/mgr/sg/xcxj/xjwtcl' }, + { id: id(), title: '巡检项配置', path: '/mgr/sg/xcxj/xjxpz' }, + ] + }, + { + id: id(), title: '安全管理', redirect: '/mgr/sg/aqgl/fxgkqd', + children: [ + { id: id(), title: '风险管控清单', path: '/mgr/sg/aqgl/fxgkqd' }, + { id: id(), title: '安全隐患排查', path: '/mgr/sg/aqgl/aqyhpc' }, + { id: id(), title: '安全检查管理', path: '/mgr/sg/aqgl/aqjcgl' }, + { id: id(), title: '安全事故登记', path: '/mgr/sg/aqgl/aqsgdj' }, + { id: id(), title: '安全鉴定台帐', path: '/mgr/sg/aqgl/aqjdtz' }, + { id: id(), title: '除险加固台帐', path: '/mgr/sg/aqgl/cxjgtz' }, + ] + }, + { + id: id(), title: '白蚁防治', redirect: '/mgr/sg/byfz/bypc', + children: [ + { id: id(), title: '白蚁普查', path: '/mgr/sg/byfz/bypc' }, + { id: id(), title: '防治宣传', path: '/mgr/sg/byfz/byxc' }, + ] + }, + { + id: id(), title: '维修养护', path: '/mgr/sg/wxyh', + }, + { + id: id(), title: '值班管理', redirect: '/mgr/sg/zbgl/zbb', + children: [ + { id: id(), title: '值班表', path: '/mgr/sg/zbgl/zbb' }, + { id: id(), title: '值班日志', path: '/mgr/sg/zbgl/zbrz' }, + ] + }, + { + id: id(), title: '报表管理', redirect: '/mgr/sg/btbb/sdjyrbb', + children: [ + { id: id(), title: '时段降雨日报表', path: '/mgr/sg/btbb/sdjyrbb' }, + { id: id(), title: '日降雨量年报表', path: '/mgr/sg/btbb/rjylnbb' }, + { id: id(), title: '时段水位日报表', path: '/mgr/sg/btbb/sdswbb' }, + { id: id(), title: '日均水位年报表', path: '/mgr/sg/btbb/rjswbb' }, + ] + }, + { + id: id(), title: '告警管理', redirect: '/mgr/sg/gjgl/aigj', + children: [ + { id: id(), title: 'AI告警', path: '/mgr/sg/gjgl/aigj' }, + { id: id(), title: '广播预警', path: '/mgr/sg/gjgl/gbyj' }, + ] + }, + ], + }, + { id: id(), title: '工程安全监测', redirect: '/mgr/gcaqjc/gcaqyj/bzt', icon: 'fxzb', + children: [ + { + id: id(), title: '布置图', path: '/mgr/gcaqjc/gcaqyj/bzt', + }, { id: id(), title: '工程安全分析', redirect: '/mgr/gcaqjc/gcaqfx/jrx', children: [ - { id: id(), title: '浸润线', path: '/mgr/gcaqjc/gcaqfx/jrx' }, - + { id: id(), title: '浸润线', path: '/mgr/gcaqjc/gcaqfx/jrx'}, ] }, { @@ -240,23 +327,19 @@ export async function loadMenu(): Promise { children: [ { id: id(), title: '隐患预警', path: '/mgr/gcaqjc/gcaqyj/yhyj' }, { id: id(), title: '预警规则配置', path: '/mgr/gcaqjc/gcaqyj/yjgzpz' }, - ] }, { - id: id(), title: '数据统计查询', redirect: '/mgr/gcaqjc/sjtjcx/sljx', + id: id(), title: '数据统计查询', redirect: '/mgr/gcaqjc/sjtjcx/czcx', children: [ { id: id(), title: '测值查询', path: '/mgr/gcaqjc/sjtjcx/czcx' }, { id: id(), title: '渗压监测', path: '/mgr/gcaqjc/sjtjcx/syjx' }, - { id: id(), title: '渗流监测', path: '/mgr/gcaqjc/sjtjcx/sljx' }, - { id: id(), title: '位移监测', path: '/mgr/gcaqjc/sjtjcx/wyjx' }, + { id: id(), title: '渗流监测 ', path: '/mgr/gcaqjc/sjtjcx/sljx' }, + { id: id(), title: '位移监测 ', path: '/mgr/gcaqjc/sjtjcx/wyjx' }, { id: id(), title: '年度渗压统计表', path: '/mgr/gcaqjc/sjtjcx/ndsytjb' }, { id: id(), title: '年度渗流统计表', path: '/mgr/gcaqjc/sjtjcx/ndsltjb' }, - { id: id(), title: '年度位移统计表', path: '/mgr/gcaqjc/sjtjcx/ndwytjb' }, - ] }, - ], }, diff --git a/src/service/apiurl.js b/src/service/apiurl.js index 058492be4..0a4f2a2ea 100644 --- a/src/service/apiurl.js +++ b/src/service/apiurl.js @@ -7,6 +7,13 @@ const zdkapi = 'https://slt-sh.chutianyun.gov.cn:8002' //中电科的市级平 const service_fxdd = '/gunshiApp/xyt' const service_shzh = '/shzh' const apiurl = { + fxya: { + page: service_fxdd + "/resPlanB/list", + update: service_fxdd + "/resPlanB/update", + save: service_fxdd + "/resPlanB/insert", + delete:service_fxdd + "/resPlanB/del", + getFile:service_fxdd + "/resPlanB/file/get" + }, setMenu: service_fxdd + '/visitMenuLog/insert', setPassword: service_fxdd + '/user/updateSecretKey', xytlogin: { @@ -414,11 +421,10 @@ const apiurl = { controler:service_fxdd + "/attCctvBase/control" } }, - sdz:{ + sdz: { zrrByCode:service_fxdd + '/hEHystSafePerson/hystCode', gctp:service_fxdd + '/attHystBase/projectImgList', sjzl:service_fxdd + '/attHystBase/desFileList', - fxya:service_fxdd + '/attHystBase/planList', delGctp:service_fxdd + '/hEHystProjectImg/delete', filedNameById:service_fxdd + '/hEHystProjectImg/file/get/' }, diff --git a/src/views/AppRouters.tsx b/src/views/AppRouters.tsx index 0b41e1b57..e86283d6a 100644 --- a/src/views/AppRouters.tsx +++ b/src/views/AppRouters.tsx @@ -79,6 +79,10 @@ import Gstjfx from "./gxsl/gstjfx" import Spjk from "./video" import AiWarn from "./spjk/aiWarn" + +// 四制 - 组织机构查看 +import Zzjgck from './sz/zzjgck' + const HomePage = lazy(() => import('./Home')) const IframePage = lazy(() => import('./Iframe')) @@ -118,16 +122,16 @@ const AppRouters: React.FC = () => { { path: 'sy/hsyb/csgl', element: }, // 调度规程 - { path: 'fxzb/ddgc', element: }, + { path: 'sy/ddgc', element: }, // 防汛预案 - { path: 'fxzb/fxya', element: }, + { path: 'sy/fxya', element: }, // 抢险物料 - { path: 'fxzb/qxwl', element: }, + { path: 'sy/qxwl', element: }, // 抢险队伍 - { path: 'fxzb/qxdw', element: }, + { path: 'sy/qxdw', element: }, // 工程安全监测 @@ -149,33 +153,33 @@ const AppRouters: React.FC = () => { { path: 'gcaqjc/gcaqfx/jrx', element: }, // 日常管理-水质整编 - { path: 'rcgl/btbb/rjswbb', element: }, - { path: 'rcgl/btbb/rjylnbb', element: }, - { path: 'rcgl/btbb/sdswbb', element: }, - { path: 'rcgl/btbb/sdjyrbb', element: }, - { path: 'rcgl/xcxj/xcrw', element: }, - { path: 'rcgl/xcxj/xjwtcl', element: }, - { path: 'rcgl/xcxj/xjxpz', element: }, - { path: 'byfz/fzxc', element: }, - { path: 'byfz/bypc', element: }, - { path: 'rcgl/wxyh', element: }, - { path: 'rcgl/aqgl/aqjcgl', element: }, - { path: 'rcgl/aqgl/fxgkqd', element: }, - { path: 'rcgl/aqgl/cxjbtz', element: }, - { path: 'rcgl/aqgl/aqjdtz', element: }, - { path: 'rcgl/aqgl/aqyhpc', element: }, - { path: 'rcgl/aqgl/aqsgdj', element: }, - { path: 'rcgl/gcdsj', element: }, - { path: 'rcgl/szzb', element: }, + { path: 'sg/btbb/rjswbb', element: }, + { path: 'sg/btbb/rjylnbb', element: }, + { path: 'sg/btbb/sdswbb', element: }, + { path: 'sg/btbb/sdjyrbb', element: }, + { path: 'sg/xcxj/xcrw', element: }, + { path: 'sg/xcxj/xjwtcl', element: }, + { path: 'sg/xcxj/xjxpz', element: }, + { path: 'sg/byfz/byxc', element: }, + { path: 'sg/byfz/bypc', element: }, + { path: 'sg/wxyh', element: }, + { path: 'sg/aqgl/aqjcgl', element: }, + { path: 'sg/aqgl/fxgkqd', element: }, + { path: 'sg/aqgl/cxjgtz', element: }, + { path: 'sg/aqgl/aqjdtz', element: }, + { path: 'sg/aqgl/aqyhpc', element: }, + { path: 'sg/aqgl/aqsgdj', element: }, + { path: 'sg/gcdsj', element: }, + { path: 'sg/szzb', element: }, { path: 'rcgl/stlljc', element: }, - { path: 'rcgl/zbgl/zbb', element: }, - { path: 'rcgl/zbgl/zbrz', element: }, + { path: 'sg/zbgl/zbb', element: }, + { path: 'sg/zbgl/zbrz', element: }, // 日常管理-监督考核 - { path: 'rcgl/jdkh/khtj', element: }, - { path: 'rcgl/jdkh/khzbgl', element: }, - { path: 'rcgl/jdkh/khmbgl', element: }, - { path: 'rcgl/jdkh/khwtzg', element: }, - { path: 'rcgl/jdkh/khrwgl', element: }, + { path: 'sz/jdkh/khtj', element: }, + { path: 'sz/jdkh/khzbgl', element: }, + { path: 'sz/jdkh/khmbgl', element: }, + { path: 'sz/jdkh/khwtzg', element: }, + { path: 'sz/jdkh/khrwgl', element: }, // 供水兴利 @@ -188,7 +192,7 @@ const AppRouters: React.FC = () => { { path: 'fxzb/jczw/sqz', element: }, // 视频监控 { path: 'spjk/spjk', element: }, - { path: 'spjk/aiWarn', element: }, + { path: 'sg/gjgl/aigj', element: }, // { path: 'fxzb/zbb', element: }, // { path: 'fxzb/txl', element: }, @@ -207,6 +211,9 @@ const AppRouters: React.FC = () => { { path: 'fxdd/ddjc/yjxy', element: }, { path: 'fxdd/ddjc/ddzl', element: }, { path: 'videoSurveillance', element: }, + + // 四制-组织机构查看 + { path: 'sz/gltx/zzjgck', element: }, ], }, { path: '/login', element: }, diff --git a/src/views/fxzb/ddgc/form.js b/src/views/fxzb/ddgc/form.js index f9d3777eb..8770a8a5a 100644 --- a/src/views/fxzb/ddgc/form.js +++ b/src/views/fxzb/ddgc/form.js @@ -1,38 +1,96 @@ -import React,{useEffect,useState} from 'react'; -import { Form, Button, Input, message,Row, Col, DatePicker,Upload,Image,Modal } from 'antd'; -import { DeleteOutlined,FileWordOutlined,FilePdfOutlined,FilePptOutlined,FileZipOutlined,FileExcelOutlined } from '@ant-design/icons'; +import React,{useEffect,useState,useRef} from 'react'; +import { Form, Button, Input, Row, Col,Upload,DatePicker,Modal,message,Image } from 'antd'; +import {PaperClipOutlined,DeleteOutlined,FileWordOutlined,FilePdfOutlined,FilePptOutlined,FileZipOutlined,FileExcelOutlined} from '@ant-design/icons'; import { formItemLayout, btnItemLayout } from '../../../components/crud/FormLayoutProps'; import apiurl from '../../../service/apiurl'; -import { createCrudService } from '../../../components/crud/_'; +import { httpget2 } from '../../../utils/request'; import moment from 'moment'; -const { Dragger } = Upload; +import "./index.less"; const url = "http://223.75.53.141:9102/test.by-lyf.tmp" -const ModalForm = ({ mode, record,onEdit,onSave }) => { - if(record.prodDate){ - record.myTm = moment(record.prodDate) - } +const ModalForm = ({ mode, record,onEdit,onSave,onCrudSuccess }) => { const [form] = Form.useForm(); const [fileList, setFileList] = useState([]) //上传文件列表 - const [fileIds, setFileIds] = useState([]) - const [flag, setFlag] = useState(true) - const [iframeSrc, setIframeSrc] = useState('') - const [pdfViewOPen, setPdfViewOPen] = useState(false) const [loading, setLoading] = useState(false) - /** - * @description 删除上传的图片 - * @param {string} id 删除的id - */ - const deleteFile = (fileId) => { - let filterFile = fileList.filter(item => item.response?.data?.fileId !== fileId); - setFileList(filterFile) + const [iframeId, setIframeId] = useState('') + const [perviewOpen, setPerviewOpen] = useState(false) + + const fileChange = (info) => { + console.log("file",info); + + if (info.file.status === "done") { + setLoading(false); + setFileList(info.fileList) + + } + if (info.file.status === "uploading") { + setLoading(true); + } + if (info.file.status === "error") { + message.error("文件上传失败") + setLoading(false); + } + if (fileList.length > 0) { + return + } + setFileList(info.fileList) } - /** - * @description 文件下载 - * @param {String} params 文件fileId - */ - const download = (params) => { + + const deleteFile = (fileId) => { + let filterFile = fileList.filter(item => item.response?.data?.fileId !== fileId); + setFileList(filterFile) +} + const onFinish = async (values) => { + if (fileList.length <= 0) { + message.error("请上传预案文件") + return + } + let oldFiles = fileList.map(item => ({ fileId: item.response?.data?.fileId })) + values.resCode = "42120250085" + values.type = 2 + values.files = oldFiles; + values.prepTime = moment(values.prepTime).format("YYYY-MM-DD 00:00:00") + values.apprTime = moment(values.apprTime).format("YYYY-MM-DD 00:00:00") + if (mode === 'edit') { + values.id = record?.id; + onEdit(apiurl.fxya.update,values) + } + if (mode === 'save') { + onSave(apiurl.fxya.save,values) + } + } + + const viewPdf = (params) => { + setIframeId(params) + setPerviewOpen(true) + } + const beforeUpload = () => { + if (fileList.length > 0) { + message.error("只能上传一个附件"); + return false; + } + } + const getFileInfo = async(id) => { + try { + const res = await httpget2(`${apiurl.dataResourcesCenter.projectAndWater.fxya.getFile}/${id}`) + let obj ={ + name: res.data.fileName, + response: { + data: { + filePath: res.data.filePath, + fileId:res.data.fileId + } + }, + } + setFileList([obj]) + } catch (error) { + console.log(error); + + } + } + + const download = (params) => { let downloadLink = document.createElement("a"); - downloadLink.href = `http://local.gunshiiot.com:18083/gunshiApp/xfflood/xfIdeoImgB/file/download/${params}`; + downloadLink.href = `http://local.gunshiiot.com:18083/gunshiApp/xyt/resPlanB/file/download/${params}`; downloadLink.download = `${params.fileName}`; downloadLink.style.display = "none"; // 将链接添加到页面中 @@ -41,153 +99,120 @@ const ModalForm = ({ mode, record,onEdit,onSave }) => { // 模拟点击事件,开始下载 downloadLink.click(); } - /** - * @description 上传图片 - * @param {string} file 上传的文件 - */ - const fileChange = (info) => { - if (info.file.status === "done") { - setLoading(false); - } - if (info.file.status === "uploading") { - setLoading(true); - } - if (info.file.status === "error") { - message.error("文件上传失败") - setLoading(false); - } - let fileIds = info.fileList.map(file => { - return file.response?.data?.fileId - }) - setFileIds(fileIds) - setFileList(info.fileList) - setFlag(false) - } - const onFinish = (values) => { - if(values.myTm){ - values.prodDate = moment(values.myTm).format('YYYY-MM-DD') - delete values.myTm - } - if (mode === 'edit') { - let oldFiles = fileList.map(item => item.response?.data?.fileId ) - values.id = record.id - values.fileIds = oldFiles; - onEdit(apiurl.fxzb.sxfd.fxtj.edit,values) - } - if (mode === 'save') { - values.fileIds = fileIds - onSave(apiurl.fxzb.sxfd.fxtj.save,values) - } - } - /** - * @description 获取查看时文件 - * @param {*} type - * @returns - */ - const getFileInfo = (params) => { - let fetchArr = params?.attachList.map(item => { - return createCrudService(apiurl.fxzb.gczx.ytygc.getFile + `/${item.fileId}`) - .delGet() - } - ); - Promise.all(fetchArr).then(res => { - let fileArr = res.map(item => { - return { - name: item.data.fileName, - response: { - data: { - filePath: item.data.filePath, - fileId:item.data.fileId - } - }, - } - }) - setFlag(true) - setFileList(fileArr) - }).catch(err => console.log(err)) - } - /** - * @description pdf文件预览 - * @param {String} params 文件预览url - */ - const viewPdf = (params) => { - if (params) { - setIframeSrc(params) - setPdfViewOPen(true) - } - } useEffect(() => { - console.log(record); - if ((mode === "view" || mode === "edit") && record.attachList?.length) { - getFileInfo(record) - } - }, [record, mode]) + if (record && mode != "save") { + getFileInfo(record?.files[0]?.fileId) + } + }, [record,mode]) + return ( <>
- + + - - + + + - + - - - + dateString} + getValueProps={value => ({ + value: value ? moment(value) : undefined + })} rules={[{ required: true }]} > - + - - - - + + + - {mode !== "view" && - + + + + dateString} + getValueProps={value => ({ + value: value ? moment(value) : undefined + })} + rules={[{ required: true }]} + > + + + + + + + + { console.log(info.dataTransfer.files); }} - fileList={fileList} - disabled={loading} - // onSuccess={handleSuccess} + fileList={fileList} + maxCount={1} + disabled={loading} + showUploadList={false} + beforeUpload={beforeUpload} > -

点击或拖拽文件到此区域上传

-

- 支持扩展名:.rar .zip .doc .docx .pdf .jpg .png .ppt -

- - } - + {mode == "view" ? null : + + } +
+
+ + +
+ { loading ? 文件正在上传中,请等待 : fileList.length > 0 && fileList.map(file => { @@ -239,25 +264,28 @@ const ModalForm = ({ mode, record,onEdit,onSave }) => { } {file.name} - -
deleteFile(file.response?.data?.fileId)}> +
+ {mode !== "view" && +
deleteFile(file.response?.data?.fileId)} + >
+ } ) }) } -
-
- -
+
+ { mode==='view'?null:( <> @@ -265,13 +293,13 @@ const ModalForm = ({ mode, record,onEdit,onSave }) => { }
{ - setPdfViewOPen(false) + setPerviewOpen(false) }} >