This commit is contained in:
余同学 2024-08-21 18:01:01 +08:00
commit ffda9f2af2
2 changed files with 242 additions and 64 deletions

View File

@ -16,14 +16,19 @@
v-model="searchForm.name" v-model="searchForm.name"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-button type="primary" @click="$refs.oTable.reload();">搜索</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
> >
</div> </div>
</obj-table-plus> </obj-table-plus>
<add-template ref="addTemplate"></add-template> <add-template
ref="addTemplate"
@refresh="$refs.oTable.refresh()"
></add-template>
</div> </div>
</template> </template>
@ -49,11 +54,14 @@ export default {
}) })
.then((res) => { .then((res) => {
console.log(res); console.log(res);
this.$refs.oTable.complete(res.data.data.data,Number(res.data.data.total)); this.$refs.oTable.complete(
res.data.data.data,
Number(res.data.data.total)
);
}) })
.catch(err=>{ .catch((err) => {
this.$refs.oTable.complete(false); this.$refs.oTable.complete(false);
}) });
}, },
addFareTemplate() { addFareTemplate() {
this.$refs.addTemplate.toggle().add(); this.$refs.addTemplate.toggle().add();
@ -66,26 +74,59 @@ export default {
type: "jsx", type: "jsx",
render: (row) => { render: (row) => {
console.log(row); console.log(row);
this.$api.mer_admin.getShippingTemplateInfo(row.id) this.$api.mer_admin.getShippingTemplateInfo(row.id).then((res) => {
.then(res=>{
console.log(res); console.log(res);
// this.$set(row,tableData,); // this.$set(row,tableData,);
}) });
const appointMapper = { const appointMapper = {
0:'(全国包邮)', 0: "(全国包邮)",
1:'(部分包邮)', 1: "(部分包邮)",
2:'(自定义运费)' 2: "(自定义运费)",
} };
const edit = () => {
this.$api.mer_admin
.getShippingTemplateInfo(row.id)
.then((res) => {
console.log(res);
this.$refs.addTemplate.toggle().update(res.data.data);
});
};
const copy = () => {
this.$api.mer_admin
.getShippingTemplateInfo(row.id)
.then((res) => {
console.log(res);
this.$refs.addTemplate.toggle().copy(res.data.data);
});
};
const remove = () => {
this.$api.mer_admin.removeShippingTemplate(row.id)
.then(res=>{
this.$refs.oTable.refresh();
})
};
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.name}{appointMapper[row.appoint]}</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.updateTime}</div> <div class="mr-5">最后编辑时间{row.updateTime}</div>
<div> <div>
<el-button type="text">复制模板</el-button> <el-button type="text" onClick={copy}>
<el-button type="text">修改</el-button> 复制模板
<el-button type="text">删除</el-button> </el-button>
<el-button type="text" onClick={edit}>
修改
</el-button>
<el-popconfirm class="ml-2" title="确认删除模板?" onConfirm={remove}>
<el-button type="text" slot="reference">
删除
</el-button>
</el-popconfirm>
</div> </div>
</div> </div>
</div> </div>

View File

@ -65,7 +65,11 @@ export default {
place: "", // place: "", //
}; };
}, },
mounted() {}, mounted() {
window.onbeforeunload = function (e) {
return "还有未保存的数据,确定离开此页吗?";
};
},
methods: { methods: {
computedCityOptions() { computedCityOptions() {
function filterTree(tree, filterArray) { function filterTree(tree, filterArray) {
@ -110,25 +114,77 @@ export default {
} else { } else {
this.modalConfig.show = false; this.modalConfig.show = false;
} }
if (e) { //
console.log(e); const refillData = (e) => {
this.init(cloneDeep(e.row)); let _data = cloneDeep(e);
console.log("_data", _data);
//
_data.shippingTemplatesRegionList =
[_data.shippingTemplatesRegionResultList?.[0]] ||
BASE_DATA.shippingTemplatesRegionList;
//
_data.shippingTemplatesRegionListAppend =
_data.shippingTemplatesRegionResultList
?.slice(1, _data.shippingTemplatesRegionResultList.length)
?.map((item) => {
item.cityCodes = item.cityCodes.split(",");
return item;
}) || BASE_DATA.shippingTemplatesRegionListAppend;
//
_data.shippingTemplatesConditionList =
_data.shippingTemplatesConditionResultList?.map((item) => {
item.cityCodes = item.cityCodes.split(",");
// item.conditionType=
if (item.price && item.number) {
item.conditionType = "件数+金额";
} else if (item.price && !item.number) {
item.conditionType = "金额";
} else if (!item.price && item.number) {
item.conditionType = "件数";
} }
return item;
}) || BASE_DATA.shippingTemplatesConditionList;
//
_data.calculateMethod = {
1: "按件数",
2: "按重量",
3: "按体积",
}[_data.groups];
//
_data.fareConfig = {
0: "全国包邮",
2: "自定义运费",
}[_data.appoint];
//
_data.templateName = _data.name;
this.modalData = _data;
};
return { return {
add: (item) => { add: () => {
console.log(item);
this.$nextTick(() => { this.$nextTick(() => {
this.modalData = JSON.parse(JSON.stringify(BASE_DATA)); this.modalData = JSON.parse(JSON.stringify(BASE_DATA));
}); });
this.isAdd = true; this.isAdd = true;
this.modalConfig.title = "添加运费模板";
}, },
update: (row) => { update: (e) => {
this.modalData = row;
this.isAdd = false; this.isAdd = false;
refillData(e);
this.modalConfig.title = "编辑运费模板";
},
copy: (e) => {
this.isAdd = true;
refillData(e);
this.modalConfig.title = "添加运费模板";
this.modalData.templateName += "(复制)";
}, },
}; };
}, },
init(row) {},
}, },
computed: { computed: {
modalCols() { modalCols() {
@ -310,7 +366,7 @@ export default {
<el-input-number <el-input-number
style="width:100%;" style="width:100%;"
min={0} min={0}
max={row.firstPrice} max={Number(row.firstPrice)}
controls={false} controls={false}
precision={2} precision={2}
v-model={row.renewalPrice} v-model={row.renewalPrice}
@ -337,6 +393,7 @@ export default {
{ {
// //
cityCodes: "", cityCodes: "",
//
// //
first: "", first: "",
// //
@ -465,6 +522,9 @@ export default {
> >
<el-input-number <el-input-number
min={0} min={0}
max={
Number(this.modalData.shippingTemplatesRegionList[0].firstPrice)
}
controls={false} controls={false}
precision={2} precision={2}
v-model={ v-model={
@ -479,6 +539,13 @@ export default {
</div> </div>
<div> <div>
<obj-table-plus <obj-table-plus
tableProp={{
"scroll-y": {
enabled: true,
gt: 5,
},
'show-overflow':true
}}
style="height:50vh;" style="height:50vh;"
enable-auto-query={false} enable-auto-query={false}
v-model={this.modalData.shippingTemplatesRegionListAppend} v-model={this.modalData.shippingTemplatesRegionListAppend}
@ -697,7 +764,8 @@ export default {
handle: debounce(() => { handle: debounce(() => {
console.log(this.modalData); console.log(this.modalData);
if (this.isAdd) { if (this.isAdd) {
this.$api.mer_admin.addShippingTemplate({ this.$api.mer_admin
.addShippingTemplate({
linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId, linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
defaults: 0, // defaults: 0, //
sort: 0, // sort: 0, //
@ -736,11 +804,80 @@ export default {
this.modalData.shippingTemplatesConditionList.map( this.modalData.shippingTemplatesConditionList.map(
(item) => { (item) => {
item.cityCodes = item.cityCodes.join(","); item.cityCodes = item.cityCodes.join(",");
//
if (item.conditionType == "件数") {
item.price = null;
} else if (item.conditionType == "金额") {
item.number = null;
}
return item; return item;
} }
) )
) )
), ),
})
.then((res) => {
this.toggle();
this.$emit("refresh");
});
} else {
//
this.$api.mer_admin
.updateShippingTemplate({
id: this.modalData.id,
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(",");
//
if (item.conditionType == "件数") {
item.price = null;
} else if (item.conditionType == "金额") {
item.number = null;
}
return item;
}
)
)
),
})
.then((res) => {
this.toggle();
this.$emit("refresh");
}); });
} }
}, 300), }, 300),