<template>
  <div class="table-box">
    <div class="block-title">
      销售方列表
      <el-button
        type="primary"
        style="margin-right:10px"
        @click="$refs.modal.show(null,'add')"
      >
        新增
      </el-button>
    </div>
    <el-table
      ref="table"
      border
      stripe
      v-loading="loading"
      :data="tableData">
      <el-table-column
        prop="invoice_seller"
        label="名称">
      </el-table-column>

      <el-table-column
        prop="mch_no"
        label="商户号">
      </el-table-column>

      <el-table-column
        prop="mch_taxpayer_num"
        label="纳税人识别号">
      </el-table-column>

      <el-table-column
        prop="private_key"
        label="接口密钥">
      </el-table-column>

      <el-table-column
        prop="invoiceType"
        label="开票类型">
      </el-table-column>

      <el-table-column
        prop="business_type"
        label="行业类型">
      </el-table-column>

      <el-table-column
        prop="tax_type"
        label="征税方式">
      </el-table-column>

      <el-table-column
        prop="tax_num"
        label="税率">
      </el-table-column>

      <el-table-column
        prop="special_ticket_type"
        label="特殊票种">
      </el-table-column>

      <el-table-column
        prop="invoice_property"
        label="发票号性质">
      </el-table-column>

      <el-table-column
        prop="goods_code"
        label="商品编码">
      </el-table-column>

      <el-table-column
        prop="goods_code_name"
        label="商品项目名称">
      </el-table-column>

      <el-table-column
        label="操作"
        width="160"
        fixed="right">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="small"
            @click="$refs.modal.show(scope.row,'edit')"
            style="margin-right:5px"
          >
            编辑
          </el-button>

          <el-popconfirm
            title="这是一段内容确定删除吗？"
            @confirm="confirm(scope.row.id)"
          >
            <el-button slot="reference">
              删除
            </el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>

    <Modal
      ref="modal"
      @update="getList"></Modal>
  </div>
</template>
<script>
import { listInvoiceSales, deleteInvoiceSale } from '@/api/ticketType'
import Modal from './Modal'

export default {
  components: {
    Modal
  },
  data () {
    return {
      loading: false,
      tableData: []
    }
  },
  methods: {
    getList () {
      this.loading = true
      listInvoiceSales({}).then(res => {
        this.tableData = res?.data
      }).finally(() => {
        this.loading = false
      })
    },
    confirm (id) {
      deleteInvoiceSale({ id }).then(res => {
        this.$message.success('删除成功')
        this.getList()
      })
    }
  }
}
</script>

    <style lang="scss" scoped>
    </style>
