Commit 6cfd2826 by LJM

发票管理

parent 43b76cce
...@@ -68,9 +68,9 @@ ...@@ -68,9 +68,9 @@
} }
} }
.p3 { .p3 {
height: 66rpx;
font-size: 24rpx; font-size: 24rpx;
color: #919399; color: #919399;
margin-bottom: 16rpx;
} }
.operate { .operate {
.edit { .edit {
...@@ -221,6 +221,11 @@ ...@@ -221,6 +221,11 @@
width: 155rpx; width: 155rpx;
font-size: 26rpx; font-size: 26rpx;
color: #484b59; color: #484b59;
&.required::before {
content: '*';
font-size: 26rpx;
color: #1969f9;
}
} }
.intl_code { .intl_code {
.uni-input { .uni-input {
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</view> </view>
</template> </template>
<view class="row verCenter"> <view class="row verCenter">
<navigator class="edit row verCenter" url="/user/invoiceEdit" hover-class="none"> <navigator class="edit row verCenter" :url="'/user/invoiceEdit?tax_id=' + item.tax_id + '&inv_type=' + item.inv_type" hover-class="none">
<text class="iconfont icon-bjt"></text> <text class="iconfont icon-bjt"></text>
<text class="tt">编辑</text> <text class="tt">编辑</text>
</navigator> </navigator>
......
...@@ -100,12 +100,12 @@ ...@@ -100,12 +100,12 @@
</view> </view>
</view> </view>
</template> </template>
<view class="setting-default row verCenter bothSide"> <view class="setting-default row verCenter bothSide" style="margin-bottom: 24rpx;">
<text class="tt">设为默认发票</text> <text class="tt">设为默认发票</text>
<view><switch @change="onSwitchChange" checked style="transform:scale(0.7)" /></view> <view><switch @change="onSwitchChange" checked style="transform:scale(0.7)" /></view>
</view> </view>
<!-- 收票信息 --> <!-- 收票信息 -->
<view class="info-title row bothSide verCenter" @click="toggle = !toggle"> <view class="info-title row bothSide verCenter" @click="toggle = !toggle" v-if="curr == 0">
<text class="info-title-t1">展开收票信息(非必填)</text> <text class="info-title-t1">展开收票信息(非必填)</text>
<template v-if="toggle"> <template v-if="toggle">
<text class="iconfont icon-arrtop"></text> <text class="iconfont icon-arrtop"></text>
...@@ -116,11 +116,11 @@ ...@@ -116,11 +116,11 @@
</view> </view>
<view class="form-box" v-if="toggle"> <view class="form-box" v-if="toggle">
<view class="input-box input row verCenter"> <view class="input-box input row verCenter">
<text class="tt">收货</text> <text class="tt" :class="{ required: curr == 1 }">收票</text>
<input type="text" placeholder="请输入收人" class="uni-input" v-model="formParams.consignee" /> <input type="text" placeholder="请输入收人" class="uni-input" v-model="formParams.consignee" />
</view> </view>
<view class="input-box input row verCenter"> <view class="input-box input row verCenter">
<text class="tt">手机号码</text> <text class="tt" :class="{ required: curr == 1 }">手机号码</text>
<picker @change="bindPickerChange" :value="index" :range="array" class="intl_code"> <picker @change="bindPickerChange" :value="index" :range="array" class="intl_code">
<view class="row verCenter bothSide"> <view class="row verCenter bothSide">
<view class="uni-input">{{ array[index] }}</view> <view class="uni-input">{{ array[index] }}</view>
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
<input type="number" placeholder="请输入手机号" class="uni-input" style="margin-left: 24rpx;" v-model="formParams.consignee_phone" /> <input type="number" placeholder="请输入手机号" class="uni-input" style="margin-left: 24rpx;" v-model="formParams.consignee_phone" />
</view> </view>
<view class="input-box input row verCenter"> <view class="input-box input row verCenter">
<text class="tt">所在地区</text> <text class="tt" :class="{ required: curr == 1 }">所在地区</text>
<picker mode="multiSelector" @change="pickerChange" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray" :range-key="'name'"> <picker mode="multiSelector" @change="pickerChange" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray" :range-key="'name'">
<view>{{ selectText }}</view> <view>{{ selectText }}</view>
</picker> </picker>
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
<view class="input-box textarea row verCenter"><textarea placeholder="请输入详细街道地址" v-model="formParams.consignee_address"></textarea></view> <view class="input-box textarea row verCenter"><textarea placeholder="请输入详细街道地址" v-model="formParams.consignee_address"></textarea></view>
</view> </view>
<view class="btn row verCenter"> <view class="btn row verCenter">
<view class="btn1 row rowCenter verCenter"><text class="text">保存</text></view> <view class="btn1 row rowCenter verCenter" @click="invoiceCreate()"><text class="text">保存</text></view>
</view> </view>
</view> </view>
</template> </template>
...@@ -178,7 +178,7 @@ export default { ...@@ -178,7 +178,7 @@ export default {
consignee_city: '', //寄送地址市 consignee_city: '', //寄送地址市
consignee_district: '', //寄送地址区 consignee_district: '', //寄送地址区
consignee_address: '', //详细地址 consignee_address: '', //详细地址
is_default: '' //设置默认 is_default: 1 //设置默认
} }
}; };
}, },
...@@ -189,8 +189,20 @@ export default { ...@@ -189,8 +189,20 @@ export default {
tab(index, type) { tab(index, type) {
if (type == 1) { if (type == 1) {
this.curr = index; this.curr = index;
if (this.curr == 0) {
this.formParams.inv_type = 4;
} else if (this.curr == 1) {
this.formParams.inv_type = 3;
this.toggle = true;
}
} else if (type == 2) { } else if (type == 2) {
//增值税普通发票公司-个人切换
this.taxIndex = index; this.taxIndex = index;
if (this.taxIndex == 0) {
this.formParams.inv_type = 4;
} else if (this.taxIndex == 1) {
this.formParams.inv_type = 2;
}
} }
}, },
/** /**
...@@ -206,6 +218,137 @@ export default { ...@@ -206,6 +218,137 @@ export default {
this.formParams.intl_code = this.array[e.detail.value]; this.formParams.intl_code = this.array[e.detail.value];
}, },
/** /**
* 新增发票
*/
invoiceCreate() {
if (this.curr == 0) {
if (this.taxIndex == 0) {
//增值税普通发票-公司
if (!this.formParams.tax_title) {
uni.showToast({
title: '请输入开票公司名称',
icon: 'none'
});
return false;
}
if (!this.formParams.tax_no) {
uni.showToast({
title: '请输入税务登记号',
icon: 'none'
});
return false;
}
var params = Object.assign({}, this.formParams, {
is_self: 1
});
} else if (this.taxIndex == 1) {
//增值税普通发票-个人
if (!this.formParams.tax_title) {
uni.showToast({
title: '请输入开票人名称',
icon: 'none'
});
return false;
}
var params = Object.assign({}, this.formParams, {
is_self: 1
});
}
} else {
//增值税专用发票
if (!this.formParams.tax_title) {
uni.showToast({
title: '请输入开票公司名称',
icon: 'none'
});
return false;
}
if (!this.formParams.company_address) {
uni.showToast({
title: '请输入注册地址',
icon: 'none'
});
return false;
}
if (!this.formParams.company_phone) {
uni.showToast({
title: '请输入电话号码',
icon: 'none'
});
return false;
}
if (!this.formParams.tax_no) {
uni.showToast({
title: '请输入纳税人识别号',
icon: 'none'
});
return false;
}
if (!this.formParams.bank_name) {
uni.showToast({
title: '请输入开户银行',
icon: 'none'
});
return false;
}
if (!this.formParams.bank_account) {
uni.showToast({
title: '请输入开户银行账号',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee) {
uni.showToast({
title: '请输入收票人',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee_phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee_province) {
uni.showToast({
title: '请输入省、市、区',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee_address) {
uni.showToast({
title: '请输入详细街道地址',
icon: 'none'
});
return false;
}
var params = Object.assign({}, this.formParams);
}
this.request(Api_Url + '/invoice/create', 'POST', params, true, true).then(res => {
if (res.err_code === 0) {
uni.showToast({
title: '新增发票成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 2000);
} else {
uni.showToast({
title: res.err_msg,
icon: 'none'
});
}
});
},
/**
* 省市区联动监听 * 省市区联动监听
* @param {Object} e * @param {Object} e
*/ */
......
<template> <template>
<view class="page-userAddress-add"> <view class="page-userAddress-add">
<navElement title="编辑发票"></navElement> <navElement title="编辑发票">
<template slot="title-bar">
<view class="delete" @click="deleteInvoice()" style="font-size: 28rpx;color: #1969F9;text-align: right;">删除</view>
</template>
</navElement>
<view class="tab row avarage verCenter"> <view class="tab row avarage verCenter">
<view class="box row rowCenter verCenter" @click="tab(index)" :class="{ curr: index == curr }" :key="index" v-for="(item, index) in text_arr">{{ item }}</view> <view class="box row rowCenter verCenter" @click="tab(index, 1)" :class="{ curr: index == curr }" :key="index" v-for="(item, index) in text_arr">{{ item }}</view>
</view> </view>
<view class="tip row"> <view class="tip row">
<text class="iconfont icon-ts"></text> <text class="iconfont icon-ts"></text>
<view class="text column"> <view class="text column">
<text class="t1">1.自营商品的增值税普通发票,将随货一起快递给您;</text> <template v-if="curr == 0">
<text class="t1">2.默认使用收货地址,您也可以自行修改。</text> <text class="t1">1.自营商品的增值税普通发票,将随货一起快递给您;</text>
<text class="t1">2.默认使用收货地址,您也可以自行修改。</text>
</template>
<template v-else-if="curr == 1">
<text class="t1">1、自营商品单笔订单额大于200元,立即申请开票;单笔订单小于200元,统一每月10号开票;</text>
<text class="t1">2、联营商品月消费额最低满1000元,统一开具发票,如未满1000元,则顺延至下月。</text>
</template>
</view> </view>
</view> </view>
<view class="invoice-form"> <!--增值税普通发票-->
<view class="label-box"><text class="t1">开票信息</text></view> <template v-if="curr == 0">
<view class="tab-type row bothSide verCenter"> <view class="invoice-form">
<view class="box curr row rowCenter verCenter">公司</view> <view class="label-box"><text class="t1">开票信息</text></view>
<view class="box row rowCenter verCenter">个人</view> <view class="tab-type row bothSide verCenter">
</view> <view class="box row rowCenter verCenter" @click="tab(index, 2)" :class="{ curr: index == taxIndex }" :key="index" v-for="(item, index) in taxType">{{ item }}</view>
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">开票公司名称:</text>
</view> </view>
<view><input type="text" placeholder="请输入开票公司名称" class="uni-input" /></view> <!-- 公司 -->
<template v-if="taxIndex == 0">
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">开票公司名称:</text>
</view>
<view><input type="text" placeholder="请输入开票公司名称" class="uni-input" v-model="formParams.tax_title" /></view>
</view>
<view class="input-box" style="margin-bottom: 0;">
<view class="input-label">
<text class="required">*</text>
<text class="tt">税务登记号:</text>
</view>
<view><input type="text" placeholder="请输入税务登记号" class="uni-input" v-model="formParams.tax_no" /></view>
</view>
</template>
<!-- 个人 -->
<template v-else-if="taxIndex == 1">
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">开票人名称:</text>
</view>
<view><input type="text" placeholder="请输入开票人名称" class="uni-input" v-model="formParams.tax_title" /></view>
</view>
</template>
</view> </view>
<view class="input-box" style="margin-bottom: 0;"> </template>
<view class="input-label"> <!--增值税专用发票-->
<text class="required">*</text> <template v-else-if="curr == 1">
<text class="tt">税务登记号:</text> <view class="invoice-form">
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">开票公司名称:</text>
</view>
<view><input type="text" placeholder="请输入开票公司名称" class="uni-input" v-model="formParams.tax_title" /></view>
</view>
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">公司注册地址:</text>
</view>
<view><input type="text" placeholder="请输入注册地址" class="uni-input" v-model="formParams.company_address" /></view>
</view>
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">公司电话:</text>
</view>
<view><input type="text" placeholder="请输入电话号码" class="uni-input" v-model="formParams.company_phone" /></view>
</view>
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">纳税人识别号:</text>
</view>
<view><input type="text" placeholder="请输入纳税人识别号" class="uni-input" v-model="formParams.tax_no" /></view>
</view>
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">开户银行:</text>
</view>
<view><input type="text" placeholder="请输入开户银行" class="uni-input" v-model="formParams.bank_name" /></view>
</view>
<view class="input-box">
<view class="input-label">
<text class="required">*</text>
<text class="tt">银行账号:</text>
</view>
<view><input type="text" placeholder="请输入开户银行账号" class="uni-input" v-model="formParams.bank_account" /></view>
</view> </view>
<view><input type="text" placeholder="请输入税务登记号" class="uni-input" /></view>
</view> </view>
</view> </template>
<view class="setting-default row verCenter bothSide"> <view class="setting-default row verCenter bothSide" style="margin-bottom: 24rpx;">
<text class="tt">设为默认发票</text> <text class="tt">设为默认发票</text>
<view><switch checked style="transform:scale(0.7)" /></view> <view><switch @change="onSwitchChange" :checked="is_default" style="transform:scale(0.7)" /></view>
</view> </view>
<view class="info-title row bothSide verCenter"> <!-- 收票信息 -->
<view class="info-title row bothSide verCenter" @click="toggle = !toggle" v-if="curr == 0">
<text class="info-title-t1">展开收票信息(非必填)</text> <text class="info-title-t1">展开收票信息(非必填)</text>
<text class="iconfont icon-arrtop"></text> <template v-if="toggle">
<text class="iconfont icon-arrtop"></text>
</template>
<template v-else>
<text class="iconfont icon-arrbot"></text>
</template>
</view> </view>
<view class="form-box"> <view class="form-box" v-if="toggle">
<view class="input-box input row verCenter"> <view class="input-box input row verCenter">
<text class="tt">收货</text> <text class="tt" :class="{ required: curr == 1 }">收票</text>
<input type="text" placeholder="请输入收货人" class="uni-input" /> <input type="text" placeholder="请输入收票人" class="uni-input" v-model="formParams.consignee" />
</view> </view>
<view class="input-box input row verCenter"> <view class="input-box input row verCenter">
<text class="tt">手机号码</text> <text class="tt" :class="{ required: curr == 1 }">手机号码</text>
<picker @change="bindPickerChange" :value="index" :range="array" class="intl_code"> <picker @change="bindPickerChange" :value="index" :range="array" class="intl_code">
<view class="row verCenter bothSide"> <view class="row verCenter bothSide">
<view class="uni-input">{{ array[index] }}</view> <view class="uni-input">{{ array[index] }}</view>
<view class="iconfont icon-arrbot"></view> <view class="iconfont icon-arrbot"></view>
</view> </view>
</picker> </picker>
<input type="number" placeholder="请输入手机号" class="uni-input" style="margin-left: 24rpx;" /> <input type="number" placeholder="请输入手机号" class="uni-input" style="margin-left: 24rpx;" v-model="formParams.consignee_phone" />
</view> </view>
<view class="input-box input row verCenter"> <view class="input-box input row verCenter">
<text class="tt">所在地区</text> <text class="tt" :class="{ required: curr == 1 }">所在地区</text>
<picker @change="bindPickerChange" :value="index" :range="array" class="area"> <picker mode="multiSelector" @change="pickerChange" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray" :range-key="'name'">
<view class="row verCenter bothSide"> <view>{{ selectText }}</view>
<view class="uni-input">省、市、区</view>
<view class="iconfont icon-arrbot"></view>
</view>
</picker> </picker>
</view> </view>
<view class="input-box textarea row verCenter"><textarea placeholder="请输入详细街道地址"></textarea></view> <view class="input-box textarea row verCenter"><textarea placeholder="请输入详细街道地址" v-model="formParams.consignee_address"></textarea></view>
</view> </view>
<view class="btn row verCenter"> <view class="btn row verCenter">
<view class="btn1 row rowCenter verCenter"><text class="text">保存</text></view> <view class="btn1 row rowCenter verCenter" @click="invoiceUpdate()"><text class="text">保存修改</text></view>
</view> </view>
</view> </view>
</template> </template>
...@@ -84,22 +159,412 @@ export default { ...@@ -84,22 +159,412 @@ export default {
return { return {
index: 0, index: 0,
array: ['0086', '00886', '00853', '00852'], array: ['0086', '00886', '00853', '00852'],
formParams: {
intl_code: '86'
},
curr: 0, curr: 0,
text_arr: ['增值税普通发票', '增值税专用发票'] text_arr: ['增值税普通发票', '增值税专用发票'],
taxIndex: 0,
taxType: ['公司', '个人'],
toggle: false,
multiArray: [[], [], []], //省市区数据
multiIndex: [0, 0, 0], //选中省市区的索引
selectText: '请选择省市区', //省市区显示文本
is_default: true,
formParams: {
tax_id: '',
inv_type: 4, //发票类型
tax_title: '', //开票公司名称
tax_no: '', //税务登记号
company_address: '', //公司注册地址
company_phone: '', //公司电话
bank_name: '', //开户行
bank_account: '', //开户银行账号
consignee: '', //收票人
consignee_phone: '', //收票手机号
intl_code: '0086',
consignee_province: '', //寄送地址省
consignee_city: '', //寄送地址市
consignee_district: '', //寄送地址区
consignee_address: '', //详细地址
is_default: 1 //设置默认
}
}; };
}, },
onLoad() {}, onLoad(options) {
this.formParams.tax_id = options.tax_id || '';
let inv_type = options.inv_type || '';
if (inv_type == 2) {
this.curr = 0;
this.taxIndex = 1;
} else if (inv_type == 3) {
this.curr = 0;
this.taxIndex = 0;
} else if (inv_type == 4) {
this.curr = 1;
this.taxIndex = 0;
this.toggle = true;
} else {
this.curr = 0;
this.taxIndex = 0;
}
},
onShow() {
this.getData();
},
methods: { methods: {
tab(index) { tab(index, type) {
this.curr = index; if (type == 1) {
this.curr = index;
if (this.curr == 0) {
this.formParams.inv_type = 4;
} else if (this.curr == 1) {
this.formParams.inv_type = 3;
this.toggle = true;
}
} else if (type == 2) {
//增值税普通发票公司-个人切换
this.taxIndex = index;
if (this.taxIndex == 0) {
this.formParams.inv_type = 4;
} else if (this.taxIndex == 1) {
this.formParams.inv_type = 2;
}
}
},
/**
* @param {Object} arr
* @param {Object} target
* @param {Object} type
*/
findIndex(arr, target, type) {
const result = [];
arr.map((item, index) => {
if (type) {
if (item.value == target) {
result.push(index);
}
} else {
if (item == target) {
result.push(index);
}
}
});
return result;
},
/**
* 设置默认监听
* @param {Object} e
*/
onSwitchChange(e) {
this.formParams.is_default = e.detail.value ? 1 : 0;
}, },
bindPickerChange: function(e) { bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value); console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value; this.index = e.detail.value;
this.formParams.intl_code = this.array[e.detail.value]; this.formParams.intl_code = this.array[e.detail.value];
},
/**
* 获取信息
*/
getData() {
this.request(Api_Url + '/invoice/info', 'POST', { tax_id: this.formParams.tax_id }, true, true).then(res => {
if (res.err_code === 0) {
this.formParams.inv_type = res.data.inv_type;
this.formParams.tax_title = res.data.tax_title;
this.formParams.tax_no = res.data.tax_no;
this.formParams.company_address = res.data.company_address;
this.formParams.company_phone = res.data.company_phone;
this.formParams.bank_name = res.data.bank_name;
this.formParams.bank_account = res.data.bank_account;
this.formParams.consignee = res.data.consignee;
this.formParams.consignee_phone = res.data.consignee_phone;
this.formParams.intl_code = res.data.intl_code;
this.formParams.consignee_province = res.data.consignee_province;
this.formParams.consignee_city = res.data.consignee_city;
this.formParams.consignee_district = res.data.consignee_district;
this.formParams.consignee_address = res.data.consignee_address;
this.is_default = res.data.is_default == 1 ? true : false;
this.formParams.is_default = res.data.is_default;
this.selectText = `${res.data.consignee_province_val + ',' + res.data.consignee_city_val + ',' + res.data.consignee_district_val}`;
//收票信息
if (this.formParams.consignee && this.formParams.consignee_phone) {
this.toggle = true;
}
//区号
let index = this.findIndex(this.array, res.data.intl_code);
this.index = index;
//初始化省市区
this.getProvince(1, res.data.consignee_province);
}
});
},
/**
* 删除发票
*/
deleteInvoice() {
uni.showModal({
title: '',
content: '您确定删除该发票嘛',
success: res => {
if (res.confirm) {
this.request(Api_Url + '/invoice/delete', 'POST', { tax_id: this.formParams.tax_id }, true, true).then(res => {
if (res.err_code === 0) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 2000);
} else {
uni.showToast({
title: res.err_msg,
icon: 'none'
});
}
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
/**
* 更新发票
*/
invoiceUpdate() {
if (this.curr == 0) {
if (this.taxIndex == 0) {
//增值税普通发票-公司
if (!this.formParams.tax_title) {
uni.showToast({
title: '请输入开票公司名称',
icon: 'none'
});
return false;
}
if (!this.formParams.tax_no) {
uni.showToast({
title: '请输入税务登记号',
icon: 'none'
});
return false;
}
var params = Object.assign({}, this.formParams, {
is_self: 1
});
} else if (this.taxIndex == 1) {
//增值税普通发票-个人
if (!this.formParams.tax_title) {
uni.showToast({
title: '请输入开票人名称',
icon: 'none'
});
return false;
}
var params = Object.assign({}, this.formParams, {
is_self: 1
});
}
} else {
//增值税专用发票
if (!this.formParams.tax_title) {
uni.showToast({
title: '请输入开票公司名称',
icon: 'none'
});
return false;
}
if (!this.formParams.company_address) {
uni.showToast({
title: '请输入注册地址',
icon: 'none'
});
return false;
}
if (!this.formParams.company_phone) {
uni.showToast({
title: '请输入电话号码',
icon: 'none'
});
return false;
}
if (!this.formParams.tax_no) {
uni.showToast({
title: '请输入纳税人识别号',
icon: 'none'
});
return false;
}
if (!this.formParams.bank_name) {
uni.showToast({
title: '请输入开户银行',
icon: 'none'
});
return false;
}
if (!this.formParams.bank_account) {
uni.showToast({
title: '请输入开户银行账号',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee) {
uni.showToast({
title: '请输入收票人',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee_phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee_province) {
uni.showToast({
title: '请输入省、市、区',
icon: 'none'
});
return false;
}
if (!this.formParams.consignee_address) {
uni.showToast({
title: '请输入详细街道地址',
icon: 'none'
});
return false;
}
var params = Object.assign({}, this.formParams);
}
this.request(Api_Url + '/invoice/update', 'POST', params, true, true).then(res => {
if (res.err_code === 0) {
uni.showToast({
title: '修改发票成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 2000);
} else {
uni.showToast({
title: res.err_msg,
icon: 'none'
});
}
});
},
/**
* 省市区联动监听
* @param {Object} e
*/
bindMultiPickerColumnChange(e) {
console.log(e.detail);
if (e.detail.column === 0) {
// 第一列滑动
this.multiIndex[0] = e.detail.value;
this.getCity(this.multiArray[0][e.detail.value].value, true);
// 第一列滑动之后 第二列 和第三列 都变为第一个
this.multiIndex.splice(1, 1, 0);
this.multiIndex.splice(2, 1, 0);
} else if (e.detail.column === 1) {
// 第二列滑动
this.multiIndex[1] = e.detail.value;
this.getDistrict(this.multiArray[1][e.detail.value].value);
// 第二列滑动之后 第三列 变成第一个
this.multiIndex.splice(2, 1, 0);
} else if (e.detail.column === 2) {
// 第三列滑动
this.multiIndex[2] = e.detail.value;
}
this.$forceUpdate();
},
/**
* 省市区选择确定
* @param {Object} e
*/
pickerChange(e) {
this.multiIndex = e.detail.value;
this.formParams.consignee_province = this.multiArray[0][this.multiIndex[0]].value;
this.formParams.consignee_city = this.multiArray[1][this.multiIndex[1]].value;
this.formParams.consignee_district = this.multiArray[2][this.multiIndex[2]].value;
this.selectText = `${this.multiArray[0][this.multiIndex[0]].name + ',' + this.multiArray[1][this.multiIndex[1]].name + ',' + this.multiArray[2][this.multiIndex[2]].name}`;
},
/**
* 获取省数据
*/
getProvince(id = 1, defaultValue) {
console.log('获取省数据id:' + id);
this.request(Api_Url + '/address/pcd', 'POST', { id: id }, false, true).then(res => {
if (res.err_code === 0) {
var arr = [];
for (var key in res.data) {
arr.push({ name: res.data[key], value: parseInt(key) });
}
this.multiArray[0] = arr;
if (defaultValue) {
let index = this.findIndex(arr, defaultValue, true);
this.multiIndex.splice(0, 1, index[0]);
}
this.getCity(this.formParams.consignee_province, this.formParams.consignee_city);
this.$forceUpdate();
}
});
},
/**
* 获取市数据
* @param {Object} id
* @param {Object} defaultValue
*/
getCity(id, defaultValue) {
console.log('获取市数据id:' + id);
this.request(Api_Url + '/address/pcd', 'POST', { id: id }, false, true).then(res => {
if (res.err_code === 0) {
var arr = [];
for (var key in res.data) {
arr.push({ name: res.data[key], value: parseInt(key) });
}
this.multiArray[1] = arr;
if (defaultValue) {
let index = this.findIndex(arr, defaultValue, true);
this.multiIndex.splice(1, 1, index[0]);
this.getDistrict(this.formParams.consignee_city, this.formParams.consignee_district);
}
this.$forceUpdate();
}
});
},
/**
* 获取区数据
* @param {Object} id
*/
getDistrict(id, defaultValue) {
console.log('获取区数据id:' + id);
this.request(Api_Url + '/address/pcd', 'POST', { id: id }, false, true).then(res => {
if (res.err_code === 0) {
var arr = [];
for (var key in res.data) {
arr.push({ name: res.data[key], value: parseInt(key) });
}
this.multiArray[2] = arr;
if (defaultValue) {
let index = this.findIndex(arr, defaultValue, true);
this.multiIndex.splice(2, 1, index[0]);
}
this.$forceUpdate();
}
});
} }
} }
}; };
......
...@@ -111,7 +111,7 @@ export default { ...@@ -111,7 +111,7 @@ export default {
return result; return result;
}, },
/** /**
* 地址监听 * 省市区联动监听
* @param {Object} e * @param {Object} e
*/ */
bindMultiPickerColumnChange(e) { bindMultiPickerColumnChange(e) {
...@@ -138,7 +138,7 @@ export default { ...@@ -138,7 +138,7 @@ export default {
this.$forceUpdate(); this.$forceUpdate();
}, },
/** /**
* 省市区完成 * 省市区选择确定
* @param {Object} e * @param {Object} e
*/ */
pickerChange(e) { pickerChange(e) {
...@@ -250,6 +250,7 @@ export default { ...@@ -250,6 +250,7 @@ export default {
}); });
}, },
/** /**
* 获取市数据
* @param {Object} id * @param {Object} id
* @param {Object} defaultValue * @param {Object} defaultValue
*/ */
......
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 sign in to comment