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

        <table v-show="basicExpand">
          <tr>
            <!-- 财务系统名称 -->
            <sd-form-item-td name="financialSystemName" />
            <!-- 财务系统版本 -->
            <sd-form-item-td name="financialSystemVersion" />
          </tr>
          <tr>
            <!-- 账套查询SQL -->
            <sd-form-item-td name="bookSetQuerySql" :colspan="3">
              <a-textarea v-model="model.bookSetQuerySql" :auto-size="{ minRows: 3, maxRows: 3 }" />
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 维护人员 -->
            <sd-form-item-td name="creatorName" />
            <!-- 维护日期 -->
            <sd-form-item-td name="creationTime" />
          </tr>
        </table>
      </template>
    </sd-detail-form>
  </audit-form-top-banner>
</template>

<script>
import axios from '@/common/services/axios-instance'
import { message } from '@/common/one-ui'
import crossWindowWatcher from '@/common/services/cross-window-watcher'
import auditFormTopBanner from '@product/iam/components/audit-form-top-banner'
import auditAdvancedGroup from '@product/iam//components/audit-advanced-group.vue'
import auditAdvancedGroupMixins from '@product/iam//components/audit-advanced-group-mixins'
import components from './_import-components/iam-dm-finsystem-form-import'

export default {
  name: 'IamDmFinsystemForm',
  metaInfo: {
    title: '财务系统版本',
  },
  components: {
    ...components,
    auditAdvancedGroup,
    auditFormTopBanner,
  },
  mixins: [auditAdvancedGroupMixins],
  data() {
    return {
      saveFlag: true,
      mode: null,
      basicExpand: true,
    }
  },
  methods: {
    // 页面加载完成后
    sdFormReady() {
      this.mode = this.$refs.docform.formData.mode
    },
    // 保存
    saveForm() {
      this.$refs.docform.saveBtnClick()
    },
    saved() {
      message.success({ content: '保存成功' }).then(() => {
        this.close(true)
      })
    },
    close(flag) {
      crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
      window.close()
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
@import '@/webflow/sd-flow-form.scss';
</style>
