From ef3888074340a1b14c8ab47e88f4a73431b91415 Mon Sep 17 00:00:00 2001 From: yangchunlong <292345300@qq.com> Date: Sat, 11 Oct 2025 10:51:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=A7=A9=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DetailsSearch/index.vue | 7 ++- src/components/SearchForm/index.vue | 6 +- src/hooks/useTable.ts | 2 +- src/views/foundation/subscribe/list/add.vue | 57 +++++++++++++++---- .../subscribe/list/constant/add/serach.ts | 2 +- .../subscribe/list/constant/list/search.ts | 2 +- src/views/foundation/subscribe/list/index.vue | 55 +++++++++++++++--- .../subscribe/list/init/setDetailsData.ts | 12 ++-- 8 files changed, 113 insertions(+), 30 deletions(-) diff --git a/src/components/DetailsSearch/index.vue b/src/components/DetailsSearch/index.vue index b454a74..4dc4f90 100644 --- a/src/components/DetailsSearch/index.vue +++ b/src/components/DetailsSearch/index.vue @@ -188,6 +188,7 @@ const emits = defineEmits<{ }>(); const handleRomoveTag = (item: any) => { + console.log(_searchResult.value, "=-_searchResult.value="); emits("selectMultipleRemoveTag", { item, org_number: _searchResult.value.org_number }); }; const handleTagRemove1 = (item: any) => { @@ -205,8 +206,10 @@ const getCustomers = async (keywords: any, item: any) => { let options: any = []; data.forEach((item: any) => { options.push({ - value: item.customer_number, - label: item.customer_name + value: item.customer_number + "_" + item.use_org_number, + label: item.customer_name + " " + `(${item.use_org_name})`, + id: item.use_org_number, + useOrgName: item.use_org_name }); }); item.options = options; diff --git a/src/components/SearchForm/index.vue b/src/components/SearchForm/index.vue index c75db94..a5c55b6 100644 --- a/src/components/SearchForm/index.vue +++ b/src/components/SearchForm/index.vue @@ -228,8 +228,10 @@ const getCustomers = async (keywords: any, item: any) => { let options: any = []; data.forEach((it: any) => { options.push({ - value: it.customer_number, - label: it.customer_name + value: it.customer_number + "_" + it.use_org_number, + label: it.customer_name + " " + `(${it.use_org_name})`, + id: it.use_org_number, + useOrgName: it.use_org_name }); }); item.options = options; diff --git a/src/hooks/useTable.ts b/src/hooks/useTable.ts index bfedf6b..87fcf3d 100644 --- a/src/hooks/useTable.ts +++ b/src/hooks/useTable.ts @@ -66,7 +66,7 @@ export const useTable = ( }; //删除临时参数和空值参数 const deleteParams = () => { - const KEY = ["Time", "customer_number1"]; + const KEY = ["Time", "customer_number1", "customer_numbers"]; for (let key in state.totalParam) { if (KEY.includes(key) || !state.totalParam[key]) { delete state.totalParam[key]; diff --git a/src/views/foundation/subscribe/list/add.vue b/src/views/foundation/subscribe/list/add.vue index ca4813d..547c766 100644 --- a/src/views/foundation/subscribe/list/add.vue +++ b/src/views/foundation/subscribe/list/add.vue @@ -129,20 +129,36 @@ const getSubscribeDetails = async () => { setDetailsData(dataStore, data); } }; + +const filterBySecondArray = (firstArray: any, secondArray: any) => { + if (!firstArray || !secondArray) { + return; + } + if (!firstArray.length || !secondArray.length) { + return; + } + // 创建一个Set用于快速查找 + const filterSet = new Set(secondArray); + + // 过滤出后缀在第二个数组中的元素(保留符合条件的) + return firstArray.filter((item: any) => { + // 分割字符串获取后缀部分 + const suffix = item.split("_")[1]; + // 检查后缀是否在过滤集合中,保留存在的元素 + return filterSet.has(suffix); + }); +}; + //本地多选远程搜索Tag删除回调(组织) const handleSelectMultipleRemoveTag = async (params: any) => { const { org_number } = params; - let customers: any = []; - // 筛选出 org_number 在 ids 中的数据 - dataStore.formData[1].options = dataStore.formData[1].options.filter((item: any) => org_number.includes(item.org_number)); - dataStore.formData[1].options.length && - dataStore.formData[1].options.forEach((item: any) => { - customers.push(item.value); - }); - console.log(customers, "=customers="); - dataStore.ruleForm.customer_number = customers; - console.log(dataStore.ruleForm.customer_number, "=123=="); + // 筛选出 org_number 数组包含的数据 + dataStore.formData[1].options = dataStore.formData[1].options.filter((item: any) => { + return org_number.includes(item.id); + }); + + dataStore.ruleForm.customer_number1 = filterBySecondArray(dataStore.ruleForm.customer_number1, org_number); }; getSubscribeDetails(); @@ -155,4 +171,25 @@ const handleButtonClickCallback = (item: any) => { handleCommit(); } }; +const getPrefixes = (arr: any) => { + // 遍历数组,返回每个元素下划线前面的部分 + return arr.map((item: any) => { + // 分割字符串并返回下划线前面的部分(索引0) + return item.split("_")[0]; + }); +}; + +watch( + () => dataStore.ruleForm.customer_number1, + (newVal: any) => { + if (Array.isArray(newVal) && newVal.length) { + dataStore.ruleForm.customer_number = getPrefixes(newVal); + } else { + dataStore.ruleForm.customer_number = []; + } + }, + { + deep: true + } +); diff --git a/src/views/foundation/subscribe/list/constant/add/serach.ts b/src/views/foundation/subscribe/list/constant/add/serach.ts index dfa1fc7..8ce9521 100644 --- a/src/views/foundation/subscribe/list/constant/add/serach.ts +++ b/src/views/foundation/subscribe/list/constant/add/serach.ts @@ -11,7 +11,7 @@ export const FORM_DATA: any[] = [ options: [] }, { - prop: "customer_number", + prop: "customer_number1", placeholder: "请输入", type: "selectMultipleRemoteCustomersNames", label: "客户名称:", diff --git a/src/views/foundation/subscribe/list/constant/list/search.ts b/src/views/foundation/subscribe/list/constant/list/search.ts index a310763..cc3148f 100644 --- a/src/views/foundation/subscribe/list/constant/list/search.ts +++ b/src/views/foundation/subscribe/list/constant/list/search.ts @@ -24,7 +24,7 @@ export const FORM_DATA: FormItem[] = [ options: [] }, { - prop: "customer_number", + prop: "customer_numbers", placeholder: "请输入客户名称", type: "selectMultipleRemote", label: "客户名称: ", diff --git a/src/views/foundation/subscribe/list/index.vue b/src/views/foundation/subscribe/list/index.vue index 10bbebe..fd6275b 100644 --- a/src/views/foundation/subscribe/list/index.vue +++ b/src/views/foundation/subscribe/list/index.vue @@ -110,21 +110,58 @@ const handleOpen = (row: any) => { query: { id: row.id, title: "编辑订阅" } }); }; +const filterBySecondArray = (firstArray: any, secondArray: any) => { + if (!firstArray || !secondArray) { + return; + } + if (!firstArray.length || !secondArray.length) { + return; + } + // 创建一个Set用于快速查找 + const filterSet = new Set(secondArray); + + // 过滤出后缀在第二个数组中的元素(保留符合条件的) + return firstArray.filter((item: any) => { + // 分割字符串获取后缀部分 + const suffix = item.split("_")[1]; + // 检查后缀是否在过滤集合中,保留存在的元素 + return filterSet.has(suffix); + }); +}; + +const getPrefixes = (arr: any) => { + // 遍历数组,返回每个元素下划线前面的部分 + return arr.map((item: any) => { + // 分割字符串并返回下划线前面的部分(索引0) + return item.split("_")[0]; + }); +}; //本地多选远程搜索Tag删除回调(组织) const handleSelectMultipleRemoveTag = async (params: any) => { const { org_number } = params; - let customers: any = []; - // 筛选出 org_number 在 ids 中的数据 - dataStore.formData[1].options = dataStore.formData[1].options.filter((item: any) => org_number.includes(item.org_number)); - dataStore.formData[1].options.length && - dataStore.formData[1].options.forEach((item: any) => { - customers.push(item.value); - }); - nextTick(() => { - dataStore.initParam.customer_number = customers; + + // 筛选出 org_number 数组包含的数据 + dataStore.formData[1].options = dataStore.formData[1].options.filter((item: any) => { + return org_number.includes(item.id); }); + let customer_numbers = filterBySecondArray(dataStore.initParam.customer_numbers, org_number); + dataStore.initParam.customer_numbers = customer_numbers; }; + +watch( + () => dataStore.initParam.customer_numbers, + (newVal: any) => { + if (Array.isArray(newVal) && newVal.length) { + dataStore.initParam.customer_number = getPrefixes(newVal); + } else { + dataStore.initParam.customer_number = []; + } + }, + { + deep: true + } +);