|
@@ -36,7 +36,7 @@
|
|
|
>
|
|
|
<a-select
|
|
|
v-model:value="condition.code"
|
|
|
- :options="conditionList"
|
|
|
+ :options="options"
|
|
|
:field-names="fieldNames"
|
|
|
style="width: 200px"
|
|
|
@change="() => conditionChange(index)"
|
|
@@ -169,12 +169,44 @@ function onDeleteCondition(index: number) {
|
|
|
formData.conditions.splice(index, 1);
|
|
|
}
|
|
|
|
|
|
+const checkRepeat = (): boolean => {
|
|
|
+ let cts = formData.conditions;
|
|
|
+ let strs: string[] = cts.map((item) => item.code + "_" + (item.value || ""));
|
|
|
+ if ([...new Set(strs)].length < cts.length) {
|
|
|
+ window.$message.error("编辑中的任务条件有重复,请删除");
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ //从curRow中获取服务端已有的任务条件,对比判断是否有重复
|
|
|
+ let curRowCts: string[] = (props.rowData?.conditions || []).map(
|
|
|
+ (item) => item.code + "_" + (item.value || "")
|
|
|
+ );
|
|
|
+ let repeatStrs: string[] = [];
|
|
|
+ for (let i = 0; i < strs.length; i++) {
|
|
|
+ let s = strs[i];
|
|
|
+ if (curRowCts.includes(s)) {
|
|
|
+ const [code, value] = s.split("_");
|
|
|
+ let name =
|
|
|
+ (props.conditionList || []).find((item) => item.code == code)?.name ||
|
|
|
+ "";
|
|
|
+ repeatStrs.push(name + value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (repeatStrs.length) {
|
|
|
+ window.$message.error(`任务${repeatStrs.toString()}已创建过`);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+};
|
|
|
+
|
|
|
/* confirm */
|
|
|
const { loading, setLoading } = useLoading();
|
|
|
async function confirm() {
|
|
|
const valid = await formRef.value?.validate().catch(() => false);
|
|
|
if (!valid) return;
|
|
|
-
|
|
|
+ // let checkRepeatResult = checkRepeat();
|
|
|
+ // if (!checkRepeatResult) return;
|
|
|
setLoading(true);
|
|
|
const res = await recognizeCheckTaskSave(formData).catch(() => false);
|
|
|
setLoading(false);
|
|
@@ -223,4 +255,13 @@ function modalOpenHandle() {
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+const options = computed(() => {
|
|
|
+ return (props.conditionList || []).map((item: any) => {
|
|
|
+ item.disabled =
|
|
|
+ (props.rowData?.conditions || []).find((v) => v.code == item.code) ||
|
|
|
+ formData.conditions.find((v) => v.code == item.code);
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+});
|
|
|
</script>
|