<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="channelName"></el-table-column>
        <el-table-column
          label="税率"
          prop="taxNum">
        </el-table-column>
        <el-table-column
          prop="goodsCode"
          label="商品编码">
        </el-table-column>
        <el-table-column
          prop="goodsCodeName"
          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 { getInvoiceChannelList } from '@/api/invoice'
import ElDialog from '@/components/Dialog'
import EditDialog from './invoiceChannel/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
      getInvoiceChannelList(this.form).then(res => {
        this.tableData = res.data || []
        this.loading = false
      })
    },
    // 打开编辑对话框
    showDialog (type, item) {
      this.dialogType = type
      this.currentItem = item || {}
      this.dialogVisible = true
    }
  }
}
</script>
