<template>
  <div class="compare-view-wrap">
    <compareBasicSection
      sectionTitle="基础信息"
      headerLabel="查看表单模板"
      :objType="objType"
      :objCode="objCode"
      :compareHData1="compareHData1"
      :compareHData2="compareHData2"
      :preVersion="preVersion"
      :curVersion="curVersion"
      :fields="basicFields"
      @reverCallback="$emit('reverCallback')"
    />
    <compareCodeSection
      sectionTitle="表单模板JSON"
      :preVersion="preVersion"
      :curVersion="curVersion"
      :leftCode="leftFormViewContent"
      :rightCode="rightFormViewContent"
      mode="json"
      enableDiff
    />
  </div>
</template>

<script>
import compareMixin from "./compareMixin";
import compareBasicSection from "./compareBasicSection.vue";
import compareCodeSection from "./compareCodeSection.vue";

export default {
  name: "formTemplateCompareView",
  mixins: [compareMixin],
  components: {
    compareBasicSection,
    compareCodeSection,
  },
  computed: {
    leftFormViewContent() {
      return this.formatJson(this.compareHData1?.formViewContent);
    },
    rightFormViewContent() {
      return this.formatJson(this.compareHData2?.formViewContent);
    },
    basicFields() {
      return [
        { key: "formName", label: "模板名称" },
        { key: "formCode", label: "模板编码" },
        {
          key: "enabled",
          label: "是否启用",
          formatter: (val) => this.formatBool(val, "启用", "禁用"),
        },
        {
          key: "hasWf",
          label: "启用流程",
          formatter: (val) => this.formatBool(val),
        },
        { key: "menuKindName", label: "表单分类" },
        { key: "remark", label: "备注" },
        {
          key: "formTemplateTagDTOs",
          label: "项目标签",
          formatter: (val) => this.formatTags(val),
        },
        { key: "serviceName", label: "服务名" },
        { key: "sid", label: "唯一标识" },
        ...this.auditFields(),
      ];
    },
  },
};
</script>
