This commit is contained in:
KangKang0928 2024-08-20 18:01:45 +08:00
parent 579e4d860e
commit 8b052b2eb7
3 changed files with 212 additions and 256 deletions

View File

@ -102,7 +102,7 @@ export const mer_admin = {
getShippingTemplateInfo: (id) => {
return $http.request({
method: 'get',
url: '/merchant-api/shippingTemplates/list',
url: '/merchant-api/shippingTemplates/detail',
params: { id }
})
}

View File

@ -11,9 +11,12 @@
<div slot="tableTop" class="mb-2">
<el-form inline>
<el-form-item label="模板名称:">
<el-input placeholder="请输入模板名称"></el-input>
<el-input
placeholder="请输入模板名称"
v-model="searchForm.name"
></el-input>
</el-form-item>
<el-button type="primary">搜索</el-button>
<el-button type="primary" @click="$refs.oTable.reload();">搜索</el-button>
</el-form>
<el-button type="primary" @click="addFareTemplate"
>添加运费模板</el-button
@ -31,223 +34,26 @@ export default {
data() {
return {
dataList: [],
searchForm: {
name: "",
},
};
},
methods: {
queryList(pageNo, pageSize) {
setTimeout(() => {
this.$refs.oTable.complete([
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
{
templateName: "运费模板名称(全国包邮)",
lastEditTime: "2022-02-15 12:02",
tableData: [
{
a: "中国",
b: 1,
c: 0.0,
d: 1,
e: 0.0,
},
],
},
]);
}, 1000);
this.$api.mer_admin
.getShippingTemplatePage({
pageNumber: pageNo,
pageSize: pageSize,
...this.searchForm,
})
.then((res) => {
console.log(res);
this.$refs.oTable.complete(res.data.data.data,Number(res.data.data.total));
})
.catch(err=>{
this.$refs.oTable.complete(false);
})
},
addFareTemplate() {
this.$refs.addTemplate.toggle().add();
@ -260,13 +66,22 @@ export default {
type: "jsx",
render: (row) => {
console.log(row);
this.$api.mer_admin.getShippingTemplateInfo(row.id)
.then(res=>{
console.log(res);
// this.$set(row,tableData,);
})
const appointMapper={
0:'(全国包邮)',
1:'(部分包邮)',
2:'(自定义运费)'
}
return (
<div class="mb-5">
<div class="flex justify-between items-center bg-gray-100 px-4">
<div>{row.templateName}</div>
<div>{row.name}{appointMapper[row.appoint]}</div>
<div class="flex justify-between items-center">
<div class="mr-5">最后编辑时间{row.lastEditTime}</div>
<div class="mr-5">最后编辑时间{row.updateTime}</div>
<div>
<el-button type="text">复制模板</el-button>
<el-button type="text">修改</el-button>

View File

@ -67,6 +67,43 @@ export default {
},
mounted() {},
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;
@ -81,7 +118,7 @@ export default {
add: (item) => {
console.log(item);
this.$nextTick(() => {
this.modalData = BASE_DATA;
this.modalData = JSON.parse(JSON.stringify(BASE_DATA));
});
this.isAdd = true;
},
@ -101,6 +138,8 @@ export default {
prop: "templateName",
type: "Input",
maxlength: "30",
width: "300px",
clearable: true,
placeholder: "请输入模板名称",
rules: {
required: true,
@ -145,6 +184,7 @@ export default {
);
},
},
//
{
label: "自定义运费配置",
type: "jsx-out",
@ -156,35 +196,58 @@ export default {
width: "300px",
field: "cityCodes",
type: "jsx",
render: ({ row }) => {
render: ({ row, $rowIndex }) => {
const change = (e) => {
console.log(e);
console.log(
this.$refs.cityCode
.getCheckedNodes()
.filter((item) => !(item.parent && item.parent.checked))
);
};
return (
<el-cascader
style="width:100%;"
v-model={row.cityCodes}
onChange={change}
options={this.$api.mer_admin.getCityOptions()}
show-all-levels={false}
collapse-tags={true}
props={{
props: {
multiple: true,
checkStrictly: false,
emitPath: true,
label: "name",
value: "code",
},
<el-form-item
label-width="0"
prop={
"shippingTemplatesRegionListAppend." +
$rowIndex +
".cityCodes"
}
rules={{
required: true,
message: "请选择运送城市",
}}
clearable
filterable
></el-cascader>
>
<el-cascader
ref="cityCode"
style="width:100%;"
v-model={row.cityCodes}
onChange={change}
options={this.$api.mer_admin.getCityOptions()}
show-all-levels={false}
collapse-tags={true}
placeholder="点击选择运送城市"
props={{
props: {
multiple: true,
checkStrictly: false,
emitPath: false,
label: "name",
value: "code",
},
}}
clearable
filterable
></el-cascader>
</el-form-item>
);
},
},
{
title: "首重kg",
title:
this.modalData.calculateMethod == "按重量"
? "首重kg"
: "首件(个)",
field: "first",
type: "jsx",
render: ({ row }) => {
@ -193,7 +256,9 @@ export default {
style="width:100%;"
min={0}
controls={false}
precision={2}
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
v-model={row.first}
></el-input-number>
);
@ -216,7 +281,10 @@ export default {
},
},
{
title: "续重kg",
title:
this.modalData.calculateMethod == "按重量"
? "续重kg"
: "续件数(个)",
field: "renewal",
type: "jsx",
render: ({ row }) => {
@ -225,7 +293,9 @@ export default {
style="width:100%;"
min={0}
controls={false}
precision={2}
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
v-model={row.renewal}
></el-input-number>
);
@ -317,14 +387,23 @@ export default {
}}
label="默认运费"
>
<el-input
<el-input-number
v-model={
this.modalData.shippingTemplatesRegionList[0].first
}
></el-input>
min={0}
controls={false}
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;kg内&nbsp;
&nbsp;
{this.modalData.calculateMethod == "按重量"
? "kg内"
: "件内"}
&nbsp;
</span>
<el-form-item
label-width="0"
@ -336,11 +415,14 @@ export default {
}}
label=""
>
<el-input
<el-input-number
v-model={
this.modalData.shippingTemplatesRegionList[0].firstPrice
}
></el-input>
min={0}
controls={false}
precision={2}
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;每增加&nbsp;
@ -355,14 +437,21 @@ export default {
}}
label=""
>
<el-input
<el-input-number
v-model={
this.modalData.shippingTemplatesRegionList[0].renewal
}
></el-input>
min={0}
controls={false}
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;kg增加运费&nbsp;
&nbsp;
{this.modalData.calculateMethod == "按重量" ? "kg" : "件"}
增加运费&nbsp;
</span>
<el-form-item
label-width="0"
@ -374,12 +463,15 @@ export default {
}}
label=""
>
<el-input
<el-input-number
min={0}
controls={false}
precision={2}
v-model={
this.modalData.shippingTemplatesRegionList[0]
.renewalPrice
}
></el-input>
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;&nbsp;
@ -437,7 +529,7 @@ export default {
props: {
multiple: true,
checkStrictly: false,
emitPath: true,
emitPath: false,
label: "name",
value: "code",
},
@ -502,7 +594,7 @@ export default {
return (
<div class="flex justify-start items-center">
<el-select
style="width:80px;"
style="width:120px;"
v-model={row.conditionType}
>
<el-option label="件数" value="件数"></el-option>
@ -602,7 +694,56 @@ export default {
type: "primary",
loading: this.isLoading,
submit: true,
handle: debounce(() => {}, 300),
handle: debounce(() => {
console.log(this.modalData);
if (this.isAdd) {
this.$api.mer_admin.addShippingTemplate({
linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
defaults: 0,//
sort: 0,//
type:2,//
name: this.modalData.templateName,
groups: {
按重量: 2,
按件数: 1,
按体积: 3,
}[this.modalData.calculateMethod],
appoint: {
全国包邮: 0,
自定义运费: 2,
}[this.modalData.fareConfig],
shippingTemplatesRegionList:
this.modalData.fareConfig == "全国包邮"
? null
: [
...this.modalData.shippingTemplatesRegionList,
...JSON.parse(
JSON.stringify(
this.modalData.shippingTemplatesRegionListAppend.map(
(item) => {
item.cityCodes = item.cityCodes.join(",");
return item;
}
)
)
),
],
shippingTemplatesConditionList:
this.modalData.fareConfig == "全国包邮"
? null
: JSON.parse(
JSON.stringify(
this.modalData.shippingTemplatesConditionList.map(
(item) => {
item.cityCodes = item.cityCodes.join(",");
return item;
}
)
)
),
});
}
}, 300),
},
];
},