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

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import operation_mixin from '@/components/template/operation_mixin.js'
import { enginMaterialListPageSettlementV2, enginMaterialPageSettlementExport, enginMaterialDetail, enginMaterialLineSettlementHui } from "@/api/applicationWithoutFee.js"
import { EventBus } from '@/utils/eventBus'
export default {
  components: {
    TemplatePage,
  },
  mixins: [import_mixin, operation_mixin],
  data() {
    return {
      formBool: false,
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: false,
      },
      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
      formData: {}
    }
  },
  methods: {
    // 列表请求函数
    getList: enginMaterialListPageSettlementV2,

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

    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },

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

    operation() {
      return this.operationBtn({
        detail: {
          click: ({ row, index, column }) => {
            var { websitId, workerId } = row
            EventBus.$emit("tabTypeCkChange", { websitId, workerId, status: "", tabTypeCk: "offline" })
          }
        },
        settle: {
          prompt:"是否确认结算！",
          conditions: ({ row, index, column }) => {
            return row.totalAmount != row.giveAmount
          },
          click: ({ row, index, column }) => {
            var { websitId, workerId } = row
            enginMaterialLineSettlementHui({ websitId, workerId }).then(res => {
              this.$refs.pageRef.refreshList()
            })
          }
        },
      })
    },

  }
}
</script>

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