addInvoice.vue 17.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 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
<template>
  <div>
    <div class="box">

      <el-card :body-style="{ padding: '0px' }" class="mt20">
        <div slot="header">
          <div class="bg-lineg">
            <div class="pl-back" @click="goBack">
              <el-icon><ArrowLeftBold /></el-icon> 返回
            </div>
            {{ language == 0 ? '发票开具' : 'Invoice application' }}</div>
        </div>
        <el-row class="pd20" :gutter="20">
          <el-col :span="24">
            <!--已选订单-->
            <div v-if="orderType!=6" class="border-info" v-for="b in list" :key="b.id">
              <label class="blueTag" v-if="orderType == 0"> {{ language==0?'酒店订单':'HOTEL' }}</label>
              <label class="orangeTag" v-if="b.orderType == 1"> {{ language==0?'车辆订单':'TRANSPORTATION' }}</label>
              <label class="purpleTag" v-if="b.orderType == 2"> {{ language==0?'餐饮订单':'DINING' }}</label>
              <label class="pinkTag" v-if="b.orderType == 3"> {{ language==0?'化妆订单':'MakeUp' }}</label>
              <label class="yellowTag" v-if="b.orderType == 4"> {{ language==0?'拍摄订单':'Shooting'}}</label>
              <label class="yellowTag" v-if="!b.orderType&&orderType==5">{{ language==0?'赛事报名':'REGISTRATION' }}</label>
              <h3 v-if="b.name">{{ b.name }}</h3>
              <h3 v-if="b.cptName">{{ b.cptName }}</h3>

              <div v-if="!b.orderType&&orderType==5">
                <p v-if="b.groupName">{{ language==0?'团队名称':'Team name' }}{{b.groupName}}</p>
                <p v-if="b.payTime">{{ language==0?'支付时间':'Payment time' }}{{b.payTime}}</p>
                <p class="poPrice" v-if="b.totalPayAmount">{{paymentType!=2?'¥':'€'}} {{b.totalPayAmount}}</p>
              </div>
<!--              酒店订单-->
              <div v-if="b.orderType == 0">
                <p>{{b.messageObj.roomInfo}}</p>
                <p>{{b.messageObj.roomStayDate}}</p>
                <p class="poPrice" v-if="b.totalStr">{{ b.paymentType==3?'€' :'¥' }}{{b.totalStr}}</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" v-if="b.total">{{ b.paymentType==3?'€' :'¥' }}{{b.totalStr}}</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" v-if="b.total">{{ b.paymentType==3?'€' :'¥' }}{{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" v-if="b.total">{{ b.paymentType==3?'€' :'¥' }}{{b.totalStr}}</p>
              </div>
            </div>

            <div class="border-info" v-if="orderType==6">
              <label class="blueTag" >{{language==0?'票务订单':'Ticket'}}</label>
              <h3>{{ formDate.name }}</h3>
              <div>
                <p>地点:{{formDate.placeName}}</p>
                <p>单价:{{paymentType!=2?'¥':'€'}}{{formDate.singlePrice}}</p>
                <p>数量:{{formDate.seatList?.length}}</p>
                <p class="poPrice">{{paymentType!=2?'¥':'€'}}{{formDate.payAmount}}</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="language == 0 ?'开票金额':'Amount'">
                  <span  v-if="orderType==5||orderType==6" class="bigprice">{{paymentType!=2?'¥':'€'}}{{totalMoney}}</span>
                  <span v-else class="bigprice">{{paymentType!=3?'¥':'€'}}{{totalMoney}}</span>
                </el-form-item>

                <el-form-item :label="language == 0 ?`发票形式`:'Invoice Form'" 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-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="language == 0 ?`发票类型`:'Invoice Type'" 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="language == 0 ?`发票抬头`:'Invoice Title'" required prop="invoiceTitle">
                  <el-input v-model="form.invoiceTitle"/>
                </el-form-item>
                <el-form-item :label="language == 0 ?`税号`:'Duty Paragraph'" required v-if="form.invoiceType=='0'" prop="invoiceTfn">
                  <el-input v-model="form.invoiceTfn"/>
                </el-form-item>
                <el-form-item :label="`邮箱`" v-if="form.invoiceForm=='1'" required prop="invoiceEmail">
                  <el-input v-model="form.invoiceEmail"/>
                </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" v-if="remark">
                <label>{{ language == 0 ?'开票须知':'Invoice Notice' }}:</label>
                <div v-html="remark"></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 {submitTitckInvoice, invoice, TitckUpdateInvoice} from '@/viewsPc/seat/api/index'
import {
  addressList,
  editInvoice,
  editInvoiceMatch,
  submitInvoice,
  getInvoiceDetailBills,
  getInvoiceDetail,
  submitCptInvoice, getBaseInfoByActiveId, getLeagueInvoiceDetail, getLeagueInvoiceDetailPC,getInvoiceDetailMatch
} from "@/apiPc/booking";
import {getOrderDetail} from "@/viewsPc/seat/api/index";


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 formDate = ref({})
const orderType=ref(1)
const paymentType=ref(1)
const list = ref([])
const addrList = ref([])
const nowAddress = ref({})
const totalMoney = ref(0)
const kpType = ref('1')
const remark = ref('')
const rules = ref({
  invoiceType: [
    {required: true, message: language.value==0?'请选择发票类型':'Please select invoice type', trigger: 'change'}
  ],
  invoiceEmail: [
    {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
let cptId


onMounted(() => {
  orderType.value=route.query.orderType
  paymentType.value=route.query.paymentType
  if(route.query.orders){
    let obj = JSON.parse(decodeURIComponent(route.query.orders)) || {}
    if(obj.cptId){
      cptId = obj.cptId
    }else if(obj.activeId){
      cptId = obj.activeId
    }else{
      cptId = '1778253367748993026'
    }

    console.log(obj)
    getRemark()
    let arr = []
    list.value.push(obj)
    for (let bill of list.value) {
      if(bill?.message){
        bill.messageObj = JSON.parse(bill.message)
      }
      arr.push(bill.id)
    }
    form.value.orders = arr.toString()
    console.log(list.value)
  }
  if(route.query.activeId){
    cptId = 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
  }
  route.query.orderSn&&getDataInfo()
})

async function getDataInfo(){
  const res =await getOrderDetail({orderSn:route.query.orderSn})
  formDate.value=res.data
}

function getList() {
  if(route.query.type=='5'){
    getLeagueInvoiceDetailPC(invoiceId).then(res => {
      // 订单
      list.value = res.rows
      console.log(list.value)
      cptId = res.rows[0].activeId||res.rows[0].cptId
      getRemark()
      for (var bill of list.value) {
        if (bill.messageObj)bill.messageObj = JSON.parse(bill.message)
      }
    });
  } else {
    getInvoiceDetailBills(invoiceId).then(res => {
      // 订单
      list.value = res.rows;
      cptId = res.rows[0].activeId||res.rows[0].cptId
      getRemark()
      for (var bill of list.value) {
        bill.messageObj = JSON.parse(bill.message)
      }
    });
  }

  // 回显
  if (orderType.value==6){
    invoice(invoiceId).then(res=>{
      // console.log(res)
      form.value = res.data;
      form.value.invoiceForm='1'
      totalMoney.value = form.value.total
    })
  }else if(orderType.value==5){
    getInvoiceDetailMatch(invoiceId).then(res => {
      form.value = res.data;
      totalMoney.value = form.value.total
      // if (form.value.invoiceForm == '1') {
      //   email.value = form.value.address
      // }
      // getAddrList()
    });
  }else{
    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 getRemark() {
  getBaseInfoByActiveId(cptId).then(res=>{
     if(res.data){
       // remark.value = res.data.remarks
       remark.value = res.data.remarks.replace(/\n/g, '<br>')
     }
  })
}
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){
        // 提交确认
        ElMessageBox.confirm(language.value == 0 ? '确认提交吗?' : 'Confirm to submit ?', {
          confirmButtonText: language.value == 0 ? '确定' : 'Confirm',
          cancelButtonText: language.value == 0 ? '取消' : 'Cancel',
          type: 'warning'
        }).then(() => {
          form.value.activeId =  cptId
          form.value.total = totalMoney.value
          form.value.version = 2
          form.value.invoicePhone=paymentType.value
          if (isEdit.value) {
            update()
          } else {
            add()
          }
        })
      }
  })
}

function update() {
  if (orderType.value==6){
    TitckUpdateInvoice(form.value).then(res=>{
      //返回列表
      backList()
    })
  }else if(orderType.value==5){
    editInvoiceMatch(form.value).then(res=>{
      //返回列表
      backList()
    })
  }else{
    editInvoice(form.value).then(res=>{
      //返回列表
      backList()
    })
  }

}
function add() {
  if(orderType.value==6){
    submitTitckInvoice(form.value).then((res)=>{
      backList()
    })
  }else if(list.value[0].orderType||list.value[0].orderType==0){
    submitInvoice(form.value).then(res=>{
      //返回列表
      backList()
    })
  } else {
    submitCptInvoice(form.value).then(res=>{
      //返回列表
      backList()
    })
  }


}
function backList() {
  router.push({
    // name: 'invoice'
    name: 'myKP'
  })
}
function goBack() {
  router.go(-1)
}
</script>

<style scoped lang="scss">
.pl-back{position: absolute;padding: 0 15px;display: flex;align-items: center;cursor: pointer}
.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>