/*
 *@description:费用信息
 *@author: hudw
 *@date: 2022-03-14 15:14:53
*/
<template>
  <t-table
    :activeKey="activeID"
    :id="$route.meta.menuId + '_feeTable'"
    :selectedRowKeys="selectedRowKeys"
    :scroll="{ x: true }"
    :dataSource="dataSource"
    ref="childrenTable"
    :vScrollX="{enabled:false}"
     :vScrollY="{enabled:true,rows:4}"
     autoColWidth
     rowKey="id"
    bordered
    :autoLoad="false"
    :columns="mx_columns"
    :remoteUrl="mx_remoteUrl"
    :remoteBefore="remoteBefore"
    dragle
    v-on="$listeners"
    :rowSelectType="2"
    :getCheckboxProps="
      (record) => ({
        props: {
          disabled: record.expenseStatus == 0 ? false : true,
        },
      })
    "
  >
  <template slot="operation" slot-scope="text, record">
      <a href="javascript:;" @click.stop="submitFee(record)" v-if="record.expenseStatus == 0">提交</a>
    </template>
  </t-table>
</template>
<script>


import { adjustTableInfoUrl } from '../../api'
import { setMainColumns } from './feeTableConfig.js'

export default {
  props: {
    options: {
      type: Object,
      default: () => {},
    },
    isShow: {
      type: Boolean,
      default: false
    },
    currentRow: {
      type: Object,
      default: () => null,
    },
    selectedRowKeys: {
      type: Array,
      default: () => [],
    },
    tableExtendedField: {
      type: Array,
    },
    getFieldsValue: {
      type: Function,
    },
    mainRowKey: { type: null },
    activeID: {
      type: null,
    },
  },
  data() {
    return {
      confirmLoading: false,
      dataSource: [],
      mx_remoteUrl: {
        method: 'post',
        url: adjustTableInfoUrl,
      },
      mx_remoteParams: {},
      mx_columns: setMainColumns(this, this.tableExtendedField),
    }
  },
  mounted() {},
  watch: {
    mainRowKey(value) {
      if (value&&this.isShow) {
        this.reload()
      } else {
        this.dataSource=[]
      }
    },
    tableExtendedField(value) {
      if (value.length > 0) {
        this.mx_columns = setMainColumns(this, value)
      }
    },

  },
  methods: {


    submitFee(record) {
      this.$emit('submit',record)
    },
    remoteBefore(vnode, res) {
      // delete res.data
      res.data = { ...res.data, id: this.mainRowKey }
    },
    reload(args) {

      this.dataSource=[]
      this.mainRowKey&&  this.$refs.childrenTable.reload(args)
    },
  },
}
</script>
