<template>
  <template-page
    ref="pageRef"
    :get-list="getList"
    :table-attributes="tableAttributes"
    :table-events="tableEvents"
    :options-evens-group="optionsEvensGroup"
    :moreParameters="moreParameters"
    :column-parsing="columnParsing"
    :exportList="exportList"
  >
    <!-- :operation="operation()" -->
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import ImageUpload from '@/components/file-upload'
import operation_mixin from '@/components/template/operation_mixin.js'
import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
import {
  dailySummaryRepiarAllList,
  dailySummaryRepiarAllListExport,
  repairAllCount
} from '@/api/maintenanceWorkOrderSettlement'
export default {
  components: { TemplatePage, ImageUpload },
  mixins: [import_mixin, operation_mixin],
  data() {
    return {
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: false
      },
      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
      // 勾选选中行
      recordSelected: [],
      count: {}
    }
  },
  computed: {
    // 更多参数
    moreParameters() {
      return [
        {
          name: '工单类型',
          key: 'status',
          value: '',
          conditions: [
            {
              label: '全部',
              value: ''
            },
            {
              label: `未发放${this.count.waitCount}`,
              value: '1'
            },
            {
              label: `已发放${this.count.endCount}`,
              value: '2'
            },
            {
              label: `受理中${this.count.ingCount}`,
              value: '3'
            },
            {
              label: `发放失败${this.count.errCount}`,
              value: '4'
            },
            {
              label: `驳回${this.count.rejectCount}`,
              value: '5'
            }
          ]
        }
      ]
    },
    optionsEvensGroup() {
      return []
    }
  },
  methods: {
    // 列表请求函数
    getList(p, cb) {
      var pam = JSON.parse(JSON.stringify(p))
      try {
        if (pam.status) {
          pam.params.push({ param: 'c.status', compare: '=', value: pam.status })
        }
        cb && cb(pam)
        return dailySummaryRepiarAllList(pam)
      } catch (err) {
      } finally {
        repairAllCount().then(res => {
          this.count = res.data
          console.log(res.data)
        })
      }
    },
    // 列表导出函数
    exportList: dailySummaryRepiarAllListExport,
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },
    // 监听勾选变化
    selectionChange(data) {
      this.recordSelected = data
    },
    operation() {
      return this.operationBtn({
        deductionExpenses: {
          prompt: '确定扣回费用吗？',
          click: ({ row, index, column }) => {}
        },
        resumeSettlement: {
          prompt: '确定恢复结算吗？',
          click: ({ row, index, column }) => {}
        },
        collect: {
          prompt: '确定汇总吗？',
          click: ({ row, index, column }) => {}
        },
        del: {
          prompt: '确定删除吗？',
          click: ({ row, index, column }) => {}
        }
      })
    }
  }
}
</script>

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