Commit 365074f7 authored by 涂伟's avatar 涂伟

fix: '1.运维维保卡片配置功能2.编码填写校验逻辑优化3.台账表设置表单样式优化'

parent a6c4d4d5
Pipeline #70618 waiting for manual action with stages
......@@ -122,7 +122,7 @@
"js-calendar-converter": "0.0.4",
"lodash": "4.17.11",
"minimist": "1.2.0",
"panda-xform": "^3.0.7",
"panda-xform": "^3.10.4",
"prop-types": "15.7.2",
"quill": "^1.3.7",
"rc-tween-one": "^3.0.6",
......
......@@ -467,7 +467,7 @@ const TableManager = props => {
title: '名称',
dataIndex: 'tableName',
key: 'tableName',
width: 400,
width: 200,
render: (text, record) => (
<div
onClick={e => fieldsConfig(record, e)}
......@@ -496,6 +496,7 @@ const TableManager = props => {
dataIndex: 'tableAlias',
key: 'tableAlias',
align: 'center',
width: 200,
render: text => <div>{text || <span style={{ color: 'grey' }}>(无)</span>}</div>,
},
{
......@@ -503,7 +504,7 @@ const TableManager = props => {
dataIndex: 'tableStyle',
key: 'tableStyle',
align: 'center',
width: 80,
width: 100,
render: text => <div>{!text ? <span style={{ color: 'grey' }}>(无)</span> : text}</div>,
},
// {
......
/* eslint-disable indent */
/* eslint-disable camelcase */
/* eslint-disable no-unused-expressions */
import React, { useState, useEffect } from 'react';
import {
Drawer,
Form,
Input,
notification,
Row,
Col,
Select,
Button,
Dropdown,
Tooltip,
Menu,
Space,
Radio,
Switch,
TreeSelect,
Tag,
Upload,
Modal,
message,
} from 'antd';
import { UploadChangeParam } from 'antd/es/upload';
import { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
import {
PlusOutlined,
DownOutlined,
StepForwardFilled,
InfoCircleOutlined,
MinusCircleOutlined,
LoadingOutlined,
UploadOutlined,
EyeOutlined,
} from '@ant-design/icons';
import FileViewer from 'react-file-viewer';
import { setAutoFreeze } from 'immer';
import styles from './optionEditModal.less';
import { EditDeviceConfig } from '@/services/maintenance/api';
import { loadEventFields } from '@/services/flow/flow';
import { GetTaskSyncField } from '@/services/PatrolFeedback/api';
import { reloadTableFields } from '@/services/tablemanager/tablemanager';
import Fieldselection from './optionEditComponents/Fieldselection';
import {
GetCM_Event_LoadEventTable,
CM_Event_LoadDepartmentAndRoles,
} from '@/services/standingBook/api';
import RMSComponents from '@/components/RolePmSite/index';
import ChangeAdd from './ChangeAdd';
import logo from '@/assets/images/icons/值映射.png';
const { Option } = Select;
const OptionEditModal = props => {
const { callBackSubmit = () => {}, visible, type, formObj, keepTableData } = props;
const [Type1, setType1] = useState('');
const [showField, setShowField] = useState(false); // 选择字段弹窗
const [filedList, setFiledList] = useState([]); // 全部字段数据
const [fieldData, setFieldData] = useState([]); // 已选字段数据
const [fieldName, setFieldName] = useState(''); // 字段选择类型名称
const [standList, setStandList] = useState([]); //
const [loading, setLoading] = useState(false); // 上传按钮loading
const [previewVisible, setPreviewVisible] = useState(false); // 预览文件弹窗
const [fileType, setFileType] = useState('pdf'); // 预览文件类型
const [fileUrl, setFileUrl] = useState(
'http://192.168.10.167:8088/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=520d9de3-b69b-42c0-bb65-f198a30d0cd4\\%E5%B7%A5%E5%8D%95%E6%97%B6%E9%99%90%E9%85%8D%E7%BD%AE.pdf',
); // 预览文件路径
const [form] = Form.useForm();
const [formAdd] = Form.useForm();
const { Item } = Form;
useEffect(() => {
if (formObj) {
form.setFieldsValue({ ...formObj });
setStandList(JSON.parse(formObj.StandardConfig));
}
}, [visible]);
useEffect(() => {}, []);
// 获取关联事件数据
// const getEventData = () => {
// GetCM_Event_LoadEventTable().then(res => {
// if (res.code === 0) {
// let aa = [];
// let bb = [];
// res.data.map(i => {
// i.root.map(j => {
// aa.push(j.name);
// bb.push(j);
// });
// });
// setKeepAllData(bb);
// setEventData(aa);
// }
// });
// };
const onSubmit = () => {
form.validateFields().then(validate => {
let data = validate;
data.StandardConfig = JSON.stringify(standList);
EditDeviceConfig(data).then(res => {
if (res.code === 0) {
form.resetFields();
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: '编辑成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
});
});
};
// const inputType1 = e => {
// setType1(e.target.value);
// form.setFieldsValue({ businessType: e.target.value });
// };
// 字段配置
const deployField = val => {
let value = form.getFieldsValue(true);
setFieldName(val);
loadEventFields({
eventTableName: formObj.AccountTableName,
}).then(res => {
if (res.code === 0) {
let defaultCheckedList = value[val] ? value[val].split(',') : [];
// 保存所有的字段用于右侧显示
setFieldData(defaultCheckedList);
let allFields = []; // 所有得字段用来判断是否为外部字段
// 处理树形结构
let checkList = res.data.map(item => {
let plainOptions = [];
// 存入没个组得字段
item.root.forEach(ele => {
plainOptions = [...plainOptions, ele.fieldName];
});
// 存所有得字段
allFields = [...allFields, ...plainOptions];
return {
groupName: item.groupName,
plainOptions,
defaultCheckedList: [],
};
});
let externalFields = {
groupName: '外部字段',
indeterminate: false,
checkAll: true,
plainOptions: [],
defaultCheckedList: [],
}; // 外部字段
defaultCheckedList.forEach(item => {
// 添加外部字段
let isExternal = allFields.some(checkName => checkName === item);
if (!isExternal) {
externalFields.plainOptions.push(item);
externalFields.defaultCheckedList.push(item);
}
checkList.forEach(element => {
// 当前得模块是否有当前字段
let indeterminate = element.plainOptions.some(checkName => checkName === item);
// 处理已选中的字段
if (indeterminate) {
element.defaultCheckedList.push(item);
}
if (
element.defaultCheckedList.length > 0 &&
element.defaultCheckedList.length < element.plainOptions.length
) {
element.indeterminate = true;
} else {
element.indeterminate = false;
}
// 处理是否全选字段
if (element.defaultCheckedList.length === element.plainOptions.length) {
element.checkAll = true;
} else {
element.checkAll = false;
}
});
});
// 添加外部字段
if (externalFields.plainOptions.length > 0) {
checkList.push(externalFields);
}
setFiledList(checkList);
setTimeout(() => {
setShowField(true);
}, 0);
}
});
};
// 字段修改后回调函数
const setFiled = val => {
let Fields = '';
val.forEach((item, index) => {
if (index === val.length - 1) {
Fields = `${Fields + item}`;
} else {
Fields = `${Fields + item},`;
}
});
let obj = {};
obj[fieldName] = Fields;
form.setFieldsValue(obj);
// saveOutFieldsLength(fieldName, filedList);
setShowField(false);
};
const getBase64 = (img, callback) => {
const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result));
reader.readAsDataURL(img);
};
const [fileList, setFileList] = useState([
{
uid: '-1',
name: 'xxx.png',
status: 'done',
url: 'http://www.baidu.com/xxx.png',
},
]);
const handleChange = (file, item, index) => {
if (file.file.status === 'done' && file.file.response.code === 0) {
message.success('上传成功!');
let list = JSON.parse(JSON.stringify(standList));
list[index].pdfUrl = file.file.response.data;
list[index].type = file.file.type.split('/')[1];
setStandList(list);
}
let newFileList = [...file.fileList];
// 1. Limit the number of uploaded files
// Only to show two recent uploaded files, and old ones will be replaced by the new
newFileList = newFileList.slice(-2);
// 2. Read from response and show file link
newFileList = newFileList.map(files => {
if (file.response) {
// Component will show file.url as link
files.url = file.response.url;
}
return files;
});
setFileList(newFileList);
};
const beforeUpload = (file, fileList) => {
console.log(file);
const isJpgOrPng =
file.type === 'image/jpeg' ||
file.type === 'image/png' ||
file.type === 'image/jpg' ||
file.type === 'application/pdf';
return new Promise((resolve, reject) => {
if (!isJpgOrPng) {
message.error('仅支持.jpg .png .pdf格式的文件');
// message.error('支持.jpg .png .pdf ,单个文件不能超过20MB');
reject(file);
}
if (file) {
const size = file.size / 1024 / 1024;
if (size > 20) {
message.error('图片大小不能超过20M');
reject(file);
}
resolve(file);
}
});
};
const setInputValue = (e, item, index) => {
let list = JSON.parse(JSON.stringify(standList));
let obj = item;
list[index].name = e.currentTarget.value;
setStandList(list);
};
const uprops = {
// action: `${window.location.origin}/PandaWorkFlow/WorkFlow/AccountManage/UploaderFiles`,
action: `${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/UploaderFiles`,
multiple: true,
};
const previewFile = file => {};
const add = () => {
let list = standList ? JSON.parse(JSON.stringify(standList)) : [];
list.push({ name: '', pdfUrl: '' });
setPreviewVisible(true);
setStandList(list);
};
const remove = index => {
let list = JSON.parse(JSON.stringify(standList));
list.splice(index, 1);
setStandList(list);
};
const preview = item => {
setFileType(item.type);
setFileUrl(
`${window.origin +
'/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath='}${item.pdfUrl}`,
);
setPreviewVisible(true);
};
return (
<Drawer
title="设备档案库配置"
visible={visible}
destroyOnClose
width="600px"
{...props}
footer={
<Space>
<Button onClick={onSubmit} type="primary">
确定
</Button>
</Space>
}
>
<Form form={form} labelCol={{ span: 7 }} style={{ overflowY: 'scroll' }}>
<Row>
<Col span={24}>
<Item
label="维保设备"
name="AccountName"
labelCol={{ span: 5 }}
// rules={[
// {
// required: true,
// message: '请输入业务名称',
// },
// {
// validator: (rule, value) => {
// let aa = form.getFieldValue().businessName;
// if (type === 'add' && keepTableData.indexOf(aa) != -1) {
// return Promise.reject('业务名称已存在');
// }
// if (
// type === 'edit' &&
// keepTableData.indexOf(aa) != -1 &&
// aa != formObj.businessName
// ) {
// return Promise.reject('业务名称已存在');
// }
// return Promise.resolve();
// },
// },
// ]}
>
<Input placeholder="" disabled />
</Item>
</Col>
<Col span={24}>
<Item
label="维保类型"
name="DeviceType"
labelCol={{ span: 5 }}
// rules={[
// {
// required: true,
// message: '请输入业务名称',
// },
// {
// validator: (rule, value) => {
// let aa = form.getFieldValue().businessName;
// if (type === 'add' && keepTableData.indexOf(aa) != -1) {
// return Promise.reject('业务名称已存在');
// }
// if (
// type === 'edit' &&
// keepTableData.indexOf(aa) != -1 &&
// aa != formObj.businessName
// ) {
// return Promise.reject('业务名称已存在');
// }
// return Promise.resolve();
// },
// },
// ]}
>
<Input placeholder="" disabled />
</Item>
</Col>
<Col span={24}>
<Item
label={
<div style={{ display: 'flex', alignItems: 'center' }}>
{/* <Tooltip title={`存在${summaryValue}个外部字段`}>
<InfoCircleOutlined
style={{
color: 'red',
display: summaryIsShow,
}}
/>
</Tooltip> */}
<span>卡片字段</span>
</div>
}
// name="CarField"
labelCol={{ span: 5 }}
// rules={[
// {
// validator: (rule, value) => {
// console.log(checkedList1);
// let aa = form.getFieldValue().SummaryFields;
// let bb = [];
// console.log(aa.split(','));
// aa.split(',').map(i => {
// if (i != '') {
// bb.push(i);
// }
// });
// console.log(bb);
// if (aa == '') {
// return Promise.reject('摘要字段必选');
// }
// if (bb.length < 1 || aa.split(',').length > 5) {
// return Promise.reject('最少配置一个字段,最多配置五个字段');
// }
// return Promise.resolve();
// },
// },
// {
// required: true,
// message: '请选择摘要字段',
// },
// ]}
>
<div style={{ display: 'flex' }}>
<Form.Item name="CarField" style={{ marginBottom: 0, width: '100%' }}>
<Input placeholder="请选择卡片字段" allowClear />
</Form.Item>
<Button
type="dashed"
onClick={() => deployField('CarField')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '10px', width: '70px' }}
/>
</div>
</Item>
</Col>
<Col span={24}>
<Item
label={
<div style={{ display: 'flex', alignItems: 'center' }}>
{/* <Tooltip title={`存在${summaryValue}个外部字段`}>
<InfoCircleOutlined
style={{
color: 'red',
display: summaryIsShow,
}}
/>
</Tooltip> */}
<span>详情字段</span>
</div>
}
// name="CarField"
labelCol={{ span: 5 }}
// rules={[
// {
// validator: (rule, value) => {
// console.log(checkedList1);
// let aa = form.getFieldValue().SummaryFields;
// let bb = [];
// console.log(aa.split(','));
// aa.split(',').map(i => {
// if (i != '') {
// bb.push(i);
// }
// });
// console.log(bb);
// if (aa == '') {
// return Promise.reject('摘要字段必选');
// }
// if (bb.length < 1 || aa.split(',').length > 5) {
// return Promise.reject('最少配置一个字段,最多配置五个字段');
// }
// return Promise.resolve();
// },
// },
// {
// required: true,
// message: '请选择摘要字段',
// },
// ]}
>
<div style={{ display: 'flex' }}>
<Form.Item name="DetailsField" style={{ marginBottom: 0, width: '100%' }}>
<Input placeholder="请选择详情字段" allowClear />
</Form.Item>
<Button
type="dashed"
onClick={() => deployField('DetailsField')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '10px', width: '70px' }}
/>
</div>
</Item>
</Col>
<Col span={24}>
<Item
label="设备反馈"
name="FeedbackNames"
labelCol={{ span: 5 }}
// rules={[
// {
// required: true,
// message: '请输入业务名称',
// },
// {
// validator: (rule, value) => {
// if (form.getFieldsValue().businessType == '') {
// return Promise.reject('业务类型必填');
// }
// return Promise.resolve();
// },
// },
// ]}
>
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
{formObj?.FeedbackNames?.map(item => (
<div>
<Tag color="success">{item}</Tag>
</div>
))}
{formObj?.FeedbackNames?.length === 0 ? '暂无' : ''}
</div>
</Item>
</Col>
{/* <Col span={24}>
<Item label="点检标准" name="docycle" labelCol={{ span: 5 }} />
</Col> */}
<Col span={24}>
<Item label="点检标准" labelCol={{ span: 5 }}>
<div>
{standList?.length
? standList.map((item, index) => (
<div
style={{
display: 'flex',
alignItems: 'flex-start',
justifyContent: 'center',
marginBottom: '5px',
}}
>
<Input
placeholder="请输入点检标准名称"
value={item.name}
onChange={e => {
setInputValue(e, item, index);
}}
/>
<div>
<Upload
{...uprops}
onChange={value => handleChange(value, item, index)}
beforeUpload={beforeUpload}
previewFile={file => previewFile(file)}
maxCount={1}
showUploadList={false}
>
{item.pdfUrl ? (
<Button
style={{ marginLeft: '3px', width: '96px' }}
icon={<UploadOutlined />}
>
已上传
</Button>
) : (
<Button
style={{ marginLeft: '3px', width: '96px' }}
icon={<UploadOutlined />}
>
上传
</Button>
)}
</Upload>
</div>
<EyeOutlined
onClick={() => preview(item)}
style={{ marginLeft: '10px', fontSize: '20px' }}
/>
<MinusCircleOutlined
onClick={() => remove(index)}
style={{ marginLeft: '10px', fontSize: '20px' }}
/>
</div>
))
: null}
<Button
type="dashed"
onClick={() => add()}
block
icon={<PlusOutlined />}
style={{ marginLeft: '-2px', marginTop: '10px' }}
>
再加一条
</Button>
</div>
</Item>
</Col>
</Row>
</Form>
<Fieldselection
visible={showField}
handleCancel={() => setShowField(false)}
fieldList={filedList}
onSubumit={val => setFiled(val)}
fieldData={fieldData}
fieldName={fieldName}
/>
<Modal
visible={previewVisible}
title="文件预览"
width="850px"
footer={null}
onCancel={() => setPreviewVisible(false)}
bodyStyle={{ height: '600px', overflow: 'hidden', overflowY: 'scroll' }}
// style={{ overflow: 'auto' }}
>
<FileViewer fileType={fileType} filePath={fileUrl} />
</Modal>
</Drawer>
);
};
export default OptionEditModal;
/* eslint-disable no-else-return */
/* eslint-disable react-hooks/rules-of-hooks */
/* eslint-disable camelcase */
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useMemo } from 'react';
import { Space, Table, Popconfirm, Tooltip, Button, notification, Tag } from 'antd';
import {
CM_XWBPlan_DataList,
CM_XWBPlan_RemovePlan,
CM_XWBPlan_ChangeOrder,
GetDeviceConfigList,
EditDeviceConfig,
} from '@/services/maintenance/api';
import { EditTwoTone, DeleteOutlined, PlusOutlined, OrderedListOutlined } from '@ant-design/icons';
import styles from './maintenance.less';
import AddModal from './AddModal';
import OptionEditModal from './OptionEditModal';
import SortModal from './SortModal';
const maintenance = () => {
const [addVisible, setAddVisible] = useState(false);
const [optionVisible, setOptionVisible] = useState(false);
const [type, setType] = useState('');
const [formObj, setFormObj] = useState('');
const [treeLoading, setTreeLoading] = useState(false);
......@@ -22,8 +26,258 @@ const maintenance = () => {
const [sortVisible, setSortVisible] = useState(false);
const [tableData, setTableData] = useState([]);
const [keepTableData, setKeepTableData] = useState([]);
const [activeName, setActiveName] = useState('template');
const columns = [
// const columns = [
// {
// title: '业务名称',
// dataIndex: 'businessName',
// key: 'businessName',
// width: 150,
// onCell: () => ({
// style: {
// maxWidth: 150,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// align: 'center',
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// {
// title: '业务类型',
// dataIndex: 'businessType',
// key: 'businessType',
// width: 100,
// onCell: () => ({
// style: {
// maxWidth: 100,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// align: 'center',
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// {
// title: '执行周期',
// dataIndex: 'docycle',
// key: 'docycle',
// width: 100,
// align: 'center',
// },
// {
// title: '维保设备',
// dataIndex: 'accountName',
// key: 'accountName',
// width: 200,
// onCell: () => ({
// style: {
// maxWidth: 200,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// align: 'center',
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// {
// title: '反馈名称',
// dataIndex: 'feedbackName',
// key: 'feedbackName',
// onCell: () => ({
// style: {
// maxWidth: 200,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// align: 'center',
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// {
// title: '执行角色',
// dataIndex: 'doRole',
// key: 'doRole',
// align: 'center',
// onCell: () => ({
// style: {
// maxWidth: 200,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// {
// title: '预生成天数',
// dataIndex: 'produceDays',
// key: 'produceDays',
// width: 90,
// align: 'center',
// onCell: () => ({
// style: {
// maxWidth: 80,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// },
// {
// title: '在线任务量',
// dataIndex: 'onLines',
// key: 'onLines',
// width: 90,
// align: 'center',
// onCell: () => ({
// style: {
// maxWidth: 80,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// // {
// // title: '启停',
// // dataIndex: 'doNot',
// // key: 'doNot',
// // width: 80,
// // align: 'center',
// // },
// {
// title: '是否送审',
// dataIndex: 'isSubmit',
// key: 'isSubmit',
// width: 80,
// align: 'center',
// render: record => {
// if (record === '是') {
// return <Tag color="success">是</Tag>;
// } else {
// return <Tag color="processing">否</Tag>;
// }
// },
// },
// {
// title: '台账过滤条件',
// dataIndex: 'filterCondition',
// key: 'filterCondition',
// width: 150,
// onCell: () => ({
// style: {
// maxWidth: 150,
// overflow: 'hidden',
// whiteSpace: 'nowrap',
// textOverflow: 'ellipsis',
// cursor: 'pointer',
// },
// }),
// align: 'center',
// render: record => (
// <Tooltip placement="topLeft" title={record}>
// {record}
// </Tooltip>
// ),
// },
// {
// title: '操作',
// ellipsis: true,
// key: 'action',
// align: 'center',
// render: (text, record) => (
// <Space>
// <Tooltip title="修改">
// <EditTwoTone onClick={() => editEventType(record)} style={{ fontSize: '16px' }} />
// </Tooltip>
// <Tooltip title="删除">
// <Popconfirm
// placement="bottomRight"
// title={<p>是否确认删除?</p>}
// okText="确认"
// cancelText="取消"
// onConfirm={() => deleteEventType(record)}
// >
// <DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
// </Popconfirm>
// </Tooltip>
// </Space>
// ),
// },
// ];
useEffect(() => {
setTreeLoading(true);
if (activeName === 'template') {
CM_XWBPlan_DataList().then(res => {
setTreeLoading(false);
if (res.msg === 'Ok') {
setTableData(res.data);
let list = [];
res.data.map(i => {
list.push(i.businessName);
});
setKeepTableData(list);
}
});
} else {
GetDeviceConfigList().then(res => {
setTreeLoading(false);
if (res.msg === 'Ok') {
setTableData(res.data);
// let list = [];
// res.data.map(i => {
// list.push(i.AccountName);
// });
// setKeepTableData(list);
}
});
}
}, [flag, activeName]);
const columns = useMemo(() => {
if (activeName === 'template') {
return [
{
title: '业务名称',
dataIndex: 'businessName',
......@@ -240,21 +494,149 @@ const maintenance = () => {
),
},
];
useEffect(() => {
setTreeLoading(true);
CM_XWBPlan_DataList().then(res => {
setTreeLoading(false);
if (res.msg === 'Ok') {
setTableData(res.data);
let list = [];
res.data.map(i => {
list.push(i.businessName);
});
setKeepTableData(list);
} else {
return [
{
title: '维保设备',
dataIndex: 'AccountName',
key: 'AccountName',
width: 150,
onCell: () => ({
style: {
maxWidth: 150,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
cursor: 'pointer',
},
}),
align: 'center',
render: record => (
<Tooltip placement="topLeft" title={record}>
{record}
</Tooltip>
),
},
{
title: '设备类型',
dataIndex: 'DeviceType',
key: 'DeviceType',
width: 100,
onCell: () => ({
style: {
maxWidth: 100,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
cursor: 'pointer',
},
}),
align: 'center',
render: record => (
<Tooltip placement="topLeft" title={record}>
{record}
</Tooltip>
),
},
{
title: '卡片字段',
dataIndex: 'CarField',
key: 'CarField',
width: 100,
align: 'center',
render: record => {
if (record) {
return <Tag color="success">已配置</Tag>;
} else {
return <Tag color="processing">未配置</Tag>;
}
});
}, [flag]);
},
},
{
title: '详情字段',
dataIndex: 'DetailsField',
key: 'DetailsField',
width: 100,
align: 'center',
render: record => {
if (record) {
return <Tag color="success">已配置</Tag>;
} else {
return <Tag color="processing">未配置</Tag>;
}
},
},
{
title: '维保反馈',
dataIndex: 'FeedbackNames',
key: 'FeedbackNames',
width: 200,
onCell: () => ({
style: {
maxWidth: 200,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
cursor: 'pointer',
},
}),
align: 'center',
render: record => {
if (record?.length) {
return (
<div>
{record.map(item => (
<div style={{ marginBottom: '2px' }}>
<Tag color="success">{item}</Tag>
</div>
))}
</div>
);
} else {
return '-';
}
},
},
{
title: '点检标准',
dataIndex: 'StandardConfig',
key: 'StandardConfig',
width: 200,
onCell: () => ({
style: {
maxWidth: 200,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
cursor: 'pointer',
},
}),
align: 'center',
render: record => {
if (record) {
return <Tag color="success">已上传</Tag>;
} else {
return <Tag color="processing">未上传</Tag>;
}
},
},
{
title: '操作',
ellipsis: true,
key: 'action',
align: 'center',
width: 200,
render: (text, record) => (
<Space>
<Tooltip title="修改">
<EditTwoTone onClick={() => editOption(record)} style={{ fontSize: '16px' }} />
</Tooltip>
</Space>
),
},
];
}
}, [activeName]);
const add = () => {
setAddVisible(true);
......@@ -265,6 +647,17 @@ const maintenance = () => {
setType('edit');
setFormObj(record);
};
const editOption = record => {
let obj = record;
obj.CarField = obj.CarField
? Array.from(new Set(obj.CarField.split(','))).join(',')
: obj.CarField;
obj.DetailsField = obj.DetailsField
? Array.from(new Set(obj.CarField.split(','))).join(',')
: obj.DetailsField;
setOptionVisible(true);
setFormObj(obj);
};
const deleteEventType = record => {
CM_XWBPlan_RemovePlan({ planId: record.id }).then(res => {
if (res.msg === '') {
......@@ -284,11 +677,16 @@ const maintenance = () => {
});
};
const onSubmit = () => {
if (activeName === 'template') {
setAddVisible(false);
} else {
setOptionVisible(false);
}
setFlag(flag + 1);
};
const sort = () => {
console.log('触发咯6666');
setSortVisible(true);
};
......@@ -318,7 +716,27 @@ const maintenance = () => {
<div className={styles.maintenanceContainer}>
<div className={styles.contentContainers}>
<div style={{ height: '50px', backgroundColor: 'white' }}>
<span style={{ float: 'right', marginRight: '10px' }}>
<div className={styles.tabs}>
<div
className={activeName === 'template' ? styles.active : ''}
onClick={() => setActiveName('template')}
>
维保模板
</div>
<div
className={activeName === 'configuration' ? styles.active : ''}
onClick={() => setActiveName('configuration')}
>
设备库配置
</div>
</div>
<span
style={{
float: 'right',
marginRight: '10px',
display: activeName === 'template' ? 'block' : 'none',
}}
>
<Button
icon={<PlusOutlined className={styles.icon} />}
onClick={add}
......@@ -352,7 +770,11 @@ const maintenance = () => {
onRow={record => ({
onDoubleClick: event => {
event.stopPropagation();
if (activeName === 'template') {
editEventType(record);
} else {
editOption(record);
}
}, // 双击
})}
columns={columns}
......@@ -376,6 +798,13 @@ const maintenance = () => {
keepTableData={keepTableData}
placement="right"
/>
<OptionEditModal
visible={optionVisible}
onClose={() => setOptionVisible(false)}
callBackSubmit={onSubmit}
formObj={formObj}
placement="right"
/>
<SortModal
title="调整顺序"
visible={sortVisible}
......
......@@ -15,6 +15,29 @@
.ant-pagination {
padding: 10px;
}
.tabs {
display: flex;
align-items: center;
justify-content: center;
float: left;
margin-left: 10px;
height: 100%;
>div {
margin-right: 10px;
border: 1px solid gainsboro;
padding: 5px 10px;
border-radius: 3px;
&:hover {
cursor: pointer;
}
&.active {
border-color: rgb(24,144,255);
color: rgb(24,144,255);
}
}
}
}
.ant-card-body {
......@@ -64,6 +87,10 @@
width: 100%;
}
.optionModal {
}
.doctorTable {
margin-bottom: 16px;
}
......
import React, { useEffect, useState, useRef, useMemo } from 'react';
import { Modal, Divider, Checkbox } from 'antd';
import styles from './optionEdit.less';
import DragTable from '@/components/DragTable/DragTable';
const CheckboxGroup = Checkbox.Group;
const Fieldselection = props => {
// 自定义获取改变后的值hooks
const usePrevious = value => {
const ref = useRef();
useEffect(() => {
ref.current = value;
});
return ref.current;
};
const { onSubumit, handleCancel, visible, fieldList, fieldData, fieldName } = props;
const [checkList, setCheckList] = useState([]);
const [selectList, setSelectList] = useState([]); // 选中字段列表
const [isFirst, setIsFirst] = useState(true);
const prevAmount = usePrevious({ checkList });
const columns = [
{
title: '字段名',
dataIndex: 'name',
width: 150,
key: 'name',
},
];
useEffect(() => {
if (visible) {
setCheckList(fieldList);
let newArr = fieldData.map(item => ({ name: item }));
setSelectList(newArr);
} else {
setSelectList([]);
setCheckList([]);
setIsFirst(true);
}
}, [visible]);
useEffect(() => {
if (prevAmount) {
selectAll();
}
}, [checkList]);
const selectAll = () => {
if (!visible) {
return;
}
// 是否第一次保存数据
if (isFirst) {
setIsFirst(false);
return;
}
// 新的选择后的数据(已选字段列表数据)
let newSelect = JSON.parse(JSON.stringify(selectList));
// 当前选中的
let currentArr = [];
// 上一次选中的
let preArr = [];
// 获取扁平化后的数组
checkList.forEach(item => {
currentArr = [...currentArr, ...item.defaultCheckedList];
});
prevAmount.checkList.forEach(item => {
preArr = [...preArr, ...item.defaultCheckedList];
});
currentArr = new Set(currentArr);
preArr = new Set(preArr);
// 找出相同的部分
let someArr = [...new Set([...currentArr].filter(x => preArr.has(x)))];
// 复选框事选中还是取消选中 add or del
let checkType;
if ([...currentArr].length > [...preArr].length) {
checkType = 'add';
} else if ([...currentArr].length < [...preArr].length) {
checkType = 'del';
}
if (checkType === 'add') {
// 添加新选中的元素
currentArr.forEach(item => {
if (someArr.indexOf(item) === -1) {
newSelect.push({ name: item });
}
});
} else if (checkType === 'del') {
// 删除取消勾选的元素
preArr.forEach(item => {
if (someArr.indexOf(item) === -1) {
newSelect.splice(newSelect.findIndex(ele => ele.name === item), 1);
}
});
}
setSelectList(newSelect);
};
// 提交表单
const onFinish = () => {
let callArr = selectList.map(item => item.name);
onSubumit(callArr);
};
// 复选框
const onChange = (list, index) => {
setCheckList(value => {
const chooseList = JSON.parse(JSON.stringify(value));
chooseList[index].defaultCheckedList = list;
chooseList[index].indeterminate =
!!list.length && list.length < chooseList[index].plainOptions.length;
chooseList[index].checkAll = list.length === chooseList[index].plainOptions.length;
return chooseList;
});
};
// 全选
const onCheckAllChange = (e, index) => {
setCheckList(value => {
const chooseList = JSON.parse(JSON.stringify(value));
chooseList[index].defaultCheckedList = e.target.checked ? chooseList[index].plainOptions : [];
chooseList[index].indeterminate = false;
chooseList[index].checkAll = e.target.checked;
return chooseList;
});
};
// 拖拽回调
const dragCallBack = arr => {
if (arr) {
setSelectList(arr);
}
};
return (
<Modal
title={fieldName === 'CarField' ? '卡片字段配置' : '详情字段配置'}
visible={visible}
onOk={onFinish}
width="750px"
onCancel={handleCancel}
maskClosable={false}
destroyOnClose
centered
>
<div className={styles.fieldContent}>
{/* 待选字段列表 */}
<div className={styles.willSelectBox}>
<div className={styles.header}>
<Divider orientation="left" className={styles.headDivider}>
待选字段列表
</Divider>
</div>
<div className={styles.cardContent}>
{checkList.map((item, index) => (
<div className={styles.cardBox} key={index}>
<div className={styles.title}>
<Divider orientation="left" className={styles.cardDivider}>
<span className={styles.groupName}>{item.groupName}</span>
<Checkbox
indeterminate={item.indeterminate}
onChange={e => onCheckAllChange(e, index)}
checked={item.checkAll}
/>
</Divider>
</div>
<div className={styles.filedList}>
<CheckboxGroup
key={index}
options={item.plainOptions}
value={item.defaultCheckedList}
onChange={list => onChange(list, index)}
/>
</div>
</div>
))}
</div>
</div>
{/* 已选字段列表 */}
<div className={styles.hasSelectBox}>
<div className={styles.header}>
<Divider orientation="left" className={styles.headDivider}>
已选字段列表
</Divider>
</div>
<div className={styles.doctorTable}>
<DragTable
bordered
rowKey={record => record.name}
columns={columns}
dataSource={selectList}
pagination={false}
size="small"
dragCallBack={dragCallBack}
ItemTypes="stadingOrder"
/>
</div>
</div>
</div>
</Modal>
);
};
export default Fieldselection;
// 字段集选择
.fieldContent {
display: flex;
.willSelectBox {
width: 50%;
height: 600px;
overflow-y: scroll;
padding: 8px;
border-right: 1px solid rgb(153, 187, 232);
box-sizing: border-box;
.cardContent {
height: 530px;
overflow-y: scroll;
.cardBox {
padding: 10px;
margin-bottom: 10px;
border: 1px solid #b5b8c8;
box-sizing: border-box;
}
.filedList {
.ant-checkbox-wrapper {
width: 100%;
}
}
}
}
.hasSelectBox {
width: 50%;
height: 600px;
padding: 8px 8px 8px 12px;
box-sizing: border-box;
.doctorTable {
margin-bottom: 16px;
height: 530px;
overflow-y: scroll;
}
}
.header {
margin: 0px 0px 10px;
background-color: rgb(223, 232, 246);
.headDivider {
margin-bottom: 10px;
background-color: #dfe8f6;
}
}
.cardDivider {
margin-bottom: 10px;
font-weight: 700;
color: #15428b;
line-height: 100%;
border-top-color: #99bbe8;
.groupName {
display: inline-block;
margin-right: 10px;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: middle;
}
.ant-checkbox-wrapper {
vertical-align: middle;
}
}
}
\ No newline at end of file
.feedBack {
display: flex;
flex-wrap: wrap;
>div {
width: 51%;
}
}
\ No newline at end of file
......@@ -1506,12 +1506,22 @@ const AddModal = props => {
required: true,
message: '请输入编码前缀',
},
{
validator: (rule, value) => {
let regex = new RegExp(/^[A-Z]{2,6}$/g);
if (!regex.test(value)) {
return Promise.reject('编码只能输入2-6位纯大写英文!');
}
return Promise.resolve();
},
},
]}
>
<Input
value={prefixName}
placeholder="请输入编码前缀"
style={{ marginLeft: '-3px' }}
maxLength={6}
/>
</Item>
</Col>
......
......@@ -429,7 +429,7 @@ const incident = () => {
});
},
okText: '确认导入',
cancelText: '我想想',
cancelText: '我想想',
});
} else {
message.error(res.msg);
......
......@@ -203,6 +203,7 @@ const NodeEdit = props => {
setFieldName(val);
loadEventFields({ eventTableName: value.TableName }).then(res => {
if (res.code === 0) {
console.log(value[val], value, val, 'valuevaluevaluevaluevalue');
let defaultCheckedList = value[val] ? value[val].split(',') : [];
// 保存所有的字段用于右侧显示
......
......@@ -540,14 +540,14 @@ const FlowModal = props => {
if (modalType === 'edit' && keep.indexOf(aa) != -1 && aa != msg.FlowName) {
return Promise.reject('流程名称已存在');
}
prefix(value);
// prefix(value);
// form.setFieldsValue({ Type: msg.name, Prefix: value });
return Promise.resolve();
},
},
]}
>
<Input placeholder="请输入流程名称" readOnly={modalType === 'edit'} />
<Input placeholder="请输入流程名称" onChange={prefix} readOnly={modalType === 'edit'} />
</Form.Item>
<Form.Item
label="分组信息"
......@@ -584,9 +584,18 @@ const FlowModal = props => {
required: true,
message: '请输入编码前缀',
},
{
validator: (rule, value) => {
let regex = new RegExp(/^[A-Z]{2,6}$/g);
if (!regex.test(value)) {
return Promise.reject('编码只能输入2-6位纯大写英文!');
}
return Promise.resolve();
},
},
]}
>
<Input placeholder="请输入编码前缀" maxLength={12} />
<Input placeholder="请输入编码前缀" maxLength={6} />
</Form.Item>
<Form.Item label="流程描述" name="Text">
<Input placeholder="请输入流程描述" />
......
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