/*
 *@description:审批信息
 *@author: hudw
 *@date: 2022-03-14 15:14:53
*/
<template>
  <a-row :gutter="20">
    <a-col :span="12">
      <t-table
        :id="$route.meta.menuId + '_bus_detail'"
        :sign="true"
        rowSelectFixed
        :activeKey="activeID"
        :rowKey="rowKey"
        :scroll="{ x: true }"
        :vScrollX="{enabled:false}"
        :vScrollY="{enabled:true,rows:4}"

        ref="mainTable"
        bordered
        :columns="bus_detail"
        :dataSource="dataSource"
        :autoLoad="false"
        :doneBefore="t_doneBefore"
        :remoteUrl="mx_remoteUrl"
        :remoteBefore="s_remoteBefore"
        dragle
        :rowSelectType="false"
        v-on="$listeners"
      />
    </a-col>
    <a-col :span="12">
      <t-table
        :id="$route.meta.menuId + '_bus_detail'"
        :sign="true"
        rowSelectFixed
        :activeKey="activeID"
        :rowKey="rowKey"
        :selectedRowKeys="selectedRowKeys"
        :scroll="{ x: true }"
        ref="mainTable"
        bordered

        :vScrollX="{enabled:false}"
        :vScrollY="{enabled:true,rows:4}"

        :columns="bus_log"
        :dataSource="dataSource"
        :autoLoad="false"
        :doneBefore="t_doneBefore"
        :remoteUrl="mx_remoteUrl"
        :remoteBefore="s_remoteBefore"
        dragle
        :pagination="false"

        :rowSelectType="false"
        v-on="$listeners"
      />
    </a-col>
  </a-row>
</template>
<script>
import { setMainColumns } from './tableConfig'

let bus_detail = [
  { dataIndex: 'id', title: '审批业务明细ID', hidden: true },
  { dataIndex: 'approvalNodeOrder', title: '节点顺序' },
  { dataIndex: 'approverRoleName', title: '角色名称' },
  { dataIndex: 'approverUserName', title: '用户名称' },
  {
    dataIndex: 'statusName',
    title: '节点状态',
  },
  { dataIndex: 'approvalTime', title: '审批时间' },
]
let bus_log = [
  { dataIndex: 'id', title: '审批日志ID', hidden: true },
  { dataIndex: 'approverRoleName', title: '审核角色' },
  { dataIndex: 'approverPersonName', title: '审核人' },
  { dataIndex: 'approverStatusName', title: '审核状态' },
  {
    dataIndex: 'resultName',
    title: '审核结果',
  },
  { dataIndex: 'approvalTime', title: '审核时间' },
  { dataIndex: 'approvalOpinion', title: '审核意见' },
]

export default {
  name: 'parcel-table',
  props: {
    url: {
      type: String,
    },
    mainRowKey: { type: null },

    isShow: {
      type: Boolean,
      default: false
    },
    rowKey: {
      type: null,
      default: '_row_count', //1运单模式,2收货方模式
    },
    doneBefore: { type: Function },
    options: {
      type: Object,
      default: () => {},
    },
    selectedRowKeys: {
      type: Array,
      default: () => [],
    },
    tableExtendedField: {
      type: Array,
    },
    getFieldsValue: {
      type: Function,
    },
    remoteBefore: {
      type: Function,
    },
    activeID: {
      type: null,
    },
  },

  data() {
    let mx_remoteUrl = {
      method: 'post',
      url: this.url,
    }

    return {
      bus_log,
      bus_detail,
      confirmLoading: false,
      dataSource: [],
      mx_remoteUrl,
      mx_remoteParams: {},
      mx_columns: setMainColumns(this),
    }
  },
  mounted() {
    console.log(JSON.stringify(setMainColumns(this)))
  },
  watch: {
    mainRowKey(value) {
      if (value&&this.isShow) {
        this.reload()
      } else {
        this.dataSource=[]
      }
    },
    // activeID(v) {

  },
  methods: {
    print_item() {
      alert('开发中...')
      this.$emit('print', record)
    },
    copy_item(record) {
      this.$emit('copy', record)
    },
    submit_item(record) {
      this.$emit('submitItem', [record.shipbillId])
    },
    show_info_item(record) {
      this.$emit('view', record)
    },
    delete_item(record) {
      this.$emit('delete', [record.shipbillId])
    },
    update_item(record) {
      this.$emit('update', record)
    },
    t_doneBefore(res) {

      this.doneBefore && this.doneBefore(res)
    },
    reload(args) {
      this.dataSource=[]
      this.mainRowKey&&  this.$refs.mainTable.reload(args)
    },


    s_remoteBefore(vnode, res) {
      delete res.data
      res.params = { id: this.mainRowKey }
    },
  },
}
</script>
