Commit 5e0b4c47 authored by 邓超's avatar 邓超

fix: 修改台账管理模多层模态为抽屉形式,根据模块调整文件位置,并修改路由配置

parent 6c891ab0
Pipeline #35955 skipped with stages
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, Tooltip, Button, notification, Image, Menu, Dropdown } from 'antd';
import {
Form,
Modal,
Input,
Select,
Tooltip,
Button,
notification,
Image,
Menu,
Dropdown,
Drawer,
Space,
} from 'antd';
import {
PlusOutlined,
InfoCircleOutlined,
DownOutlined
DownOutlined,
} from '@ant-design/icons';
import {
LoadEventFields
} from '@/services/platform/bs'
import { LoadEventFields } from '@/services/platform/bs';
import add from '@/assets/images/thumbnail/add.jpg';
import editor from '@/assets/images/thumbnail/editor.jpg';
import hand from '@/assets/images/thumbnail/hand.png';
......@@ -15,26 +26,43 @@ import search from '@/assets/images/thumbnail/search.jpg';
import taizhang from '@/assets/images/thumbnail/taizhang.jpg';
import web from '@/assets/images/thumbnail/web.jpg';
import {
GetCM_Ledger_LoadLedgerTable, GetCMLedger_QueryLedgers, GetCMLedger_OperateLedger
GetCM_Ledger_LoadLedgerTable,
GetCMLedger_QueryLedgers,
GetCMLedger_OperateLedger,
} from '@/services/standingBook/api';
import styles from './standingBook.less';
import ChangeAdd from './changeAdd'
import ChangeAdd from './changeAdd';
import { orderBy } from 'lodash';
const { Option } = Select;
const { TextArea } = Input;
const AddModal = props => {
const { callBackSubmit = () => { }, type, formObj, visible, tableData, maxLength } = props;
const {
callBackSubmit = () => {},
type,
formObj,
visible,
tableData,
maxLength,
onCancel,
} = props;
const [standingTable, setStandingTable] = useState([]);
const [inputValue, setInputVaule] = useState({ Fields: '', EditFields: '', AddFields: '', MobileFields: '', SearchFields: '', WebFields: '' });
const [inputValue, setInputVaule] = useState({
Fields: '',
EditFields: '',
AddFields: '',
MobileFields: '',
SearchFields: '',
WebFields: '',
});
const [isVisible, setIsVisible] = useState(false); // 弹窗
const [loading, setLoading] = useState(false);
const [pickItem, setPickItem] = useState('')
const [pickItem, setPickItem] = useState('');
const [filed, setFiled] = useState({}); // 传给子组件列表数据
const [types, setTypes] = useState(''); // 弹窗类型
const [Order, setOrder] = useState(''); // 弹窗类型
const [checkedList, setCheckedList] = useState([])
const [Type,setType] = useState('')
const [characterValue, setCharacterValue] = useState('')
const [checkedList, setCheckedList] = useState([]);
const [Type, setType] = useState('');
const [characterValue, setCharacterValue] = useState('');
const [standingType, setStandingType] = useState(['台账', '反馈', '设备']);
const [form] = Form.useForm();
const { Item } = Form;
......@@ -44,7 +72,10 @@ const AddModal = props => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
let data = type == 'add' ? { ...obj, ...inputValue, Order: maxLength } : { ...obj, Order, ID: formObj.ID }
let data =
type == 'add'
? { ...obj, ...inputValue, Order: maxLength }
: { ...obj, Order, ID: formObj.ID };
GetCMLedger_OperateLedger(data)
.then(res => {
setLoading(false);
......@@ -72,37 +103,36 @@ const AddModal = props => {
});
setLoading(false);
});
}
});
};
const onFinish = value => { };
const onFinish = value => {};
useEffect(() => {
getTableData()
getTableData();
if (type === 'edit') {
GetCMLedger_QueryLedgers({ ledgerId: formObj.ID }).then(res => {
res.data.root && form.setFieldsValue({ ...res.data.root });
setInputVaule({ ...res.data.root })
setOrder(res.data.root.Order)
setType(res.data.root.Type)
changTable(res.data.root.TableName)
})
}
else if (type === 'add') {
setInputVaule({ Fields: '', EditFields: '', AddFields: '', MobileFields: '', SearchFields: '', WebFields: '' })
setFiled({})
setInputVaule({ ...res.data.root });
setOrder(res.data.root.Order);
setType(res.data.root.Type);
changTable(res.data.root.TableName);
});
} else if (type === 'add') {
setInputVaule({
Fields: '',
EditFields: '',
AddFields: '',
MobileFields: '',
SearchFields: '',
WebFields: '',
});
setFiled({});
form.resetFields();
form.setFieldsValue({ AccountType: '台账' });
}
}, [visible]);
const layout = {
layout: 'horizontal',
labelCol: {
......@@ -113,100 +143,97 @@ const AddModal = props => {
},
};
const getTableData = () => {
setType('')
setType('');
GetCM_Ledger_LoadLedgerTable().then(res => {
if (res.msg === 'Ok') {
setStandingTable(res.data.root)
}
})
setStandingTable(res.data.root);
}
const changTable = (value) => {
});
};
const changTable = value => {
LoadEventFields({ eventTableName: value, distinctFields: '' }).then(res => {
if (res.data.root && res.data.root.length) {
setFiled(formateArrDataA(res.data.root, 'group'))
}
})
setFiled(formateArrDataA(res.data.root, 'group'));
}
});
};
const formateArrDataA = (initialArr, name) => {
// 判定传参是否符合规则
if (!(initialArr instanceof Array)) {
return '请传入正确格式的数组'
return '请传入正确格式的数组';
}
if (!name) {
return '请传入对象属性'
return '请传入对象属性';
}
//先获取一下这个数组中有多少个"name"
let nameArr = []
let nameArr = [];
for (let i in initialArr) {
if (nameArr.indexOf(initialArr[i][`${name}`]) === -1) {
nameArr.push(initialArr[i][`${name}`])
nameArr.push(initialArr[i][`${name}`]);
}
}
//新建一个包含多个list的结果对象
let tempObj = {}
let tempObj = {};
// 根据不同的"name"生成多个数组
console.log(initialArr)
console.log(initialArr);
for (let k in nameArr) {
for (let j in initialArr) {
if (initialArr[j][`${name}`] == nameArr[k]) {
// 每次外循环时新建一个对应"name"的数组, 内循环时当前数组不变
tempObj[nameArr[k]] = tempObj[nameArr[k]] || []
tempObj[nameArr[k]].push(initialArr[j])
tempObj[nameArr[k]] = tempObj[nameArr[k]] || [];
tempObj[nameArr[k]].push(initialArr[j]);
}
}
}
console.log(tempObj);
for (let key in tempObj) {
let arr = []
let arr = [];
tempObj[key].map(item => {
tempObj[key] = arr;
arr.push(item.fieldName)
})
}
return tempObj
arr.push(item.fieldName);
});
}
return tempObj;
};
const onOK = prop => {
setIsVisible(false)
let inputText = { ...inputValue }
inputText[prop.pickItem] = prop.str
setCheckedList(prop.checkedList)
setInputVaule(inputText)
}
const pickFiled = (fileds) => {
setTypes('add')
setCharacterValue(inputValue[fileds])
setCheckedList(inputValue[fileds].split(','))
setPickItem(fileds)
setIsVisible(true)
}
setIsVisible(false);
let inputText = { ...inputValue };
inputText[prop.pickItem] = prop.str;
setCheckedList(prop.checkedList);
setInputVaule(inputText);
};
const pickFiled = fileds => {
setTypes('add');
setCharacterValue(inputValue[fileds]);
setCheckedList(inputValue[fileds].split(','));
setPickItem(fileds);
setIsVisible(true);
};
const changeText = (e, type) => {
let inputText = { ...inputValue }
inputText[type] = e.target.value
setInputVaule(inputText)
}
const inputType = (e) => {
setType(e.target.value)
form.setFieldsValue({ Type:e.target.value })
}
let inputText = { ...inputValue };
inputText[type] = e.target.value;
setInputVaule(inputText);
};
const inputType = e => {
setType(e.target.value);
form.setFieldsValue({ Type: e.target.value });
};
return (
<Modal
<Drawer
title={`${type === 'add' ? '台账配置' : '台账编辑'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '80px' }}
width="700px"
destroyOnClose
maskClosable={false}
cancelText="取消"
okText="确认"
{...props}
onOk={() => onSubmit()}
confirmLoading={loading}
forceRender={true}
getContainer={false}
width="500px"
visible={visible}
onClose={onCancel}
footer={
<Space>
<Button onClick={onCancel}>取消</Button>
<Button onClick={onSubmit} type="primary">
确定
</Button>
</Space>
}
>
{visible && (
<div className={styles.formData}>
......@@ -220,31 +247,55 @@ const AddModal = props => {
<Input
className="ue-editable-select-input"
onChange={inputType}
value = {Type}
>
</Input>
value={Type}
/>
<Dropdown
placement='bottomRight'
style={{width:'20rem'}}
overlay={<Menu>
{tableData.length ? tableData.map((item, index) => { return <Menu.Item onClick={()=>{setType(item); form.setFieldsValue({ Type:item})}} style={{width:'26.6rem'}} key={index}>{item}</Menu.Item> }) : ''}
</Menu>} >
<div className={styles.linkDrowp} onClick={e => e.preventDefault()}>
<DownOutlined style={{fontSize:'12px',color:'rgba(0, 0, 0, 0.25)'}} />
placement="bottomRight"
style={{ width: '20rem' }}
overlay={
<Menu>
{tableData.length
? tableData.map((item, index) => {
return (
<Menu.Item
onClick={() => {
setType(item);
form.setFieldsValue({ Type: item });
}}
style={{ width: '26.6rem' }}
key={index}
>
{item}
</Menu.Item>
);
})
: ''}
</Menu>
}
>
<div
className={styles.linkDrowp}
onClick={e => e.preventDefault()}
>
<DownOutlined
style={{ fontSize: '12px', color: 'rgba(0, 0, 0, 0.25)' }}
/>
</div>
</Dropdown>
{/* {tableData.length ? tableData.map((item, index) => { return <Option key={index} value={item}>{item}</Option> }) : ''} */}
</div>
</Item>
<Item
label="台账类型"
name="AccountType"
>
<Select
placeholder="选择台账类型"
>
{standingType.length ? standingType.map((item, index) => { return <Option key={index} value={item}>{item}</Option> }) : ''}
<Item label="台账类型" name="AccountType">
<Select placeholder="选择台账类型">
{standingType.length
? standingType.map((item, index) => {
return (
<Option key={index} value={item}>
{item}
</Option>
);
})
: ''}
</Select>
</Item>
<Item
......@@ -265,102 +316,214 @@ const AddModal = props => {
optionFilterProp="children"
onChange={changTable}
>
{standingTable.length ? standingTable.map((item, index) => { return <Option key={index} value={item.value}>{item.text}</Option> }) : ''}
{standingTable.length
? standingTable.map((item, index) => {
return (
<Option key={index} value={item.value}>
{item.text}
</Option>
);
})
: ''}
</Select>
</Item>
<Item
label={<div className={styles.formData_label}>
<Tooltip title={<Image
width={200}
src={taizhang}
/>}><InfoCircleOutlined style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }} /></Tooltip><span>台账字段</span> </div>}
label={
<div className={styles.formData_label}>
<Tooltip title={<Image width={200} src={taizhang} />}>
<InfoCircleOutlined
style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }}
/>
</Tooltip>
<span>台账字段</span>{' '}
</div>
}
name="Fields"
>
<div className={styles.filed_listItem} >
<TextArea placeholder="前端详情查看字段" onChange={(e) => changeText(e, 'Fields')} value={inputValue.Fields} allowClear />
<Button type="dashed" onClick={() => pickFiled('Fields')} icon={<PlusOutlined />} style={{ marginLeft: '0.5rem', height: '100%', width: '3.5rem' }} />
<div className={styles.filed_listItem}>
<TextArea
placeholder="前端详情查看字段"
onChange={e => changeText(e, 'Fields')}
value={inputValue.Fields}
allowClear
/>
<Button
type="dashed"
onClick={() => pickFiled('Fields')}
icon={<PlusOutlined />}
style={{
marginLeft: '0.5rem',
height: '100%',
width: '3.5rem',
}}
/>
</div>
</Item>
<Item
label={<div className={styles.formData_label}> <Tooltip title={<Image
width={200}
src={search}
/>}><InfoCircleOutlined style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }} /></Tooltip><span>检索字段</span> </div>}
label={
<div className={styles.formData_label}>
{' '}
<Tooltip title={<Image width={200} src={search} />}>
<InfoCircleOutlined
style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }}
/>
</Tooltip>
<span>检索字段</span>{' '}
</div>
}
name="SearchFields"
>
<div className={styles.filed_listItem} >
<TextArea placeholder="前端列表检索字段" onChange={(e) => changeText(e, 'SearchFields')} value={inputValue.SearchFields} allowClear />
<Button type="dashed" onClick={() => pickFiled('SearchFields')} icon={<PlusOutlined />} style={{ marginLeft: '0.5rem', height: '100%', width: '3.5rem' }} />
<div className={styles.filed_listItem}>
<TextArea
placeholder="前端列表检索字段"
onChange={e => changeText(e, 'SearchFields')}
value={inputValue.SearchFields}
allowClear
/>
<Button
type="dashed"
onClick={() => pickFiled('SearchFields')}
icon={<PlusOutlined />}
style={{
marginLeft: '0.5rem',
height: '100%',
width: '3.5rem',
}}
/>
</div>
</Item>
<Item
label={<div className={styles.formData_label}> <Tooltip title={<Image
width={200}
src={add}
/>}><InfoCircleOutlined style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }} /></Tooltip><span>添加字段</span> </div>}
label={
<div className={styles.formData_label}>
{' '}
<Tooltip title={<Image width={200} src={add} />}>
<InfoCircleOutlined
style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }}
/>
</Tooltip>
<span>添加字段</span>{' '}
</div>
}
name="AddFields"
>
<div className={styles.filed_listItem} >
<TextArea placeholder="前端数据添加字段" onChange={(e) => changeText(e, 'AddFields')} value={inputValue.AddFields} allowClear />
<Button type="dashed" onClick={() => pickFiled('AddFields')} icon={<PlusOutlined />} style={{ marginLeft: '0.5rem', height: '100%', width: '3.5rem' }} />
<div className={styles.filed_listItem}>
<TextArea
placeholder="前端数据添加字段"
onChange={e => changeText(e, 'AddFields')}
value={inputValue.AddFields}
allowClear
/>
<Button
type="dashed"
onClick={() => pickFiled('AddFields')}
icon={<PlusOutlined />}
style={{
marginLeft: '0.5rem',
height: '100%',
width: '3.5rem',
}}
/>
</div>
</Item>
<Item
label={<div className={styles.formData_label}>
<Tooltip
title={<Image
width={200}
src={editor}
/>}><InfoCircleOutlined style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }} /></Tooltip><span>编辑字段</span> </div>}
label={
<div className={styles.formData_label}>
<Tooltip title={<Image width={200} src={editor} />}>
<InfoCircleOutlined
style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }}
/>
</Tooltip>
<span>编辑字段</span>{' '}
</div>
}
name="EditFields"
>
<div className={styles.filed_listItem} >
<TextArea placeholder="前端可编辑字段" onChange={(e) => changeText(e, 'EditFields')} value={inputValue.EditFields} allowClear />
<Button type="dashed" onClick={() => pickFiled('EditFields')} icon={<PlusOutlined />} style={{ marginLeft: '0.5rem', height: '100%', width: '3.5rem' }} />
<div className={styles.filed_listItem}>
<TextArea
placeholder="前端可编辑字段"
onChange={e => changeText(e, 'EditFields')}
value={inputValue.EditFields}
allowClear
/>
<Button
type="dashed"
onClick={() => pickFiled('EditFields')}
icon={<PlusOutlined />}
style={{
marginLeft: '0.5rem',
height: '100%',
width: '3.5rem',
}}
/>
</div>
</Item>
<Item
label={<div className={styles.formData_label}>
<Tooltip title={<Image
width={200}
src={web}
/>}><InfoCircleOutlined style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }} /></Tooltip><span>前端字段</span> </div>}
label={
<div className={styles.formData_label}>
<Tooltip title={<Image width={200} src={web} />}>
<InfoCircleOutlined
style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }}
/>
</Tooltip>
<span>前端字段</span>{' '}
</div>
}
name="WebFields"
>
<div className={styles.filed_listItem} >
<TextArea placeholder="前端列表展示字段" onChange={(e) => changeText(e, 'WebFields')} value={inputValue.WebFields} allowClear />
<Button type="dashed" onClick={() => pickFiled('WebFields')} icon={<PlusOutlined />} style={{ marginLeft: '0.5rem', height: '100%', width: '3.5rem' }} />
<div className={styles.filed_listItem}>
<TextArea
placeholder="前端列表展示字段"
onChange={e => changeText(e, 'WebFields')}
value={inputValue.WebFields}
allowClear
/>
<Button
type="dashed"
onClick={() => pickFiled('WebFields')}
icon={<PlusOutlined />}
style={{
marginLeft: '0.5rem',
height: '100%',
width: '3.5rem',
}}
/>
</div>
</Item>
<Item
label={<div className={styles.formData_label}>
<Tooltip title={<Image
width={100}
src={hand}
/>}><InfoCircleOutlined style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }} /></Tooltip><span>手持字段</span> </div>}
label={
<div className={styles.formData_label}>
<Tooltip title={<Image width={100} src={hand} />}>
<InfoCircleOutlined
style={{ color: '#1890FF', padding: '0.2rem 0.2rem 0 0' }}
/>
</Tooltip>
<span>手持字段</span>{' '}
</div>
}
name="MobileFields"
>
<div className={styles.filed_listItem} >
<TextArea placeholder="手持展示字段" onChange={(e) => changeText(e, 'MobileFields')} value={inputValue.MobileFields} allowClear />
<Button type="dashed" onClick={() => pickFiled('MobileFields')} icon={<PlusOutlined />} style={{ marginLeft: '0.5rem', height: '100%', width: '3.5rem' }} />
<div className={styles.filed_listItem}>
<TextArea
placeholder="手持展示字段"
onChange={e => changeText(e, 'MobileFields')}
value={inputValue.MobileFields}
allowClear
/>
<Button
type="dashed"
onClick={() => pickFiled('MobileFields')}
icon={<PlusOutlined />}
style={{
marginLeft: '0.5rem',
height: '100%',
width: '3.5rem',
}}
/>
</div>
</Item>
<Item
label='接口配置'
name="Interface"
>
<div className={styles.filed_listItem} >
<Item label="接口配置" name="Interface">
<div className={styles.filed_listItem}>
<TextArea placeholder="服务项目dll库" allowClear />
</div>
</Item>
......@@ -374,12 +537,11 @@ const AddModal = props => {
filed={filed}
pickItem={pickItem}
characterValue={characterValue}
formObj={formObj} />
formObj={formObj}
/>
</div>
)
}
</Modal >
)}
</Drawer>
);
};
export default AddModal;
......@@ -331,8 +331,9 @@
}
}
.formData{
height: 38rem;
height: calc(100vh - 170px);
overflow-y: scroll;
padding-right: 20px;
.ant-form-item-label > label.ant-form-item-required:not(.ant-form-item-required-mark-optional)::before{
display: none;
}
......
......@@ -18,7 +18,7 @@ import RequestTest from '../pages/testPages/request';
import InitDataBase from '../pages/database/InitDataBase';
import ManagementDataBase from '../pages/database/ManagementDataBase';
import DatabaseConnectConfig from '@/pages/database/databaseConfig/DatabaseConfig';
import CurrentSolution from '@/pages/database/CurrentSolution';
import CurrentSolution from '@/pages/currentSolution/CurrentSolution';
import UserManage from '../pages/userCenter/userManage/UserManage';
import RoleManage from '@/pages/userCenter/roleManage/RoleManage';
import SiteManage from '../pages/userCenter/siteManage/SiteManage';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment