This commit is contained in:
KangKang0928 2024-08-19 17:15:18 +08:00
parent 072be0973a
commit da75cc1813
1 changed files with 608 additions and 128 deletions

View File

@ -1,156 +1,636 @@
<template> <template>
<div> <div>
<obj-modal class="obj-modal" ref="modal" labelWidth="100px" :modalCols="modalCols" :modalConfig="modalConfig" <obj-modal
:modalData="modalData" :modalHandles="modalHandles"> class="obj-modal"
<template slot="dialog__before"> ref="modal"
<!-- <el-tabs v-model="currentPanel"> labelWidth="100px"
:modalCols="modalCols"
:modalConfig="modalConfig"
:modalData="modalData"
:modalHandles="modalHandles"
>
<template slot="dialog__before">
<!-- <el-tabs v-model="currentPanel">
<el-tab-pane label="基础信息" name="基础信息"></el-tab-pane> <el-tab-pane label="基础信息" name="基础信息"></el-tab-pane>
<el-tab-pane label="销售信息" name="销售信息"></el-tab-pane> <el-tab-pane label="销售信息" name="销售信息"></el-tab-pane>
<el-tab-pane label="其他信息" name="其他信息"></el-tab-pane> <el-tab-pane label="其他信息" name="其他信息"></el-tab-pane>
</el-tabs> --> </el-tabs> -->
</template> </template>
</obj-modal> </obj-modal>
</div> </div>
</template> </template>
<script> <script>
import { debounce, cloneDeep } from "lodash"; import { debounce, cloneDeep } from "lodash";
const BASE_DATA = {
calculateMethod: "按重量",
fareConfig: "全国包邮",
//
shippingTemplatesRegionList: [
{
//
cityCodes: "0",
//
first: "",
//
firstPrice: "",
//
renewal: "",
//
renewalPrice: "",
},
],
//
shippingTemplatesRegionListAppend: [],
//
shippingTemplatesConditionList: [
// {
// cityCodes: "",
// price: "",
// number: "",
// },
],
};
export default { export default {
data() { data() {
return { return {
currentPanel: "基础信息", currentPanel: "基础信息",
modalData: { modalData: {},
}, modalConfig: {
modalConfig: { title: "添加运费模板",
title: "添加运费模板", show: false,
show: false, width: "1300px",
width: "1300px", fullscreen: true,
fullscreen: true, },
}, fileList: [], //
fileList: [], // place: "", //
place: "", // };
}; },
mounted() {},
methods: {
toggle(e) {
if (this.modalConfig.show == false) {
this.modalConfig.show = true;
} else {
this.modalConfig.show = false;
}
if (e) {
console.log(e);
this.init(cloneDeep(e.row));
}
return {
add: (item) => {
console.log(item);
this.$nextTick(() => {
this.modalData = BASE_DATA;
});
this.isAdd = true;
},
update: (row) => {
this.modalData = row;
this.isAdd = false;
},
};
}, },
mounted() { }, init(row) {},
methods: { },
toggle(e) { computed: {
if (this.modalConfig.show == false) { modalCols() {
this.modalConfig.show = true; return [
} else { {
this.modalConfig.show = false; label: "模板名称",
} prop: "templateName",
if (e) { type: "Input",
console.log(e); maxlength: "30",
this.init(cloneDeep(e.row)); placeholder: "请输入模板名称",
} rules: {
return { required: true,
add: (item) => { message: "请输入模板名称",
console.log(item); trigger: "blur,change",
this.$nextTick(() => { },
this.modalData = { },
}; {
}); label: "计价方式",
this.isAdd = true; prop: "calculateMethod",
type: "jsx",
rules: {
required: true,
message: "请选择计价方式",
trigger: "blur",
},
render: () => {
return (
<el-radio-group v-model={this.modalData.calculateMethod}>
<el-radio label="按重量">按重量</el-radio>
<el-radio label="按件数">按件数</el-radio>
</el-radio-group>
);
},
},
{
label: "运费配置",
prop: "fareConfig",
type: "jsx",
required: true,
rules: {
required: true,
message: "请选择计价方式",
trigger: "blur",
},
render: () => {
return (
<el-radio-group v-model={this.modalData.fareConfig}>
<el-radio label="全国包邮">全国包邮</el-radio>
<el-radio label="自定义运费">自定义运费</el-radio>
</el-radio-group>
);
},
},
{
label: "自定义运费配置",
type: "jsx-out",
show: this.modalData.fareConfig == "自定义运费",
render: () => {
const tableCols = [
{
title: "运送到",
width: "300px",
field: "cityCodes",
type: "jsx",
render: ({ row }) => {
const change = (e) => {
console.log(e);
};
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",
},
}}
clearable
filterable
></el-cascader>
);
}, },
update: (row) => { },
this.modalData = row; {
this.isAdd = false; title: "首重kg",
field: "first",
type: "jsx",
render: ({ row }) => {
return (
<el-input-number
style="width:100%;"
min={0}
controls={false}
precision={2}
v-model={row.first}
></el-input-number>
);
}, },
},
{
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>
);
},
},
{
title: "续重kg",
field: "renewal",
type: "jsx",
render: ({ row }) => {
return (
<el-input-number
style="width:100%;"
min={0}
controls={false}
precision={2}
v-model={row.renewal}
></el-input-number>
);
},
},
{
title: "续费(元)",
field: "renewalPrice",
type: "jsx",
render: ({ row }) => {
return (
<el-input-number
style="width:100%;"
min={0}
max={row.firstPrice}
controls={false}
precision={2}
v-model={row.renewalPrice}
></el-input-number>
);
},
},
{
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: "",
//
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>
);
},
},
];
const addAreaFare = () => {
this.modalData.shippingTemplatesRegionListAppend.push({
//
cityCodes: "",
//
first: "",
//
firstPrice: "",
//
renewal: "",
//
renewalPrice: "",
});
}; };
return (
<div>
<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
v-model={
this.modalData.shippingTemplatesRegionList[0].first
}
></el-input>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;kg内&nbsp;
</span>
<el-form-item
label-width="0"
prop="shippingTemplatesRegionList[0].firstPrice"
rules={{
required: true,
message: "请填写默认运费",
trigger: "change",
}}
label=""
>
<el-input
v-model={
this.modalData.shippingTemplatesRegionList[0].firstPrice
}
></el-input>
</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
v-model={
this.modalData.shippingTemplatesRegionList[0].renewal
}
></el-input>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;kg增加运费&nbsp;
</span>
<el-form-item
label-width="0"
prop="shippingTemplatesRegionList[0].renewalPrice"
rules={{
required: true,
message: "请填写默认运费",
trigger: "change",
}}
label=""
>
<el-input
v-model={
this.modalData.shippingTemplatesRegionList[0]
.renewalPrice
}
></el-input>
</el-form-item>
<span style="transform:translateY(-12px);">
&nbsp;&nbsp;
</span>
</div>
<div>
<obj-table-plus
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>
</div>
);
},
}, },
init(row) { }, //
}, {
computed: { label: "",
modalCols() { prop: "",
return [ type: "jsx-out",
{ show: this.modalData.fareConfig == "自定义运费",
label: "模板名称", render: () => {
prop: "templateName", const tableCols = [
required: true, {
type: "Input", title: "运送到",
maxlength:"30", width: "300px",
placeholder: "请输入模板名称" field: "cityCodes",
type: "jsx",
render: ({ row }) => {
const change = (e) => {
console.log(e);
};
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",
},
}}
clearable
filterable
></el-cascader>
);
}, },
{ },
label: "计价方式", {
prop: "calculateMethod", title: "包邮条件",
type: "jsx", field: "conditions",
required: true, type: "jsx",
rules: { render: ({ row }) => {
required: true, const _conditionMapper = {
message: "请选择计价方式", 件数: (
trigger: "blur", <div>
}, <el-input-number
render: () => { style="width:150px;"
return ( min={0}
<el-radio-group v-model={this.modalData.calculateMethod}> controls={false}
<el-radio label="按重量">按重量</el-radio> precision={0}
<el-radio label="按件数">按件数</el-radio> v-model={row.number}
</el-radio-group> ></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
style="width:80px;"
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>
);
}, },
{ },
label: "运费配置", {
prop: "fareConfig", title: "操作",
type: "jsx", width: "200px",
required: true, type: "jsx",
rules: { render: (e) => {
required: true, const remove = () => {
message: "请选择计价方式", console.log(e);
trigger: "blur", this.modalData.shippingTemplatesConditionList.splice(
}, e.rowIndex,
render: () => { 1
return ( );
<el-radio-group v-model={this.modalData.fareConfig}> };
<el-radio label="全国包邮">全国包邮</el-radio> const add = () => {
<el-radio label="自定义运费">自定义运费</el-radio> console.log(e);
</el-radio-group> this.modalData.shippingTemplatesConditionList.splice(
); e.rowIndex + 1,
}, 0,
} {
]; cityCodes: "",
}, price: "",
modalHandles() { number: "",
return [ conditionType: "件数",
{ }
label: "关闭", );
type: "", };
handle: debounce(() => { return (
this.toggle(); <div>
}, 300), <el-button type="primary" size="mini" onClick={add}>
}, 向下添加
{ </el-button>
label: "确认", <el-button type="danger" size="mini" onClick={remove}>
type: "primary", 删除
loading: this.isLoading, </el-button>
submit: true, </div>
handle: debounce(() => { );
},
}, 300), },
}
]; ];
const addAreaFare = () => {
this.modalData.shippingTemplatesConditionList.push({
cityCodes: "",
price: "",
number: "",
conditionType: "件数",
});
};
return (
<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>
);
},
}, },
];
}, },
asyncComputed: { modalHandles() {
async getProductCategory() { return [
let res = await this.$api.mer_admin.getProductCategory(); {
return res.data.data; label: "关闭",
type: "",
handle: debounce(() => {
this.toggle();
}, 300),
}, },
async getSaleUnit() { {
let res = await this.$api.mer_admin.getSaleUnit({ label: "确认",
shopId: JSON.parse(sessionStorage.getItem("userInfo")).shopId, type: "primary",
}); loading: this.isLoading,
console.log(res); submit: true,
handle: debounce(() => {}, 300),
},
];
},
},
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; return res.data.data;
},
}, },
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.obj-modal ::v-deep { .obj-modal ::v-deep {
.el-dialog__body { .el-dialog__body {
padding: 0 30px; padding: 0 30px;
} }
} }
</style> </style>