/*
 *@description:承运商应付管理-付款查询
 *@author: hudw
 *@date: 2022-09-06 10:11:23
*/
<template>
    <div class="pages">
       <searchBar ref="searchBar" :options="options"  @submit="$searchSubmit"></searchBar>
       <mainTable
        ref="mainTable"
        :rowKey="'id'"
        title="结算单信息"
        :url="mainUrl"
        :options="options"
        :activeID="mainId"
        :tableExtendedField="tableExtendedField"
        :selectedRowKeys.sync="mainsSelectedRowKeys"
        :operation="false"
        @view="$handleView"
        @clickRow="handleRowClick"
      />
      <p-card :bordered="false" style="margin-top: 10px" :bodyStyle="{ minHeight: '300px' }">
      <a-tabs style="background-color: #fff" v-model="tabsKey">
        <a-tab-pane :key="0" tab="费用信息">
          <feeTable ref="childrenTable_0" :url="feeListUrl" :options="options" :isShow="tabsKey === 0" :mainRowKey="mainId" :activeID="childrenId" />
        </a-tab-pane>
        <a-tab-pane :key="1" tab="操作日志">
          <logTable ref="childrenTable_1" :url="findListForLogUrl" :options="options" :isShow="tabsKey === 1" :mainRowKey="mainId" /></a-tab-pane>
      </a-tabs>
    </p-card>
    </div>
</template>
<script>
import useMixin from '@/views/BMS/settlement/$common/mixins/useMixin.js'
import dictionary from '@/views/BMS/settlement/$common/mixins/dictionary.js'
import {mainTableInfoUrl,auditSubmit,feeListUrl,findListForLogUrl} from './api.js'
import { resultExtendedField } from '@/blocks/utils'

export default {
  mixins: [useMixin, dictionary],

  data() {
    return {
      feeListUrl,findListForLogUrl,
      tabsKey: 0,
      mainUrl: mainTableInfoUrl,
      detailsState: 0/**0=不显示,1=查看,2=新建,3=修改,4=复制 */,
      tableExtendedField: [],
    }
  },
  watch: {
    tabsKey(value) {
      if (this.mainCurrent) {
        this.handleRowClick(null, this.mainId, this.mainCurrent)
      }
    },
  },
  mounted() {
    let _this = this
    resultExtendedField({ extendedObjectCode: '20' }).then((data) => {
      if (data) {
        _this.tableExtendedField = data.table
      }
    })
  },
  methods: {


    handleRowClick(event, key, data) {

      this.clearChildrenTableAll(true)
      this.mainId = key
      if (key) {
        this.mainCurrent = data
        let id = data.id
        this.$nextTick(() => {
          const { childrenTable_0, childrenTable_1 } = this.$refs
          let ref = [childrenTable_0, childrenTable_1]
          ref = ref[this.tabsKey]
          ref && ref.reload({ data: { id } })
        })
      } else {
        this.currentMainData = null
      }
    },
  },
}
</script>
<style lang='less'>
</style>