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) => { getShippingTemplateInfo: (id) => {
return $http.request({ return $http.request({
method: 'get', method: 'get',
url: '/merchant-api/shippingTemplates/list', url: '/merchant-api/shippingTemplates/detail',
params: { id } params: { id }
}) })
} }

View File

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

View File

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