Commit ce438be4 authored by 涂伟's avatar 涂伟
parents 1c655002 e2679c15
Pipeline #75279 passed with stages
......@@ -10,7 +10,16 @@ const fnList = [
{ label: '上报人工单统计', value: '$fn.caseNum()' },
];
const RuleConfig = props => {
const { visible, handleCancel, fieldList, onSubumit, RuleContent, flag, flowID } = props;
const {
visible,
handleCancel,
fieldList,
onSubumit,
RuleContent,
flag,
flowID,
showInsertFn,
} = props;
const [rule, setRule] = useState([]);
const [expandedKey, setExpandedKey] = useState(''); // 默认展开项
const [currentSelectId, setCurrentSelectId] = useState(''); // 选中得节点
......@@ -109,9 +118,11 @@ const RuleConfig = props => {
<div className={styles.rightContent}>
{flag == 1 && <div className={styles.title}>符合以下条件时工单扭转到对应的节点</div>}
<div className={styles.textAreaBox}>
<Dropdown overlay={fnListRender} placement="bottom" arrow>
<div className={styles.insertFn}>插入函数</div>
</Dropdown>
{flag == 1 && (
<Dropdown overlay={fnListRender} placement="bottom" arrow>
<div className={styles.insertFn}>插入函数</div>
</Dropdown>
)}
<TextArea
id="ruleText"
......
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable indent */
/* eslint-disable camelcase */
/* eslint-disable no-unused-expressions */
......@@ -18,6 +19,7 @@ import {
Radio,
Switch,
TreeSelect,
message,
} from 'antd';
import {
PlusOutlined,
......@@ -28,6 +30,7 @@ import {
} from '@ant-design/icons';
import { setAutoFreeze } from 'immer';
import styles from './maintenance.less';
import RuleConfig from '@/components/RuleConfig';
import {
CM_XWBPlan_AccountTable,
CM_XWBPlan_feedbackTable,
......@@ -35,6 +38,8 @@ import {
CM_XWBPlan_DataList,
CM_XWBPlan_DeviceAccountTable,
GetParentDeviceTemplate,
GetFeedbackTableFields,
GetAccountConfigInfo,
} from '@/services/maintenance/api';
import { GetTaskSyncField } from '@/services/PatrolFeedback/api';
......@@ -60,7 +65,7 @@ const AddModal = props => {
const [selectValue1, setSelectValue1] = useState('');
const [treeData, setTreeData] = useState([]);
const [isVisible, setIsVisible] = useState(false);
const [filed, setFiled] = useState({}); // 传给子组件列表数据
const [filed, setFiled] = useState([]); // 传给子组件列表数据
const [filed1, setFiled1] = useState({}); // 传给子组件列表数据
const [types, setTypes] = useState(''); // 弹窗类型
const [pickItem, setPickItem] = useState(''); // 复选框数据填入项
......@@ -78,19 +83,12 @@ const AddModal = props => {
const [autoFlag, setAutoFlag] = useState(false); // 禁用自动派发
const [keepData, setKeepData] = useState('');
const [parentList, setParentList] = useState([]);
const [keep, setKeep] = useState([
'任务编码',
'设备编码',
'计划编码',
'任务类型',
'设备类型',
'坐标位置',
'详细地址',
'执行人',
]); // 保存初始完整任务同步事件字段
const [keep, setKeep] = useState([]); // 保存初始完整任务同步事件字段
const [keepAllData, setKeepAllData] = useState([]); // 保存所有关联事件类型数据
const [keepTree, setKeepTree] = useState([]);
const [keepAll, setKeepAll] = useState([]); // 保存所选关联事件下完整的字段值
const [showRule, setShowRule] = useState(false);
const [fieldList, setFieldList] = useState([]);
const [form] = Form.useForm();
const [formAdd] = Form.useForm();
......@@ -157,13 +155,14 @@ const AddModal = props => {
} else if (type === 'edit') {
CM_XWBPlan_DataList({ id: formObj.id }).then(res => {
let data = res.data[0];
if (data.isSubmit == '是') {
if (data.isSubmit === '是') {
setAutoFlag(true);
} else {
setAutoFlag(false);
}
setVisibleChecked(data.isSubmit == '是');
setVisibleChecked1(data.autoAssign == '是');
onChangeFeed(data.feedbackName);
setVisibleChecked(data.isSubmit === '是');
setVisibleChecked1(data.autoAssign === '是');
console.log(data);
data && form.setFieldsValue({ ...data });
if (data.parentBusinessName) {
......@@ -188,7 +187,8 @@ const AddModal = props => {
form.resetFields();
formAdd.resetFields();
setKeepTree([]);
setKeepData('');
setKeepData([]);
setKeep([]);
}
}, [visible]);
......@@ -212,8 +212,8 @@ const AddModal = props => {
if (res.code === 0) {
let aa = [];
let bb = [];
res.data.map(i => {
i.root.map(j => {
res.data.forEach(i => {
i.root.forEach(j => {
aa.push(j.name);
bb.push(j);
});
......@@ -239,22 +239,29 @@ const AddModal = props => {
if (validate) {
let obj = form.getFieldsValue();
let mappingFields = formAdd.getFieldValue('parmars');
// mappingFields &&
// mappingFields.forEach(i => {
// keep.forEach(j => {
// if (j === i.fromField) {
// i.fromField = j;
// }
// });
// });
mappingFields &&
mappingFields.map(i => {
keep.map(j => {
if (j === i.fromField) {
i.fromField = j;
}
});
mappingFields.forEach(i => {
let data = i.fromField.split('%');
i.fromField = data[0];
i.fromTable = data[1];
});
obj.isSubmit = visibleChecked == true ? '是' : '否';
obj.autoAssign = visibleChecked1 == true ? '是' : '否';
if (type == 'add') {
obj.isSubmit = visibleChecked === true ? '是' : '否';
obj.autoAssign = visibleChecked1 === true ? '是' : '否';
if (type === 'add') {
CM_XWBPlan_DataEditORAdd({
...obj,
mappingFields: mappingFields && JSON.stringify(mappingFields),
}).then(res => {
if (res.msg == '') {
if (res.msg === '') {
form.resetFields();
callBackSubmit();
notification.success({
......@@ -271,17 +278,17 @@ const AddModal = props => {
}
});
}
if (type == 'edit') {
if (type === 'edit') {
console.log(obj.isSubmit);
obj.isSubmit = visibleChecked == true ? '是' : '否';
obj.autoAssign = visibleChecked1 == true ? '是' : '否';
obj.isSubmit = visibleChecked === true ? '是' : '否';
obj.autoAssign = visibleChecked1 === true ? '是' : '否';
console.log(obj);
CM_XWBPlan_DataEditORAdd({
...obj,
id: formObj.id,
mappingFields: mappingFields && JSON.stringify(mappingFields),
}).then(res => {
if (res.msg == '') {
if (res.msg === '') {
form.resetFields();
callBackSubmit();
notification.success({
......@@ -352,9 +359,9 @@ const AddModal = props => {
const groupArr = (initialArr, name) => {
let list = {};
initialArr.data.map(i => {
initialArr.data.forEach(i => {
let ar = [];
i.root.map(j => {
i.root.forEach(j => {
let ss = {};
ss.label = j.Name;
ss.value = j.ID.toString();
......@@ -369,7 +376,7 @@ const AddModal = props => {
CM_XWBPlan_feedbackTable().then(res => {
if (res.code === 0) {
let arr = [];
res.data.map((item, index) => {
res.data.forEach((item, index) => {
arr.push(item.accountName);
});
setFiled(arr);
......@@ -381,28 +388,19 @@ const AddModal = props => {
let a1 = [];
let a2;
let a3 = [];
initialArr.data.map(i => {
// console.log(i.groupType)
initialArr.data.forEach(i => {
a2 = i.groupType;
// console.log(a2)
// console.log(i.root)
a1 = i.root;
a1.map(j => {
a1.forEach(j => {
j.group = a2;
// console.log(j)
});
aa.push(i.root);
});
// console.log(aa)
aa.map(p => {
// console.log(p)
p.map(o => {
// console.log(o)
aa.forEach(p => {
p.forEach(o => {
a3.push(o);
});
});
console.log(a3);
// 判定传参是否符合规则
if (!(a3 instanceof Array)) {
return '请传入正确格式的数组';
......@@ -412,12 +410,11 @@ const AddModal = props => {
}
// 先获取一下这个数组中有多少个"name"
let nameArr = [];
a3.map(i => {
a3.forEach(i => {
if (nameArr.indexOf(i.group) === -1) {
nameArr.push(i.group);
}
});
console.log(nameArr);
// 新建一个包含多个list的结果对象
let tempObj = {};
// 根据不同的"name"生成多个数组
......@@ -430,7 +427,6 @@ const AddModal = props => {
}
}
}
console.log(tempObj);
for (let key in tempObj) {
let arr = [];
tempObj[key].map(item => {
......@@ -440,12 +436,7 @@ const AddModal = props => {
}
return tempObj;
};
const changTable = value => {
setSelectValue(value);
};
const changTable1 = value => {
setSelectValue1(value);
};
const onOK = prop => {
setIsVisibleRoles(false);
let inputText = {};
......@@ -470,7 +461,7 @@ const AddModal = props => {
};
const change = e => {
if (e == true) {
if (e === true) {
setVisibleChecked1(false);
}
console.log(e);
......@@ -508,33 +499,54 @@ const AddModal = props => {
return <TreeNode value={org} title={org} key={org} />;
};
const mapTreeFiled = (org, parent) => {
if (org.TableFields) {
return (
<TreeNode value={org.TableName} title={org.TableName} disabled>
{org.TableFields.map(item => mapTreeFiled(item, org.TableName))}
</TreeNode>
);
}
return (
<TreeNode value={`${org.FieldName}%${parent}`} title={org.FieldName} key={org.FieldName} />
);
};
// 获取字段名数据
const getGetTaskSyncField = e => {
// 编辑时处理数据为下拉框过滤调已选数据
if (e) {
let datalist = [...e];
datalist.map(i => {
keep.map(j => {
if (j === i.fromField) {
i.fromField = j;
}
});
// datalist.forEach(i => {
// keep.forEach(j => {
// if (j === i.fromField) {
// i.fromField = j;
// }
// });
// });
let arr = [];
datalist.forEach(i => {
if (i.fromTable) {
arr.push({ fromField: `${i.fromField}%${i.fromTable}`, toField: i.toField });
} else {
arr.push({ fromField: i.fromField, toField: i.toField });
}
});
formAdd.setFieldsValue({ parmars: datalist }); // 处理数据让下拉框回显title值
formAdd.setFieldsValue({ parmars: arr }); // 处理数据让下拉框回显title值
let aa = e;
let from = [];
aa.map(i => {
aa.forEach(i => {
if (i && i.fromField) {
from.push(i.fromField);
}
});
let lastFrom = [];
keep.map(j => {
if (from.indexOf(j) == -1) {
keep.forEach(j => {
if (from.indexOf(j) === -1) {
lastFrom.push(j);
}
});
setKeepData(lastFrom);
// setKeepData(lastFrom);
} else {
setKeepData(keep);
}
......@@ -542,13 +554,11 @@ const AddModal = props => {
};
const changeValue = () => {
console.log(formAdd.getFieldsValue().parmars);
let aa = formAdd.getFieldsValue().parmars;
if (aa) {
console.log(aa);
let from = [];
let to = [];
aa.map(i => {
aa.forEach(i => {
if (i && i.fromField) {
from.push(i.fromField);
}
......@@ -556,37 +566,52 @@ const AddModal = props => {
to.push(i.toField);
}
});
let lastFrom = [];
let lastTo = [];
keep.map(j => {
if (from.indexOf(j) == -1) {
keep.forEach(j => {
if (from.indexOf(j) === -1) {
lastFrom.push(j);
}
});
setKeepData(lastFrom);
let bb = detailData(keep, from);
keepAll.map(j => {
if (to.indexOf(j.name) == -1) {
setKeepData(lastFrom);
keepAll.forEach(j => {
if (to.indexOf(j.name) === -1) {
lastTo.push(j);
}
});
setKeepTree(lastTo);
}
};
// let data = keepAll;
// data.map(k => {
// console.log(k);
// k.children.map((j, h) => {
// console.log(j);
// if (to.indexOf(j.name) != -1) {
// console.log(j);
// k.children.splice(h, 1);
// }
// });
// });
// console.log(data);
// setKeepTree(data);
const detailData = (val, from) => {
let newKeep = {};
val.forEach(i => {
i.TableFields.forEach(j => {
let data = `${j.FieldName}%${i.TableName}`;
// if (from.indexOf(data) === -1) {
// if (!newKeep[i.TableName]) {
// newKeep[i.TableName] = [j];
// } else {
// newKeep[i.TableName].push(j);
// }
// }
if (from.indexOf(data) === -1) {
if (!newKeep[i.TableName]) {
newKeep[i.TableName] = [j];
} else {
newKeep[i.TableName].push(j);
}
}
});
});
let arr = [];
let keys = Object.keys(newKeep);
keys.forEach(item => {
arr.push({ TableName: item, TableFields: newKeep[item] });
});
return arr;
};
// 改变关联事件类型
......@@ -595,7 +620,7 @@ const AddModal = props => {
setKeepData(keep);
formAdd.resetFields();
}
let aa = keepAllData.find(i => i.name === e);
let aa = keepAllData.find(item => item.name === e);
if (aa) {
getReloadTableField(aa.tableName, i); // 找到关联事件对应事件表获取对应表的所有字段
}
......@@ -611,14 +636,14 @@ const AddModal = props => {
if (i) {
let aa = i;
let to = [];
aa.map(j => {
aa.forEach(j => {
if (j && j.toField) {
to.push(j.toField);
}
});
let lastTo = [];
res.data.root.map(b => {
if (to.indexOf(b.name) == -1) {
res.data.root.forEach(b => {
if (to.indexOf(b.name) === -1) {
lastTo.push(b);
}
});
......@@ -627,18 +652,18 @@ const AddModal = props => {
setKeepTree(res.data.root);
}
let arrlist = [];
let arrList = [];
let data = {};
let listArr = [];
res.data.root.map(i => {
arrlist.push(i.name);
res.data.root.forEach(item => {
arrList.push(item.name);
});
data.TableFieldNames = arrlist;
data.TableFieldNames = arrList;
data.TableName = e;
listArr.push(data);
let arr = formateArrDataA2(res.data.root, 'group');
let arr = formateArrDataA(res.data.root, 'group');
let newArr = [];
Object.keys(arr).map((item, index) => {
Object.keys(arr).forEach((item, index) => {
newArr.push({ type: item, key: index, id: index });
});
let aa = [];
......@@ -653,7 +678,7 @@ const AddModal = props => {
}
});
};
const formateArrDataA2 = (initialArr, name) => {
const formateArrDataA = (initialArr, name) => {
// 判定传参是否符合规则
if (!(initialArr instanceof Array)) {
return '请传入正确格式的数组';
......@@ -661,35 +686,47 @@ const AddModal = props => {
if (!name) {
return '请传入对象属性';
}
// 先获取一下这个数组中有多少个"name"
let nameArr = [];
// eslint-disable-next-line no-restricted-syntax
for (let i in initialArr) {
if (nameArr.indexOf(initialArr[i][`${name}`]) === -1) {
nameArr.push(initialArr[i][`${name}`]);
let arr = {};
initialArr.forEach((item, index) => {
let data = item.group;
if (!arr[data]) {
arr[data] = [item];
} else {
arr[data].push(item);
}
}
// 新建一个包含多个list的结果对象
let tempObj = {};
// 根据不同的"name"生成多个数组
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]);
}
});
return arr;
};
const onChangeFeed = val => {
GetFeedbackTableFields({ feedbackName: val }).then(res => {
if (res.code === 0) {
let newData = [res.data.DeviceData];
res.data.FeedbackData.length > 0 &&
res.data.FeedbackData.forEach(i => {
newData.push(i);
});
setKeepData(newData);
setKeep(newData);
}
}
for (let keys in tempObj) {
let arr = [];
tempObj[keys].map((item, index) => {
tempObj[keys] = arr;
item.key = index;
arr.push(item);
});
}
return tempObj;
});
GetAccountConfigInfo({ accountName: val }).then(res => {
if (res.code === 0) {
let list = res.data.editFieldGroup.split(',');
let newList = list.filter(i => i && i.trim());
let data = [{ TableName: val, TableFieldNames: newList }];
setFieldList(data);
}
});
};
const saveRule = e => {
form.setFieldsValue({ feedbackRule: e });
setShowRule(false);
};
const editRule = () => {
setShowRule(true);
};
return (
......@@ -793,7 +830,7 @@ const AddModal = props => {
},
{
validator: (rule, value) => {
if (form.getFieldsValue().accountName == '') {
if (form.getFieldsValue().accountName === '') {
return Promise.reject('维保设备必选');
}
return Promise.resolve();
......@@ -843,7 +880,7 @@ const AddModal = props => {
rules={[
{
validator: (rule, value) => {
if (form.getFieldValue().feedbackName == '') {
if (form.getFieldValue().feedbackName === '') {
return Promise.reject('反馈名称必填');
}
return Promise.resolve();
......@@ -857,14 +894,27 @@ const AddModal = props => {
>
<div style={{ display: 'flex' }}>
<Item name="feedbackName" style={{ marginBottom: 0, width: '100%' }}>
<Input placeholder="请选择反馈名称" allowClear />
<Select
placeholder="请选择反馈名称"
showSearch
allowClear
onChange={e => onChangeFeed(e)}
>
{filed
? filed.map((item, index) => (
<Option key={index} value={item}>
{item}
</Option>
))
: ''}
</Select>
</Item>
<Button
{/* <Button
type="dashed"
onClick={() => pickFiled('feedbackName')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '10px', width: '70px' }}
/>
/> */}
</div>
</Item>
</Col>
......@@ -876,7 +926,7 @@ const AddModal = props => {
rules={[
{
validator: (rule, value) => {
if (form.getFieldValue().doRole == '') {
if (form.getFieldValue().doRole === '') {
return Promise.reject('执行角色必填');
}
return Promise.resolve();
......@@ -995,6 +1045,28 @@ const AddModal = props => {
<Input placeholder="例如:and 泵房品牌='熊猫'(SQL表达式)" />
</Item>
</Col>
<Col span={24}>
<Item label="反馈联动" name="feedbackRule" labelCol={{ span: 5 }}>
<div
style={{
border: '2px solid #6A98FA',
minHeight: '34px',
lineHeight: '34px',
textAlign: 'center',
}}
onClick={() => {
let obj = form.getFieldsValue().feedbackName;
if (!obj) {
message.warning('请先选择反馈名称!');
} else {
editRule();
}
}}
>
<span>{form.getFieldsValue().feedbackRule}</span>
</div>
</Item>
</Col>
<Col span={24}>
<Item label="关联事件" name="relationEvent" labelCol={{ span: 5 }}>
<Select
......@@ -1047,21 +1119,22 @@ const AddModal = props => {
validateTrigger={['onChange', 'onBlur']}
rules={[{ required: true, message: '请填写字段名' }]}
>
<Select
placeholder="选择字段名"
// onSelect={changTable}
// optionLabelProp="key"
<TreeSelect
showSearch
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="请选择字段名"
treeDefaultExpandAll
style={{ width: '159px' }}
showCheckedStrategy
onFocus={() => {
let obj = form.getFieldsValue().feedbackName;
if (!obj) {
message.warning('请先选择反馈名称!');
}
}}
>
{keepData
? keepData.map((item, index) => (
<Option key={item} value={item}>
{item}
</Option>
))
: ''}
</Select>
{keepData.length > 0 && keepData.map(i => mapTreeFiled(i))}
</TreeSelect>
</Form.Item>
<img src={logo} style={{ height: '24px' }} alt="" />
<Form.Item
......@@ -1100,7 +1173,7 @@ const AddModal = props => {
block
icon={<PlusOutlined />}
style={{ marginLeft: '-2px' }}
disabled={keepData && !(keepData.length > 0)}
// disabled={keepData && !(keepData.length > 0)}
>
添加映射
</Button>
......@@ -1137,6 +1210,15 @@ const AddModal = props => {
keepFiled={keepFiled}
dataType="name"
/>
<RuleConfig
RuleContent={form.getFieldsValue().feedbackRule || ''}
tableName={form.getFieldsValue().feedbackName}
fieldList={fieldList}
visible={showRule}
handleCancel={() => setShowRule(false)}
onSubumit={e => saveRule(e)}
flag={2}
/>
</Drawer>
);
};
......
......@@ -155,17 +155,21 @@ const FlowChart = props => {
delLinks.add(item.data.LineId);
}
});
CheckDoingFlowNodes({ activityIds: [...delNodes] }).then(res => {
if (res.code === 0) {
if (res.data > 0) {
showCloseList([...delNodeIds], [...delNodes], [...delLinks], res.data);
if (delNodes.size === 0) {
delNode([...delNodeIds], [...delNodes], [...delLinks]);
} else {
CheckDoingFlowNodes({ activityIds: [...delNodes] }).then(res => {
if (res.code === 0) {
if (res.data > 0) {
showCloseList([...delNodeIds], [...delNodes], [...delLinks], res.data);
} else {
showDeleteConfirm([...delNodeIds], [...delNodes], [...delLinks]);
}
} else {
showDeleteConfirm([...delNodeIds], [...delNodes], [...delLinks]);
message.error(res.msg);
}
} else {
message.error(res.msg);
}
});
});
}
return false;
};
......@@ -1039,9 +1043,11 @@ const FlowChart = props => {
}).then(response => {
if (response.code === 0) {
console.log(currentNode.current);
let list = JSON.parse(JSON.stringify(currentNode.current));
list.FlowNodeBackfillConfigs = jsonData(list.FlowNodeBackfillConfigs);
currentNode.current = list;
// let list = JSON.parse(JSON.stringify(currentNode.current));
// list.FlowNodeBackfillConfigs = jsonData(list.FlowNodeBackfillConfigs);
// currentNode.current = list;
let flowNodeBackfillConfigs = currentNode.current.FlowNodeBackfillConfigs;
currentNode.current.FlowNodeBackfillConfigs = jsonData(flowNodeBackfillConfigs);
console.log(currentNode.current);
FlowNodeSave({
PreviewImage: response.data,
......@@ -1083,10 +1089,8 @@ const FlowChart = props => {
let listArr = [];
val.map((item, index) => {
console.log(item);
debugger;
if (!item.Config) {
console.log(item);
debugger;
let arr = [];
arr.push({
mapServer: item.schemeName,
......@@ -1278,7 +1282,6 @@ const FlowChart = props => {
}),
1.2, // 压缩比例
base64 => {
console.log(base64);
SaveWorkFlowImage({
flowName: flowData.flowName,
base64Data: base64,
......
......@@ -47,3 +47,9 @@ export const CM_XWBPlan_ChangeOrder = planIds =>
// 获取父级维保模板
export const GetParentDeviceTemplate = query =>
get(`${PUBLISH_SERVICE}/WorkOrderCenter/GetParentDeviceTemplate`, query);
export const GetFeedbackTableFields = query =>
get(`${PUBLISH_SERVICE}/WorkOrderCenter/GetFeedbackTableFields`, query);
export const GetAccountConfigInfo = query =>
get(`/PandaWorkFlow/WorkFlow/AccountManage/GetAccountConfigInfo`, query);
\ No newline at end of file
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