<template>
  <template-page
    ref="pageRef"
    :getList="getList"
    :exportList="exportList"
    :columnParsing="columnParsing"
    :optionsEvensGroup="optionsEvensGroup"
    :morePlan="morePlan"
    :operationColumnWidth="200"
    :operation="operation()"
  >
    <Popu v-if="visible">
      <el-page-header slot="head" content="" @back="handleClose" />
      <InsuranceContractForm
        :item="item"
        :type="showType"
        @success="
          () => {
            handleClose()
            $refs.pageRef.refreshList()
          }
        "
      />
    </Popu>
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import Popu from '@/components/template/popu.vue'
import InsuranceContractForm from './InsuranceContractForm.vue'
import operation_mixin from '@/components/template/operation_mixin.js'
import { workerApplyList, workerApplyListExport } from '@/api/difficultyExpenseApproval.js'
export default {
  components: { TemplatePage, Popu, InsuranceContractForm },
  mixins: [import_mixin, operation_mixin],
  data() {
    return {
      morePlan: [],
      // 事件组合
      optionsEvensGroup: [],
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: true
      },
      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
      recordSelected: [],
      visible: false,
      item: null,
      showType: null
    }
  },
  methods: {
    // 列表请求函数
    getList: workerApplyList,
    // 导出
    exportList: workerApplyListExport,
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },
    // 监听勾选变化
    selectionChange(data) {
      this.recordSelected = data
    },
    operation() {
      return this.operationBtn({
        networkAudit: {
          conditions: ({ row, index, column }) => {
            return row.websitStatus == 1
          },
          click: ({ row, index, column }) => {
            this.item = row
            this.visible = true
            this.showType = 1
          }
        },
        centralAudit: {
          conditions: ({ row, index, column }) => {
            return row.status == 3
          },
          click: ({ row, index, column }) => {
            this.item = row
            this.visible = true
            this.showType = 2
          }
        },
        details: {
          click: ({ row, index, column }) => {
            this.item = row
            this.visible = true
            this.showType = 3
          }
        }
      })
    },
    // 关闭新增弹窗
    handleClose() {
      this.visible = false
      this.item = null
      this.showType = null
    }
  }
}
</script>

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