mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-21 18:35:53 +08:00
提b2c部分基础迁移代码
This commit is contained in:
321
manager/src/views/logistics/company.vue
Normal file
321
manager/src/views/logistics/company.vue
Normal file
@@ -0,0 +1,321 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<Card>
|
||||
<Row class="operation padding-row">
|
||||
<Button @click="add" type="primary">添加</Button>
|
||||
</Row>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
>
|
||||
<!-- 页面展示 -->
|
||||
<template slot="disableSlot" slot-scope="{row}">
|
||||
<i-switch size="large" :true-value="true" :false-value="false" :value="row.switch" @on-change="changeSwitch(row)">
|
||||
<span slot="open">开启</span>
|
||||
<span slot="close">禁用</span>
|
||||
</i-switch>
|
||||
</template>
|
||||
</Table>
|
||||
<Row type="flex" justify="end" class="mt_10">
|
||||
<Page
|
||||
:current="searchForm.pageNumber"
|
||||
:total="total"
|
||||
:page-size="searchForm.pageSize"
|
||||
@on-change="changePage"
|
||||
@on-page-size-change="changePageSize"
|
||||
:page-size-opts="[10, 20, 50]"
|
||||
size="small"
|
||||
show-total
|
||||
show-elevator
|
||||
show-sizer
|
||||
></Page>
|
||||
</Row>
|
||||
</Card>
|
||||
<Modal
|
||||
:title="modalTitle"
|
||||
v-model="modalVisible"
|
||||
:mask-closable="false"
|
||||
:width="500"
|
||||
>
|
||||
<Form ref="form" :model="form" :label-width="120" :rules="formValidate">
|
||||
<FormItem label="物流公司名称" prop="name">
|
||||
<Input v-model="form.name" clearable style="width: 100%"/>
|
||||
</FormItem>
|
||||
<FormItem label="物流公司代码" prop="code">
|
||||
<Input v-model="form.code" clearable style="width: 100%"/>
|
||||
</FormItem>
|
||||
<FormItem label="支持电子面单">
|
||||
<i-switch v-model="form.standBy" size="large">
|
||||
<span slot="open">开</span>
|
||||
<span slot="close">关</span>
|
||||
</i-switch>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="禁用状态" prop="disabled">
|
||||
|
||||
<i-switch true-value="OPEN" false-value="CLOSE" v-model="form.disabled" size="large">
|
||||
<span slot="open">开启</span>
|
||||
<span slot="close">禁用</span>
|
||||
</i-switch>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div slot="footer">
|
||||
<Button type="text" @click="modalVisible = false">取消</Button>
|
||||
<Button type="primary" :loading="submitLoading" @click="handleSubmit"
|
||||
>提交
|
||||
</Button
|
||||
>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getLogisticsPage,
|
||||
updateLogistics,
|
||||
addLogistics,
|
||||
delLogistics,
|
||||
} from "@/api/logistics";
|
||||
|
||||
export default {
|
||||
name: "logistics",
|
||||
data() {
|
||||
return {
|
||||
loading: true, // 表单加载状态
|
||||
modalVisible: false, // 添加或编辑显示
|
||||
modalTitle: "", // 添加或编辑标题
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 1, // 当前页数
|
||||
pageSize: 20, // 页面大小
|
||||
sort: "createTime", // 默认排序字段
|
||||
order: "desc", // 默认排序方式
|
||||
name: "",
|
||||
},
|
||||
form: {
|
||||
// 添加或编辑表单对象初始化数据
|
||||
name: "",
|
||||
disabled:"CLOSE"
|
||||
},
|
||||
// 表单验证规则
|
||||
formValidate: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入物流公司名称",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
columns: [
|
||||
{
|
||||
title: "物流公司名称",
|
||||
key: "name",
|
||||
minWidth: 120,
|
||||
sortable: false,
|
||||
},
|
||||
{
|
||||
title: "物流公司编码",
|
||||
key: "code",
|
||||
minWidth: 120,
|
||||
sortable: false,
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "disabled",
|
||||
width: 150,
|
||||
slot: "disableSlot",
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
key: "createTime",
|
||||
width: 180,
|
||||
sortable: false,
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
align: "center",
|
||||
width: 150,
|
||||
render: (h, params) => {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small",
|
||||
},
|
||||
style: {
|
||||
marginRight: "5px",
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.detail(params.row);
|
||||
},
|
||||
},
|
||||
},
|
||||
"修改"
|
||||
),
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "error",
|
||||
size: "small",
|
||||
},
|
||||
style: {
|
||||
marginRight: "5px",
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.remove(params.row);
|
||||
},
|
||||
},
|
||||
},
|
||||
"删除"
|
||||
),
|
||||
]);
|
||||
},
|
||||
},
|
||||
],
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
this.getDataList();
|
||||
},
|
||||
// 分页 改变页码
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v;
|
||||
this.getDataList();
|
||||
},
|
||||
// 分页 改变页数
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
// 获取列表
|
||||
getDataList() {
|
||||
this.loading = true;
|
||||
|
||||
getLogisticsPage(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
const data = res.result.records;
|
||||
data.forEach(e => {
|
||||
e.switch = e.disabled === 'OPEN' ? true : false;
|
||||
e.standBy = e.standBy == 'null' || !e.standBy ? false : true;
|
||||
});
|
||||
this.data = data;
|
||||
console.log(data)
|
||||
this.total = res.result.total;
|
||||
}
|
||||
});
|
||||
this.total = this.data.length;
|
||||
this.loading = false;
|
||||
},
|
||||
// switch 切换状态
|
||||
changeSwitch (v) {
|
||||
this.form.name = v.name;
|
||||
this.form.code = v.code;
|
||||
this.form.standBy = v.standBy;
|
||||
|
||||
this.form.disabled = v.disabled === 'CLOSE' ? 'OPEN' : 'CLOSE';
|
||||
updateLogistics(v.id, this.form).then((res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 确认提交
|
||||
handleSubmit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.submitLoading = true;
|
||||
|
||||
if (this.modalTitle == "添加") {
|
||||
// 添加 避免编辑后传入id等数据 记得删除
|
||||
delete this.form.id;
|
||||
|
||||
|
||||
addLogistics(this.form).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
this.modalVisible = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 编辑
|
||||
updateLogistics(this.id, this.form).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
this.modalVisible = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 添加信息
|
||||
add() {
|
||||
this.modalTitle = "添加";
|
||||
this.form = {};
|
||||
this.$refs.form.resetFields();
|
||||
|
||||
this.modalVisible = true;
|
||||
},
|
||||
// 编辑
|
||||
detail(v) {
|
||||
this.id = v.id;
|
||||
this.modalTitle = "修改";
|
||||
this.modalVisible = true;
|
||||
|
||||
this.form.name = v.name;
|
||||
this.form.code = v.code;
|
||||
console.log(v)
|
||||
this.form.standBy = v.standBy;
|
||||
|
||||
|
||||
|
||||
|
||||
this.form.disabled = v.disabled
|
||||
},
|
||||
// 删除物流公司
|
||||
remove(v) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
// 记得确认修改此处
|
||||
content: "您确认要删除 " + v.name + " ?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
// 删除
|
||||
delLogistics(v.id).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,321 +1,32 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<Card>
|
||||
<Row class="operation padding-row">
|
||||
<Button @click="add" type="primary">添加</Button>
|
||||
</Row>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
>
|
||||
<!-- 页面展示 -->
|
||||
<template slot="disableSlot" slot-scope="{row}">
|
||||
<i-switch size="large" :true-value="true" :false-value="false" :value="row.switch" @on-change="changeSwitch(row)">
|
||||
<span slot="open">开启</span>
|
||||
<span slot="close">禁用</span>
|
||||
</i-switch>
|
||||
</template>
|
||||
</Table>
|
||||
<Row type="flex" justify="end" class="mt_10">
|
||||
<Page
|
||||
:current="searchForm.pageNumber"
|
||||
:total="total"
|
||||
:page-size="searchForm.pageSize"
|
||||
@on-change="changePage"
|
||||
@on-page-size-change="changePageSize"
|
||||
:page-size-opts="[10, 20, 50]"
|
||||
size="small"
|
||||
show-total
|
||||
show-elevator
|
||||
show-sizer
|
||||
></Page>
|
||||
</Row>
|
||||
</Card>
|
||||
<Modal
|
||||
:title="modalTitle"
|
||||
v-model="modalVisible"
|
||||
:mask-closable="false"
|
||||
:width="500"
|
||||
>
|
||||
<Form ref="form" :model="form" :label-width="120" :rules="formValidate">
|
||||
<FormItem label="物流公司名称" prop="name">
|
||||
<Input v-model="form.name" clearable style="width: 100%"/>
|
||||
</FormItem>
|
||||
<FormItem label="物流公司代码" prop="code">
|
||||
<Input v-model="form.code" clearable style="width: 100%"/>
|
||||
</FormItem>
|
||||
<FormItem label="支持电子面单">
|
||||
<i-switch v-model="form.standBy" size="large">
|
||||
<span slot="open">开</span>
|
||||
<span slot="close">关</span>
|
||||
</i-switch>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="禁用状态" prop="disabled">
|
||||
|
||||
<i-switch true-value="OPEN" false-value="CLOSE" v-model="form.disabled" size="large">
|
||||
<span slot="open">开启</span>
|
||||
<span slot="close">禁用</span>
|
||||
</i-switch>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div slot="footer">
|
||||
<Button type="text" @click="modalVisible = false">取消</Button>
|
||||
<Button type="primary" :loading="submitLoading" @click="handleSubmit"
|
||||
>提交
|
||||
</Button
|
||||
>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
<Card>
|
||||
<Tabs :value="type">
|
||||
<TabPane label="物流公司" name="company">
|
||||
<company/>
|
||||
</TabPane>
|
||||
<TabPane label="物流模版" name="template">
|
||||
<!-- <shipTemplate/> -->
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getLogisticsPage,
|
||||
updateLogistics,
|
||||
addLogistics,
|
||||
delLogistics,
|
||||
} from "@/api/logistics";
|
||||
|
||||
import company from './company.vue'
|
||||
import shipTemplate from './shipTemplate.vue';
|
||||
export default {
|
||||
name: "logistics",
|
||||
data() {
|
||||
return {
|
||||
loading: true, // 表单加载状态
|
||||
modalVisible: false, // 添加或编辑显示
|
||||
modalTitle: "", // 添加或编辑标题
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 1, // 当前页数
|
||||
pageSize: 20, // 页面大小
|
||||
sort: "createTime", // 默认排序字段
|
||||
order: "desc", // 默认排序方式
|
||||
name: "",
|
||||
},
|
||||
form: {
|
||||
// 添加或编辑表单对象初始化数据
|
||||
name: "",
|
||||
disabled:"CLOSE"
|
||||
},
|
||||
// 表单验证规则
|
||||
formValidate: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入物流公司名称",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
columns: [
|
||||
{
|
||||
title: "物流公司名称",
|
||||
key: "name",
|
||||
minWidth: 120,
|
||||
sortable: false,
|
||||
},
|
||||
{
|
||||
title: "物流公司编码",
|
||||
key: "code",
|
||||
minWidth: 120,
|
||||
sortable: false,
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "disabled",
|
||||
width: 150,
|
||||
slot: "disableSlot",
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
key: "createTime",
|
||||
width: 180,
|
||||
sortable: false,
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
align: "center",
|
||||
width: 150,
|
||||
render: (h, params) => {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small",
|
||||
},
|
||||
style: {
|
||||
marginRight: "5px",
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.detail(params.row);
|
||||
},
|
||||
},
|
||||
},
|
||||
"修改"
|
||||
),
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "error",
|
||||
size: "small",
|
||||
},
|
||||
style: {
|
||||
marginRight: "5px",
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.remove(params.row);
|
||||
},
|
||||
},
|
||||
},
|
||||
"删除"
|
||||
),
|
||||
]);
|
||||
},
|
||||
},
|
||||
],
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
};
|
||||
components:{
|
||||
company,
|
||||
shipTemplate
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
this.getDataList();
|
||||
},
|
||||
// 分页 改变页码
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v;
|
||||
this.getDataList();
|
||||
},
|
||||
// 分页 改变页数
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
// 获取列表
|
||||
getDataList() {
|
||||
this.loading = true;
|
||||
|
||||
getLogisticsPage(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
const data = res.result.records;
|
||||
data.forEach(e => {
|
||||
e.switch = e.disabled === 'OPEN' ? true : false;
|
||||
e.standBy = e.standBy == 'null' || !e.standBy ? false : true;
|
||||
});
|
||||
this.data = data;
|
||||
console.log(data)
|
||||
this.total = res.result.total;
|
||||
}
|
||||
});
|
||||
this.total = this.data.length;
|
||||
this.loading = false;
|
||||
},
|
||||
// switch 切换状态
|
||||
changeSwitch (v) {
|
||||
this.form.name = v.name;
|
||||
this.form.code = v.code;
|
||||
this.form.standBy = v.standBy;
|
||||
|
||||
this.form.disabled = v.disabled === 'CLOSE' ? 'OPEN' : 'CLOSE';
|
||||
updateLogistics(v.id, this.form).then((res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 确认提交
|
||||
handleSubmit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.submitLoading = true;
|
||||
|
||||
if (this.modalTitle == "添加") {
|
||||
// 添加 避免编辑后传入id等数据 记得删除
|
||||
delete this.form.id;
|
||||
|
||||
|
||||
addLogistics(this.form).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
this.modalVisible = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 编辑
|
||||
updateLogistics(this.id, this.form).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
this.modalVisible = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 添加信息
|
||||
add() {
|
||||
this.modalTitle = "添加";
|
||||
this.form = {};
|
||||
this.$refs.form.resetFields();
|
||||
|
||||
this.modalVisible = true;
|
||||
},
|
||||
// 编辑
|
||||
detail(v) {
|
||||
this.id = v.id;
|
||||
this.modalTitle = "修改";
|
||||
this.modalVisible = true;
|
||||
|
||||
this.form.name = v.name;
|
||||
this.form.code = v.code;
|
||||
console.log(v)
|
||||
this.form.standBy = v.standBy;
|
||||
|
||||
|
||||
|
||||
|
||||
this.form.disabled = v.disabled
|
||||
},
|
||||
// 删除物流公司
|
||||
remove(v) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
// 记得确认修改此处
|
||||
content: "您确认要删除 " + v.name + " ?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
// 删除
|
||||
delLogistics(v.id).then((res) => {
|
||||
this.$Modal.remove();
|
||||
if (res.success) {
|
||||
this.$Message.success("操作成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
data(){
|
||||
return{
|
||||
type:'company'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
|
||||
633
manager/src/views/logistics/shipTemplate.vue
Normal file
633
manager/src/views/logistics/shipTemplate.vue
Normal file
@@ -0,0 +1,633 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<Card>
|
||||
<Row>
|
||||
<Button @click="refresh">刷新</Button>
|
||||
<Button @click="add" type="primary">添加</Button>
|
||||
</Row>
|
||||
<Tabs @on-click="handleClickType" v-model="currentTab" style="margin-top: 10px">
|
||||
<TabPane label="运费模板" name="INFO">
|
||||
<table class="ncsc-default-table order m-b-30" :key="index" v-for="(item,index) in shipInfo">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="sep-row" colspan="20"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="20">
|
||||
<span class="temp-name">{{item.name}}</span>
|
||||
<Tag v-if="item.pricingMethod==='FREE'" class="baoyou" color="warning">包邮</Tag>
|
||||
<span class="fr m-r-5">
|
||||
<time style="margin-right: 20px" title="最后编辑时间">
|
||||
<i class="icon-time"></i>{{item.updateTime}}
|
||||
</time>
|
||||
<Button @click="edit(item)" type="info">修改</Button>
|
||||
<Button @click="remove(item.id)" type="error">删除</Button>
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
<tr v-if="item.pricingMethod!=='FREE'">
|
||||
<td class="w10 bdl"></td>
|
||||
<td class="cell-area tl w150">运送到</td>
|
||||
<td class="w150">首件(重)</td>
|
||||
<td class="w150">运费</td>
|
||||
<td class="w150">续件(重)</td>
|
||||
<td class="w150 bdr">运费</td>
|
||||
</tr>
|
||||
<template v-if="item.pricingMethod!=='FREE'">
|
||||
<tr v-for="(children,index) in item.freightTemplateChildList" :key="index">
|
||||
<td class="bdl"></td>
|
||||
<td class="cell-area tl w150" style="width: 60%;white-space:normal;">{{children.area}}</td>
|
||||
<td>
|
||||
{{children.firstCompany}}
|
||||
</td>
|
||||
<td>
|
||||
<span class="yuan">¥</span><span class="integer">{{children.firstPrice | unitPrice}}</span>
|
||||
</td>
|
||||
<td>
|
||||
{{children.continuedCompany}}
|
||||
</td>
|
||||
<td class="bdr">
|
||||
<span class="yuan">¥</span><span class="integer">{{children.continuedPrice | unitPrice}}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</TabPane>
|
||||
<TabPane v-if="csTab" :label="title" :name="operation">
|
||||
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
|
||||
<FormItem label="模板名称" prop="name">
|
||||
<Input v-model="form.name" maxlength="10" clearable style="width: 20%" />
|
||||
</FormItem>
|
||||
<FormItem label="计价方式" prop="pricingMethod">
|
||||
<RadioGroup type="button" button-style="solid" v-model="form.pricingMethod">
|
||||
<Radio label="WEIGHT">按重量</Radio>
|
||||
<Radio label="NUM">按件数</Radio>
|
||||
<Radio label="FREE">包邮</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="详细设置" v-if="form.pricingMethod !== 'FREE'">
|
||||
<Alert type="warning" >点击右侧修改按钮编辑数据</Alert>
|
||||
<div class="ncsu-trans-type" data-delivery="TRANSTYPE">
|
||||
<div class="entity">
|
||||
<div class="tbl-except">
|
||||
<table cellspacing="0" class="ncsc-default-table">
|
||||
<thead>
|
||||
<tr style="border-bottom: 1px solid #ddd;">
|
||||
<th class="w10"></th>
|
||||
<th class="tl">运送到</th>
|
||||
<th class="w10"></th>
|
||||
<th class="w50">首件(重)</th>
|
||||
<th class="w110">首费</th>
|
||||
<th class="w50">续件(重)</th>
|
||||
<th class="w110">续费</th>
|
||||
<th class="w150">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="bd-line" data-group="n1" v-for="(item,index) in form.freightTemplateChildList"
|
||||
:key="index">
|
||||
<td></td>
|
||||
<td class="tl cell-area">
|
||||
<span class="area-group">
|
||||
<p style="display:inline-block">{{item.area}}</p>
|
||||
</span>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<InputNumber class="text w40" type="text" v-model="item.firstCompany" :max="999" :min="0" :step="0.1" clearable/>
|
||||
</td>
|
||||
<td>
|
||||
<InputNumber class="text w60" type="text" v-model="item.firstPrice" :max="999999" :min="0" clearable :formatter="value => `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
|
||||
:parser="value => value.replace(/\¥\s?|(,*)/g, '')">
|
||||
</InputNumber>
|
||||
</td>
|
||||
<td>
|
||||
<InputNumber class="text w40" type="text" v-model="item.continuedCompany" :max="999" :min="0" :step="0.1"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<InputNumber class="text w60" type="text" v-model="item.continuedPrice" :max="999999" :min="0" clearable :formatter="value => `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
|
||||
:parser="value => value.replace(/\¥\s?|(,*)/g, '')">
|
||||
</InputNumber>
|
||||
</td>
|
||||
<td class="nscs-table-handle">
|
||||
<Button @click="editRegion(item,index)" type="info" size="small"
|
||||
style="margin-bottom: 5px">修改
|
||||
</Button>
|
||||
<Button @click="removeTemplateChildren(index)" type="error"
|
||||
size="small" style="margin-bottom: 5px">删除
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tbl-attach p-5">
|
||||
<div class="div-error" v-if="saveError">
|
||||
<i class="fa fa-exclamation-circle" aria-hidden="true"></i>
|
||||
<Icon type="ios-information-circle-outline" />
|
||||
指定地区城市为空或指定错误
|
||||
<!-- <Icon type="ios-information-circle-outline" />
|
||||
首费应输入正确的金额
|
||||
<Icon type="ios-information-circle-outline" />
|
||||
续费应输入正确的金额 -->
|
||||
<Icon type="ios-information-circle-outline" />
|
||||
首(续)件(重)费应输入大于0的整数
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</FormItem>
|
||||
<Form-item>
|
||||
<Button @click="addShipTemplateChildren(index)" v-if="form.pricingMethod !== 'FREE'"
|
||||
icon="ios-create-outline">为指定城市设置运费模板
|
||||
</Button>
|
||||
<Button @click="handleSubmit" type="primary" style="margin-right:5px">保存
|
||||
</Button>
|
||||
</Form-item>
|
||||
</Form>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
<multiple-region ref="region" @selected="handleSelect">
|
||||
|
||||
</multiple-region>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as API_Shop from "@/api/shops";
|
||||
import multipleRegion from "@/components/map/multiple-region";
|
||||
|
||||
export default {
|
||||
name: "shipTemplate",
|
||||
components: {
|
||||
multipleRegion,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
gotop: false,
|
||||
index:'0',
|
||||
selectedIndex: 0, //选中的地址模板下标
|
||||
item: "", //运费模板子模板
|
||||
shipInfo: {}, // 运费模板数据
|
||||
title: "添加运费模板", // 模态框标题
|
||||
operation: "add", // 操作状态
|
||||
currentTab: "", // 当前模板tab
|
||||
// submitLoading:false,
|
||||
saveError: false, // 是否显示错误提示
|
||||
csTab: false, // 添加运费模板显示
|
||||
form: {
|
||||
// 添加或编辑表单对象初始化数据
|
||||
name: "",
|
||||
pricingMethod: "WEIGHT",
|
||||
},
|
||||
formValidate: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入模板名称",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
pricingMethod: [
|
||||
// 计费方式
|
||||
{
|
||||
required: true,
|
||||
message: "请选择计费方式",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
regions() {
|
||||
return this.$store.state.regions;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 初始化数据
|
||||
init() {
|
||||
this.getData();
|
||||
},
|
||||
//切换tabPane
|
||||
handleClickType(v) {
|
||||
if (v == "INFO") {
|
||||
this.getData();
|
||||
this.csTab = false;
|
||||
}
|
||||
},
|
||||
//添加运费模板
|
||||
add() {
|
||||
this.$refs.region.clear();
|
||||
this.title = "添加运费模板";
|
||||
this.csTab = true;
|
||||
this.operation = "ADD";
|
||||
this.currentTab = "ADD";
|
||||
this.saveError = false;
|
||||
this.form = {
|
||||
pricingMethod: "WEIGHT",
|
||||
name: "",
|
||||
freightTemplateChildList: [
|
||||
{
|
||||
area: "",
|
||||
areaId: "",
|
||||
firstCompany: 0,
|
||||
firstPrice: 0,
|
||||
continuedCompany: 0,
|
||||
continuedPrice: 0,
|
||||
selectedAll: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
handleScroll(){
|
||||
let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
scrolltop > 30 ? (this.gotop = true) : (this.gotop = false);
|
||||
},
|
||||
//修改运费模板
|
||||
edit(item) {
|
||||
this.title = "修改运费模板";
|
||||
this.csTab = true;
|
||||
this.operation = "EDIT";
|
||||
this.currentTab = "EDIT";
|
||||
this.saveError = false;
|
||||
//给form赋值
|
||||
this.form = item;
|
||||
|
||||
let top = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
// 实现滚动效果
|
||||
const timeTop = setInterval(() => {
|
||||
document.body.scrollTop = document.documentElement.scrollTop = top -= 50;
|
||||
if (top <= 0) {
|
||||
clearInterval(timeTop);
|
||||
}
|
||||
}, 0);
|
||||
},
|
||||
//选择地区
|
||||
editRegion(item, index) {
|
||||
this.selectedIndex = index;
|
||||
this.item = item;
|
||||
|
||||
this.regions.forEach((addr) => {
|
||||
this.form.freightTemplateChildList.forEach((child) => {
|
||||
child.area.split(",").forEach((area) => {
|
||||
if (addr.name == area) {
|
||||
addr.selectedAll = true;
|
||||
this.$set(child, "selectedAll", true);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
this.$store.state.shipTemplate = this.form.freightTemplateChildList;
|
||||
|
||||
this.$refs.region.open(item, index);
|
||||
},
|
||||
//刷细数据
|
||||
refresh() {
|
||||
this.csTab = false;
|
||||
this.operation = "INFO";
|
||||
this.currentTab = "INFO";
|
||||
this.getData();
|
||||
this.$Message.success("刷新成功");
|
||||
},
|
||||
//运费模板数据
|
||||
getData() {
|
||||
API_Shop.getShipTemplate().then((res) => {
|
||||
this.shipInfo = res.result;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 选择地址回调
|
||||
*/
|
||||
handleSelect(v) {
|
||||
let area = "";
|
||||
let areaId = "";
|
||||
if (v != "") {
|
||||
v.forEach((child) => {
|
||||
if (child.selectedList != "") {
|
||||
// 只显示省份
|
||||
|
||||
if (child.selectedAll) {
|
||||
area += child.name + ",";
|
||||
this.form.freightTemplateChildList[
|
||||
this.selectedIndex
|
||||
].selectedAll = true;
|
||||
}
|
||||
|
||||
child.selectedList.forEach((son) => {
|
||||
if (child.selectedAll) {
|
||||
areaId += son.id + ",";
|
||||
return;
|
||||
} else {
|
||||
// 显示城市
|
||||
area += son.name + ",";
|
||||
areaId += son.id + ",";
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
this.item.area = area;
|
||||
this.item.areaId = areaId;
|
||||
},
|
||||
//添加或者修改运费模板
|
||||
handleSubmit() {
|
||||
const headers = {
|
||||
"Content-Type": "application/json;charset=utf-8",
|
||||
};
|
||||
|
||||
this.$refs.form.validate((valid) => {
|
||||
// const regNumber = /^\+?[1-9][0-9]*$/;
|
||||
// const regMoney =
|
||||
// /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
|
||||
if (valid) {
|
||||
if (this.form.pricingMethod != "FREE") {
|
||||
//校验运费模板详细信息
|
||||
for (
|
||||
let i = 0;
|
||||
i < this.form.freightTemplateChildList.length;
|
||||
i++
|
||||
) {
|
||||
if (
|
||||
this.form.freightTemplateChildList[i].area == "" ||
|
||||
this.form.freightTemplateChildList[i].firstCompany == "" ||
|
||||
// this.form.freightTemplateChildList[i].firstPrice == "" ||
|
||||
this.form.freightTemplateChildList[i].continuedCompany == ""
|
||||
// this.form.freightTemplateChildList[i].continuedPrice == ""
|
||||
) {
|
||||
this.saveError = true;
|
||||
return;
|
||||
}
|
||||
// if (
|
||||
// regNumber.test(
|
||||
// this.form.freightTemplateChildList[i].firstCompany
|
||||
// ) == false ||
|
||||
// regNumber.test(
|
||||
// this.form.freightTemplateChildList[i].continuedCompany
|
||||
// ) == false ||
|
||||
// regMoney.test(
|
||||
// this.form.freightTemplateChildList[i].firstPrice
|
||||
// ) == false ||
|
||||
// regMoney.test(
|
||||
// this.form.freightTemplateChildList[i].continuedPrice
|
||||
// ) == false
|
||||
// ) {
|
||||
// this.saveError = true;
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
if (this.operation == "ADD") {
|
||||
API_Shop.addShipTemplate(this.form, headers).then((res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("新增成功");
|
||||
this.operation = "INFO";
|
||||
this.currentTab = "INFO";
|
||||
this.csTab = false;
|
||||
this.getData();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
API_Shop.editShipTemplate(this.form.id, this.form, headers).then(
|
||||
(res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("新增成功");
|
||||
this.operation = "INFO";
|
||||
this.currentTab = "INFO";
|
||||
this.csTab = false;
|
||||
this.getData();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
//添加子模板
|
||||
addShipTemplateChildren() {
|
||||
const params = {
|
||||
area: "",
|
||||
areaId: "",
|
||||
firstCompany: 0,
|
||||
firstPrice: 0,
|
||||
continuedCompany: 0,
|
||||
continuedPrice: 0,
|
||||
selectedAll: false,
|
||||
};
|
||||
this.form.freightTemplateChildList.push(params);
|
||||
},
|
||||
//删除一个子模板
|
||||
removeTemplateChildren(index) {
|
||||
if (Object.keys(this.form.freightTemplateChildList).length == 1) {
|
||||
this.$Message.error("必须保留一个子模板");
|
||||
return;
|
||||
}
|
||||
this.form.freightTemplateChildList.splice(index, 1);
|
||||
},
|
||||
//删除运费模板
|
||||
remove(id) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
// 记得确认修改此处
|
||||
content: "您确认要删除此运费模板 ?",
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
API_Shop.deleteShipTemplate(id).then((res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("删除成功");
|
||||
}
|
||||
this.$Modal.remove();
|
||||
this.getData();
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
window.addEventListener("scroll", this.handleScroll, true);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.ncsc-default-table thead th {
|
||||
line-height: 20px;
|
||||
color: #555;
|
||||
background-color: #fafafa;
|
||||
text-align: center;
|
||||
height: 20px;
|
||||
padding: 9px 0;
|
||||
border-bottom: solid 1px #ddd;
|
||||
}
|
||||
|
||||
.ncsc-default-table {
|
||||
line-height: 20px;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
|
||||
tbody th {
|
||||
background-color: #fafafa;
|
||||
border: solid #e6e6e6;
|
||||
border-width: 1px 0;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
tbody td {
|
||||
color: #999;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
padding: 6px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.order tbody tr td {
|
||||
border-bottom: 1px solid #e6e6e6;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.order tbody tr td.bdr {
|
||||
border-right: 1px solid #e6e6e6;
|
||||
}
|
||||
|
||||
.order tbody tr th {
|
||||
border: solid 1px #ddd;
|
||||
}
|
||||
|
||||
.order tbody tr td.sep-row {
|
||||
height: 14px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.w10 {
|
||||
width: 10px !important;
|
||||
}
|
||||
|
||||
.tl {
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
.order tbody tr td.bdl {
|
||||
border-left: 1px solid #e6e6e6;
|
||||
}
|
||||
|
||||
.order tbody tr th .temp-name {
|
||||
float: left;
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
// line-height: 44px;
|
||||
margin: 7px 0 0 10px;
|
||||
}
|
||||
|
||||
.m-r-5 {
|
||||
margin-right: 5px !important;
|
||||
}
|
||||
|
||||
.fr {
|
||||
float: right !important;
|
||||
}
|
||||
|
||||
.m-b-30 {
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
|
||||
Button {
|
||||
margin: 3px 5px 0px 5px;
|
||||
}
|
||||
|
||||
thead {
|
||||
display: table-header-group;
|
||||
vertical-align: middle;
|
||||
border-color: inherit;
|
||||
}
|
||||
|
||||
tr {
|
||||
display: table-row;
|
||||
vertical-align: inherit;
|
||||
border-color: inherit;
|
||||
}
|
||||
|
||||
caption,
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tl {
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
colgroup {
|
||||
display: table-column-group;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.bd-line td {
|
||||
border-bottom: solid 1px #eee;
|
||||
}
|
||||
|
||||
.w40 {
|
||||
width: 60px !important;
|
||||
}
|
||||
|
||||
.w60 {
|
||||
width: 100px !important;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
Input[type="text"],
|
||||
Input[type="password"],
|
||||
Input.text,
|
||||
Input.password {
|
||||
display: inline-block;
|
||||
min-height: 20px;
|
||||
padding: 10px;
|
||||
border: solid 1px #e6e9ee;
|
||||
outline: 0 none;
|
||||
}
|
||||
|
||||
ncsc-default-table {
|
||||
line-height: 20px;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.ncsu-trans-type {
|
||||
background-color: #fff;
|
||||
border: solid #ddd 1px;
|
||||
}
|
||||
|
||||
i,
|
||||
cite,
|
||||
em {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.cell-area {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.div-error {
|
||||
margin-left: 7px;
|
||||
margin-bottom: -8px;
|
||||
font-size: 15px;
|
||||
color: #f00;
|
||||
}
|
||||
.baoyou {
|
||||
margin: 6px 10px 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user