<template>
  <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
    <a-row :gutter="48" slot="extra">
      <a-col :md="48" :sm="48">
        <span class="table-page-search-submitButtons" style="float: right">
          <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
        </span>
      </a-col>
    </a-row>
    <title-divider title="基础信息" width="90px"></title-divider>
    <detail-list :col="2">
      <detail-list-item term="表单名称">{{ model.name }}</detail-list-item>
      <detail-list-item term="表单类型">{{ this.typeMap[model.type ] }}</detail-list-item>
      <detail-list-item term="模板分类">{{ this.categoryMap[model.category ] }}</detail-list-item>
      <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
      <detail-list-item term="创建人">{{ model.createdUserName }}</detail-list-item>
      <detail-list-item term="创建时间">{{ model.createdTime }}</detail-list-item>
    </detail-list>
    <title-divider title="表单配置" width="90px"></title-divider>
    <a-card>
      <a-form
        :labelCol="BaseTool.Constant.labelCol"
        :wrapperCol="BaseTool.Constant.wrapperCol">
        <a-row>
          <MComponent
            class="hover"
            v-for="item in formComponentConfig.components"
            :key="item.id"
            :config="formComponentConfig.config"
            :detail="item"
          />
        </a-row>
      </a-form>
    </a-card>
  </a-card>
</template>

<script>
import DetailList from '@/components/tools/DetailList'
import MComponent from './component/modules/Component.vue'
const DetailListItem = DetailList.Item

export default {
  name: 'CustomFormDetail',
  components: {
    DetailList,
    DetailListItem,
    MComponent
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      model: {
      },
      categoryMap: {},
      typeMap: {},
      formComponentConfig: {}
    }
  },
  created () {
    // 下拉框map
    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CUSTOM_FORM_TYPE)
    this.categoryMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CATEGORY_TYPE)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
      this.formComponentConfig = JSON.parse(record.jsonString)
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
      this.$emit('ok')
    }
  }
}
</script>
