Commit a5651e47 authored by zhengke's avatar zhengke
parents cbe51ad9 f9d8fe75
<template>
<div class="addFreeshipping">
<div class="form-box">
<div>
<span style="color: rgb(64, 158, 255);cursor: pointer;margin-left: 20px" @click="cancel">包邮规则</span>
<span style="margin: 0 5px;color: #C0C4CC;">/</span>
<span>添加规则</span>
</div>
</div>
<div id="pane-first">
<div class="form-box">
<el-form :model="msg" style="padding:0 50px;" :rules="rules" ref="msg" label-width="90px">
<el-form-item label="规则名称" prop="RulesName" class="is-required">
<el-input v-model="msg.RulesName" class="inputM_l"/>
</el-form-item>
<el-form-item label="包邮金额" prop="AllRegionPrice" class="is-required">
<el-tooltip class="item" effect="dark" content="订单满XXX包邮" placement="top"
style="position: absolute;left: -10px;top:13px">
<i class="el-tooltip el-icon-info"></i>
</el-tooltip>
<el-input v-model="msg.AllRegionPrice" class="inputM_l"/>
</el-form-item>
<el-form-item label="运费规则" class="is-required" prop="List">
<div class="gez_list el-card inputM_l" v-if="msg.List.length>0">
<div style="width: 500px;" >
<div >区域:<span v-for="(item,index) in msg.List" :key="index" class="quyu">
{{item.RegionName}}</span>
</div> </div>
<div style="width: 110px;display: flex;flex-direction: row;justify-content: space-around">
<el-tooltip class="item" effect="dark" content="编辑" placement="top" >
<img src="../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="edit()">
</el-tooltip>
<el-tooltip class="item" effect="dark" content="删除" placement="top">
<img src="../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b()">
</el-tooltip>
</div>
</div>
<span style="color: #409EFF;font-size: 14px;cursor: pointer;" @click="addOf" v-if="this.msg.List.length==0">+新增规则</span>
</el-form-item>
</el-form>
</div>
<el-button type="primary" style="margin: 12px 0 " @click="preserve('msg')">保存</el-button>
<el-button style="margin: 12px 0 " @click="cancel">取消</el-button>
</div>
<el-dialog title="新增规则" :visible.sync="dialogFormVisible" >
<el-form :model="msg" :rules="rules" ref="msg">
<el-form-item label="包邮地区" prop="List">
<region_Choice @event1="change($event)" ref="child"></region_Choice>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button type="primary" @click="Addto()">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import region_Choice from './view/regionChoice'
export default {
name: "addFreeshipping",
data(){
return{
msg:{
ID:0,
RulesName:'',
AllRegionPrice:0,
List:[],
},
List:[],
isedit:false,
editindex:0,
dialogFormVisible:false,
rules: {
RulesName: [
{required: true, message: "请填写包邮规则名称", trigger: "blur"}
],
AllRegionPrice: [
{required: true, message: "请输入数字", trigger: "blur"}
],
List:[
{ type: 'array', required: true, message: '请选择包邮地区', trigger: 'change' }
],
},
}
},
components:{
region_Choice,
},
created(){
if(this.$route.query.ID){
this.getLogisticsPinkage(this.$route.query.ID)
}
},
methods:{
getLogisticsPinkage(ID){
this.apipost("/api/MallBase/GetLogisticsPinkage",{'ID':ID} , res => {
if (res.data.resultCode == 1) {
this.msg.ID =res.data.data.ID;
this.msg.RulesName =res.data.data.RulesName;
this.msg.AllRegionPrice =res.data.data.AllRegionPrice;
this.msg.List =res.data.data.List;
} else {
this.Info(res.data.message);
}
})
},
cancel(){
this.$router.go(-1);//返回上一层
},
change(data){
this.List = data;
},
delete_b(){
this.msg.List=[]
},
edit(){
this.dialogFormVisible=true;
setTimeout(()=>{
this.$refs.child.Receive(this.msg.List)
},1000)
},
addOf(){
this.List=[]
this.dialogFormVisible=true;
this.isedit=false;//设置为编辑状态
setTimeout(()=>{
this.$refs.child.Receive(this.List)
},1000)
},
preserve(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
let msg = this.msg;
for(let i=0;i<msg.List.length;i++){
delete msg.List[i].GrandpaID;
delete msg.List[i].ParentID;
}
this.msg.AllRegionPrice = parseInt(this.msg.AllRegionPrice)
this.apipost("/api/MallBase/AddOrUpdateLogisticsPinkage ",msg , res => {
if (res.data.resultCode == 1) {
this.Success(res.data.message);
this.$router.push({
name: 'ruleSetup',
query: {
activeName:'third',
blank: "y"
}
});
} else {
this.Info(res.data.message);
}
})
} else {
return false;
}
});
},
Addto(){
this.dialogFormVisible=false
this.msg.List =this.List;
},
},
}
</script>
<style scoped>
.addFreeshipping .form-box {
background: #fff;
padding: 20px 50% 20px 0;
margin-top: 10px;
}
.addFreeshipping .prompt{
margin: -10px 20px 20px;
background-color: #F4F4F5;
padding: 10px 15px;
color: #909399;
display: inline-block;
font-size: 13px;
}
.addFreeshipping .gez_list{
width: 650px;
margin-bottom: 12px;
padding: 20px;
border: 1px solid #EBEEF5;
background-color: #FFF;
color: #303133;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.addFreeshipping .imgstyle{
width: 32px;
height: 32px;
margin: 0 5px;
}
.addFreeshipping .quyu{
background-color: #f4f4f5;
color: #909399;
padding: 10px;
line-height: 30px;
height: 30px;
font-size: 12px;
border-radius: 4px;
white-space: nowrap;
margin: 5px;
}
.addFreeshipping .inputM_l{
margin-left: 20px;
}
</style>
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<el-radio :label="2">按件计费</el-radio> <el-radio :label="2">按件计费</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="运费规则" class="is-required"> <el-form-item label="运费规则" class="is-required" prop="Detail">
<div class="gez_list el-card" v-for="(item,index) in msg.Detail" :key="index"> <div class="gez_list el-card" v-for="(item,index) in msg.Detail" :key="index">
<div style="width: 500px;"> <div style="width: 500px;">
<span>首重/件(克/个):{{item.First}} <span class="xie">/</span> 首费(元):{{item.FirstPrice}} <span class="xie">/</span>续重/件(克/个):{{item.Second}}<span class="xie">/</span>续费(元){{item.SecondPrice}}</span> <span>首重/件(克/个):{{item.First}} <span class="xie">/</span> 首费(元):{{item.FirstPrice}} <span class="xie">/</span>续重/件(克/个):{{item.Second}}<span class="xie">/</span>续费(元){{item.SecondPrice}}</span>
...@@ -89,46 +89,46 @@ ...@@ -89,46 +89,46 @@
</el-form> </el-form>
</div> </div>
<el-button type="primary" style="margin: 12px 0 " @click="preserve">保存</el-button> <el-button type="primary" style="margin: 12px 0 " @click="preserve('msg')">保存</el-button>
<el-button style="margin: 12px 0 " @click="cancel">取消</el-button> <el-button style="margin: 12px 0 " @click="cancel">取消</el-button>
</div> </div>
<!--新增规则弹窗--> <!--新增规则弹窗-->
<el-dialog title="新增规则" :visible.sync="dialogFormVisible" > <el-dialog title="新增规则" :visible.sync="dialogFormVisible" >
<el-form :rules="rules"> <el-form :model="ruleForm" :rules="rules" ref="ruleForm" >
<el-row :gutter="0"> <el-row :gutter="0">
<el-col :span="11" > <el-col :span="11" >
<el-form-item label="首重(克):" label-width="100px" style="padding: 0px 1rem;" prop="First"> <el-form-item label="首重(克):" label-width="100px" style="padding: 0px 1rem;" prop="First">
<el-input v-model="First" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" /> <el-input v-model="ruleForm.First" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="11"> <el-col :span="11">
<el-form-item label="首费(元)" label-width="100px" style="padding: 0px 1rem;" prop="FirstPrice"> <el-form-item label="首费(元)" label-width="100px" style="padding: 0px 1rem;" prop="FirstPrice">
<el-input v-model="FirstPrice" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" /> <el-input v-model="ruleForm.FirstPrice" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="0"> <el-row :gutter="0">
<el-col :span="11"> <el-col :span="11">
<el-form-item label="续重(克):" label-width="100px" style="padding: 0px 1rem;" prop="Second"> <el-form-item label="续重(克):" label-width="100px" style="padding: 0px 1rem;" prop="Second">
<el-input v-model="Second" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" /> <el-input v-model="ruleForm.Second" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="11"> <el-col :span="11">
<el-form-item label="续费(元)" label-width="100px" style="padding: 0px 1rem;" prop="SecondPrice"> <el-form-item label="续费(元)" label-width="100px" style="padding: 0px 1rem;" prop="SecondPrice">
<el-input v-model="SecondPrice" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" /> <el-input v-model="ruleForm.SecondPrice" step="1" min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="地区选择"> <el-form-item label="地区选择" prop="List">
<region_Choice @event1="change($event)" :List="List" ref="child"></region_Choice> <region_Choice @event1="change($event)" :List="ruleForm.List" ref="child"></region_Choice>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button> <el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button type="primary" @click="Addto">确 定</el-button> <el-button type="primary" @click="Addto('ruleForm')">确 定</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
...@@ -146,11 +146,14 @@ ...@@ -146,11 +146,14 @@
ChargeMode:1, ChargeMode:1,
Detail:[], Detail:[],
}, },
First:0, ruleForm:{
FirstPrice:0, First:0,
Second:0, FirstPrice:0,
SecondPrice:0, Second:0,
List:[], SecondPrice:0,
List:[],
},
isedit:false, isedit:false,
editindex:0, editindex:0,
...@@ -159,19 +162,27 @@ ...@@ -159,19 +162,27 @@
RulesName: [ RulesName: [
{required: true, message: "请输入规则名称", trigger: "blur"} {required: true, message: "请输入规则名称", trigger: "blur"}
], ],
Detail:[
{ type: 'array', required: true, message: '请输入运费规则', trigger: 'change' }
],
First:[ First:[
{ validator: this.isNumber, trigger: 'blur' } {required: true, message: "请输入数字", trigger: "blur"}
], ],
FirstPrice:[ FirstPrice:[
{ validator: this.isNumber, trigger: 'blur' } {required: true, message: "请输入数字", trigger: "blur"}
], ],
Second:[ Second:[
{ validator: this.isNumber, trigger: 'blur' } {required: true, message: "请输入数字", trigger: "blur"}
], ],
SecondPrice:[ SecondPrice:[
{ validator: this.isNumber, trigger: 'blur' } {required: true, message: "请输入数字", trigger: "blur"}
], ],
List:[
{ type: 'array', required: true, message: '请选择地区', trigger: 'change' }
]
}, },
} }
}, },
...@@ -201,37 +212,9 @@ ...@@ -201,37 +212,9 @@
}) })
}, },
change(data){ change(data){
let List=[];
for(let i=0 ;i<data.length;i++){
if(data[i].ischeckAll==true && data[i].indeterminate==false){ //全选的情况 只穿省的ID
List.push({'ID':0,'RegionId':data[i].ID,"RegionName":data[i].Name,'GrandpaID':0,'ParentID':0})
}
if(data[i].indeterminate==true){//传市的ID
if(data[i].hasOwnProperty('cityList')==true){
let citylist = data[i].cityList;
for(let j= 0;j<citylist.length;j++){
if(citylist[j].ischeckAll==true && citylist[j].indeterminate==false){
List.push({'ID':0,'RegionId':citylist[j].ID,"RegionName":citylist[j].Name,'GrandpaID':0,'ParentID':data[i].ID})
}
if(citylist[j].indeterminate==true){
if(citylist[j].hasOwnProperty('areaList')==true){
let areaList = citylist[j].areaList;
for(let z= 0;z<areaList.length;z++){
if(areaList[z].ischeckAll==true){
List.push({'ID':0,'RegionId':areaList[z].ID,"RegionName":areaList[z].Name,'GrandpaID':data[i].ID,'ParentID':citylist[j].ID})
}
}
}
}
}
} this.ruleForm.List = data;
}
}
this.List = List;
}, },
delete_b(index){ delete_b(index){
...@@ -240,79 +223,96 @@ ...@@ -240,79 +223,96 @@
edit(index,data){ edit(index,data){
this.isedit=true;//设置为编辑状态 this.isedit=true;//设置为编辑状态
this.editindex=index;//编辑的索引 this.editindex=index;//编辑的索引
this.ruleForm = data
this.First=data.First;
this.FirstPrice=data.FirstPrice;
this.Second=data.Second;
this.SecondPrice=data.SecondPrice;
this.List=data.List;
this.dialogFormVisible=true; this.dialogFormVisible=true;
setTimeout(()=>{ setTimeout(()=>{
this.$refs.child.Receive(this.List) this.$refs.child.Receive(this.ruleForm.List)
},1000) },1000)
}, },
addOf(){ addOf(){
this.First=0; this.ruleForm={
this.FirstPrice=0; First:0,
this.Second=0; FirstPrice:0,
this.SecondPrice=0; Second:0,
this.List=[]; SecondPrice:0,
this.dialogFormVisible=true List:[],
}
this.dialogFormVisible=true;
this.isedit=false;//设置为编辑状态
setTimeout(()=>{ setTimeout(()=>{
this.$refs.child.Receive(this.List) this.$refs.child.Receive([])
},1000) },1000)
}, },
Addto(){ Addto(formName){
this.dialogFormVisible=false this.$refs[formName].validate((valid) => {
if (valid) {
this.dialogFormVisible=false
let First = parseInt(this.First); let Detail = {
let FirstPrice = parseInt(this.FirstPrice); 'ID':0,
let Second = parseInt(this.Second); 'First':parseInt(this.ruleForm.First),
let SecondPrice = parseInt(this.SecondPrice); 'FirstPrice':parseInt(this.ruleForm.FirstPrice),
'Second':parseInt(this.ruleForm.Second),
let Detail = { 'SecondPrice':parseInt(this.ruleForm.SecondPrice),
'ID':0, 'List':this.ruleForm.List,
'First':First, }
'FirstPrice':FirstPrice,
'Second':Second, if( this.isedit==true){
'SecondPrice':SecondPrice, this.msg.Detail[this.editindex] =Detail;
'List':this.List, this.isedit=false //编辑之后复原
} }else {
this.msg.Detail.push(Detail)
}
} else {
return false;
}
});
if( this.isedit==true){
this.msg.Detail[this.editindex] =Detail;
this.isedit=false //编辑之后复原
}else {
this.msg.Detail.push(Detail)
}
}, },
preserve(){ preserve(formName){
this.apipost("/api/MallBase/AddOrUpdateLogisticsRules",this.msg , res => {
if (res.data.resultCode == 1) { this.$refs[formName].validate((valid) => {
this.Success(res.data.message); if (valid) {
this.$router.push({ let msg = this.msg;
name: 'ruleSetup', for(let i=0;i<msg.Detail.length;i++){
query: { for(let j = 0;j<msg.Detail[i].List.length;j++){
activeName:'second', delete msg.Detail[i].List[j].GrandpaID;
blank: "y" delete msg.Detail[i].List[j].ParentID;
}
}
this.apipost("/api/MallBase/AddOrUpdateLogisticsRules",msg , res => {
if (res.data.resultCode == 1) {
this.Success(res.data.message);
this.$router.push({
name: 'ruleSetup',
query: {
activeName:'second',
blank: "y"
}
});
} else {
this.Info(res.data.message);
} }
}); })
} else { } else {
this.Info(res.data.message); return false;
} }
}) });
}, },
isNumber(rule, value, callback) { isNumber(rule, value, callback) {
if (value === '') { if (value === '') {
return callback(); return callback();
} //这是用来判断如果不是必须输入的,则直接跳出 } //这是用来判断如果不是必须输入的,则直接跳出
const r = /^[0-9]*$/; // 正整数 const r = /^\+?[0-9][0-9]*$/; // 正整数
// 如果判断不符合正则,则不是正整数不能提交 // 如果判断不符合正则,则不是正整数不能提交
if (!r.test(value)) { if (!r.test(value)) {
return callback(new Error('请输入数字')); return callback(new Error('请输入数字'));
......
...@@ -16,7 +16,11 @@ ...@@ -16,7 +16,11 @@
<freight @AddRule="AddRule"></freight> <freight @AddRule="AddRule"></freight>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="包邮规则" name="third">包邮规则</el-tab-pane> <el-tab-pane label="包邮规则" name="third">
<freeShipping @AddFreeShipping = 'AddFreeShipping'></freeShipping>
</el-tab-pane>
<el-tab-pane label="起送规则" name="fourth">起送规则</el-tab-pane> <el-tab-pane label="起送规则" name="fourth">起送规则</el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
...@@ -25,6 +29,7 @@ ...@@ -25,6 +29,7 @@
<script> <script>
import vlogistics from './view/logistics'; import vlogistics from './view/logistics';
import freight from './view/freight'; import freight from './view/freight';
import freeShipping from './view/freeShipping'
export default { export default {
name: "ruleSetup", name: "ruleSetup",
...@@ -41,7 +46,8 @@ ...@@ -41,7 +46,8 @@
}, },
components:{ components:{
vlogistics, vlogistics,
freight freight,
freeShipping
}, },
methods: { methods: {
handleClick(tab, event) { handleClick(tab, event) {
...@@ -49,6 +55,10 @@ ...@@ -49,6 +55,10 @@
}, },
AddRule(){ AddRule(){
this.$router.push('/addFreightRule'); this.$router.push('/addFreightRule');
},
AddFreeShipping(){
this.$router.push('/addFreeshipping');
} }
} }
} }
......
<template>
<div class="freeShipping">
<div id="pane-first">
<div class="form-box">
<div class='table-body'>
<div style="justify-content: space-between; display: flex;">
<div class="input-item">
<el-input placeholder="请输入内容" v-model="msg.RulesName" >
<el-button slot="append" icon="el-icon-search" @click="search"></el-button>
</el-input>
</div>
<el-button type="primary" style="margin: -5px 0px; width: 80px; height: 32px; padding: 0" @click="addRule">添加规则</el-button>
</div>
<el-table
:data="list"
border
style="width: 1707px">
<el-table-column
fixed
prop="ID"
label="ID"
width="309">
</el-table-column>
<el-table-column
fixed
prop="RulesName"
label="包邮规则名称"
width="309">
</el-table-column>
<el-table-column
fixed
prop="AllRegionPrice"
label="订单金额"
width="309">
</el-table-column>
<el-table-column
fixed
label="地区"
width="500">
<template slot-scope="scope">
<div style="display: flex;flex-direction: row;flex-wrap: wrap">
<span v-for="(item,index) in scope.row.RegionList" :key="index">{{item}}</span>
</div>
</template>
</el-table-column >
<el-table-column
fixed="right"
label="操作"
width="280">
<template slot-scope="scope">
<el-tooltip class="item" effect="dark" content="编辑" placement="top" >
<img src="../../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="Edit(scope.row)">
</el-tooltip>
<el-tooltip class="item" effect="dark" content="删除" placement="top" >
<img src="../../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b(scope.row)">
</el-tooltip>
</template>
</el-table-column>
</el-table>
<el-pagination style="text-align:right" background @current-change="handleCurrentChange"
v-if="list&&list.length>0" :current-page.sync="msg.pageIndex"
layout="total,prev, pager, next" :page-size="msg.pageSize" :total="total">
</el-pagination>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "freeShipping",
data(){
return{
list:[],
msg:{
pageIndex:1,
pageSize:20,
RulesName:'',
},
total:0,//总条数
}
},
methods:{
getLogisticsPinkagePage(){
this.apipost("/api/MallBase/GetLogisticsPinkagePage", this.msg, res => {
if (res.data.resultCode == 1) {
this.list = res.data.data.pageData;
this.total = res.data.data.count;
} else {
this.Info(res.data.message);
}
})
},
search(){
this.msg.pageIndex=1;
this.msg.pageSize=20;
this.getLogisticsPinkagePage()
},
formatterColumn(cellValue){
console.log(cellValue)
},
addRule(){
this.$emit("AddFreeShipping",);
},
Edit(row){
this.$router.push({
name: 'addFreeshipping',
query: {
ID:row.ID,
blank: "y"
}
});
},
delete_b(row){
let that=this;
that.Confirm("是否删除?", function () {
that.apipost(
"/api/MallBase/DelPinkage",
{Id:row.ID},
res => {
if (res.data.resultCode == 1) {
that.Success(res.data.message);
that.getLogisticsPinkagePage();
} else {
that.Error(res.data.message);
}
},
);
});
},
handleCurrentChange(val){
this.msg.pageIndex = val;
this.GetLogisticsRulesPage();
}
},
mounted(){
this.getLogisticsPinkagePage()
}
}
</script>
<style scoped>
.freeShipping .form-box{
background: #fff;
padding: 10px 0px 0px;
margin-top: 10px;
}
.freeShipping .table-body{
padding: 20px;
background-color: #fff;
margin-bottom: 20px;
}
.freeShipping .input-item{
width: 250px;
margin: 0 0 20px;
}
.freeShipping .imgstyle{
width: 32px;
height: 32px;
margin: 0 5px;
}
</style>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div class="input-item"> <div class="input-item">
<el-input placeholder="请输入内容" v-model="msg.RulesName" > <el-input placeholder="请输入内容" v-model="msg.RulesName" >
<el-button slot="append" icon="el-icon-search"></el-button> <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
</el-input> </el-input>
</div> </div>
<el-button type="primary" style="margin: -5px 0px; width: 80px; height: 32px; padding: 0" @click="addRule">添加规则</el-button> <el-button type="primary" style="margin: -5px 0px; width: 80px; height: 32px; padding: 0" @click="addRule">添加规则</el-button>
...@@ -69,9 +69,12 @@ ...@@ -69,9 +69,12 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-pagination background @current-change="handleCurrentChange" :current-page.sync="currentPage"
layout="total,prev, pager, next, jumper" :page-size="msg.pageSize" :total="total"> <el-pagination style="text-align:right" background @current-change="handleCurrentChange"
v-if="list&&list.length>0" :current-page.sync="msg.pageIndex"
layout="total,prev, pager, next" :page-size="msg.pageSize" :total="total">
</el-pagination> </el-pagination>
</div> </div>
</div> </div>
</div> </div>
...@@ -91,7 +94,7 @@ ...@@ -91,7 +94,7 @@
RulesName:'', RulesName:'',
}, },
radio:'',//单选按钮绑定值 radio:'',//单选按钮绑定值
total:0,//是否有数据 total:0,//总条数
currentPage:1,//当前第几页 currentPage:1,//当前第几页
} }
}, },
...@@ -100,16 +103,23 @@ ...@@ -100,16 +103,23 @@
this.apipost("/api/MallBase/GetLogisticsRulesPage", this.msg, res => { this.apipost("/api/MallBase/GetLogisticsRulesPage", this.msg, res => {
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
this.list = res.data.data.pageData; this.list = res.data.data.pageData;
this.total = res.data.data.count;
} else { } else {
this.Info(res.data.message); this.Info(res.data.message);
} }
}) })
}, },
search(){
this.msg.pageIndex=1;
this.msg.pageSize=20;
this.GetLogisticsRulesPage()
},
radioChange(){ radioChange(){
}, },
handleCurrentChange(){ handleCurrentChange(val){
this.msg.pageIndex = val;
this.GetLogisticsRulesPage();
}, },
addRule(){ addRule(){
this.$emit("AddRule",); this.$emit("AddRule",);
...@@ -138,7 +148,6 @@ ...@@ -138,7 +148,6 @@
that.Error(res.data.message); that.Error(res.data.message);
} }
}, },
null
); );
}); });
} }
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
for(let j=0;j<getlist.length;j++){ for(let j=0;j<getlist.length;j++){
if(getlist[j].GrandpaID==data[i].ID || getlist[j].ParentID==data[i].ID){ //如果有着2个参数再 他的子级没选择完全 if(getlist[j].GrandpaID==data[i].ID || getlist[j].ParentID==data[i].ID){ //如果有着2个参数再 他的子级没选择完全
data[i].indeterminate=true; data[i].indeterminate=true;
this.citylist(data[i].ID,i)
} }
if(getlist[j].RegionId==data[i].ID){ if(getlist[j].RegionId==data[i].ID){
data[i].ischeckAll=true; data[i].ischeckAll=true;
...@@ -75,36 +76,33 @@ ...@@ -75,36 +76,33 @@
} }
}) })
}, },
getCitylist(type=false){ getCitylist(type=false,type2=true){
let getlist =this.getlist let getlist =this.getlist
console.log()
this.apipost("/api/Destination/GetChildList",{'Id':this.cityID} , res => { this.apipost("/api/Destination/GetChildList",{'Id':this.cityID} , res => {
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
let data = res.data.data; let data = res.data.data;
this.areaID = data[this.cityindex].ID this.areaID = data[this.cityindex].ID
for(let i=0;i<data.length;i++){ for(let i=0;i<data.length;i++){
if(type2==true){
if(getlist.length>0){ if(getlist.length>0){
for(let j=0;j<getlist.length;j++){ for(let j=0;j<getlist.length;j++){
if(type==true){ if(type==true){
data[i].ischeckAll=true; data[i].ischeckAll=true;
data[i].indeterminate=false; data[i].indeterminate=false;
}else { }else {
if(getlist[j].RegionId==this.cityID){ //父 勾选
if(getlist[j].RegionId==data[i].ID || getlist[j].RegionId==this.cityID){
data[i].ischeckAll=true; data[i].ischeckAll=true;
data[i].indeterminate=false; data[i].indeterminate=false;
}else if(getlist[j].ParentID==data[i].ID){ }else if(getlist[j].ParentID==data[i].ID){
data[i].ischeckAll=false; data[i].ischeckAll=false;
data[i].indeterminate=true; data[i].indeterminate=true;
}else if(getlist[j].RegionId==data[i].ID){//如果自己身相等 }else if(data[i].hasOwnProperty('ischeckAll')==false && data[i].hasOwnProperty('indeterminate')==false){
data[i].ischeckAll=true;
data[i].indeterminate=false;
}else {
data[i].ischeckAll=false; data[i].ischeckAll=false;
data[i].indeterminate=false; data[i].indeterminate=false;
} }
}
}
} }
}else { }else {
if(type==true){ if(type==true){
...@@ -115,6 +113,11 @@ console.log() ...@@ -115,6 +113,11 @@ console.log()
data[i].indeterminate=false; data[i].indeterminate=false;
} }
} }
}else {
data[i].ischeckAll=false;
data[i].indeterminate=false;
}
} }
...@@ -131,39 +134,40 @@ console.log() ...@@ -131,39 +134,40 @@ console.log()
} }
}) })
}, },
getareaIDlist(type=false){ getareaIDlist(type=false,type2=true){
let getlist =this.getlist let getlist =this.getlist
this.apipost("/api/Destination/GetChildList",{'Id':this.areaID} , res => { this.apipost("/api/Destination/GetChildList",{'Id':this.areaID} , res => {
this.loading= false this.loading= false
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
let data = res.data.data; let data = res.data.data;
for(let i=0;i<data.length;i++){ for(let i=0;i<data.length;i++){
if(getlist.length>0){ if(type2==true){
for(let j=0;j<getlist.length;j++){ if(getlist.length>0){
if(type==true){ for(let j=0;j<getlist.length;j++){
data[i].ischeckAll=true; if(type==true){
}else {
if(getlist[j].RegionId==this.cityID){
data[i].ischeckAll=true;
}else if(getlist[j].RegionId==data[i].ID){
data[i].ischeckAll=true; data[i].ischeckAll=true;
}else { }else {
data[i].ischeckAll=false;
if(getlist[j].RegionId==this.cityID || getlist[j].RegionId==data[i].ID || getlist[j].RegionId == this.areaID){
data[i].ischeckAll=true;
}else if(data[i].hasOwnProperty('ischeckAll')==false ){
data[i].ischeckAll=false;
}
} }
} }
}
}else {
if(type==true){
data[i].ischeckAll=true;
}else { }else {
data[i].ischeckAll=false; if(type==true){
data[i].ischeckAll=true;
}else {
data[i].ischeckAll=false;
}
} }
} }else {
data[i].ischeckAll=false;
}
} }
let regionList = this.regionList; let regionList = this.regionList;
...@@ -191,12 +195,14 @@ console.log() ...@@ -191,12 +195,14 @@ console.log()
regionList[index].indeterminate=false; regionList[index].indeterminate=false;
regionList[index].ischeckAll=true; regionList[index].ischeckAll=true;
} }
if(regionList[index].hasOwnProperty('cityList')==false){
this.getCitylist(true)
}else { if(e==false){
if(e==false){
if(regionList[index].hasOwnProperty('cityList')==false) {
this.getCitylist(false,false)
}else {
let cityList = regionList[index].cityList; let cityList = regionList[index].cityList;
for(let i=0;i<cityList.length;i++){ for(let i=0;i<cityList.length;i++){
cityList[i].ischeckAll=false cityList[i].ischeckAll=false
} }
...@@ -206,7 +212,10 @@ console.log() ...@@ -206,7 +212,10 @@ console.log()
areaList[i].ischeckAll=false areaList[i].ischeckAll=false
} }
this.areaList = areaList this.areaList = areaList
}
}else {
if(regionList[index].hasOwnProperty('cityList')==false) {
this.getCitylist(true)
}else { }else {
let cityList = regionList[index].cityList; let cityList = regionList[index].cityList;
for(let i=0;i<cityList.length;i++){ for(let i=0;i<cityList.length;i++){
...@@ -222,6 +231,8 @@ console.log() ...@@ -222,6 +231,8 @@ console.log()
} }
} }
this.toParent() this.toParent()
}, },
showcity(index, id){ showcity(index, id){
...@@ -245,7 +256,7 @@ console.log() ...@@ -245,7 +256,7 @@ console.log()
let areaList = regionList[this.provinceindex].cityList[index].areaList; let areaList = regionList[this.provinceindex].cityList[index].areaList;
if(e==false){ if(e==false){
if(regionList[this.provinceindex].cityList[index].hasOwnProperty('areaList')==false){ if(regionList[this.provinceindex].cityList[index].hasOwnProperty('areaList')==false){
this.getareaIDlist() this.getareaIDlist(false,false)
}else { }else {
this.areaList = regionList[this.provinceindex].cityList[index].areaList; this.areaList = regionList[this.provinceindex].cityList[index].areaList;
} }
...@@ -257,6 +268,27 @@ console.log() ...@@ -257,6 +268,27 @@ console.log()
} }
regionList[this.provinceindex].cityList[index].indeterminate=false regionList[this.provinceindex].cityList[index].indeterminate=false
} }
let all=true;
let cityList = this.regionList[this.provinceindex].cityList;
if(cityList!=undefined){
for(let i=0;i<cityList.length;i++){
if(cityList[i].ischeckAll==true){
all=false
}
}
}
if(all==true){
this.regionList[this.provinceindex].indeterminate=false
this.regionList[this.provinceindex].ischeckAll=false
}
if(areaList!=undefined){
for(let i=0;i<areaList.length;i++){
areaList[i].ischeckAll=false
}
}
}else { }else {
if(regionList[this.provinceindex].cityList[index].hasOwnProperty('areaList')==false){ if(regionList[this.provinceindex].cityList[index].hasOwnProperty('areaList')==false){
...@@ -273,7 +305,6 @@ console.log() ...@@ -273,7 +305,6 @@ console.log()
let cityList = this.regionList[this.provinceindex].cityList; let cityList = this.regionList[this.provinceindex].cityList;
if(cityList!=undefined){ if(cityList!=undefined){
for(let i=0;i<cityList.length;i++){ for(let i=0;i<cityList.length;i++){
if(cityList[i].ischeckAll==false){ if(cityList[i].ischeckAll==false){
all=false all=false
} }
...@@ -314,16 +345,39 @@ console.log() ...@@ -314,16 +345,39 @@ console.log()
handleareaAllChange(index, id, e){ handleareaAllChange(index, id, e){
let regionList = this.regionList; let regionList = this.regionList;
this.areaindex = index; this.areaindex = index;
let areaList= regionList[this.provinceindex].cityList[this.cityindex].areaList;
let cityList= regionList[this.provinceindex].cityList;
if(e==false){ if(e==false){
regionList[this.provinceindex].indeterminate=true regionList[this.provinceindex].indeterminate=true
regionList[this.provinceindex].cityList[this.cityindex].indeterminate=true regionList[this.provinceindex].cityList[this.cityindex].indeterminate=true
let areaAll=true
for(let i=0;i<areaList.length;i++){
if(areaList[i].ischeckAll==true){
areaAll=false
}
}
if(areaAll==true){
regionList[this.provinceindex].cityList[this.cityindex].indeterminate=false;
regionList[this.provinceindex].cityList[this.cityindex].ischeckAll=false;
let provinceAll =true;
for(let i=0;i<cityList.length;i++){
if(cityList[i].ischeckAll==true || cityList[i].indeterminate==true){
provinceAll=false
}
}
if(provinceAll== true){
regionList[this.provinceindex].indeterminate=false;
regionList[this.provinceindex].ischeckAll=false;
}
}
}else { }else {
regionList[this.provinceindex].indeterminate=true regionList[this.provinceindex].indeterminate=true
regionList[this.provinceindex].cityList[this.cityindex].indeterminate=true regionList[this.provinceindex].cityList[this.cityindex].indeterminate=true
let areaList= regionList[this.provinceindex].cityList[this.cityindex].areaList;
let cityList= regionList[this.provinceindex].cityList;
let areaAll=true let areaAll=true
for(let i=0;i<areaList.length;i++){ for(let i=0;i<areaList.length;i++){
if(areaList[i].ischeckAll==false){ if(areaList[i].ischeckAll==false){
...@@ -333,6 +387,7 @@ console.log() ...@@ -333,6 +387,7 @@ console.log()
if(areaAll==true){ if(areaAll==true){
regionList[this.provinceindex].cityList[this.cityindex].indeterminate=false; regionList[this.provinceindex].cityList[this.cityindex].indeterminate=false;
regionList[this.provinceindex].cityList[this.cityindex].ischeckAll=true; regionList[this.provinceindex].cityList[this.cityindex].ischeckAll=true;
let provinceAll =true; let provinceAll =true;
for(let i=0;i<cityList.length;i++){ for(let i=0;i<cityList.length;i++){
if(cityList[i].ischeckAll==false || cityList[i].indeterminate==true){ if(cityList[i].ischeckAll==false || cityList[i].indeterminate==true){
...@@ -349,18 +404,120 @@ console.log() ...@@ -349,18 +404,120 @@ console.log()
}, },
toParent(){//传值给父组件 toParent(){//传值给父组件
this.$emit('event1', this.regionList) let List=[];
let data= this.regionList
for(let i=0 ;i<data.length;i++){
if(data[i].ischeckAll==true && data[i].indeterminate==false){ //全选的情况 只穿省的ID
List.push({'ID':0,'RegionId':data[i].ID,"RegionName":data[i].Name,'GrandpaID':0,'ParentID':0})
}
if(data[i].indeterminate==true){//传市的ID
if(data[i].hasOwnProperty('cityList')==true){
let citylist = data[i].cityList;
for(let j= 0;j<citylist.length;j++){
if(citylist[j].ischeckAll==true && citylist[j].indeterminate==false){
List.push({'ID':0,'RegionId':citylist[j].ID,"RegionName":citylist[j].Name,'GrandpaID':0,'ParentID':data[i].ID})
}
if(citylist[j].indeterminate==true){
if(citylist[j].hasOwnProperty('areaList')==true){
let areaList = citylist[j].areaList;
for(let z= 0;z<areaList.length;z++){
if(areaList[z].ischeckAll==true){
List.push({'ID':0,'RegionId':areaList[z].ID,"RegionName":areaList[z].Name,'GrandpaID':data[i].ID,'ParentID':citylist[j].ID})
}
}
}
}
}
}
}
}
this.$emit('event1', List)
},
citylist(Id,index){
let getlist =this.getlist;
let msg = {'Id':Id}
this.apipost("/api/Destination/GetChildList",msg , res => {
if (res.data.resultCode == 1) {
let data = res.data.data;
for(let i=0;i<data.length;i++){
if(getlist.length>0){
for(let j=0;j<getlist.length;j++){
if(getlist[j].RegionId==data[i].ID || getlist[j].RegionId==this.regionList[index].ID){
data[i].ischeckAll=true;
data[i].indeterminate=false;
this.arealist(data[i].ID,i,index)
}else if(getlist[j].ParentID==data[i].ID){
data[i].ischeckAll=false;
data[i].indeterminate=true;
this.arealist(data[i].ID,i,index)
}else if(data[i].hasOwnProperty('ischeckAll')==false && data[i].hasOwnProperty('indeterminate')==false){
data[i].ischeckAll=false;
data[i].indeterminate=false;
}
}
}else {
data[i].ischeckAll=false;
data[i].indeterminate=false;
}
}
this.regionList[index].cityList = data
} else {
this.Info(res.data.message);
}
})
},
arealist(Id,index,Pindex){
let getlist =this.getlist;
let msg = {'Id':Id}
this.apipost("/api/Destination/GetChildList",msg , res => {
if (res.data.resultCode == 1) {
let data = res.data.data;
for(let i=0;i<data.length;i++){
if(getlist.length>0){
for(let j=0;j<getlist.length;j++){
if(getlist[j].RegionId==this.regionList[Pindex].ID || getlist[j].RegionId==data[i].ID || getlist[j].RegionId == this.regionList[Pindex].cityList[index].ID){
data[i].ischeckAll=true;
}else if(data[i].hasOwnProperty('ischeckAll')==false ){
data[i].ischeckAll=false;
}
}
}else {
data[i].ischeckAll=false;
}
}
this.regionList[Pindex].cityList[index].areaList = data
} else {
this.Info(res.data.message);
}
})
}, },
Receive(val){ Receive(val){
console.log('进入')
this.regionList = []; this.regionList = [];
this.loading=true; this.loading=true;
this.cityindex=0, this.cityindex=0;
this.areaindex=0, this.areaindex=0;
this.cityID=0;
this.areaID=0;
this.getlist= val; this.getlist= val;
setTimeout(()=>{ setTimeout(()=>{
this.getprovince() this.getprovince()
},100) },2000)
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment