<template>
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      draggable
      width="1000px"
      append-to-body
      height="500px"
      @close="close"
      @keyup.enter.native="getBilling"
      v-model="visibleChoose">
      <div style="height: calc(100%);">
        <el-form :inline="true" class="query-form" ref="searchForm" :model="searchForm" @submit.native.prevent>
          <!-- 搜索框-->
          <el-form-item label="公司名称" prop="companyName">
            <el-input v-model="searchForm.companyName" placeholder="公司名称" clearable></el-input>
          </el-form-item>
          <el-form-item label="纳税人识别号" prop="taxpayerIdentificationNo">
            <el-input  v-model="searchForm.taxpayerIdentificationNo" placeholder="纳税人识别号" clearable></el-input>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="list()" icon="el-icon-search">查询</el-button>
            <el-button @click="resetSearch()" icon="el-icon-refresh-right">重置</el-button>
          </el-form-item>
        </el-form>

        <vxe-table
          border="inner"
          auto-resize
          resizable
          height="auto"
          max-height="400"
          :loading="loading"
          ref="billingTable"
          show-header-overflow
          show-overflow
          highlight-hover-row
          :menu-config="{}"
          :print-config="{}"
          :sort-config="{remote:true}"
          :data="dataList"
          :row-config="{isCurrent: true}"
          :radio-config="{trigger: 'row'}">
          <vxe-column type="seq" width="40"></vxe-column>
          <vxe-column type="radio" width="40px"></vxe-column>
          <vxe-column min-width="150" title="公司名称" align="center" field="companyName" tree-node></vxe-column>
<!--          <vxe-column min-width="150" title="是否有纳税人识别号" align="center" field="isTaxpayerIdentificationNo">-->
<!--            <template slot-scope="scope">-->
<!--              {{$dictUtils.getDictLabel('yes_no', scope.row.isTaxpayerIdentificationNo, '-')}}-->
<!--            </template>-->
<!--          </vxe-column>-->
<!--          <vxe-column min-width="150" title="纳税人识别号" align="center" field="taxpayerIdentificationNo"></vxe-column>-->
          <vxe-column min-width="150" title="开户行" align="center" field="accountHolder"></vxe-column>
          <vxe-column min-width="150" title="银行账号" align="center" field="account"></vxe-column>
          <vxe-column min-width="150" title="电话" align="center" field="phone"></vxe-column>
          <vxe-column min-width="150" title="地址" align="center" field="address"></vxe-column>
        </vxe-table>
      </div>
		<template #footer>
			<span class="dialog-footer">
			  <el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
			  <el-button type="primary" v-if="method != 'view'" @click="getBilling()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
			</span>
		</template>
    </el-dialog>
  </div>
</template>

<script>
  import workClientService from '@/api/cw/workClientInfo/WorkClientService'
  export default {
    data () {
      return {
        title: '',
        method: '',
        visibleChoose: false,
        loading: false,
        tablePage: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          orders: []
        },
        dataList: [],
        searchForm: {
          clientId: '',
          companyName: '',
          taxpayerIdentificationNo: ''
        },
        clientId: ''
      }
    },
    created () {
    },
    components: {
    },
    methods: {
      init (id) {
        this.title = '开票信息选择'
        this.visibleChoose = true
        this.clientId = id
        this.list()
      },
      // 表单提交
      getBilling () {
        let row = this.$refs.billingTable.getRadioRecord()
        if (this.commonJS.isEmpty(row)) {
          this.$message.error('请至少选择一条数据')
        } else {
          this.close()
          this.$emit('getBilling', row)
        }
      },
      list () {
        this.dataList = []
        this.loading = true
        this.searchForm.clientId = this.clientId
        workClientService.getBillingListByClientId(this.searchForm).then((data) => {
          this.dataList = data
          this.loading = false
        })
      },
      // 当前页
      currentChangeHandle ({currentPage, pageSize}) {
        this.tablePage.currentPage = currentPage
        this.tablePage.pageSize = pageSize
        this.list()
      },
      resetSearch () {
        this.$refs.searchForm.resetFields()
        this.list()
      },
      close () {
        this.$refs.searchForm.resetFields()
        this.visibleChoose = false
      }
    }
  }
</script>
<style scoped>
  /deep/ .el-dialog__body {
    padding-top: 0;
  }
  /deep/ .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
    margin-bottom: 0px;
  }
</style>
