This commit is contained in:
KangKang0928 2024-08-23 14:11:20 +08:00
parent 9931ae862f
commit 99757054eb
1 changed files with 62 additions and 44 deletions

View File

@ -74,43 +74,6 @@ export default {
}, },
}, },
methods: { methods: {
computedCityOptions() {
function filterTree(tree, filterArray) {
return tree
.filter((node) => !filterArray.includes(node.code)) //
.map((node) => {
//
const filteredChildren = filterTree(
node.children || [],
filterArray
);
//
const newNode = {
...node,
// children
...(filteredChildren.length > 0 && {
children: filteredChildren,
}),
};
return newNode;
});
}
let selectedArray = [];
for (let item of this.modalData.shippingTemplatesRegionListAppend) {
console.log(item);
selectedArray = selectedArray.concat(item.cityCodes);
}
console.log("执行", selectedArray);
console.log(
"过滤后",
filterTree(this.$api.mer_admin.getCityOptions(), selectedArray)
);
return filterTree(this.$api.mer_admin.getCityOptions(), selectedArray);
},
toggle(e) { toggle(e) {
if (this.modalConfig.show == false) { if (this.modalConfig.show == false) {
this.modalConfig.show = true; this.modalConfig.show = true;
@ -139,11 +102,20 @@ export default {
_data.shippingTemplatesConditionResultList?.map((item) => { _data.shippingTemplatesConditionResultList?.map((item) => {
item.cityCodes = item.cityCodes.split(","); item.cityCodes = item.cityCodes.split(",");
// item.conditionType= // item.conditionType=
if (item.price && item.number) { if (
typeof item.price == "number" &&
typeof item.number == "number"
) {
item.conditionType = "件数+金额"; item.conditionType = "件数+金额";
} else if (item.price && !item.number) { } else if (
typeof item.price == 'number' &&
typeof item.number != "number"
) {
item.conditionType = "金额"; item.conditionType = "金额";
} else if (!item.price && item.number) { } else if (
typeof item.price != "number" &&
typeof item.number == "number"
) {
item.conditionType = "件数"; item.conditionType = "件数";
} }
return item; return item;
@ -192,8 +164,44 @@ export default {
}, },
}, },
computed: { computed: {
computedCityOptions() {
return ($rowIndex, list = []) => {
// console.time();
let _arr = cloneDeep(this.$api.mer_admin.getCityOptions());
let selectedArray = [];
for (let i = 0; i < list.length; i++) {
if (i != $rowIndex) {
selectedArray = selectedArray.concat(list[i].cityCodes);
}
}
//
const filterTreeArray = (tree, bList) => {
return tree
.map((item) => {
item = Object.assign({}, item);
if (item.children) {
item.children = filterTreeArray(item.children, bList);
}
if (item.children?.length <= 0) {
return null;
}
return item;
})
.filter((item) => {
if (item == null) {
return false;
}
return !bList.includes(item.code);
});
};
let new_arr = filterTreeArray(_arr, selectedArray);
// console.timeEnd();
return new_arr;
};
},
modalCols() { modalCols() {
return [ return [
//
{ {
label: "模板名称", label: "模板名称",
prop: "templateName", prop: "templateName",
@ -208,6 +216,7 @@ export default {
trigger: "blur,change", trigger: "blur,change",
}, },
}, },
//
{ {
label: "计价方式", label: "计价方式",
prop: "calculateMethod", prop: "calculateMethod",
@ -230,6 +239,7 @@ export default {
); );
}, },
}, },
//
{ {
label: "运费配置", label: "运费配置",
prop: "fareConfig", prop: "fareConfig",
@ -259,6 +269,8 @@ export default {
type: "jsx-out", type: "jsx-out",
show: this.modalData.fareConfig == "自定义运费", show: this.modalData.fareConfig == "自定义运费",
render: () => { render: () => {
console.log("执行了render函数");
const tableCols = [ const tableCols = [
{ {
title: "运送到", title: "运送到",
@ -292,7 +304,10 @@ export default {
style="width:100%;" style="width:100%;"
v-model={row.cityCodes} v-model={row.cityCodes}
onChange={change} onChange={change}
options={this.$api.mer_admin.getCityOptions()} options={this.computedCityOptions(
$rowIndex,
this.modalData.shippingTemplatesRegionListAppend
)}
show-all-levels={false} show-all-levels={false}
collapse-tags={true} collapse-tags={true}
placeholder="点击选择运送城市" placeholder="点击选择运送城市"
@ -558,10 +573,10 @@ export default {
<obj-table-plus <obj-table-plus
tableProp={{ tableProp={{
"scroll-y": { "scroll-y": {
enabled: true enabled: true,
}, },
"show-overflow": true, "show-overflow": true,
height:"auto" height: "auto",
}} }}
style="height:50vh;" style="height:50vh;"
enable-auto-query={false} enable-auto-query={false}
@ -619,7 +634,10 @@ export default {
style="width:100%;" style="width:100%;"
v-model={row.cityCodes} v-model={row.cityCodes}
onChange={change} onChange={change}
options={this.$api.mer_admin.getCityOptions()} options={this.computedCityOptions(
$rowIndex,
this.modalData.shippingTemplatesConditionList
)}
show-all-levels={false} show-all-levels={false}
placeholder="点击选择运送城市" placeholder="点击选择运送城市"
collapse-tags={true} collapse-tags={true}