fix: 🧩 修复bug
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -11,7 +11,7 @@ export const FORM_DATA: any[] = [
|
||||
options: []
|
||||
},
|
||||
{
|
||||
prop: "customer_number",
|
||||
prop: "customer_number1",
|
||||
placeholder: "请输入",
|
||||
type: "selectMultipleRemoteCustomersNames",
|
||||
label: "客户名称:",
|
||||
|
||||
@@ -24,7 +24,7 @@ export const FORM_DATA: FormItem[] = [
|
||||
options: []
|
||||
},
|
||||
{
|
||||
prop: "customer_number",
|
||||
prop: "customer_numbers",
|
||||
placeholder: "请输入客户名称",
|
||||
type: "selectMultipleRemote",
|
||||
label: "客户名称: ",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scope lang="scss">
|
||||
|
||||
@@ -10,15 +10,19 @@ export const setDetailsData = (dataStore: any, data: any) => {
|
||||
if (data?.customers?.length) {
|
||||
data?.customers?.forEach((item: any) => {
|
||||
//客户编码
|
||||
dataStore.ruleForm.customers.push(item.customer_number);
|
||||
dataStore.ruleForm.customers.push(item.customer_number + "_" + item.use_org_number);
|
||||
//客户名称下拉框数据初始化
|
||||
customers_names.push({
|
||||
value: item.customer_number,
|
||||
label: item.customer_name,
|
||||
org_number: "100"
|
||||
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
|
||||
});
|
||||
});
|
||||
console.log(customers_names, "=customers_names=");
|
||||
console.log(dataStore.ruleForm.customers, "=dataStore.ruleForm.customers=");
|
||||
//客户名称值回填
|
||||
dataStore.ruleForm.customer_number1 = dataStore.ruleForm.customers;
|
||||
dataStore.ruleForm.customer_number = dataStore.ruleForm.customers;
|
||||
//客户名称下拉框数据
|
||||
dataStore.formData[1].options = customers_names;
|
||||
|
||||
Reference in New Issue
Block a user