merchant-web/src/views/modules/logistics-fare/logistics-template/popup/add-template.vue

984 lines
33 KiB
Vue
Raw Normal View History

2024-08-18 06:26:20 +00:00
<template>
2024-08-19 09:15:18 +00:00
<div>
<obj-modal
class="obj-modal"
ref="modal"
labelWidth="100px"
:modalCols="modalCols"
:modalConfig="modalConfig"
:modalData="modalData"
:modalHandles="modalHandles"
>
</obj-modal>
</div>
2024-08-18 06:26:20 +00:00
</template>
<script>
import { debounce, cloneDeep } from "lodash";
2024-08-19 09:15:18 +00:00
const BASE_DATA = {
calculateMethod: "按重量",
fareConfig: "全国包邮",
//为指定地区城市设置运费
shippingTemplatesRegionList: [
{
//默认运费,不限制城市
cityCodes: "0",
//首重
2024-08-22 04:58:29 +00:00
first: 1,
2024-08-19 09:15:18 +00:00
//首重价格
2024-08-22 04:58:29 +00:00
firstPrice: 0,
2024-08-19 09:15:18 +00:00
//续重
2024-08-22 04:58:29 +00:00
renewal: 1,
2024-08-19 09:15:18 +00:00
//续重价格
2024-08-22 04:58:29 +00:00
renewalPrice: 0,
2024-08-19 09:15:18 +00:00
},
],
//追加
shippingTemplatesRegionListAppend: [],
//指定包邮条件
shippingTemplatesConditionList: [
// {
// cityCodes: "",
// price: "",
// number: "",
// },
],
};
2024-08-18 06:26:20 +00:00
export default {
2024-08-19 09:15:18 +00:00
data() {
return {
2024-08-23 08:14:27 +00:00
reRender: false,
2024-08-19 09:15:18 +00:00
currentPanel: "基础信息",
modalData: {},
modalConfig: {
title: "添加运费模板",
show: false,
width: "1300px",
fullscreen: true,
},
fileList: [], //回显图片
place: "", //场地
};
},
2024-08-21 08:05:34 +00:00
mounted() {
window.onbeforeunload = function (e) {
return "还有未保存的数据,确定离开此页吗?";
};
},
2024-08-22 09:40:02 +00:00
watch: {
"modalConfig.show"(newVal) {
if (newVal) {
//关闭弹窗清空校验
setTimeout(() => {
this.$refs.modal.clearValidate();
});
}
},
},
2024-08-19 09:15:18 +00:00
methods: {
toggle(e) {
if (this.modalConfig.show == false) {
this.modalConfig.show = true;
} else {
this.modalConfig.show = false;
}
2024-08-21 08:05:34 +00:00
//回显数据
const refillData = (e) => {
let _data = cloneDeep(e);
console.log("_data", _data);
//默认运费回显
_data.shippingTemplatesRegionList =
2024-08-22 09:40:02 +00:00
_data.shippingTemplatesRegionResultList?.slice(0, 1) ||
2024-08-22 04:58:29 +00:00
cloneDeep(BASE_DATA.shippingTemplatesRegionList);
2024-08-21 08:05:34 +00:00
//指定城市设置运费
_data.shippingTemplatesRegionListAppend =
_data.shippingTemplatesRegionResultList
?.slice(1, _data.shippingTemplatesRegionResultList.length)
?.map((item) => {
item.cityCodes = item.cityCodes.split(",");
return item;
2024-08-22 04:58:29 +00:00
}) || cloneDeep(BASE_DATA.shippingTemplatesRegionListAppend);
2024-08-21 08:05:34 +00:00
//指定包邮条件
_data.shippingTemplatesConditionList =
_data.shippingTemplatesConditionResultList?.map((item) => {
item.cityCodes = item.cityCodes.split(",");
// item.conditionType=
2024-08-23 06:11:20 +00:00
if (
typeof item.price == "number" &&
typeof item.number == "number"
) {
2024-08-21 08:05:34 +00:00
item.conditionType = "件数+金额";
2024-08-23 06:11:20 +00:00
} else if (
2024-08-23 08:14:27 +00:00
typeof item.price == "number" &&
2024-08-23 06:11:20 +00:00
typeof item.number != "number"
) {
2024-08-21 08:05:34 +00:00
item.conditionType = "金额";
2024-08-23 06:11:20 +00:00
} else if (
typeof item.price != "number" &&
typeof item.number == "number"
) {
2024-08-21 08:05:34 +00:00
item.conditionType = "件数";
}
return item;
2024-08-22 04:58:29 +00:00
}) || cloneDeep(BASE_DATA.shippingTemplatesConditionList);
2024-08-21 08:05:34 +00:00
//计价方式
_data.calculateMethod = {
1: "按件数",
2: "按重量",
3: "按体积",
}[_data.groups];
//运费配置
_data.fareConfig = {
0: "全国包邮",
2: "自定义运费",
}[_data.appoint];
//模板名称
_data.templateName = _data.name;
this.modalData = _data;
};
2024-08-19 09:15:18 +00:00
return {
2024-08-21 08:05:34 +00:00
add: () => {
2024-08-19 09:15:18 +00:00
this.$nextTick(() => {
2024-08-22 04:58:29 +00:00
this.modalData = cloneDeep(BASE_DATA);
2024-08-19 09:15:18 +00:00
});
this.isAdd = true;
2024-08-21 08:05:34 +00:00
this.modalConfig.title = "添加运费模板";
2024-08-19 09:15:18 +00:00
},
2024-08-21 08:05:34 +00:00
update: (e) => {
2024-08-19 09:15:18 +00:00
this.isAdd = false;
2024-08-21 08:05:34 +00:00
refillData(e);
this.modalConfig.title = "编辑运费模板";
},
copy: (e) => {
this.isAdd = true;
refillData(e);
this.modalConfig.title = "添加运费模板";
2024-08-22 09:40:02 +00:00
console.log("this.modalData", this.modalData);
2024-08-21 08:05:34 +00:00
this.modalData.templateName += "(复制)";
2024-08-19 09:15:18 +00:00
},
};
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
},
computed: {
2024-08-23 06:11:20 +00:00
computedCityOptions() {
2024-08-23 08:14:27 +00:00
let _arr = cloneDeep(this.$api.mer_admin.getCityOptions());
2024-08-23 06:11:20 +00:00
return ($rowIndex, list = []) => {
2024-08-23 08:14:27 +00:00
console.log("计算");
if (this.reRender == false) {
return _arr;
}
2024-08-23 06:11:20 +00:00
// console.time();
2024-08-23 08:14:27 +00:00
let selectedArray = new Set();
2024-08-23 06:11:20 +00:00
for (let i = 0; i < list.length; i++) {
if (i != $rowIndex) {
2024-08-23 08:14:27 +00:00
selectedArray = new Set([...selectedArray, ...list[i].cityCodes]);
2024-08-23 06:11:20 +00:00
}
}
// 根据数组过滤树形结构数组
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;
}
2024-08-23 08:14:27 +00:00
return !bList.has(item.code);
2024-08-23 06:11:20 +00:00
});
};
let new_arr = filterTreeArray(_arr, selectedArray);
// console.timeEnd();
return new_arr;
};
},
2024-08-19 09:15:18 +00:00
modalCols() {
return [
2024-08-23 06:11:20 +00:00
//模板名称
2024-08-19 09:15:18 +00:00
{
label: "模板名称",
prop: "templateName",
type: "Input",
maxlength: "30",
2024-08-20 10:01:45 +00:00
width: "300px",
clearable: true,
2024-08-19 09:15:18 +00:00
placeholder: "请输入模板名称",
rules: {
required: true,
message: "请输入模板名称",
trigger: "blur,change",
},
},
2024-08-23 06:11:20 +00:00
//计价方式
2024-08-19 09:15:18 +00:00
{
label: "计价方式",
prop: "calculateMethod",
type: "jsx",
rules: {
required: true,
message: "请选择计价方式",
trigger: "blur",
},
render: () => {
return (
<el-radio-group v-model={this.modalData.calculateMethod}>
2024-08-22 09:40:02 +00:00
<el-radio border label="按重量">
按重量
</el-radio>
<el-radio border label="按件数">
按件数
</el-radio>
2024-08-19 09:15:18 +00:00
</el-radio-group>
);
},
},
2024-08-23 06:11:20 +00:00
//运费配置
2024-08-19 09:15:18 +00:00
{
label: "运费配置",
prop: "fareConfig",
type: "jsx",
required: true,
rules: {
required: true,
message: "请选择计价方式",
trigger: "blur",
},
render: () => {
return (
<el-radio-group v-model={this.modalData.fareConfig}>
2024-08-22 09:40:02 +00:00
<el-radio border label="全国包邮">
全国包邮
</el-radio>
<el-radio border label="自定义运费">
自定义运费
</el-radio>
2024-08-19 09:15:18 +00:00
</el-radio-group>
);
},
},
2024-08-20 10:01:45 +00:00
//自定义运费
2024-08-19 09:15:18 +00:00
{
label: "自定义运费配置",
2024-08-23 08:14:27 +00:00
prop: "customShippingFareConfig",
2024-08-19 09:15:18 +00:00
type: "jsx-out",
show: this.modalData.fareConfig == "自定义运费",
render: () => {
const tableCols = [
{
title: "运送到",
width: "300px",
field: "cityCodes",
type: "jsx",
2024-08-20 10:01:45 +00:00
render: ({ row, $rowIndex }) => {
2024-08-23 08:14:27 +00:00
console.log("this.reRender", this.reRender);
2024-08-19 09:15:18 +00:00
const change = (e) => {
console.log(e);
2024-08-20 10:01:45 +00:00
console.log(
this.$refs.cityCode
.getCheckedNodes()
.filter((item) => !(item.parent && item.parent.checked))
);
2024-08-19 09:15:18 +00:00
};
return (
2024-08-20 10:01:45 +00:00
<el-form-item
label-width="0"
prop={
"shippingTemplatesRegionListAppend." +
$rowIndex +
".cityCodes"
}
rules={{
required: true,
message: "请选择运送城市",
2024-08-19 09:15:18 +00:00
}}
2024-08-20 10:01:45 +00:00
>
<el-cascader
2024-08-23 08:14:27 +00:00
on-visible-change={(e) => {
console.log(e);
this.reRender = e;
}}
2024-08-20 10:01:45 +00:00
ref="cityCode"
style="width:100%;"
v-model={row.cityCodes}
onChange={change}
2024-08-23 06:11:20 +00:00
options={this.computedCityOptions(
$rowIndex,
this.modalData.shippingTemplatesRegionListAppend
)}
2024-08-20 10:01:45 +00:00
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>
2024-08-19 09:15:18 +00:00
);
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
},
{
2024-08-20 10:01:45 +00:00
title:
this.modalData.calculateMethod == "按重量"
? "首重kg"
: "首件(个)",
2024-08-19 09:15:18 +00:00
field: "first",
type: "jsx",
render: ({ row }) => {
return (
<el-input-number
style="width:100%;"
min={0}
controls={false}
2024-08-20 10:01:45 +00:00
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
2024-08-19 09:15:18 +00:00
v-model={row.first}
></el-input-number>
);
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
},
{
title: "首费(元)",
field: "firstPrice",
type: "jsx",
render: ({ row }) => {
return (
<el-input-number
style="width:100%;"
min={0}
controls={false}
precision={2}
v-model={row.firstPrice}
></el-input-number>
);
},
},
{
2024-08-20 10:01:45 +00:00
title:
this.modalData.calculateMethod == "按重量"
? "续重kg"
: "续件数(个)",
2024-08-19 09:15:18 +00:00
field: "renewal",
type: "jsx",
render: ({ row }) => {
return (
<el-input-number
style="width:100%;"
min={0}
controls={false}
2024-08-20 10:01:45 +00:00
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
2024-08-19 09:15:18 +00:00
v-model={row.renewal}
></el-input-number>
);
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
},
{
title: "续费(元)",
field: "renewalPrice",
type: "jsx",
render: ({ row }) => {
return (
<el-input-number
style="width:100%;"
min={0}
2024-08-21 08:05:34 +00:00
max={Number(row.firstPrice)}
2024-08-19 09:15:18 +00:00
controls={false}
precision={2}
v-model={row.renewalPrice}
></el-input-number>
);
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
},
{
title: "操作",
type: "jsx",
render: (e) => {
const remove = () => {
console.log(e);
this.modalData.shippingTemplatesRegionListAppend.splice(
e.rowIndex,
1
);
};
const add = () => {
console.log(e);
this.modalData.shippingTemplatesRegionListAppend.splice(
e.rowIndex + 1,
0,
{
//默认运费,不限制城市
cityCodes: "",
2024-08-21 08:05:34 +00:00
//城市可选的选项
2024-08-22 04:58:29 +00:00
cityOptions: [],
2024-08-19 09:15:18 +00:00
//首重
first: "",
//首重价格
firstPrice: "",
//续重
renewal: "",
//续重价格
renewalPrice: "",
}
);
};
return (
<div>
<el-button type="primary" size="mini" onClick={add}>
向下添加
</el-button>
<el-button type="danger" size="mini" onClick={remove}>
删除
</el-button>
</div>
);
},
},
2024-08-18 06:26:20 +00:00
];
2024-08-19 09:15:18 +00:00
const addAreaFare = () => {
this.modalData.shippingTemplatesRegionListAppend.push({
//默认运费,不限制城市
cityCodes: "",
//首重
first: "",
//首重价格
firstPrice: "",
//续重
renewal: "",
//续重价格
renewalPrice: "",
});
};
return (
2024-08-22 09:40:02 +00:00
<transition name="el-fade-in">
2024-08-19 09:15:18 +00:00
<div>
2024-08-22 09:40:02 +00:00
<div class="d-flex no-warp justify-start items-center">
<el-form-item
prop="shippingTemplatesRegionList[0].first"
rules={{
required: true,
message: "请填写默认运费",
trigger: "change",
}}
label="默认运费"
>
<el-input-number
v-model={
this.modalData.shippingTemplatesRegionList[0].first
}
min={0}
controls={false}
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;
{this.modalData.calculateMethod == "按重量"
? "kg内"
: "件内"}
&nbsp;
</span>
<el-form-item
label-width="0"
prop="shippingTemplatesRegionList[0].firstPrice"
rules={{
required: true,
message: "请填写默认运费",
trigger: "change",
}}
label=""
>
<el-input-number
v-model={
this.modalData.shippingTemplatesRegionList[0]
.firstPrice
}
min={0}
controls={false}
precision={2}
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;每增加&nbsp;
</span>
<el-form-item
label-width="0"
prop="shippingTemplatesRegionList[0].renewal"
rules={{
required: true,
message: "请填写默认运费",
trigger: "change",
}}
label=""
>
<el-input-number
v-model={
this.modalData.shippingTemplatesRegionList[0].renewal
}
min={0}
controls={false}
precision={
this.modalData.calculateMethod == "按重量" ? 2 : 0
}
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;
{this.modalData.calculateMethod == "按重量" ? "kg" : "件"}
增加运费&nbsp;
</span>
<el-form-item
label-width="0"
prop="shippingTemplatesRegionList[0].renewalPrice"
rules={{
required: true,
message: "请填写默认运费",
trigger: "change",
}}
label=""
>
<el-input-number
min={0}
max={Number(
this.modalData.shippingTemplatesRegionList[0]
.firstPrice
)}
controls={false}
precision={2}
v-model={
this.modalData.shippingTemplatesRegionList[0]
.renewalPrice
}
></el-input-number>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;&nbsp;
</span>
</div>
<div>
<obj-table-plus
tableProp={{
"scroll-y": {
2024-08-23 06:11:20 +00:00
enabled: true,
2024-08-22 09:40:02 +00:00
},
"show-overflow": true,
2024-08-23 06:11:20 +00:00
height: "auto",
2024-08-22 09:40:02 +00:00
}}
style="height:50vh;"
enable-auto-query={false}
v-model={this.modalData.shippingTemplatesRegionListAppend}
tableCols={tableCols}
isPagination={false}
>
<template slot="empty">
<el-button
onClick={addAreaFare}
type="text"
icon="el-icon-plus"
>
为指定地区城市设置运费除指定地区外其余地区的运费按照默认运费
</el-button>
</template>
</obj-table-plus>
</div>
2024-08-19 09:15:18 +00:00
</div>
2024-08-22 09:40:02 +00:00
</transition>
2024-08-19 09:15:18 +00:00
);
},
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
//指定包邮条件
{
label: "",
2024-08-23 08:14:27 +00:00
prop: "123",
2024-08-19 09:15:18 +00:00
type: "jsx-out",
show: this.modalData.fareConfig == "自定义运费",
render: () => {
const tableCols = [
{
title: "运送到",
width: "300px",
field: "cityCodes",
type: "jsx",
2024-08-22 09:40:02 +00:00
render: ({ row, $rowIndex }) => {
2024-08-19 09:15:18 +00:00
const change = (e) => {
console.log(e);
};
return (
2024-08-22 09:40:02 +00:00
<el-form-item
label-width="0"
prop={
"shippingTemplatesConditionList." +
$rowIndex +
".cityCodes"
}
rules={{
required: true,
message: "请选择运送城市",
2024-08-19 09:15:18 +00:00
}}
2024-08-22 09:40:02 +00:00
>
<el-cascader
style="width:100%;"
v-model={row.cityCodes}
onChange={change}
2024-08-23 08:14:27 +00:00
on-visible-change={(e) => {
console.log(e);
this.reRender = e;
}}
2024-08-23 06:11:20 +00:00
options={this.computedCityOptions(
$rowIndex,
this.modalData.shippingTemplatesConditionList
)}
2024-08-22 09:40:02 +00:00
show-all-levels={false}
placeholder="点击选择运送城市"
collapse-tags={true}
props={{
props: {
multiple: true,
checkStrictly: false,
emitPath: false,
label: "name",
value: "code",
},
}}
clearable
filterable
></el-cascader>
</el-form-item>
2024-08-19 09:15:18 +00:00
);
},
},
{
title: "包邮条件",
field: "conditions",
type: "jsx",
render: ({ row }) => {
const _conditionMapper = {
件数: (
<div>
<el-input-number
style="width:150px;"
min={0}
controls={false}
precision={0}
v-model={row.number}
></el-input-number>
<span>&nbsp;件包邮&nbsp;</span>
</div>
),
金额: (
<div>
<el-input-number
style="width:150px;"
min={0}
controls={false}
precision={2}
v-model={row.price}
></el-input-number>
<span>&nbsp;元包邮&nbsp;</span>
</div>
),
"件数+金额": (
<div>
<el-input-number
style="width:150px;"
min={0}
controls={false}
precision={0}
v-model={row.number}
></el-input-number>
<span>&nbsp;&nbsp;</span>
<el-input-number
style="width:150px;"
min={0}
controls={false}
precision={2}
v-model={row.price}
></el-input-number>
<span>&nbsp;元以上包邮&nbsp;</span>
</div>
),
};
return (
<div class="flex justify-start items-center">
<el-select
2024-08-20 10:01:45 +00:00
style="width:120px;"
2024-08-19 09:15:18 +00:00
v-model={row.conditionType}
>
<el-option label="件数" value="件数"></el-option>
<el-option label="金额" value="金额"></el-option>
<el-option
label="件数+金额"
value="件数+金额"
></el-option>
</el-select>
<span>&nbsp;&nbsp;</span>
{_conditionMapper[row.conditionType]}
</div>
);
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
},
{
title: "操作",
width: "200px",
type: "jsx",
render: (e) => {
const remove = () => {
console.log(e);
this.modalData.shippingTemplatesConditionList.splice(
e.rowIndex,
1
);
};
const add = () => {
console.log(e);
this.modalData.shippingTemplatesConditionList.splice(
e.rowIndex + 1,
0,
{
cityCodes: "",
price: "",
number: "",
conditionType: "件数",
}
);
};
return (
<div>
<el-button type="primary" size="mini" onClick={add}>
向下添加
</el-button>
<el-button type="danger" size="mini" onClick={remove}>
删除
</el-button>
</div>
);
},
},
2024-08-18 06:26:20 +00:00
];
2024-08-19 09:15:18 +00:00
const addAreaFare = () => {
this.modalData.shippingTemplatesConditionList.push({
cityCodes: "",
price: "",
number: "",
conditionType: "件数",
});
};
return (
2024-08-22 09:40:02 +00:00
<transition name="el-fade-in">
<obj-table-plus
class="mt-5"
style="height:50vh;"
enable-auto-query={false}
v-model={this.modalData.shippingTemplatesConditionList}
tableCols={tableCols}
isPagination={false}
>
<template slot="empty">
<el-button
onClick={addAreaFare}
type="text"
icon="el-icon-plus"
>
添加其他地区/其他包邮条件
</el-button>
</template>
</obj-table-plus>
</transition>
2024-08-19 09:15:18 +00:00
);
},
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
];
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
modalHandles() {
return [
{
label: "关闭",
type: "",
handle: debounce(() => {
this.toggle();
}, 300),
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
{
label: "确认",
type: "primary",
loading: this.isLoading,
submit: true,
2024-08-20 10:01:45 +00:00
handle: debounce(() => {
console.log(this.modalData);
if (this.isAdd) {
2024-08-21 08:05:34 +00:00
this.$api.mer_admin
.addShippingTemplate({
2024-11-04 08:59:29 +00:00
linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId
? JSON.parse(sessionStorage.getItem("userInfo")).shopId
: JSON.parse(sessionStorage.getItem("userInfo")).merchantId,
2024-08-21 08:05:34 +00:00
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 == "全国包邮"
2024-08-22 04:58:29 +00:00
? nu
2024-08-21 08:05:34 +00:00
: [
...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(
2024-08-20 10:01:45 +00:00
JSON.stringify(
2024-08-21 08:05:34 +00:00
this.modalData.shippingTemplatesConditionList.map(
2024-08-20 10:01:45 +00:00
(item) => {
item.cityCodes = item.cityCodes.join(",");
2024-08-21 08:05:34 +00:00
//过滤
if (item.conditionType == "件数") {
item.price = null;
} else if (item.conditionType == "金额") {
item.number = null;
}
2024-08-20 10:01:45 +00:00
return item;
}
)
)
),
2024-08-21 08:05:34 +00:00
})
.then((res) => {
this.toggle();
this.$emit("refresh");
});
} else {
//编辑
this.$api.mer_admin
.updateShippingTemplate({
id: this.modalData.id,
2024-11-04 08:59:29 +00:00
linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId
? JSON.parse(sessionStorage.getItem("userInfo")).shopId
: JSON.parse(sessionStorage.getItem("userInfo")).merchantId,
2024-08-21 08:05:34 +00:00
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(",");
//过滤
if (item.conditionType == "件数") {
item.price = null;
} else if (item.conditionType == "金额") {
item.number = null;
}
return item;
}
)
2024-08-20 10:01:45 +00:00
)
2024-08-21 08:05:34 +00:00
),
})
.then((res) => {
this.toggle();
this.$emit("refresh");
});
2024-08-20 10:01:45 +00:00
}
}, 300),
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
];
},
},
asyncComputed: {
async getCityOptions() {
let res = await this.$api.mer_admin.getCity();
return res.data.data;
},
async getProductCategory() {
let res = await this.$api.mer_admin.getProductCategory();
return res.data.data;
},
async getSaleUnit() {
let res = await this.$api.mer_admin.getSaleUnit({
shopId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
});
console.log(res);
return res.data.data;
2024-08-18 06:26:20 +00:00
},
2024-08-19 09:15:18 +00:00
},
2024-08-18 06:26:20 +00:00
};
</script>
<style lang="scss" scoped>
.obj-modal ::v-deep {
2024-08-19 09:15:18 +00:00
.el-dialog__body {
padding: 0 30px;
}
2024-08-18 06:26:20 +00:00
}
</style>