addInvoice.vue
13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<template>
<div>
<div class="box">
<el-card :body-style="{ padding: '0px' }" class="mt20">
<div slot="header">
<div class="bg-lineg">{{ language == 0 ? '发票开具' : 'Invoice application' }}</div>
</div>
<el-row class="pd20" :gutter="20">
<el-col :span="24">
<!--已选订单-->
<div class="border-info" v-for="b in list" :key="b.id">
<label class="blueTag" v-if="b.orderType == 0"> 酒店订单</label>
<label class="orangeTag" v-if="b.orderType == 1"> 接送订单</label>
<label class="purpleTag" v-if="b.orderType == 2"> 餐饮订单</label>
<label class="pinkTag" v-if="b.orderType == 3">化妆订单</label>
<label class="yellowTag" v-if="b.orderType == 4">拍照订单</label>
<h3>{{ b.name }}</h3>
<!-- 酒店订单-->
<div v-if="b.orderType == 0">
<p>{{b.messageObj.roomInfo}}</p>
<p>{{b.messageObj.roomStayDate}}</p>
<p class="poPrice">¥{{b.total}}</p>
</div>
<!-- 接送订单-->
<div v-if="b.orderType == 1">
<p v-for="(car,index) in b.messageObj.carsList" :key="index" v-show="car.num>0">
<span>{{car.name}}:{{car.num}} 辆</span>
</p>
<p class="poPrice">¥{{b.total}}</p>
</div>
<!-- 餐饮订单-->
<div v-if="b.orderType == 2">
<p v-for="(n,index) in b.messageObj.foodsList" :key="index">
<span v-if="n.num > 0">
{{n.name}}({{n.categoryName}}) <span>{{n.num}} 份</span>
</span>
</p>
<p class="poPrice">¥{{b.total}}</p>
</div>
<div v-if="b.orderType == 3 || b.orderType == 4">
<div>
{{language==0?'套餐名称:':''}}{{b.messageObj.packageName}}
</div>
<div>
{{language==0?'预约时间:':''}}{{b.deliveryTime.slice(0,10)}} {{b.messageObj.timePeriod}}
</div>
<p class="poPrice">¥{{b.total}}</p>
</div>
</div>
<div class="leftboderTT">{{ language == 0 ? '开票信息' : 'Invoice information' }}</div>
<div class="border-rr mt20 pd20">
<el-form class="mw500" :model="form" :label-width="language == 0 ?'100':'150'" :rules="rules" ref="formRef">
<el-form-item :label="'开票金额'">
<span class="bigprice">¥{{totalMoney}}</span>
</el-form-item>
<el-form-item :label="`发票形式`" required prop="invoiceForm">
<el-radio-group v-model="form.invoiceForm">
<el-radio value="1">{{ language == 0 ? '电子发票' : 'E-invoice' }}</el-radio>
<!-- <el-radio value="2" v-if="kpType.indexOf('2')!=-1">{{ language == 0 ? '纸质普票' : 'Paper-invoice' }}</el-radio>-->
<!-- <el-radio value="3" v-if="kpType.indexOf('3')!=-1">{{ language == 0 ? '纸质专票' : 'Paper-special-invoice' }}</el-radio>-->
</el-radio-group>
</el-form-item>
<!-- <el-form-item :label="`邮箱`" v-if="form.invoiceForm=='1'" required prop="address">-->
<!-- <el-input v-model="form.address"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item :label="`邮寄地址`" v-else required>-->
<!-- <el-button plain type="primary" size="small" v-if="addrList.length==0" @click="goEditAddress">-->
<!-- +{{ language==0?'添加地址':'Add' }}-->
<!-- </el-button>-->
<!-- <div v-else class="flexCenter">-->
<!-- <div>-->
<!-- <div class="bigSize">{{nowAddress.contact}} {{nowAddress.phone}}</div>-->
<!-- <div class="smallSize">{{nowAddress.addName}}</div>-->
<!-- </div>-->
<!-- <a @click="goEditAddress" class="text-primary">-->
<!-- <el-icon><Switch /></el-icon>切换-->
<!-- </a>-->
<!-- </div>-->
<!-- </el-form-item>-->
<el-form-item :label="`发票类型`" required prop="invoiceType">
<el-radio-group v-model="form.invoiceType">
<el-radio value="0">{{ language == 0 ? '企业' : 'Company' }}</el-radio>
<el-radio value="1">{{ language == 0 ? '个人非企业' : 'Individual' }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="`发票抬头`" required prop="invoiceTitle">
<el-input v-model="form.invoiceTitle"/>
</el-form-item>
<el-form-item :label="`税号`" required v-if="form.invoiceType=='0'" prop="invoiceTfn">
<el-input v-model="form.invoiceTfn"/>
</el-form-item>
<div v-if="form.invoiceForm=='3'&&form.invoiceType=='0'">
<el-form-item :label="`地址`" required prop="invoiceAddress">
<el-input v-model="form.invoiceAddress"/>
</el-form-item>
<el-form-item :label="`电话`" required prop="invoicePhone">
<el-input v-model="form.invoicePhone"/>
</el-form-item>
<el-form-item :label="`开户行`" required prop="invoiceBank">
<el-input v-model="form.invoiceBank"/>
</el-form-item>
<el-form-item :label="`账户`" required prop="invoiceAccount">
<el-input v-model="form.invoiceAccount"/>
</el-form-item>
</div>
</el-form>
<div class="tip">
<label>开票须知:</label>
<div>
1.发票开具时间:提交后后,开票时间为开票日起7天(含7天)内;<br/>
2.开具发票后,发票金额不得修改;<br/>
3.未开具发票前,可修改修改公司抬头/税号;<br/>
4.未开票成功,请及时联系客服处理;<br/>
5.发票开具后,将发送至当前登录账号邮箱;
</div>
</div>
</div>
</el-col>
</el-row>
<el-row justify="center" align="middle" class="pd20">
<el-col :span="12" class="text-center">
<el-button type="primary" class="btn-lineG w200px" size="large" round @click="submit">
{{ language==0?'提交':'Submit' }}
</el-button>
</el-col>
</el-row>
</el-card>
<div style="height: 60px;"></div>
</div>
</div>
<address-list-dialog ref="dialogAddressListRef" @submit="getAddress"/>
<!-- 开票须知 -->
</template>
<script setup>
import {useRouter, useRoute} from "vue-router";
import {ref, reactive, onMounted} from "vue";
import {useStorage} from "@vueuse/core/index";
import AddressListDialog from "./component/addressList"
import dayjs from 'dayjs'
import {ElMessage,ElMessageBox} from "element-plus";
import useUserStore from "@/store/modules/user";
import {getCurrentInstance} from "@vue/runtime-core";
import {addressList, editInvoice, submitInvoice,getInvoiceDetailBills,getInvoiceDetail} from "@/apiPc/booking";
const {proxy} = getCurrentInstance()
const user = useUserStore().user
const language = useStorage('language', 0)
const router = useRouter()
const route = useRoute()
const form = ref({
invoiceForm: '1',
invoiceType: '0'
})
const list = ref([])
const addrList = ref([])
const nowAddress = ref({})
const totalMoney = ref(0)
const kpType = ref('1')
const rules = ref({
invoiceType: [
{required: true, message: language.value==0?'请选择发票类型':'Please select invoice type', trigger: 'change'}
],
address: [
{required: true, message: language.value==0?'请输入邮箱':'Please enter email', trigger: 'blur'}
],
invoiceForm: [
{required: true, message: language.value==0?'请选择发票形式':'Please select invoice form', trigger: 'change'}
],
invoiceTitle: [
{required: true, message: language.value==0?'请输入发票抬头':'Please enter invoice title', trigger: 'blur'}
],
invoiceTfn: [
{required: true, message: language.value==0?'请输入税号':'Please enter TFN', trigger: 'blur'}
],
invoiceAddress: [
{required: true, message: language.value==0?'请输入地址':'Please enter address', trigger: 'blur'}
],
invoicePhone: [
{required: true, message: language.value==0?'请输入电话':'Please enter phone', trigger: 'blur'}
],
invoiceBank: [
{required: true, message: language.value==0?'请输入开户行':'Please enter bank', trigger: 'blur'}
],
invoiceAccount: [
{required: true, message: language.value==0?'请输入账户':'Please enter account', trigger: 'blur'}
],
})
const isEdit = ref(false)
let invoiceId
onMounted(() => {
if(route.query.orders){
let obj = JSON.parse(decodeURIComponent(route.query.orders)) || []
let arr = []
list.value.push(obj)
for (var bill of list.value) {
bill.messageObj = JSON.parse(bill.message)
arr.push(bill.id)
}
form.value.orders = arr.toString()
}
if(route.query.activeId){
form.value.activeId = route.query.activeId
}
if (route.query.totalMoney) {
totalMoney.value = route.query.totalMoney
form.value.total = totalMoney.value
}
// if(route.query.kpType){
// kpType.value = route.query.kpType
// if(kpType.value.indexOf('2')>-1 || kpType.value.indexOf('3')>-1){
// getAddrList()
// }
// } else {
// kpType.value = '1'
// }
if (route.query.isEdit) {
isEdit.value = route.query.isEdit
invoiceId = route.query.invoiceId
getList()
}
if(user.userName.indexOf('@')>-1){
form.value.address = user.userName
}
})
function getList() {
getInvoiceDetailBills(invoiceId).then(res => {
// 订单
list.value = res.rows;
for (var bill of list.value) {
bill.messageObj = JSON.parse(bill.message)
}
});
getInvoiceDetail(invoiceId).then(res => {
form.value = res.data;
totalMoney.value = form.value.total
// if (form.value.invoiceForm == '1') {
// email.value = form.value.address
// }
getAddrList()
});
}
function goEditAddress(id) {
var obj = {
title: language.value==0?'地址列表':'Address list',
show: true,
id: id
}
proxy.$refs['dialogAddressListRef'].open(obj)
}
function getAddrList() {
addressList(user.userId).then(res=>{
addrList.value = res.rows
if(addrList.value.length>0){
nowAddress.value = addrList.value[0]
}
})
}
function getAddress(obj) {
getAddrList()
nowAddress.value = obj
}
function submit() {
proxy.$refs['formRef'].validate((valid) => {
if(valid){
// if((kpType.value.indexOf('2')>-1 || kpType.value.indexOf('3')>-1)&&!nowAddress.value){
// ElMessage({
// message: language.value==0?'请选择邮寄地址':'Please select address',
// type: 'warning',
// duration: 2000
// })
// return
// }
// 提交确认
ElMessageBox.confirm(language.value == 0 ? '确认提交吗?' : 'Confirm to submit ?', {
confirmButtonText: language.value == 0 ? '确定' : 'Confirm',
cancelButtonText: language.value == 0 ? '取消' : 'Cancel',
type: 'warning'
}).then(() => {
form.value.total = totalMoney.value
form.value.version = 2
if (isEdit.value) {
update()
} else {
add()
}
})
}
})
}
function update() {
editInvoice(form.value).then(res=>{
//返回列表
backList()
})
}
function add() {
submitInvoice(form.value).then(res=>{
//返回列表
backList()
})
}
function backList() {
router.push({
// name: 'invoice'
name: 'myKP'
})
}
</script>
<style scoped lang="scss">
.bigMoney {
font-size: 36px !important;
font-family: 'DIN Alternate';
font-weight: bold;
}
.btn-lineG{font-size: 16px}
.bg-lineg {
height: 40px;
line-height: 40px;
font-size: 18px;
text-align: center;
}
.border-info{position: relative;
&>label{position: absolute;right: 0;top: 0;margin: 0;border-radius: 0 0 0px 15px;
padding: 5px 15px;font-size: 14px;
}
.poPrice{position: absolute;bottom: 0px;right: 10px;font-size: 24px;
line-height: 1;font-family: "DIN Alternate"}
}
.blueTag {
color: #fff;
background-color: #1EC886;
}
.purpleTag {
color: #fff;
background-color: #717bef;
}
.orangeTag {
color: #fff;
background-color: #ff8124;
}
.pinkTag {
color: #fff;
background-color: #f55497;
}
.yellowTag {
color: #fff;
background-color: #bad814;
}
.leftboderTT {
font-weight: 600;
font-size: 16px;
color: #453DEA;
}
.border-rr {
border-radius: 5px;
border: 1px solid #DCDFE6;
}
.room {
font-weight: 400;
font-size: 14px;
color: #929AA0;
}
.ccitemBox {
overflow: auto;
label {
margin: 10px 0;
display: block;
min-height: 30px;
span {
color: #FF8124;
font-family: DIN Alternate;
font-size: 24px;
}
}
}
.ccitem {
display: flex;
justify-content: space-between;
font-size: 15px;
color: #666;
margin: 5px 0 10px;
label {
font-size: 16px;
color: #000;
}
span {
font-size: 13px;
}
}
.red {
color: #FF8124;
}
.tip{font-size: 14px;color: #666;padding: 0 10px;}
.mw500{max-width: 500px;margin: auto}
.bigSize {
font-size: 16px;
margin-bottom: 5px;
}
.smallSize {
font-size: 14px;
color: #999;
}
.flexCenter {
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
background: #f4f4f4;
padding: 10px;
box-sizing: border-box;
}
.bigprice {
font-size: 26px;
line-height: 1;font-family: "DIN Alternate";
}
</style>