/*
 *@description:发货单信息/备货等待/关闭信息
 *@author: hudw
 *@date: 2022-03-14 15:14:53
*/
<template>
  <t-table
    :id="id"
    :sign="true"
    rowSelectFixed
    :rowKey="rowKey"
    :customScrollbar="true"
    :selectedRowKeys="selectedRowKeys"
    :vScrollX="{enabled:false}"
    :vScrollY="{enabled:true,rows:4}"
    :scroll="scroll"
    ref="mainTable"
    bordered
    :columns="mx_columns"
    :dataSource="dataSource"
    :doneBefore="t_doneBefore"
    :autoLoad="false"
    :remoteUrl="mx_remoteUrl"
    :remoteBefore="s_remoteBefore"
    dragle
    :rowSelectType="rowSelectType"
    v-on="$listeners"
  >
  <template v-if="operation" slot="operation" slot-scope="text, record">
        <slot name="operation" :text="text" :record="record"> </slot>
      </template>
  </t-table>
</template>
<script>
import  setMainColumns  from './tableConfig'

export default {
  name: 'shipbillTable',
 props: {
    title: {
      type: null,
    },
    mode: {
      type: null,
      default: 1, //1运单模式,2收货方模式,3派车单信息
    },
    rowKey: {
      type: null,
      default: '_row_count',
    },
    url: {
      type: null,
    },

    doneBefore: { type: Function },
    rowSelectType: { type:null,default:0 },
    options: {
      type: Object,
      default: () => {},
    },
    scroll: {
      type: Object,
      default: () => {return { x: true } },
    },
    operation: {
      type: Object,

    },
    selectedRowKeys: {
      type: Array,
      default: () => [],
    },
    tableColumnsList: {
      type: Array,
    },
    tableExtendedField: {
      type: Array,
    },
    getFieldsValue: {
      type: Function,
    },

    activeID: {
      type: null,
   },
   id: {
      type: null,
   },


  },

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

    return {
      confirmLoading: false,
      dataSource: [],
      mx_remoteUrl,
      mx_remoteParams: {},
      mx_columns: this.tableColumnsList?this.tableColumnsList:setMainColumns(this,this.tableExtendedField)
    }
  },
  mounted() {
  },
  watch: {
    tableColumnsList(value) {
      this.mx_columns=value
    },
    tableExtendedField(value) {
      if (value.length > 0) {
        this.mx_columns=setMainColumns(this,value)
      }
    },

  },
  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) {
      return this.$refs.mainTable.reload(args)
    },
    s_remoteBefore(vNode, remoteUrl) {
      let searchBar = this.$parent.$parent.$parent.$refs.searchBar
      if (searchBar) {
        const { getFieldsValue } = searchBar
        remoteUrl.data = { ...this.mx_remoteUrl.data,...remoteUrl.data, ...getFieldsValue() }
      } else {
        remoteUrl.data = { ...this.mx_remoteUrl.data,...remoteUrl.data }
      }
      this.mx_remoteUrl=remoteUrl
      this.remoteBefore && this.remoteBefore(vNode, remoteUrl)
    },
  },
}
</script>
