第一次上传

This commit is contained in:
dt_2916866708
2024-01-11 09:33:24 +08:00
commit b59bab8e90
822 changed files with 105065 additions and 0 deletions

View File

@@ -0,0 +1,314 @@
<template>
<div>
<el-dialog :visible.sync="addressModal" title="选择可配送区域" width="50%" class="modal">
<el-row :gutter="24" >
<el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24" class="item">
<div class="acea-row row-right row-middle">
<el-checkbox v-model="iSselect" @change="allCheckbox">全选</el-checkbox>
<div class="empty" @click="empty">清空</div>
</div>
</el-col>
</el-row>
<el-row v-if="item.isShow" :gutter="24" v-loading="loading">
<el-col
:xl="6"
:lg="6"
:md="6"
:sm="8"
:xs="6"
class="item"
v-for="(item, index) in cityList"
:key="index"
>
<el-popover
placement="top-start"
width="600"
trigger="hover"
:open-delay="600">
<div>
<div class="city">
<div class="checkBox">
<div class="arrow"></div>
<div>
<el-checkbox
v-model="city.checked"
:label="city.name"
@change="primary(index, indexn)"
class="itemn"
v-for="(city, indexn) in item.children"
:key="indexn"
v-show="city.isShow"
>{{ city.name }}</el-checkbox
>
</div>
</div>
</div>
</div>
<el-checkbox slot="reference" v-model="item.checked" :label="item.name" @change="checkedClick(index)">{{
item.name
}}</el-checkbox
><span class="red">({{ (item.count || 0) + '/' + item.childNum }})</span>
</el-popover>
</el-col>
</el-row>
<div slot="footer">
<el-button @click="close">取消</el-button>
<el-button type="primary" @click="confirm">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { mapState } from 'vuex';
// import { templatesCityListApi } from '@/api/setting';
export default {
name: 'city',
props: {
type: {
type: Number,
default: 0,
},
selectArr: {
type: Array,
default: [],
},
},
data() {
return {
iSselect: false,
addressModal: false,
cityList: [],
activeCity: -1,
loading: false,
};
},
computed: {},
methods: {
enter(index) {
this.activeCity = index;
},
leave() {
this.activeCity = null;
},
getCityList() {
this.loading = true;
// templatesCityListApi().then((res) => {
// this.loading = false;
// this.selectArr = [];
// res.data.forEach((el, index, arr) => {
// el.isShow = true;
// el.children.forEach((child, j) => {
// child.isShow = true;
// if (this.selectArr.length > 0) {
// this.selectArr.forEach((sel, sindex) => {
// sel.children.forEach((sitem, sj) => {
// if (child.city_id == sitem.city_id) {
// child.isShow = false;
// }
// });
// });
// }
// });
// });
// res.data.forEach((el, index, arr) => {
// let num = 0;
// let oldNum = 0;
// el.children.forEach((child, j) => {
// if (!child.isShow) {
// num++;
// } else {
// oldNum++;
// }
// });
// if (num == el.children.length) {
// el.isShow = false;
// }
// el.childNum = oldNum;
// });
// this.cityList = res.data;
// });
},
/**
* 全选或者反选
* @param checked
*/
allCheckbox: function () {
let that = this,
checked = this.iSselect;
that.cityList.forEach(function (item, key) {
that.$set(that.cityList[key], 'checked', checked);
if (checked) {
that.$set(that.cityList[key], 'count', that.cityList[key].children.length);
} else {
that.$set(that.cityList[key], 'count', 0);
}
that.cityList[key].children.forEach(function (val, k) {
that.$set(that.cityList[key].children[k], 'checked', checked);
});
});
// this.render();
},
// 清空;
empty() {
let that = this;
that.cityList.forEach(function (item, key) {
that.$set(that.cityList[key], 'checked', false);
that.cityList[key].children.forEach(function (val, k) {
that.$set(that.cityList[key].children[k], 'checked', false);
});
that.$set(that.cityList[key], 'count', 0);
});
this.iSselect = false;
},
/**
* 点击省
* @param index
*/
checkedClick: function (index) {
let that = this;
if (that.cityList[index].checked) {
that.$set(that.cityList[index], 'count', that.cityList[index].childNum);
that.cityList[index].children.forEach(function (item, key) {
that.$set(that.cityList[index].children[key], 'checked', true);
});
} else {
that.$set(that.cityList[index], 'count', 0);
that.$set(that.cityList[index], 'checked', false);
that.cityList[index].children.forEach(function (item, key) {
that.$set(that.cityList[index].children[key], 'checked', false);
});
that.iSselect = false;
}
// this.render();
},
/**
* 点击市区
* @param index
* @param ind
*/
primary: function (index, ind) {
let checked = false,
count = 0;
this.cityList[index].children.forEach(function (item, key) {
if (item.checked) {
checked = true;
count++;
}
});
this.$set(this.cityList[index], 'count', count);
this.$set(this.cityList[index], 'checked', checked);
// this.render();
},
// 确定;
confirm() {
let that = this;
// 被选中的省市;
let selectList = [];
that.cityList.forEach(function (item, key) {
let data = {};
if (item.checked) {
data = {
name: item.name,
city_id: item.city_id,
children: [],
};
}
that.cityList[key].children.forEach(function (i, k) {
if (i.checked) {
data.children.push({
city_id: i.city_id,
});
}
});
if (data.city_id !== undefined) {
selectList.push(data);
}
});
if (selectList.length === 0) {
return that.$message.error('至少选择一个省份或者城市');
} else {
this.$emit('selectCity', selectList, this.type);
that.addressModal = false;
this.cityList = [];
}
// parent.selectCity(selectList,type);
// var index = parent.layer.getFrameIndex(window.name);
// parent.layer.close(index);
},
close() {
this.addressModal = false;
this.cityList = [];
},
},
mounted() {
// this.getCityList();
},
};
</script>
<style scoped lang="stylus">
.modal .item {
margin-bottom: 20px;
}
.modal .item .city {
position: absolute;
z-index: 9;
top: 17px;
width: 100%;
padding-top: 18px;
}
.modal .item .city .checkBox {
width: 97%;
padding: 10px;
border: 1px solid #eee;
background-color: #fff;
max-height: 100px;
overflow-x: hidden;
overflow-y: auto;
}
.modal .item .city .checkBox .arrow {
position: absolute;
top: 3px;
width: 0;
height: 0;
border: 8px solid transparent;
border-bottom-color: #ddd;
}
.modal .item .city .checkBox .arrow:before {
position: absolute;
bottom: -8px;
right: -7px;
content: '';
width: 0;
height: 0;
border: 7px solid transparent;
border-bottom-color: #fff;
}
.modal .item .city .checkBox .itemn {
margin-bottom: 14px;
}
.radio {
padding: 5px 0;
font-size: 14px !important;
}
.red {
color: #ff0000;
}
.empty {
cursor: pointer;
font-size: 12px;
margin-left: 10px;
line-height: 19px;
color: var(--prev-color-text-primary);
font-weight: 500;
}
</style>

View File

@@ -0,0 +1,488 @@
<template>
<div>
<el-dialog
:visible.sync="isTemplate"
title="运费模版"
width="1000px"
if="isTemplate"
@on-cancel="cancel"
@closed="close"
>
<div class="Modals">
<el-form class="form" ref="formData" label-width="120px" label-position="right">
<el-row :gutter="24">
<el-col :xl="18" :lg="18" :md="18" :sm="24" :xs="24">
<el-form-item label="模板名称:" prop="name">
<el-input type="text" placeholder="请输入模板名称" :maxlength="20" v-model="formData.name" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xl="18" :lg="18" :md="18" :sm="24" :xs="24">
<el-form-item label="计费方式:" props="state" label-for="state">
<el-radio-group class="radio" v-model="formData.type" @input="changeRadio" element-id="state">
<el-radio :label="1">按件数</el-radio>
<el-radio :label="2">按重量</el-radio>
<el-radio :label="3">按体积</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
<el-form-item class="label" label="配送区域及运费:" props="state" label-for="state">
<el-table ref="table" :data="templateList" class="ivu-mt" empty-text="暂无数据" border>
<el-table-column label="可配送区域" minWidth="100">
<template slot-scope="scope">
<el-input v-model="templateList[scope.$index].regionName" />
</template>
</el-table-column>
<el-table-column
:label="formData.type === 2 ? '首件重量(KG)' : formData.type === 3 ? '首件体积(m³)' : '首件'"
minWidth="100"
>
<template slot-scope="scope">
<el-input type="number" v-model="templateList[scope.$index].first" />
</template>
</el-table-column>
<el-table-column label="运费(元)" minWidth="100">
<template slot-scope="scope">
<el-input type="number" v-model="templateList[scope.$index].price" />
</template>
</el-table-column>
<el-table-column
:label="formData.type === 2 ? '续件重量(KG)' : formData.type === 3 ? '续件体积(m³)' : '续件'"
minWidth="100"
>
<template slot-scope="scope">
<el-input type="number" v-model="templateList[scope.$index].continue" />
</template>
</el-table-column>
<el-table-column label="续费(元)" minWidth="100">
<template slot-scope="scope">
<el-input type="number" v-model="templateList[scope.$index].continue_price" />
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="100">
<template slot-scope="scope">
<a
v-if="scope.row.regionName !== '默认全国'"
@click="delCity(scope.row, '配送区域', scope.$index, 1)"
>删除</a
>
</template>
</el-table-column>
</el-table>
<el-row class="addTop">
<el-col>
<el-button type="primary" icon="md-add" @click="addCity(1)">添加配送区域</el-button>
</el-col>
</el-row>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
<el-form-item label="指定包邮:" prop="store_name" label-for="store_name">
<el-radio-group class="radio" v-model="formData.appoint_check">
<el-radio :label="1">开启</el-radio>
<el-radio :label="0">关闭</el-radio>
</el-radio-group>
<el-table
ref="table"
:data="appointList"
class="addTop mt10"
empty-text="暂无数据"
border
v-if="formData.appoint_check === 1"
>
<el-table-column label="选择区域" minWidth="100">
<template slot-scope="scope">
<el-input v-model="appointList[scope.$index].placeName" />
</template>
</el-table-column>
<el-table-column
:label="formData.type === 2 ? '包邮重量' : formData.type === 3 ? '包邮体积(m³)' : '包邮件数'"
minWidth="100"
>
<template slot-scope="scope">
<el-input type="number" v-model="appointList[scope.$index].a_num" />
</template>
</el-table-column>
<el-table-column label="包邮金额(元)" minWidth="100">
<template slot-scope="scope">
<el-input type="number" v-model="appointList[scope.$index].a_price" />
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="100">
<template slot-scope="scope">
<a
v-if="scope.row.regionName !== '默认全国'"
@click="delCity(scope.row, '配送区域', scope.$index, 2)"
>删除</a
>
</template>
</el-table-column>
</el-table>
<div v-if="formData.appoint_check === 1" class="free_tips">指定地区需同时满足包邮件数/重量/体积和包邮金额的条件才可实现包邮</div>
<el-row class="addTop mt5" v-if="formData.appoint_check === 1">
<el-col>
<el-button type="primary" icon="md-add" @click="addCity(2)">添加包邮区域</el-button>
</el-col>
</el-row>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
<el-form-item label="指定不送达:" prop="store_name" label-for="store_name">
<el-radio-group class="radio" v-model="formData.no_delivery_check">
<el-radio :label="1">开启</el-radio>
<el-radio :label="0">关闭</el-radio>
</el-radio-group>
<el-table
ref="table"
:data="noDeliveryList"
class="addTop mt10"
empty-text="暂无数据"
border
v-if="formData.no_delivery_check === 1"
>
<el-table-column label="选择区域" minWidth="100">
<template slot-scope="scope">
<el-input v-model="noDeliveryList[scope.$index].placeName" />
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="100">
<template slot-scope="scope">
<a
v-if="scope.row.regionName !== '默认全国'"
@click="delCity(scope.row, '配送区域', scope.$index, 3)"
>删除</a
>
</template>
</el-table-column>
</el-table>
<el-row class="addTop" v-if="formData.no_delivery_check === 1">
<el-col>
<el-button type="primary" icon="md-add" @click="addCity(3)">添加不送达区域</el-button>
</el-col>
</el-row>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xl="18" :lg="18" :md="18" :sm="24" :xs="24">
<el-form-item label="排序:" prop="store_name" label-for="store_name">
<el-input-number
:controls="false"
:min="0"
placeholder="输入值越大越靠前"
v-model="formData.sort"
></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col>
<el-form-item prop="store_name" label-for="store_name">
<el-button type="primary" @click="handleSubmit">{{ id ? '立即修改' : '立即提交' }}</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div slot="footer"></div>
</el-dialog>
<city ref="city" @selectCity="selectCity" :type="type" :selectArr="selectArr"></city>
</div>
</template>
<script>
import { mapState } from 'vuex';
import city from '@/components/freightTemplate/city';
// import { templatesSaveApi, shipTemplatesApi } from '@/api/setting';
export default {
name: 'freightTemplate',
components: { city },
props: {},
data() {
let that = this;
return {
isTemplate: false,
templateList: [
{
region: [
{
name: '默认全国',
city_id: 0,
},
],
regionName: '默认全国',
first: 1,
price: 0,
continue: 1,
continue_price: 0,
},
],
appointList: [],
noDeliveryList: [],
type: 1,
formData: {
type: 1,
sort: 0,
name: '',
appoint_check: 0,
no_delivery_check: 0,
},
id: 0,
addressModal: false,
indeterminate: true,
checkAll: false,
checkAllGroup: [],
activeCity: -1,
provinceAllGroup: [],
index: -1,
displayData: '',
currentProvince: '',
selectArr: [], // 传递选中的城市
noShippingArr: [], // 不包邮选择的城市数据
yesShippingArr: [], // 包邮选择的城市数据
noDeliveryArr: [], // 不送达选择的城市数据
};
},
computed: {},
methods: {
close() {
this.$emit('close');
},
editFrom(id) {
this.id = id;
shipTemplatesApi(id).then((res) => {
let formData = res.data.formData;
this.templateList = res.data.templateList;
this.appointList = res.data.appointList;
this.noDeliveryList = res.data.noDeliveryList;
this.formData = {
type: formData.type,
sort: formData.sort,
name: formData.name,
appoint_check: formData.appoint_check,
no_delivery_check: formData.no_delivery_check,
};
// this.headerType();
});
},
selectCity: function (data, type) {
let cityName = data
.map(function (item) {
return item.name;
})
.join(';');
switch (type) {
case 1:
this.templateList.push({
region: data,
regionName: cityName,
first: 1,
price: 0,
continue: 1,
continue_price: 0,
});
this.noShippingArr = this.noShippingArr.concat(data);
break;
case 2:
this.appointList.push({
place: data,
placeName: cityName,
a_num: 0,
a_price: 0,
});
this.yesShippingArr = this.yesShippingArr.concat(data);
break;
case 3:
this.noDeliveryList.push({
place: data,
placeName: cityName,
});
this.noDeliveryArr = this.noDeliveryArr.concat(data);
break;
}
},
// 单独添加配送区域
addCity(type) {
this.selectArr = type == 1 ? this.noShippingArr : type == 2 ? this.yesShippingArr : this.noDeliveryArr;
this.type = type;
this.$refs.city.getCityList();
this.$refs.city.addressModal = true;
},
changeRadio() {},
// 提交
handleSubmit: function () {
let that = this;
if (!that.formData.name.trim().length) {
return that.$message.error('请填写模板名称');
}
for (let i = 0; i < that.templateList.length; i++) {
if (that.templateList[i].first <= 0) {
return that.$message.error('首件/重量/体积应大于0');
}
if (that.templateList[i].price < 0) {
return that.$message.error('运费应大于等于0');
}
if (that.templateList[i].continue <= 0) {
return that.$message.error('续件/重量/体积应大于0');
}
if (that.templateList[i].continue_price < 0) {
return that.$message.error('续费应大于等于0');
}
}
if (that.formData.appoint_check === 1) {
for (let i = 0; i < that.appointList.length; i++) {
if (that.appointList[i].a_num <= 0) {
return that.$message.error('包邮件数应大于0');
}
if (that.appointList[i].a_price < 0) {
return that.$message.error('包邮金额应大于等于0');
}
}
}
let data = {
appoint_info: that.appointList,
region_info: that.templateList,
no_delivery_info: that.noDeliveryList,
sort: that.formData.sort,
type: that.formData.type,
name: that.formData.name,
appoint: that.formData.appoint_check,
no_delivery: that.formData.no_delivery_check,
};
templatesSaveApi(that.id, data).then((res) => {
this.isTemplate = false;
// this.$parent.getList();
this.formData = {
type: 1,
sort: 0,
name: '',
appoint_check: 0,
no_delivery_check: 0,
};
this.appointList = [];
this.noDeliveryList = [];
this.addressModal = false;
this.templateList = [
{
region: [
{
name: '默认全国',
city_id: 0,
},
],
regionName: '默认全国',
first: 1,
price: 0,
continue: 1,
continue_price: 0,
},
];
this.$emit('addSuccess');
this.$message.success(res.msg);
});
},
// 删除
delCity(row, tit, num, type) {
if (type === 1) {
this.templateList.splice(num, 1);
} else if (type == 2) {
this.appointList.splice(num, 1);
} else {
this.noDeliveryList.splice(num, 1);
}
// let delfromData = {
// title: tit,
// num: num,
// url: `setting/shipping_templates/del/${row.id}`,
// method: "DELETE",
// ids: "",
// };
// this.$modalSure(delfromData)
// .then((res) => {
// this.$message.success(res.msg);
// })
// .catch((res) => {
// this.$message.error(res.msg);
// });
},
// 关闭
cancel() {
this.noShippingArr = [];
this.noDeliveryArr = [];
this.yesShippingArr = [];
this.selectArr = [];
this.formData = {
type: 1,
sort: 0,
name: '',
appoint_check: 0,
no_delivery_check: 0,
};
this.appointList = [];
this.noDeliveryList = [];
this.addressModal = false;
this.templateList = [
{
region: [
{
name: '默认全国',
city_id: 0,
},
],
regionName: '默认全国',
first: 0,
price: 0,
continue: 0,
continue_price: 0,
},
];
},
address() {
this.addressModal = true;
},
enter(index) {
this.activeCity = index;
},
leave() {
this.activeCity = null;
},
},
mounted() {},
};
</script>
<style lang="stylus" scoped>
.ivu-table-wrapper {
border-left: 1px solid #dcdee2;
border-top: 1px solid #dcdee2;
}
.ivu-table-border th, .ivu-table-border td {
padding: 0 10px !important;
}
.addTop {
margin-top: 15px;
}
.radio {
padding: 5px 0;
}
.ivu-input-number {
width: 100%;
}
.free_tips {
font-size: 12px;
color: #ccc;
}
</style>

File diff suppressed because it is too large Load Diff