<template>
  <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
    :options-evens-group="optionsEvensGroup" :more-parameters="moreParameters" :column-parsing="columnParsing"
    :operation="operation">
    <div class="cartographer">
      <el-dialog title="明细" width="100%" :modal="false" :visible.sync="formDialog" :before-close="()=>{formDialog = false}">
        <template-page v-if="formDialog" :get-list="getList2" />
      </el-dialog>
    </div>
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import {
  increOrderSettleCountList,
  increOrderSettleCountListExport
} from '@/api/orderBranchAccount'
import { increOrderSettleList } from "@/api/orderSettleManag.js"
export default {
  components: { TemplatePage },
  mixins: [import_mixin],
  data() {
    return {
      // 事件组合
      optionsEvensGroup: [],
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: false
      },
      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
      // 勾选选中数据
      recordSelected: [],
      formDialog: false,
      detailParams: []
    }
  },
  computed: {
    // 更多参数
    moreParameters() {
      return []
    },
  },
  methods: {
    // 列表请求函数
    getList(p) {
      this.detailParams = p.params.filter(item => item.param === "a.pay_time")
      return increOrderSettleCountList(p)
    },
    // 列表导出函数
    exportList: increOrderSettleCountListExport,
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },
    // 监听勾选变化
    selectionChange(data) {
      this.recordSelected = data
    },
    // 操作按钮
    operation(h, { row, index, column }) {
      return (
        <div class="operation-btns">
          <el-button type="text" onClick={() => {
            this.detailParams.push(
              {
                param: "a.websit_id",
                compare: "=",
                value: row.websitId
              }
            )
            this.$nextTick(() => {
              this.formDialog = true
            })
          }}>明细</el-button>
        </div>
      )
    },
    // 明细列表
    getList2(p) {
      var pam = JSON.parse(JSON.stringify(p))
      pam.params = [...pam.params, ...this.detailParams,]
      try {
        return increOrderSettleList(pam)
      } catch (err) {
      }
    },
  }
}
</script>

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