<template>
  <div class="system-base-info" style="display:flex; justify-content: flex-start;">
    <div class="base-info-left">
      <div class="info-item">
        <span>名称：</span>
        <p>{{ selectedCategory.cnName }}</p>
      </div>
      <div class="info-item">
        <span>节点类型：</span>
        <p v-if="selectedCategory.isType == 1">文件夹</p>
        <p v-else-if="selectedCategory.isType == 2">项目</p>
        <p v-else-if="selectedCategory.isType == 3">案卷</p>
        <p v-else-if="selectedCategory.isType == 4">卷内</p>
        <p v-else-if="selectedCategory.isType == 5">文件</p>
        <p v-else />
      </div>
      <!-- v-if="selectedCategory.pid !== '0'" -->
      <div class="info-item">
        <span>所属父级：</span>
        <p>{{ selectedCategory.parentName ? selectedCategory.parentName : '-' }}</p>
      </div>
      <div class="info-item info-content">
        <span>备注：</span>
        <p>{{ selectedCategory.remark ? selectedCategory.remark : '-' }}</p>
      </div>
    </div>
    <div class="base-info-right">
      <!-- <div v-if="selectedCategory.isType !== 1" class="info-item">
        <span>档号规则：</span>
        <p>{{ fileNoFormatStr }}</p>
      </div> -->
      <div v-if="selectedCategory.isType !== 1" class="info-item">
        <span>编码：</span>
        <p>WS01</p>
      </div>
      <div v-if="selectedCategory.isType !== 1" class="info-item">
        <span>整理方式：</span>
        <p>按件整理</p>
      </div>
      <div v-if="selectedCategory.isType !== 1" class="info-item">
        <span>是否装盒：</span>
        <p>装盒</p>
      </div>
    </div>
  </div>
</template>

<script>
import { getNoFormatField } from '@/api/category/fileNoFormat'
export default {
  name: 'BaseInfo',
  props: {
    selectedCategory: {
      type: Object,
      default: function() {
        return {
          cnName: '',
          isType: '',
          parentName: '',
          isColumnLength: '',
          remark: ''
        }
      }
    }
  },
  data() {
    return {
      fileNoFormatStr: ''
    }
  },
  watch: {
    selectedCategory: function(newValue, oldValue) {
      if (newValue && newValue.id) {
        this.initData()
      }
    }
  },
  created() {
    if (this.selectedCategory && this.selectedCategory.id) {
      this.initData()
    }
  },
  methods: {
    initData() {
      getNoFormatField({ categoryId: this.selectedCategory.id }).then((res) => {
        this.fileNoFormatStr = ''
        res.forEach((item) => {
          this.fileNoFormatStr += item.fieldCnName + item.connector
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
