|
|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import React, { useEffect, useState, useRef } from 'react';
|
|
|
|
|
import { TreeSelect, Table, Tag, DatePicker, Form, Select, Button, message, Upload, Input, Row, Col, Switch, Image,Radio } from 'antd';
|
|
|
|
|
import { TreeSelect, Table, Tag, DatePicker, Form, Select, Button, message, Upload, Input, Row, Col, Switch, Image, Radio } from 'antd';
|
|
|
|
|
import './ddForm.less'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import { InboxOutlined, LinkOutlined, DeleteOutlined, LoadingOutlined, VerticalAlignBottomOutlined } from '@ant-design/icons'
|
|
|
|
|
@ -13,8 +13,8 @@ const { RangePicker } = DatePicker;
|
|
|
|
|
const { TextArea } = Input;
|
|
|
|
|
|
|
|
|
|
const baseUrl = "http://223.75.53.141:9100/gs-tsg"
|
|
|
|
|
|
|
|
|
|
const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, formJsonData, typeUpload = 'dispatch', isModalOpen, fileType, footer = true, uploadUrl,TableZdyProps,downloadUrl,
|
|
|
|
|
let dataList = [];
|
|
|
|
|
const FormZdy = ({ fileKey, typeName = "ddForm", formJson, getFormInfo, type, formJsonData, typeUpload = 'dispatch', isModalOpen, fileType, footer = true, uploadUrl, TableZdyProps, downloadUrl,
|
|
|
|
|
onSave }) => {
|
|
|
|
|
const [fileList, setFileList] = useState([])
|
|
|
|
|
const [fileListUp, setFileLisUp] = useState([])
|
|
|
|
|
@ -23,6 +23,7 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
|
const [searchValue, setSearchValue] = useState('');
|
|
|
|
|
|
|
|
|
|
const treeRef = useRef();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
@ -119,18 +120,18 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description 文件下载
|
|
|
|
|
* @param {String} params 文件fileId
|
|
|
|
|
*/
|
|
|
|
|
const download = async(id, name) => {
|
|
|
|
|
* @description 文件下载
|
|
|
|
|
* @param {String} params 文件fileId
|
|
|
|
|
*/
|
|
|
|
|
const download = async (id, name) => {
|
|
|
|
|
var extension = name?.split('.').pop().toLowerCase();
|
|
|
|
|
httpgetExport(downloadUrl+id).then(res => {
|
|
|
|
|
exportFile(name,res.data)
|
|
|
|
|
httpgetExport(downloadUrl + id).then(res => {
|
|
|
|
|
exportFile(name, res.data)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
useEffect(()=>{
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
form.resetFields()
|
|
|
|
|
},[])
|
|
|
|
|
}, [])
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
|
|
let formType = type
|
|
|
|
|
@ -162,27 +163,48 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
}, [type, formJsonData, isModalOpen])
|
|
|
|
|
|
|
|
|
|
const handleTreeData = (treeData, searchValue = '') => {
|
|
|
|
|
const loop = (data) => {
|
|
|
|
|
return data.map((item) => {
|
|
|
|
|
const strTitle = item.title?.toString() || '';
|
|
|
|
|
const matchValue = strTitle.toLowerCase().indexOf(searchValue.toLowerCase()) > -1;
|
|
|
|
|
const loop = (treeData) =>
|
|
|
|
|
treeData.map((item) => {
|
|
|
|
|
const strTitle = item.legalName;
|
|
|
|
|
const index = strTitle?.indexOf(searchValue);
|
|
|
|
|
const beforeStr = strTitle.substring(0, index);
|
|
|
|
|
const afterStr = strTitle.slice(index + searchValue?.length);
|
|
|
|
|
const title =
|
|
|
|
|
index > -1 ? (
|
|
|
|
|
<span key={item.id}>
|
|
|
|
|
{beforeStr}
|
|
|
|
|
<span className="site-tree-search-value" style={{ color: 'red' }}>{searchValue}</span>
|
|
|
|
|
{afterStr}
|
|
|
|
|
</span>
|
|
|
|
|
) : (
|
|
|
|
|
<span key={item.id}>{strTitle}</span>
|
|
|
|
|
);
|
|
|
|
|
if (item.children) {
|
|
|
|
|
return { title: title, key: item.id, children: loop(item.children), name: strTitle };
|
|
|
|
|
}
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
|
|
|
|
|
const children = item.children ? loop(item.children) : [];
|
|
|
|
|
const hasChildren = children && children.length > 0;
|
|
|
|
|
console.log(index, strTitle, searchValue);
|
|
|
|
|
|
|
|
|
|
dataList.push(item.id)
|
|
|
|
|
// setExpandedKeys(dataList);
|
|
|
|
|
if (dataList.length < 2) {
|
|
|
|
|
treeRef.current.scrollTo({ key: dataList[0].id });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
disabled: hasChildren, // 有子节点的设为禁用
|
|
|
|
|
children: hasChildren ? children : undefined
|
|
|
|
|
title: title,
|
|
|
|
|
key: item.id,
|
|
|
|
|
name: strTitle
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return loop(treeData);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const disableParentNodes = (treeData) => {
|
|
|
|
|
debugger
|
|
|
|
|
|
|
|
|
|
return treeData.map(node => {
|
|
|
|
|
const newNode = { ...node };
|
|
|
|
|
if (node.children && node.children.length > 0) {
|
|
|
|
|
@ -235,7 +257,7 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
name={item.key}
|
|
|
|
|
rules={[{ required: item.required, message: '请输入' + item.label }]}
|
|
|
|
|
>
|
|
|
|
|
<Radio.Group disabled={type == 'view'} options={item.options}/>
|
|
|
|
|
<Radio.Group disabled={type == 'view'} options={item.options} />
|
|
|
|
|
</Form.Item>}
|
|
|
|
|
|
|
|
|
|
{/* {item.type == "Select" && <Select disabled={type == 1} options={item.options} />} */}
|
|
|
|
|
@ -256,7 +278,7 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
rules={[{ required: item.required, message: '请输入' + item.label }]}
|
|
|
|
|
>
|
|
|
|
|
{/* {formJsonData[item.key]} */}
|
|
|
|
|
<DatePicker disabled={type == 'view'} style={{ width: "100%" }} picker={item.picker}/>
|
|
|
|
|
<DatePicker disabled={type == 'view'} style={{ width: "100%" }} picker={item.picker} />
|
|
|
|
|
</Form.Item>}
|
|
|
|
|
|
|
|
|
|
{/* {item.type == "DatePicker" && <DatePicker disabled={type == 1} style={{ width: "100%" }} />} */}
|
|
|
|
|
@ -285,14 +307,16 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
>
|
|
|
|
|
<TreeSelect
|
|
|
|
|
showSearch
|
|
|
|
|
ref={treeRef}
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
|
|
|
|
allowClear
|
|
|
|
|
onSearch={setSearchValue}
|
|
|
|
|
fieldNames={item.fieldNames}
|
|
|
|
|
treeData={handleTreeData(item.treeData,searchValue)}
|
|
|
|
|
treeData={disableParentNodes(item.treeData)}
|
|
|
|
|
treeCheckable={item.multiple}
|
|
|
|
|
disabled={type == 'view'}
|
|
|
|
|
// treeNodeFilterProp='legalName'
|
|
|
|
|
filterTreeNode={(inputValue, treeNode) => {
|
|
|
|
|
return treeNode.legalName.toLowerCase().includes(inputValue.toLowerCase());
|
|
|
|
|
}}
|
|
|
|
|
@ -319,7 +343,7 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
</Dragger>}
|
|
|
|
|
<div className='flex' >
|
|
|
|
|
{fileList?.map((item) => {
|
|
|
|
|
return <div className='flex align-center file-item' style={{marginTop:5, marginRight:'3%',width:'30%',minHeight: "50px", fontSize: 14, columnGap: 10, cursor: checkMediaType(item.fileName) == 'image' || checkMediaType(item.fileName) == 'pdf' ? 'pointer' : "not-allowed" }}>
|
|
|
|
|
return <div className='flex align-center file-item' style={{ marginTop: 5, marginRight: '3%', width: '30%', minHeight: "50px", fontSize: 14, columnGap: 10, cursor: checkMediaType(item.fileName) == 'image' || checkMediaType(item.fileName) == 'pdf' ? 'pointer' : "not-allowed" }}>
|
|
|
|
|
<div style={{ width: 40, height: 40, display: "flex", alignItems: 'center' }}>
|
|
|
|
|
{checkMediaType(item.fileName) == 'image' && <Image
|
|
|
|
|
height={40}
|
|
|
|
|
@ -351,7 +375,7 @@ const FormZdy = ({ fileKey,typeName = "ddForm", formJson, getFormInfo, type, for
|
|
|
|
|
<Button type="primary" onClick={getInfo} loading={loading}>确定</Button>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
<PdfView url={`${process.env.PUBLIC_URL}/static/pdf/web/viewer.html?file=${encodeURIComponent(`/gunshiApp/tsg/rescue/goods/file/download/${url}`)}`} isModal={isModal} setModalN={(e)=>setIsModal(e)}/>
|
|
|
|
|
<PdfView url={`${process.env.PUBLIC_URL}/static/pdf/web/viewer.html?file=${encodeURIComponent(`/gunshiApp/tsg/rescue/goods/file/download/${url}`)}`} isModal={isModal} setModalN={(e) => setIsModal(e)} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div >
|
|
|
|
|
|