Commit 7bbee9a2 authored by 邓超's avatar 邓超

fix: 修改表管理类型为动态

parent 0044845e
Pipeline #65327 passed with stages
......@@ -282,7 +282,7 @@ const EditableCell = ({
return <td {...restProps}>{childNode}</td>;
};
const TableView = props => {
const { callBackSubmit, onCancel, visible, type, formObj, tableType } = props;
const { callBackSubmit, onCancel, visible, type, formObj, tableType, defaultFieldsList } = props;
const [dataSource, setDataSource] = useState([]);
const [count, setCount] = useState(0);
const [loading, setLoading] = useState(false);
......@@ -339,22 +339,16 @@ const TableView = props => {
notification.error({ message: '提示', duration: 3, description: '网络异常' });
});
} else {
let list = [];
GetDefaultTableFields().then(res => {
console.log(res.data);
res.data.forEach(item => {
if (item.value === tableType) {
list = item.list.map((val, index) => ({ ...val, keyIndex: index }));
}
});
console.log(list);
setDefaultData(list);
setCount(list.length);
setShowDefault(false);
let listitem = JSON.parse(JSON.stringify(list));
listitem = listitem.filter(item => !item.ReadOnly);
setDataSource(listitem);
});
let list = defaultFieldsList
.find(item => item.value === tableType)
.list.map((item, i) => ({ ...item, keyIndex: i }));
console.log(list);
setDefaultData(list);
setCount(list.length);
setShowDefault(false);
let listitem = JSON.parse(JSON.stringify(list));
listitem = listitem.filter(item => !item.ReadOnly);
setDataSource(listitem);
}
} else {
setShowDefault(false);
......@@ -543,7 +537,6 @@ const TableView = props => {
align: 'center',
render: (text, record) => (
<>
{console.log(record)}
<span>{text}</span>
{record.IsIndex && (
<img src={index} style={{ height: '25px', marginLeft: '5px' }} alt="" />
......
......@@ -18,6 +18,7 @@ import {
Dropdown,
Menu,
Modal,
message,
} from 'antd';
import {
EditOutlined,
......@@ -43,6 +44,7 @@ import {
loadUnattachedTables,
checkTableType,
regroupTableType,
GetDefaultTableFields,
} from '@/services/tablemanager/tablemanager';
import { useHistory } from 'react-router-dom';
import { Ellipse } from 'bizcharts/lib/g-components';
......@@ -53,7 +55,7 @@ import AddTablelList from './components/TableView';
import AffiliateAdd from './components/Field/affiliateAdd';
import LoadGroup from './components/Field/loadGroup';
import LoadGroupNew from './components/Field/loadGroupNew';
import { defaultFields } from './components/defaultFields';
// import { defaultFields } from './components/defaultFields';
import styles from './index.less';
const { Search } = Input;
const { Option } = Select;
......@@ -82,19 +84,27 @@ const TableManager = props => {
const [treeVisible, setTreeVisible] = useState(true); // 是否显示左侧树
const [hoverItemIndex, setHoverItemIndex] = useState(0); // hover流程索引
const [pickIndex, setPickIndex] = useState(0);
const [defaultFields1, setDefaultFields1] = useState([
'事件表',
'事件工单表',
'工单表',
'台账表',
'设备表',
'反馈表',
]);
const [tableType, setTableType] = useState(defaultFields1[0]);
const [defaultFields, setDefaultFields] = useState([]);
const [defaultFieldsList, setDefaultFieldsList] = useState([]);
const [tableType, setTableType] = useState(defaultFields[0]);
const [groupPopVisible, setgGroupPopVisible] = useState(false);
const [checkMsg, setCheckMsg] = useState();
const initNum = useRef(0);
useEffect(() => {
GetDefaultTableFields().then(res => {
if (res.code === 0) {
let list = [];
setDefaultFieldsList(res.data);
res.data.forEach(item => {
list.push(item.value);
});
setDefaultFields(list);
} else {
message.error(res.msg);
}
});
}, []);
useEffect(
record => {
if (props.history.location.query && initNum.current == 0) {
......@@ -256,15 +266,7 @@ const TableManager = props => {
let bb = [];
console.log(groupData, 'groupData');
// 对分组进行排序
const sortNameArr = [
'事件表',
'事件工单表',
'工单表',
'台账表',
'设备表',
'反馈表',
'其他表',
];
const sortNameArr = res.data.groupNames;
const sortList = [];
sortNameArr.forEach(ele => {
Object.keys(groupData).map((item, index) => {
......@@ -526,7 +528,7 @@ const TableManager = props => {
});
};
const menu = (
<Menu onClick={onMenuClick} items={defaultFields1.map(item => ({ key: item, label: item }))} />
<Menu onClick={onMenuClick} items={defaultFields.map(item => ({ key: item, label: item }))} />
);
return (
<Spin tip="loading..." spinning={treeLoading}>
......@@ -702,6 +704,7 @@ const TableManager = props => {
onCancel={() => setVisible(false)}
formObj={formObj}
callBackSubmit={onSubmit}
defaultFieldsList={defaultFieldsList}
tableType={tableType}
/>
{visible && type === 'affiliateAdd' && (
......
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