<template>
  <template-page ref="pageRef" :getList="getList" :operation="operation()" :exportList="exportList"
    :columnParsing="columnParsing" :tableAttributes="tableAttributes" :tableEvents="tableEvents"
    :screeningAnalysis="screeningAnalysis" :filterMethod="filterMethod" :replaceOrNotMap="true">
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import { orderBaseList, orderBaseListExport } from "@/api/workOrderPool.js"
import orderListColumn from "@/mixin/orderListColumn"
import operation_mixin from '@/components/template/operation_mixin.js'
export default {
  components: {
    TemplatePage,
  },
  mixins: [import_mixin, operation_mixin, orderListColumn],
  data() {
    return {
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: false,
      },
      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
    }
  },
  methods: {
    screeningAnalysis(jname, val) {
      if (jname == 'orderFlags') {
        return (val || []).map(item => item.tagName).join(',')
      } else {
        return val
      }
    },
    filterMethod(value, row, column) {
      if (column['property'] == 'orderFlags') {
        return (row[column['property']] || []).map(item => item.tagName).join(',') === value
      }
      return row[column['property']] === value
    },

    // 列表请求函数
    getList(p, cb) {
      var pam = JSON.parse(JSON.stringify(p))
      try {
        pam.params.push(
          { "param": "a.order_status", "compare": "=", "value": ["YWG", "YJS"] }
        )
        pam.isYb = true
        cb && cb(pam)
        return orderBaseList(pam)
      } catch (err) {
      }
    },

    // 列表导出函数
    exportList: orderBaseListExport,

    // 监听勾选变化
    selectionChange(data) {
      this.recordSelected = data
    },

    // 表格操作列
    operation() {
      return this.operationBtn({
        detail: {
          btnType: 'text',
          click: ({ row, index, column }) => {
            this.$router.push({
              name: 'workOrderPool',
              params: {
                pageName: row.id,
                pageType: 'detail',
                pageCode: row.id,
              },
            })
          }
        }
      })
    },
  }
}
</script>

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