invoice-modal.vue 2.11 KB
Newer Older
wangcong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<template>
  <Modal class-name="relate-invoice-modal" v-model="modalVisible" fullscreen title="引用票据" @on-ok="handleOk">
    <InvoiceList :mode="1" @selectionChange="handleSelectionChange" />
  </Modal>
</template>

<script>
import InvoiceList from '../../../../@rbc/invoice/src/components/invoice-list.vue'
export default {
  components: {
    InvoiceList,
  },
  data() {
    return {
      selectedRows: [],
      modalVisible: true,
      bill: null,
      invoiceName: '',
Joey committed
19
      componentName: null,
wangcong committed
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
    }
  },
  methods: {
    handleSelectionChange(rows) {
      this.selectedRows = rows
    },
    handleOk() {
      if (!this.selectedRows) {
        this.$Message.error('请选择数据')
      }
      if (this.selectedRows.some((row) => !row.frontendVerificationStatus)) {
        this.$Message.error('部分数据需先查验成功方可选择')
      }
      for (let i = 0; i < this.selectedRows.length; ++i) {
        const row = this.selectedRows[i]
        let templateName = this.invoiceName.split('.')[1]
        templateName = `${templateName}.res.json`
        GMS.$http.post(
          '/yxgl/getImageAndInvoiceMappingRelation',
          {
            imageId: row.id,
            templateName: templateName,
            yearFlag: row.yearFlag,
          },
        ).then((res) => {
          const arr = res && res.data && res.data.data || []
          arr.forEach((tableMap) => {
            const mapContent = tableMap.content
            const subBillName = tableMap.subBillName
            this.bill.addSubData(subBillName)
            const obj = this.bill.getSubData(subBillName)
            const index = obj.length - 1
            for (let key of Object.keys(mapContent)) {
              const keyVal = mapContent[key]
              obj[index].setValue(key, keyVal)
            }
            this.bill.refreshSubDataRow(subBillName)
          })
58 59 60
          setTimeout(() => {
            this.componentName && GMS.$hideContainer.remove(this.componentName)
          }, 500);
wangcong committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        })
      }
      
    },
  },
}
</script>

<style lang="less">
.relate-invoice-modal {
  .ivu-modal-body {
    padding: 0;
  }
}

</style>