You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong_qianduan/pages/invoice/editset.vue

578 lines
12 KiB

<template>
<view class="invoice">
<view class="invoice-info">
<view class="b">
<view class="item">
<view class="l">发票类型</view>
<view class="r">
7 months ago
<picker :value="arrayIndex" :range="array" @change="bindPickerChange">
<view class="lx" style="color: #888;" v-if="!arrayName">请选择发票类型</view>
<view class="lx" v-else>{{arrayName}}</view>
</picker>
</view>
</view>
<view class="item">
<view class="l">发票类型</view>
<view class="r">
<view class="li" :class="tabIndex == 1 ? 'li-on' : ''" @click="tabItem(1)">个人</view>
<view class="li" :class="tabIndex == 2 ? 'li-on' : ''" @click="tabItem(2)">单位</view>
</view>
</view>
9 months ago
<view class="item">
9 months ago
<view class="l">发票抬头</view>
<view class="r">
9 months ago
<input type="text" v-model="obj.header" :placeholder="tabIndex == 2 ? '请输入单位名称' : '请输入个人姓名'" />
</view>
</view>
<view class="item" v-if="tabIndex == 2">
<view class="l">单位税号</view>
<view class="r">
<input type="text" v-model="obj.duty_no" placeholder="请输入纳税人识别号" />
</view>
</view>
</view>
</view>
<view class="invoice-company" v-if="tabIndex == 2">
<view class="a">选填内容开户银行银行账号等
<text :class="toggleIndex ? 'on' : ''" @click="toggleItem()">{{ toggleIndex ? "收起" : "展开" }}</text>
</view>
<view class="b" v-if="toggleIndex">
<view class="item">
<view class="l">开户银行</view>
<view class="r">
<input type="text" v-model="obj.bank_name" placeholder="请输入开户银行名称" />
</view>
</view>
<view class="item">
<view class="l">银行账号</view>
<view class="r">
<input type="number" v-model="obj.bank_no" placeholder="请输入银行账号" />
</view>
</view>
<view class="item">
<view class="l">单位地址</view>
<view class="r">
<input type="text" v-model="obj.address" placeholder="请输入单位地址" />
</view>
</view>
<view class="item">
<view class="l">单位电话</view>
<view class="r">
<input type="number" v-model="obj.phone" placeholder="请输入单位电话" />
</view>
</view>
</view>
</view>
<view class="invoice-btn">
9 months ago
<view class="invoice-fd" @click="onSubmit()">
提交
</view>
</view>
</view>
</template>
<script>
7 months ago
import * as InvoiceApi from '@/api/invoice'
export default {
data() {
return {
id: '',
content: "确认您的发票信息无误后再提交",
show: true,
toggleIndex: true,
7 months ago
arrayIndex: 0,
arrayName: '',
7 months ago
array: ['普通增值税发票'],
tabIndex: 1,
sourcePage: 0,
orderDetail: '',
orderId: '',
obj: {
header: '',
duty_no: '',
bank_name: '',
bank_no: '',
address: '',
phone: '',
type: 1,
source: ''
}
7 months ago
};
9 months ago
},
7 months ago
onLoad(op) {
if (op.detailObj && op.detailObj != 'null') {
let end = JSON.parse(op.detailObj)
7 months ago
this.arrayIndex = end.type - 1;
this.arrayName = this.array[this.arrayIndex]
7 months ago
if (end.source == 1) {
7 months ago
this.tabIndex = end.source
7 months ago
} else {
this.tabIndex = 2
}
this.obj = end
}
7 months ago
9 months ago
},
7 months ago
methods: {
//添加发票
onSubmit() {
if (this.obj.id) {
this.editeInvoice()
} else {
this.addInvoice()
}
},
async addInvoice(canReset = false) {
const app = this
7 months ago
if (!app.arrayName) {
7 months ago
uni.showToast({
title: '请选择发票类型',
icon: 'none',
duration: 2000
})
return
}
if (!app.obj.header) {
uni.showToast({
title: '请输入抬头',
icon: 'none',
duration: 2000
})
return
}
if (app.tabIndex == 2 && !app.obj.duty_no) {
uni.showToast({
title: '请输入纳税人识别号',
icon: 'none',
duration: 2000
})
return
}
let {
status,
data
} = await InvoiceApi.addInvoicing(app.obj);
if (status == 200) {
uni.showToast({
title: '新增成功!',
icon: 'none',
duration: 2000
})
7 months ago
app.arrayIndex = 0
7 months ago
app.tabIndex = 1
app.obj = app.$options.data().obj;
uni.redirectTo({
url: "/pages/invoice/index"
})
}
},
async editeInvoice() {
const app = this
7 months ago
if (!app.arrayName) {
7 months ago
uni.showToast({
title: '请选择发票类型',
icon: 'none',
duration: 2000
})
return
}
if (!app.obj.header) {
uni.showToast({
title: '请输入抬头',
icon: 'none',
duration: 2000
})
return
}
if (app.tabIndex == 2 && !app.obj.duty_no) {
uni.showToast({
7 months ago
title: '请输入纳税人识别号',
7 months ago
icon: 'none',
duration: 2000
})
return
}
let {
status,
data
} = await InvoiceApi.editInvoicing(app.obj);
if (status == 200) {
uni.showToast({
title: '编辑成功!',
icon: 'none',
duration: 2000
})
7 months ago
app.arrayIndex = 0
7 months ago
app.tabIndex = 1
app.obj = app.$options.data().obj;
uni.redirectTo({
url: "/pages/invoice/index"
})
}
},
// 复制指定内容
handleCopy(value) {
const app = this
uni.setClipboardData({
data: value,
success: () => app.$toast('复制成功'),
fail: ({
errMsg
}) => app.$toast('复制失败 ' + errMsg)
9 months ago
})
7 months ago
},
// 提交信息
handleInvoice() {
const app = this
},
onClose() {},
tabItem(i) {
this.tabIndex = i;
this.obj.source = i
},
toggleItem(i) {
this.toggleIndex = !this.toggleIndex;
},
bindPickerChange(e) {
7 months ago
this.arrayIndex = e.detail.value;
this.arrayName = this.array[e.detail.value]
7 months ago
},
bindPickerChange1() {
uni.navigateTo({
url: "/pages/invoice/index"
9 months ago
})
}
}
}
</script>
<style lang="scss" scoped>
7 months ago
.invoice-btn {
width: 100%;
position: fixed;
bottom: 0;
left: 0;
padding: 30rpx 44rpx;
z-index: 8;
background: #fafafa;
}
7 months ago
.invoice-company {
margin-bottom: 170rpx;
}
7 months ago
.invoice {
padding-bottom: 1rpx;
7 months ago
&-goods {
padding: 0 20rpx 0 40rpx;
overflow: hidden;
background-color: #fff;
padding: 30rpx;
box-sizing: border-box;
display: flex;
align-items: center;
7 months ago
.a {
width: 145rpx;
height: 135rpx;
margin-right: 20rpx;
image {
width: 100%;
height: 100%;
border-radius: 10rpx;
}
}
7 months ago
.b {
flex: 1;
overflow: hidden;
7 months ago
.l {
white-space: nowrap;
text-overflow: ellipsis;
font-size: 32rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
color: #262626;
overflow: hidden;
}
.r {
font-size: 30rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #838383;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
text {
display: block;
width: 104rpx;
line-height: 60rpx;
background: #FFFFFF;
border-radius: 4rpx;
text-align: center;
border: 1px solid #CACACA;
font-size: 28rpx;
color: #555;
}
}
}
}
7 months ago
&-info {
margin-top: 20rpx;
background-color: #fff;
overflow: hidden;
7 months ago
.a {
display: flex;
align-items: center;
justify-content: space-between;
7 months ago
padding: 20rpx 30rpx 20rpx 60rpx;
box-sizing: border-box;
7 months ago
border-bottom: 1px solid #F3F3F3;
font-size: 32rpx;
font-weight: 500;
color: #262626;
7 months ago
text {
color: #006AFF;
padding-right: 40rpx;
position: relative;
7 months ago
&::after {
content: "";
width: 16rpx;
height: 16rpx;
border-top: 1px solid #006AFF;
border-left: 1px solid #006AFF;
position: absolute;
right: 0;
top: 14rpx;
z-index: 1;
transform: rotate(135deg);
}
}
7 months ago
}
7 months ago
.b {
padding: 0 30rpx 0 45rpx;
box-sizing: border-box;
overflow: hidden;
.item {
padding: 30rpx 0;
display: flex;
align-items: center;
7 months ago
justify-content: space-between;
box-sizing: border-box;
border-top: 1px solid #F3F3F3;
font-size: 32rpx;
7 months ago
font-weight: 500;
color: #262626;
7 months ago
overflow: hidden;
7 months ago
&:first-child {
border-top-color: #fff;
}
7 months ago
.l {
width: 180rpx;
font-size: 32rpx;
font-weight: 400;
color: #656565;
}
7 months ago
.r {
flex: 1;
7 months ago
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: 400;
color: #262626;
7 months ago
.li {
width: 150rpx;
height: 78rpx;
background: #F3F3F3;
border-radius: 8rpx;
text-align: center;
line-height: 78rpx;
font-size: 32rpx;
font-weight: 400;
color: #262626;
margin-right: 12rpx;
&-on {
background: #FDF4F4;
background: url(/static/invoice/select-active.png) center top no-repeat;
background-size: contain;
}
}
7 months ago
input {
flex: 1;
}
picker {
flex: 1;
.tt {
width: 180rpx;
position: relative;
color: #4894FF;
text-align: right;
&::after {
content: "";
width: 16rpx;
height: 16rpx;
border-top: 1px solid #4894FF;
border-left: 1px solid #4894FF;
position: absolute;
right: -50rpx;
top: 14rpx;
z-index: 1;
transform: rotate(135deg);
}
}
.lx {
width: 100%;
position: relative;
&::after {
content: "";
width: 16rpx;
height: 16rpx;
border-top: 1px solid #B8B8B8;
border-left: 1px solid #B8B8B8;
position: absolute;
right: 20rpx;
top: 14rpx;
z-index: 1;
transform: rotate(135deg);
}
}
}
}
}
7 months ago
}
}
7 months ago
&-fd {
height: 104rpx;
background: #F55349;
border-radius: 8rpx;
font-size: 32rpx;
7 months ago
font-weight: 500;
color: #FFFFFF;
display: flex;
align-items: center;
7 months ago
justify-content: center;
}
&-company {
overflow: hidden;
.a {
padding: 35rpx 50rpx;
font-size: 32rpx;
font-weight: 400;
display: flex;
align-items: center;
justify-content: space-between;
color: #262626;
text {
width: 70rpx;
color: #888888;
margin-right: 30rpx;
position: relative;
&::after {
content: "";
width: 16rpx;
height: 16rpx;
border-top: 1px solid #888888;
border-left: 1px solid #888888;
position: absolute;
right: -30rpx;
7 months ago
top: 10rpx;
z-index: 1;
7 months ago
transform: rotate(225deg);
}
&.on {
&::after {
content: "";
width: 16rpx;
height: 16rpx;
border-top: 1px solid #888888;
border-left: 1px solid #888888;
position: absolute;
right: -30rpx;
top: 20rpx;
z-index: 1;
transform: rotate(45deg);
}
}
}
}
7 months ago
.b {
padding: 0 30rpx 0 45rpx;
box-sizing: border-box;
7 months ago
background-color: #fff;
overflow: hidden;
7 months ago
.item {
padding: 30rpx 0;
display: flex;
align-items: center;
7 months ago
justify-content: space-between;
box-sizing: border-box;
border-top: 1px solid #F3F3F3;
font-size: 32rpx;
7 months ago
font-weight: 500;
color: #262626;
7 months ago
overflow: hidden;
7 months ago
&:first-child {
border-top-color: #fff;
}
.l {
width: 180rpx;
font-size: 32rpx;
font-weight: 400;
color: #656565;
}
.r {
flex: 1;
7 months ago
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: 400;
color: #262626;
input {
flex: 1;
}
}
}
7 months ago
}
}
}
7 months ago
</style>