<template>
  <div class="form-wrap">
    <div class="tableBox">
      <!-- <div class="block-title">查询信息</div> -->
      <el-table
        stripe
        :data="tableData"
        v-loading="loading">
        <el-table-column
          label="销售方名称"
          prop="invoiceSellerName"></el-table-column>
        <el-table-column
          label="纳税人识别号"
          prop="invoiceSellerTaxpayerNum">
        </el-table-column>
        <el-table-column
          prop="invoiceSellerAddress"
          label="销售方地址">
        </el-table-column>
        <el-table-column
          prop="invoiceSellerPhone"
          label="销售方联系电话">
        </el-table-column>
        <el-table-column
          prop="invoiceSellerBank"
          label="销售方开户银行">
        </el-table-column>
        <el-table-column
          prop="invoiceSellerAccount"
          label="销售方银行账号">
        </el-table-column>
        <el-table-column
          v-if="canEdit"
          width="120"
          label="操作">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="showDialog('edit', scope.row)">
              <i class="el-icon-edit"></i>
              编辑
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- <el-pagination
        background
        :current-page.sync="form.pageNum"
        @current-change="getList"
        layout="total, prev, pager, next"
        :total="total">
      </el-pagination> -->
    </div>

    <ElDialog
      :title="'编辑'"
      width="800px"
      v-model="dialogVisible">
      <EditDialog
        :current-item="currentItem"
        @updateList="getList"></EditDialog>
    </ElDialog>
  </div>
</template>

<script>
import { getInvoiceSellerList } from '@/api/invoice'
import ElDialog from '@/components/Dialog'
import EditDialog from './invoiceSeller/Dialog'

export default {
  components: {
    ElDialog,
    EditDialog
  },
  data () {
    return {
      projectName: localStorage.getItem('otaProject'),
      performList: [],
      dialogType: 'add',
      dialogVisible: false,
      form: {
        pageNum: 1,
        pageSize: -1,
        isSale: '',
        otaSourceId: '',
        ticketTypeId: '',
        salePrice: '',
        otaProductId: ''
      },
      loading: false,
      multipleSelection: [], // 批量删除多选数组
      total: 0,
      tableData: [],
      currentItem: {},
      ticketTypeList: [], // 票种列表
      otaList: []
    }
  },
  created () {
    this.getList()
  },
  filters: {
    formatXCProductName (time) {
      if (!time) return ''
      const map = {
        '1': '一张一人需要证件',
        '2': '一张一人不需要证件',
        '3': '一单一人需要证件',
        '4': '一单一人不需要证件'
      }
      return map[time] || ''
    }
  },
  computed: {
    canEdit () {
      return true
      // return this.$store.state.user.permissionList.includes('product:pricecode_edit')
    },
    queryClear () {
      return this.$store.state.user.permissionList.includes('stats:clearwx_query')
    }
  },
  methods: {
    // 获取列表
    getList () {
      this.loading = true
      getInvoiceSellerList(this.form).then(res => {
        this.tableData = res.data || []
        this.loading = false
      })
    },
    // 打开编辑对话框
    showDialog (type, item) {
      this.dialogType = type
      this.currentItem = item || {}
      this.dialogVisible = true
    }
  }
}
</script>
