<template>
  <audit-form-top-banner>
    <template>
      <sd-detail-form
        ref="form"
        form-id="iamTemplate"
        page-id="audit/template/iamTemplate"
        :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
        :class="[$style.form, 'readonlyform']"
      >
        <template v-slot="{ model, fields }">
          <table>
            <tr>
              <sd-form-item-td name="templateName">
                <span>{{ model.templateName }}</span>
              </sd-form-item-td>
              <sd-form-item-td name="templateType">
                <span>{{ fields.templateType.attr.displayValue }}</span>
              </sd-form-item-td>
            </tr>
            <tr>
              <sd-form-item-td name="isDefault">
                <span>{{ fields.isDefault.attr.displayValue }}</span>
              </sd-form-item-td>
              <sd-form-item-td v-if="model.isDefault === '0'" name="orgNameScope">
                <span>{{ model.orgNameScope }}</span>
              </sd-form-item-td>
            </tr>
            <tr>
              <sd-form-item-td name="templateDesc" :colspan="3">
                <span>{{ model.templateDesc }}</span>
              </sd-form-item-td>
            </tr>
            <tr>
              <sd-form-item-td name="authName">
                <span>{{ model.authName }}</span>
              </sd-form-item-td>
              <sd-form-item-td name="authTime">
                <span>{{ model.authTime }}</span>
              </sd-form-item-td>
            </tr>
            <tr>
              <sd-form-item-td name="attachment" :colspan="3">
                <template>
                  <sd-attachment
                    v-model="model.attachment"
                    :group-id="JSON.parse(fields.attachment.value).value"
                    :read-only="true"
                  />
                </template>
              </sd-form-item-td>
            </tr>
          </table>
        </template>
      </sd-detail-form>
    </template>
  </audit-form-top-banner>
</template>

<script>
import crossWindowWatcher from '@/common/services/cross-window-watcher'
import auditFormTopBanner from '../../components/audit-form-top-banner'
import components from './_import-components/audit-template-detail-import'

export default {
  name: 'AuditTemplateDetail',
  metaInfo: {
    title: '审计模板库',
  },
  components: {
    ...components,
    auditFormTopBanner,
  },
  data() {
    return {}
  },
  methods: {
    close(flag) {
      crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
      window.close()
    },
    saveForm() {
      alert('save')
    },
    getFormFieldValue(name) {
      const objArry = this.$refs.form.getFieldValue(name)
      if (objArry !== undefined) {
        if (objArry.length > 0) {
          let result = ''
          objArry.forEach((e) => {
            result += e.name + ','
          })
          return result.substr(0, result.length - 1)
        }
      }
      return ''
    },
  },
}
</script>

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

.formDiv {
  padding: 22px;

  :global(.buttons_sd-detail-form_common) {
    :global(.ant-form-item-control-wrapper) {
      padding-left: 24%;
      padding-top: 4%;
    }
  }

  .tr_border {
    box-sizing: border-box;
    border-right: 1px solid #e8e8e8;
    border-left: 1px solid #e8e8e8;
  }

  :global(.title_sd-detail-form_common) {
    font-size: 1.5em;
    text-align: center;
  }

  :global(.buttons_sd-detail-form_common) {
    display: none;
  }
}

.close-btn,
.save-btn {
  font-weight: 400;
  font-size: 16px;
  color: #fff;
  border: none;
  position: absolute;
  top: 18px;
  cursor: pointer;
}

.close-btn {
  right: 15px;
}

.save-btn {
  right: 80px;
}

.page {
  height: 100%;

  :global(.sd-frame-main) {
    height: 100%;
    padding: 10px;
    overflow: auto;
  }
}

.header {
  background: linear-gradient(to right, #3f9bff, #0e7df6);

  .header-title {
    color: #ffffff;
    font-size: 25px;
    font-weight: 400;
    display: inline;
  }
}
</style>
