<template>
  <audit-form-top-banner :handel-save-form="saveForm" @handelSaveForm="saveForm">
    <sd-detail-form
      ref="docform"
      form-id="iamIncidentTag"
      page-id="audit/maintain/iamIncidentTag"
      :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
      :class="$style.form"
      @close="close(true)"
      @saved="saved"
    >
      <template v-slot="{ model }">
        <table
          ><tr
            ><td style="padding-left:5px;border:none">
              <audit-advanced-group
                :expand="templateExpand"
                :expand-str="'templateExpand'"
                :group-label="'基本信息'"
                tablestyle="''"
                @changedClick="changedClick"
              ></audit-advanced-group> </td></tr
        ></table>

        <table v-show="templateExpand">
          <tr>
            <!-- 标签名称 -->
            <sd-form-item-td name="id" label="事件标签分类编号" :input-props="{ disabled: true }" />
            <sd-form-item-td name="tagName" label="事件标签分类名称" />
          </tr>
          <tr>
            <!-- 模型描述 -->
            <sd-form-item-td name="tagDesc" :colspan="3">
              <a-textarea v-model="model.tagDesc" :rows="3" />
            </sd-form-item-td>
          </tr>
        </table>
      </template>
    </sd-detail-form>
  </audit-form-top-banner>
</template>

<script>
import { Message } from 'ant-design-vue'
import crossWindowWatcher from '@/common/services/cross-window-watcher'
import auditFormTopBanner from '../../components/audit-form-top-banner'
import auditAdvancedGroup from '../../components/audit-advanced-group.vue'
import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
import components from './_import-components/audit-maintain-from-import'

export default {
  name: 'AuditEventTagFrom',
  metaInfo: {
    title: '审计模型',
  },
  components: {
    ...components,
    auditAdvancedGroup,
    auditFormTopBanner,
  },
  mixins: [auditAdvancedGroupMixins],
  data() {
    return {
      templateExpand: true,
      orgId: '',
    }
  },
  created() {
    if (this.$route.query.orgId) this.orgId = this.$route.query.orgId
  },
  methods: {
    close(flag) {
      crossWindowWatcher.notifyChange('/#' + this.$route.fullPath, flag)
      window.close()
    },
    // 保存
    saveForm() {
      if (this.orgId !== '') {
        this.$refs.docform.setFieldValue('auditOrgId', parseInt(this.orgId))
      }
      this.$refs.docform.validateFields().then(() => {
        this.$refs.docform.saveBtnClick()
      })
    },
    saved() {
      Message.success({ content: '保存成功！' }, 1).then(() => {
        this.close(true)
      })
    },
    initParam(model) {
      // 设置父id
      const catalogId = this.$route.query.catalogId
      const catalogName = this.$route.query.catalogName
      if (catalogId) {
        model.catalogId = Number(catalogId)
      }

      if (catalogName) {
        model.catalogName = catalogName
      }
    },
  },
}
</script>

<style module lang="scss">
@import '@/webflow/sd-flow-form.scss';
</style>
