<template>
  <ele-modal
    custom-class="ele-dialog-form long-dialog-form"
    :centered="true"
    :visible.sync="accountInfoDialogFlag"
    title="对账信息"
    append-to-body
    :close-on-click-modal="false"
    width="85%"
    :before-close="cancel">
    <!-- 销售对账单信息   -->
    <saleAccountTable v-if="accountType==1" ref="inventoryTableref"
                      :datasource.sync="datasource"
                      dialogType="view" @getAccountInfo="getAccountInfo"></saleAccountTable>
    <!-- 采购对账单信息   -->
    <purchasingAccountTable v-else ref="inventoryTableref" :datasource.sync="datasource"
                            dialogType="view" @getAccountInfo="getAccountInfo"></purchasingAccountTable>
  </ele-modal>
</template>

<script>
import purchasingAccountTable from "./purchasingAccountTable.vue";
import saleAccountTable from "./saleAccountTable.vue";
import {infoAccountStatementAPI} from "@/api/saleManage/accountstatement";

export default {
  name: "accountInfoDialog",
  components: {
    purchasingAccountTable,
    saleAccountTable
  },
  props: {
    accountInfoDialogFlag: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      datasource: [],
      accountType: ''
    }
  },
  methods: {
    //从发票管理新增发票初始化
    async init(row) {
      this.accountType = row.type
      const data = await infoAccountStatementAPI(row.id)
      this.datasource = data.orderList
    },
    //从其他来源新增发票初始化
    createInvoice(row,dialogType,sourceType) {
      console.log(row.type);
      this.init(row)
    },
    getAccountInfo(row) {
      this.$emit('getAccountInfo', row)
      this.cancel()
    },
    cancel() {
      this.$emit("update:accountInfoDialogFlag", false);
    }
  }
}
</script>


<style scoped lang="scss">

</style>
