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

170 lines
4.9 KiB
Vue
Raw Normal View History

2024-08-18 06:26:20 +00:00
<template>
<div>
<obj-table-plus
style="height: calc(100vh - 132px)"
ref="oTable"
mode="flex"
:tableCols="tableCols"
v-model="dataList"
@query="queryList"
>
<div slot="tableTop" class="mb-2">
<el-form inline>
<el-form-item label="模板名称:">
2024-08-20 10:01:45 +00:00
<el-input
placeholder="请输入模板名称"
v-model="searchForm.name"
></el-input>
2024-08-18 06:26:20 +00:00
</el-form-item>
2024-08-21 08:05:34 +00:00
<el-button type="primary" @click="$refs.oTable.reload()"
>搜索</el-button
>
2024-08-18 06:26:20 +00:00
</el-form>
<el-button type="primary" @click="addFareTemplate"
>添加运费模板</el-button
>
</div>
</obj-table-plus>
2024-08-21 08:05:34 +00:00
<add-template
ref="addTemplate"
@refresh="$refs.oTable.refresh()"
></add-template>
2024-08-18 06:26:20 +00:00
</div>
</template>
<script>
import addTemplate from "./popup/add-template.vue";
export default {
components: { addTemplate },
data() {
return {
dataList: [],
2024-08-20 10:01:45 +00:00
searchForm: {
name: "",
},
2024-08-18 06:26:20 +00:00
};
},
methods: {
queryList(pageNo, pageSize) {
2024-08-20 10:01:45 +00:00
this.$api.mer_admin
.getShippingTemplatePage({
pageNumber: pageNo,
pageSize: pageSize,
...this.searchForm,
})
.then((res) => {
console.log(res);
2024-08-21 08:05:34 +00:00
this.$refs.oTable.complete(
res.data.data.data,
Number(res.data.data.total)
);
2024-08-20 10:01:45 +00:00
})
2024-08-21 08:05:34 +00:00
.catch((err) => {
2024-08-20 10:01:45 +00:00
this.$refs.oTable.complete(false);
2024-08-21 08:05:34 +00:00
});
2024-08-18 06:26:20 +00:00
},
addFareTemplate() {
this.$refs.addTemplate.toggle().add();
},
},
computed: {
tableCols() {
return [
{
type: "jsx",
render: (row) => {
console.log(row);
2024-08-21 08:05:34 +00:00
this.$api.mer_admin.getShippingTemplateInfo(row.id).then((res) => {
console.log(res);
// this.$set(row,tableData,);
});
const appointMapper = {
0: "(全国包邮)",
1: "(部分包邮)",
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)
2024-08-20 10:01:45 +00:00
.then(res=>{
2024-08-21 08:05:34 +00:00
this.$refs.oTable.refresh();
2024-08-20 10:01:45 +00:00
})
2024-08-21 08:05:34 +00:00
};
2024-08-18 06:26:20 +00:00
return (
<div class="mb-5">
<div class="flex justify-between items-center bg-gray-100 px-4">
2024-08-21 08:05:34 +00:00
<div>
{row.name}
{appointMapper[row.appoint]}
</div>
2024-08-18 06:26:20 +00:00
<div class="flex justify-between items-center">
2024-08-20 10:01:45 +00:00
<div class="mr-5">最后编辑时间{row.updateTime}</div>
2024-08-18 06:26:20 +00:00
<div>
2024-08-21 08:05:34 +00:00
<el-button type="text" onClick={copy}>
复制模板
</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>
2024-08-18 06:26:20 +00:00
</div>
</div>
</div>
<vxe-table border align="center" data={row.tableData}>
<vxe-column
width="180px"
field="a"
title="运送到"
></vxe-column>
<vxe-column
width="200px"
field="b"
title="首件(个)"
></vxe-column>
<vxe-column
width="200px"
field="c"
title="首费(元)"
></vxe-column>
<vxe-column
width="200px"
field="d"
title="续件(个)"
></vxe-column>
<vxe-column
width="200px"
field="e"
title="运费(元)"
></vxe-column>
</vxe-table>
</div>
);
},
},
];
},
},
};
</script>
<style lang="scss" scoped></style>