<template>
  <template-page
    ref="pageRef"
    :getList="getList"
    :optionsEvensGroup="optionsEvensGroup"
    :exportList="exportList"
    :operation="operation()"
    :columnParsing="columnParsing"
  >
    <Popu v-if="visible">
      <supplier-list-detail :infoList="infoList"  @close="handleClose"/>
    </Popu>
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import add_callback_mixin from '@/components/template/add_callback_mixin.js'
import Popu from '@/components/template/popu.vue'
import { getListV2,exportListV2,getInfoApi } from '@/api/basic_data/supplier'
import SupplierListDetail from './components/supplier_list-detail.vue'
export default {
  components: { TemplatePage, Popu, SupplierListDetail },
  mixins: [import_mixin, add_callback_mixin],
  data() {
    return {
      visible: false,
      // 事件组合
      optionsEvensGroup: [],
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: true
      }, // 关闭新增弹窗

      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
      recordSelected: [],
      searchForm: {
        // 筛选表单数据
        name: ''
      },
      infoList: {},
    }
  },
  methods: {
    // 列表请求函数
    getList(...p) {
      this.recordSelected = []
      return getListV2(...p)
    },
    // 列表导出函数
    exportList: exportListV2,
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },
    // 监听勾选变化
    selectionChange(data) {
      this.recordSelected = data
    },
    operation() {
      return (h, { row, index, column }) => {
        return (
          <div class="operation-btns">
            <el-button
              size="mini"
              type="text"
              onClick={async () => {
                this.visible = true
                const res = await getInfoApi({ id:row.id })
                this.infoList = res.data
              }}
            >
              查看
            </el-button>
          </div>
        )
      }
    },
    handleClose() {
      this.addOff(() => {
        this.visible = false
      })()
    }
  }
}
</script>

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