<template>
  <div :class="$style.wrapHeight">
    <div :class="$style.rowHeight">
      <law-case-catalog-tree
        ref="lawcaseCatalogTree"
        show-line
        top-node-text="案由配置"
        :is-select-dep="true"
        :draggable="false"
        @treeSelect="treeSelect"
      ></law-case-catalog-tree>

      <div :class="$style.rightcard">
        <a-card>
          <sd-business-list
            v-if="ifRouterView"
            :module-id="moduleId"
            :form-list-id="formListId"
            :custom-values="customValues"
            :filter="Expressions"
            :parentId="parentId"
          ></sd-business-list>
        </a-card>
      </div>
    </div>
  </div>
</template>

<script>
import { Modal, message } from 'ant-design-vue'
import TableColumnTypes from '@/common/services/table-column-types'
import systemManage from '@/system-manage/system-manage'
import debounce from 'lodash.debounce'
import axios from '@/common/services/axios-instance'
import TableActionTypes from '@/common/services/table-action-types'
import sdBusinessList from '../../../../src/application-manage/sd-business-list.vue'
import LawService from '../law-service'
import lawCaseCatalogTree from './law-case-catalog-tree'
import components from './_import-components/law-case-config-import'

export default {
  name: 'LawCaseConfig',
  metaInfo: {
    title: '法律案由配置',
  },
  components: {
    ...components,
    lawCaseCatalogTree,
    sdBusinessList,
  },
  data() {
    return {
      ifRouterView: false,
      // 模块Id
      moduleId: '',
      // 列表ID
      formListId: '',
      // 搜索条件
      customValues: {},
      Expressions: [
        {
          dataType: 'str',
          name: 'PARENT_CODE',
          op: 'eq',
          stringValue: '0',
        },
      ],
      key: 0,
      waterMark: systemManage.getFormWaterMark(),
      parentId: '0',
      parentName: '案由配置',
      newNumber: '',
    }
  },
  mounted() {
    this.versionId = this.$route.query.versionId
    this.moduleId = this.$route.query.moduleId
    this.formListId = this.$route.query.formListId
    LawService.findActionCode('0').then((res) => {
      this.newNumber = res.data.toString()
      this.customValues = { sdCustomField1: this.parentId, sdCustomField2: this.newNumber }
      setTimeout(() => {
        this.ifRouterView = true
      }, 100)
    })
  },
  methods: {
    reload() {
      this.ifRouterView = false
      this.$nextTick(() => {
        this.ifRouterView = true
      })
    },
    treeSelect(selectedKeys, info) {
      this.prcPath = null
      // 父级id
      if (info != null && info.selectedNodes[0]) {
        this.parentId = info.selectedNodes[0].data.props.id.toString()
        this.parentName = info.selectedNodes[0].data.props.text // 父级名称
      } else {
        if (selectedKeys.id) {
          this.parentId = selectedKeys.id.toString()
          this.parentName = selectedKeys.text // 父级名称
        } else {
          this.parentId = '0'
        }
      }
      this.customValues = { sdCustomField1: this.parentId, sdCustomField2: this.newNumber }
      LawService.findActionCode(this.parentId).then((res) => {
        this.newNumber = res.data.toString()
      })
      this.reload()
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.wrap-height {
  height: 100%;
  .row-height {
    display: flex;
    flex: auto;
    height: 100%;
    .rightcard {
      flex: 1;
      width: calc(100% - 20%);
      height: 100%;
      :global .ant-card{
          min-height:100%;
      }
      :global .ant-table-default {
        // height: calc(50vh - 38px);
        overflow-x: hidden;
        overflow-y: auto;
      }
    }
  }
}

</style>
