|
|
@@ -265,56 +265,16 @@
|
|
|
);
|
|
|
},
|
|
|
openEditMatter(row) {
|
|
|
+ this.currentEditRow = row;
|
|
|
this.$refs.userSettingMatterAddRef.openEdit(row);
|
|
|
},
|
|
|
addMatter(matter, rules) {
|
|
|
const id = 'tem' + new Date().getTime();
|
|
|
console.log('matter', matter, rules);
|
|
|
|
|
|
- if (matter.itemType == '2') {
|
|
|
- const any = this.matterList.some((i) => i.rulesId == matter.rulesId);
|
|
|
-
|
|
|
- if (any) {
|
|
|
- return this.$message.warning(
|
|
|
- `“${matter.rulesName}”记录规则已存在,请勿重复添加`
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // 是否存在记录规则
|
|
|
- const ruleItem = this.matterList.find((i) => i.itemType == '2');
|
|
|
-
|
|
|
- if (
|
|
|
- ruleItem &&
|
|
|
- ruleItem.recordRulesClassify != matter.recordRulesClassify
|
|
|
- ) {
|
|
|
- const ruleItemClassName = this.getDictValue(
|
|
|
- '记录规则类型',
|
|
|
- ruleItem.recordRulesClassify
|
|
|
- );
|
|
|
- return this.$message.warning(
|
|
|
- `已存在“${ruleItemClassName}”记录规则分类,请勿添加不同规则分类`
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // 判断是否存在同一分类
|
|
|
- const exists = this.matterList
|
|
|
- .filter((i) => i.itemType == '2')
|
|
|
- .some(
|
|
|
- (item) =>
|
|
|
- item.recordRulesClassify == matter.recordRulesClassify &&
|
|
|
- item.recordRulesExecuteMethodId == rules.executeMethodId &&
|
|
|
- rules.executeMethodId != null
|
|
|
- );
|
|
|
-
|
|
|
- if (exists) {
|
|
|
- const className = this.getDictValue(
|
|
|
- '记录规则类型',
|
|
|
- matter.recordRulesClassify
|
|
|
- );
|
|
|
- return this.$message.warning(
|
|
|
- `已存在“${className}”记录规则分类“${rules.executeMethodName}”,请勿重复添加`
|
|
|
- );
|
|
|
- }
|
|
|
+ // 校验事项是否重复
|
|
|
+ if (!this.validateMatter(matter, rules)) {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
matter.produceTaskConfigRuleDetails = rules?.details || [];
|
|
|
@@ -344,6 +304,11 @@
|
|
|
editMatter(matter, rules) {
|
|
|
console.log('matter', matter);
|
|
|
|
|
|
+ // 校验事项是否重复
|
|
|
+ if (!this.validateMatter(matter, rules, this.currentEditRow?.id)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 编辑事项
|
|
|
this.matterList = this.matterList.map((item) => {
|
|
|
if (item.id === matter.id) {
|
|
|
@@ -377,6 +342,62 @@
|
|
|
}
|
|
|
this.handleSort();
|
|
|
},
|
|
|
+ // 校验事项是否重复
|
|
|
+ validateMatter(matter, rules, currentId) {
|
|
|
+ if (matter.itemType == '2') {
|
|
|
+ const any = this.matterList
|
|
|
+ .filter((i) => i.id !== currentId)
|
|
|
+ .some((i) => i.rulesId == matter.rulesId);
|
|
|
+
|
|
|
+ if (any) {
|
|
|
+ this.$message.warning(
|
|
|
+ `“${matter.rulesName}”记录规则已存在,请勿重复添加`
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否存在记录规则
|
|
|
+ const ruleItem = this.matterList.find(
|
|
|
+ (i) => i.itemType == '2' && i.id !== currentId
|
|
|
+ );
|
|
|
+
|
|
|
+ if (
|
|
|
+ ruleItem &&
|
|
|
+ ruleItem.recordRulesClassify != matter.recordRulesClassify
|
|
|
+ ) {
|
|
|
+ const ruleItemClassName = this.getDictValue(
|
|
|
+ '记录规则类型',
|
|
|
+ ruleItem.recordRulesClassify
|
|
|
+ );
|
|
|
+ this.$message.warning(
|
|
|
+ `已存在“${ruleItemClassName}”记录规则分类,请勿添加不同规则分类`
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否存在同一分类
|
|
|
+ const exists = this.matterList
|
|
|
+ .filter((i) => i.itemType == '2' && i.id !== currentId)
|
|
|
+ .some(
|
|
|
+ (item) =>
|
|
|
+ item.recordRulesClassify == matter.recordRulesClassify &&
|
|
|
+ item.recordRulesExecuteMethodId == rules.executeMethodId &&
|
|
|
+ rules.executeMethodId != null
|
|
|
+ );
|
|
|
+
|
|
|
+ if (exists) {
|
|
|
+ const className = this.getDictValue(
|
|
|
+ '记录规则类型',
|
|
|
+ matter.recordRulesClassify
|
|
|
+ );
|
|
|
+ this.$message.warning(
|
|
|
+ `已存在“${className}”记录规则分类“${rules.executeMethodName}”,请勿重复添加`
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
// 事项排序 根据matterList的顺序
|
|
|
handleSort() {
|
|
|
this.matterList = this.matterList.map((item, index) => {
|