Commit 6f288111 authored by 田翔's avatar 田翔

fix: 代码优化

parent 54ab8e0b
Pipeline #84561 passed with stages
/* eslint-disable react/jsx-boolean-value */
/* eslint-disable indent */
/* eslint-disable prettier/prettier */
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable block-scoped-var */
/* eslint-disable no-var */
/* eslint-disable vars-on-top */
/* eslint-disable no-plusplus */
/* eslint-disable no-array-constructor */
/* eslint-disable prefer-destructuring */
/* eslint-disable array-callback-return */
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/* eslint-disable spaced-comment */
/* eslint-disable no-shadow */
/* eslint-disable no-unused-expressions */
/* eslint-disable eqeqeq */
/* eslint-disable camelcase */
/* eslint-disable import/no-unresolved */
/* eslint-disable no-dupe-keys */
import React, { useEffect, useState } from 'react';
import {
Modal,
Drawer,
Form,
Input,
notification,
Space,
Row,
Col,
Select,
Checkbox,
Radio,
Dropdown,
Menu,
Button,
Tooltip,
Upload,
Image,
Switch,
message,
Spin,
} from 'antd';
import { Drawer, Form, Input, notification, Space, Row, Col, Select, Checkbox, Button, Tooltip, Image, Switch, Spin } from 'antd';
import {
GetCM_Event_LoadEventTypeTable,
LoadEventFields,
......@@ -50,15 +9,8 @@ import {
CM_Event_AddEventTable,
GetCM_Event_LoadEvenFlows,
} from '@/services/standingBook/api';
import {
PlusOutlined,
DownOutlined,
InfoCircleOutlined,
DeleteOutlined,
PictureOutlined,
} from '@ant-design/icons';
import { PlusOutlined, InfoCircleOutlined, DeleteOutlined, PictureOutlined, } from '@ant-design/icons';
import styles from './incident.less';
import ChangeAdd from './changeAdd';
import ChangeEdit from './changeEdit';
import RMSComponents from '@/components/RolePmSite/index';
import PreviewModal from './PreviewModal';
......@@ -468,8 +420,7 @@ const AddModal = (props) => {
const [nu, setNu] = useState([]);
const [nu1, setNu1] = useState([]);
const [editable, setEditable] = useState(false);
const [ReportFromMobile, setReportFromMobile] = useState(false);
const [ReportFromWeb, setReportFromWeb] = useState(false);
const [reportType, setReportType] = useState({ visibleCheck: true, ReportFromMobile: false, ReportFromWeb: false })
const [pickItem, setPickItem] = useState('');
const [selectValue, setSelectValue] = useState('');
const [modalLoading, setModalLoading] = useState(true);
......@@ -498,7 +449,6 @@ const AddModal = (props) => {
const [flowTableData, setFlowTableData] = useState([]);
const [eventFlowId, setEventFlowId] = useState(0);
const [show, setShow] = useState('hidden');
const [visibleChecked, setVisibleChecked] = useState(true);
const [initWay, setInitWay] = useState(); // 初始上报方式
const onSubmit = () => {
......@@ -518,29 +468,11 @@ const AddModal = (props) => {
} else {
obj.Editable = editable;
}
if (ReportFromWeb === true && ReportFromMobile === true) {
obj.ReportFromMobile = '手持';
obj.ReportFromWeb = '前端';
} else if (ReportFromWeb === true) {
obj.ReportFromMobile = '';
obj.ReportFromWeb = '前端';
} else if (ReportFromMobile === true) {
obj.ReportFromMobile = '手持';
obj.ReportFromWeb = '';
} else {
obj.ReportFromMobile = '';
obj.ReportFromWeb = '';
}
if (visibleChecked) {
obj.Reportable = true;
} else {
obj.Reportable = false;
}
obj.ReportFromWeb = reportType.ReportFromWeb
obj.ReportFromMobile = reportType.ReportFromMobile
obj.Reportable = Boolean(reportType.visibleCheck)
if ((obj.Roles == '' || obj.Roles == undefined) && value === 0) {
notification.warning({
message: '提示',
description: '事件权限必填',
});
notification.warning({ message: '提示', description: '事件权限必填' })
} else {
if (type == 'edit') {
CM_Event_EditEventTable({
......@@ -553,17 +485,9 @@ const AddModal = (props) => {
form.resetFields();
setValue('');
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: '编辑成功',
});
notification.success({ message: '提示', duration: 3, description: '编辑成功', });
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
notification.error({ message: '提示', duration: 3, description: res.msg });
}
});
setFlag(0);
......@@ -586,11 +510,7 @@ const AddModal = (props) => {
description: '新增成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
notification.error({ message: '提示', duration: 3, description: res.msg });
}
});
setFlag(0);
......@@ -608,48 +528,35 @@ const AddModal = (props) => {
getRole();
if (type === 'add') {
form.setFieldsValue({ BusinessType: rember1 });
setReportFromWeb(true);
setValue(1);
getEventData();
setSelectValue(selectData[0]);
setFiled({});
form.resetFields();
setEditable(false);
setReportFromMobile(true);
form.setFieldsValue({
ImageExpression: 'assets/images/caseCenter/events/通用问题1.png',
});
setImageUrl(
`${window.location.origin}/civweb4/assets/images/caseCenter/events/通用问题1.png`,
);
setReportType({ ...reportType, ReportFromMobile: true, ReportFromWeb: true })
form.setFieldsValue({ ImageExpression: 'assets/images/caseCenter/events/通用问题1.png' });
setImageUrl(`${window.location.origin}/civweb4/assets/images/caseCenter/events/通用问题1.png`);
setIm('assets/images/caseCenter/events/通用问题1.png');
setModalLoading(false);
} else if (type === 'edit') {
getEventData1();
GetCM_Event_QueryEventType({ eventTypeId: formObj.ID }).then(res => {
console.log('res.data.root', res.data.root)
if (res.data.root) {
const { Reportable, ReportFromMobile, ReportFromWeb } = res.data.root
setEditable(res.data.root.Editable);
setInitWay(res.data.root.CreateMode);
setValue(res.data.root.CreateMode);
setReportFromMobile(res.data.root.ReportFromMobile);
setReportFromWeb(res.data.root.ReportFromWeb);
if (res.data.root.Reportable === false) {
setVisibleChecked(false);
} else {
setVisibleChecked(true);
}
setReportType({ visibleCheck: Boolean(Reportable), ReportFromMobile, ReportFromWeb })
setOrder(res.data.root.Order);
form.setFieldsValue({ ...res.data.root });
if (res.data.root.ImageExpression) {
setImageUrl(`${window.location.origin}/civweb4/${res.data.root.ImageExpression}`);
setIm(res.data.root.ImageExpression);
} else {
form.setFieldsValue({
ImageExpression: 'assets/images/caseCenter/events/通用问题1.png',
});
setImageUrl(
`${window.location.origin}/civweb4/assets/images/caseCenter/events/通用问题1.png`,
);
form.setFieldsValue({ ImageExpression: 'assets/images/caseCenter/events/通用问题1.png' });
setImageUrl(`${window.location.origin}/civweb4/assets/images/caseCenter/events/通用问题1.png`);
setIm('assets/images/caseCenter/events/通用问题1.png');
}
LoadEventFields({
......@@ -694,8 +601,7 @@ const AddModal = (props) => {
} else if (type == 'edit' || type == 'add') {
setInitWay(null);
setEditable(false);
setReportFromMobile(false);
setReportFromWeb(false);
setReportType({ ...reportType, ReportFromMobile: false, ReportFromWeb: false })
form.resetFields();
setImageUrl('');
setIm('');
......@@ -725,8 +631,6 @@ const AddModal = (props) => {
res.data.map((item, index) => {
arr.push(item.text);
});
// setSelectValue(arr[0])
// changTable(arr[0])
}
});
};
......@@ -745,6 +649,7 @@ const AddModal = (props) => {
if (res.data.root) {
setNu(res.data.root);
setFiled(formateArrDataA(res.data.root, 'group'));
console.log('changTable,res.data.root', res.data.root)
ExternalSummaryField(res.data.root);
ExternalReportField(res.data.root);
ExternalDisplayField(res.data.root);
......@@ -955,7 +860,6 @@ const AddModal = (props) => {
let tempObj = {};
let aa = [];
// 根据不同的"name"生成多个数组
// eslint-disable-next-line guard-for-in
for (let k in nameArr) {
for (let j in initialArr) {
if (initialArr[j][`${name}`] == nameArr[k]) {
......@@ -970,7 +874,6 @@ const AddModal = (props) => {
}
}
// tempObj.内置字段 = aa;
for (let key in tempObj) {
let arr = [];
tempObj[key].map(item => {
......@@ -1005,13 +908,8 @@ const AddModal = (props) => {
return list;
};
const onChange1 = e => {
setEditable(e.target.checked);
};
const onChange2 = e => {
if (e === 1 && initWay === 0) {
// message.warning('事件模型切换为工单模型流程会清空,请谨慎修改');
GetCM_Event_LoadEvenFlows({ eventTypeId: formObj.ID }).then(res => {
if (res.msg === 'Ok') {
if (res.data.length && res.data.length === 1) {
......@@ -1026,19 +924,19 @@ const AddModal = (props) => {
}
setValue(e);
};
const onChange3 = e => {
setReportFromWeb(e.target.checked);
};
const onChange4 = e => {
setReportFromMobile(e.target.checked);
};
const reportChange = (values) => {
setReportType({ ...reportType, ...values })
}
const onOK = prop => {
setIsVisible(false);
let inputText = {};
inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.stt);
form.setFieldsValue(inputText);
};
}
const onOK1 = prop => {
setIsVisibleEdit(false);
let inputText = {};
......@@ -1205,36 +1103,15 @@ const AddModal = (props) => {
form.setFieldsValue({ BusinessType: value });
}
};
const onCancel = () => {
setIsVisible(false);
};
const onCancel11 = () => {
setIsVisibleEdit(false);
};
// 搜索框监听
const onSearch = value => {
if (value) {
form.setFieldsValue({ TableName: value });
}
};
const pictruePreview = () => {
setPreviewModal(true);
};
const uploadButton = (
<div>
<div
style={{
marginTop: 8,
}}
>
请从图片库中选择
</div>
</div>
);
const onOk = props => {
if (props) {
setImageUrl(`${window.location.origin}/civweb4/${props}`);
......@@ -1245,10 +1122,6 @@ const AddModal = (props) => {
setShow('hidden');
};
const change = e => {
setVisibleChecked(e);
};
return (
<Drawer
title={type === 'add' ? '添加事件' : '编辑事件'}
......@@ -1627,8 +1500,8 @@ const AddModal = (props) => {
<Switch
checkedChildren="标准用法"
unCheckedChildren="内置用法"
checked={visibleChecked}
onChange={change}
checked={reportType.visibleCheck}
onChange={(value) => reportChange({ visibleCheck: value })}
/>
</div>
</Item>
......@@ -1636,9 +1509,9 @@ const AddModal = (props) => {
<div style={{ display: 'inline-block', marginLeft: '112px', marginRight: '50px' }}>
<Item name="ReportFromWeb">
<Checkbox
onChange={onChange3}
checked={ReportFromWeb && visibleChecked}
disabled={!visibleChecked}
onChange={(e) => reportChange({ ReportFromWeb: e.target.checked })}
checked={reportType.ReportFromWeb && reportType.visibleCheck}
disabled={!reportType.visibleCheck}
>
前端
</Checkbox>
......@@ -1647,9 +1520,9 @@ const AddModal = (props) => {
<div style={{ display: 'inline-block' }}>
<Item name="ReportFromMobile">
<Checkbox
onChange={onChange4}
checked={ReportFromMobile && visibleChecked}
disabled={!visibleChecked}
onChange={(e) => reportChange({ ReportFromMobile: e.target.checked })}
checked={reportType.ReportFromMobile && reportType.visibleCheck}
disabled={!reportType.visibleCheck}
>
手持
</Checkbox>
......@@ -1756,7 +1629,6 @@ const AddModal = (props) => {
) : (
<Image
width="104px"
// height={100}
src="error"
onClick={pictruePreview}
fallback="data:image/png;base64,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i/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="
......@@ -1800,7 +1672,7 @@ const AddModal = (props) => {
/>
<ChangeEdit
visible={isVisibleEdit}
onCancel={onCancel11}
onCancel={() => setIsVisibleEdit(false)}
callBackSubmit={onOK1}
newCheckedList={checkedList1}
filed={filed}
......
......@@ -125,17 +125,6 @@ const incident = () => {
</Tooltip>
),
},
// {
// title: '摘要字段',
// dataIndex: 'summaryFields',
// key: 'summaryFields',
// width: 100,
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
{
title: '权限',
dataIndex: 'roles',
......@@ -147,65 +136,6 @@ const incident = () => {
</Tooltip>
),
},
// {
// title: '流程',
// dataIndex: 'flowCount',
// key: 'flowCount',
// width: 80,
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// {
// title: '上报',
// dataIndex: 'reportable',
// key: 'reportable',
// width: 50,
// },
// {
// title: '上报字段',
// dataIndex: 'reportFields',
// key: 'reportFields',
// width: 80,
// },
// {
// title: '显示字段',
// dataIndex: 'displayFields',
// key: 'displayFields',
// width: 80,
// },
// {
// title: '编辑',
// dataIndex: 'editable',
// key: 'editable',
// width: 50,
// align: 'center',
// render: record => {
// if (record == '是') {
// return <Tag color="success">{record}</Tag>;
// } else {
// return <Tag color="processing">{record}</Tag>;
// }
// },
// },
// {
// title: '编辑字段',
// dataIndex: 'editableFields',
// key: 'editableFields',
// width: 80,
// render: item => (
// <div
// ref={r => {
// if (r) {
// r.innerHTML = item;
// }
// }}
// />
// ),
// },
{
title: '外部字段',
dataIndex: 'outFields',
......@@ -300,12 +230,6 @@ const incident = () => {
style={{ fontSize: '16px', color: '#1890FF' }}
/>
</Tooltip>
{/* <Tooltip title="辅助视图">
<DesktopOutlined
onClick={() => auxiliaryView1(record)}
style={{ fontSize: '16px', color: '#1890FF' }}
/>
</Tooltip> */}
<Tooltip title="导出事件">
<ExportOutlined
onClick={() => hadelExport(record)}
......@@ -336,7 +260,6 @@ const incident = () => {
setTreeLoading(false);
if (res.code === 0) {
setKeepIdValue(res.data);
// setMaxLength(res.data.root.length + 1)
let arr = formateArrDataA(res.data, 'businessType');
let newArr = [];
let newapp = [];
......
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