This commit is contained in:
parent
9931ae862f
commit
99757054eb
|
@ -74,43 +74,6 @@ export default {
|
|||
},
|
||||
},
|
||||
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) {
|
||||
if (this.modalConfig.show == false) {
|
||||
this.modalConfig.show = true;
|
||||
|
@ -139,11 +102,20 @@ export default {
|
|||
_data.shippingTemplatesConditionResultList?.map((item) => {
|
||||
item.cityCodes = item.cityCodes.split(",");
|
||||
// item.conditionType=
|
||||
if (item.price && item.number) {
|
||||
if (
|
||||
typeof item.price == "number" &&
|
||||
typeof item.number == "number"
|
||||
) {
|
||||
item.conditionType = "件数+金额";
|
||||
} else if (item.price && !item.number) {
|
||||
} else if (
|
||||
typeof item.price == 'number' &&
|
||||
typeof item.number != "number"
|
||||
) {
|
||||
item.conditionType = "金额";
|
||||
} else if (!item.price && item.number) {
|
||||
} else if (
|
||||
typeof item.price != "number" &&
|
||||
typeof item.number == "number"
|
||||
) {
|
||||
item.conditionType = "件数";
|
||||
}
|
||||
return item;
|
||||
|
@ -192,8 +164,44 @@ export default {
|
|||
},
|
||||
},
|
||||
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() {
|
||||
return [
|
||||
//模板名称
|
||||
{
|
||||
label: "模板名称",
|
||||
prop: "templateName",
|
||||
|
@ -208,6 +216,7 @@ export default {
|
|||
trigger: "blur,change",
|
||||
},
|
||||
},
|
||||
//计价方式
|
||||
{
|
||||
label: "计价方式",
|
||||
prop: "calculateMethod",
|
||||
|
@ -230,6 +239,7 @@ export default {
|
|||
);
|
||||
},
|
||||
},
|
||||
//运费配置
|
||||
{
|
||||
label: "运费配置",
|
||||
prop: "fareConfig",
|
||||
|
@ -259,6 +269,8 @@ export default {
|
|||
type: "jsx-out",
|
||||
show: this.modalData.fareConfig == "自定义运费",
|
||||
render: () => {
|
||||
console.log("执行了render函数");
|
||||
|
||||
const tableCols = [
|
||||
{
|
||||
title: "运送到",
|
||||
|
@ -292,7 +304,10 @@ export default {
|
|||
style="width:100%;"
|
||||
v-model={row.cityCodes}
|
||||
onChange={change}
|
||||
options={this.$api.mer_admin.getCityOptions()}
|
||||
options={this.computedCityOptions(
|
||||
$rowIndex,
|
||||
this.modalData.shippingTemplatesRegionListAppend
|
||||
)}
|
||||
show-all-levels={false}
|
||||
collapse-tags={true}
|
||||
placeholder="点击选择运送城市"
|
||||
|
@ -558,10 +573,10 @@ export default {
|
|||
<obj-table-plus
|
||||
tableProp={{
|
||||
"scroll-y": {
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
"show-overflow": true,
|
||||
height:"auto"
|
||||
height: "auto",
|
||||
}}
|
||||
style="height:50vh;"
|
||||
enable-auto-query={false}
|
||||
|
@ -619,7 +634,10 @@ export default {
|
|||
style="width:100%;"
|
||||
v-model={row.cityCodes}
|
||||
onChange={change}
|
||||
options={this.$api.mer_admin.getCityOptions()}
|
||||
options={this.computedCityOptions(
|
||||
$rowIndex,
|
||||
this.modalData.shippingTemplatesConditionList
|
||||
)}
|
||||
show-all-levels={false}
|
||||
placeholder="点击选择运送城市"
|
||||
collapse-tags={true}
|
||||
|
|
Loading…
Reference in New Issue