<template>
  <!-- <div style="background:#fff;padding-top:10px"> -->
  <span :class="$style.remindconfig">
    <audit-form-top-banner :handel-save-form="saveForm" @handelSaveForm="saveForm">
      <sd-detail-form
        ref="docform"
        :key="key"
        page-id="audit/remindConfig/iamAuditRemindConfig"
        :record-id="recordId"
        :class="[$style.form]"
        @saved="saved"
      >
        <template v-slot="{ model, fields }">
          <table :class="$style.remindTable">
            <!-- <tr>
            <td
              class="ant-form-item-label ant-form-item-label"
              :colspan="4"
              style="background: none;border: none;font-size: 22px;font-weight: bold;color: #404040;"
            >
              《整改计划》提醒规则设置</td
            >
          </tr> -->
            <tr
              ><td style="border:none" colspan="4">
                <audit-advanced-group
                  :expand="basicExpand"
                  :expand-str="'basicExpand'"
                  :group-label="'《整改计划》提醒规则设置'"
                  tablestyle="''"
                  @changedClick="changedClick"
                ></audit-advanced-group> </td
            ></tr>
            <tr v-show="basicExpand">
              <!-- 计划到期前天数 -->
              <sd-form-item-td name="planTimeLimit" :colspan="3" />
            </tr>
            <tr v-show="basicExpand">
              <!-- 计划提醒对象 -->
              <sd-form-item-td name="planRemindObject" :colspan="3" />
            </tr>
            <tr v-show="basicExpand">
              <!-- 计划提醒方式 -->
              <sd-form-item-td name="planRemindType" :colspan="3" />
            </tr>
            <!-- <tr>
            <td
              class="ant-form-item-label ant-form-item-label"
              :colspan="4"
              style="background: none;border: none;font-size: 22px;font-weight: bold;color: #404040;"
            >
              《整改反馈》提醒规则设置</td
            >
          </tr> -->
            <tr
              ><td style="border:none" colspan="4">
                <audit-advanced-group
                  :expand="TxExpand"
                  :expand-str="'TxExpand'"
                  :group-label="'《整改反馈》提醒规则设置'"
                  tablestyle="''"
                  @changedClick="changedClick"
                ></audit-advanced-group> </td
            ></tr>
            <tr v-show="TxExpand">
              <!-- 反馈频率 -->
              <sd-form-item-td
                name="feedbackFrequency"
                :colspan="3"
                @change="changeFeedbackFrequency"
              />
            </tr>
            <tr v-show="TxExpand">
              <!-- 提醒设置 -->
              <sd-form-item-td name="remindSetting" :colspan="3">
                <template>
                  <audit-remind-setting
                    v-model="model.remindSetting"
                    :feedback-cycle="model.feedbackFrequency"
                  />
                </template>
              </sd-form-item-td>
            </tr>
            <tr v-show="TxExpand">
              <!-- 反馈提醒对象 -->
              <sd-form-item-td name="feedbackRemindObject" :colspan="3" />
            </tr>
            <tr v-show="TxExpand">
              <!-- 反馈提醒方式 -->
              <sd-form-item-td name="feedbackRemindType" :colspan="3" />
            </tr>
            <tr
              ><td style="border:none" colspan="4">
                <audit-advanced-group
                  :expand="CqtxExpand"
                  :expand-str="'CqtxExpand'"
                  :group-label="'《整改超期》提醒规则设置'"
                  tablestyle="''"
                  @changedClick="changedClick"
                ></audit-advanced-group> </td
            ></tr>
            <!-- <tr>
            <td class="ant-form-item-label ant-form-item-label" :colspan="4">
              《整改超期》提醒规则设置</td
            >
          </tr> -->
            <!-- <tr>
            // 整改到期前天数
              <sd-form-item-td name="rectificationTimeLimit" :colspan="3" />
            </tr> -->
            <tr v-show="CqtxExpand">
              <!-- 整改提醒对象 -->
              <sd-form-item-td name="rectificationRemindObject" :colspan="3" />
            </tr>
            <tr v-show="CqtxExpand">
              <!-- 整改提醒方式 -->
              <sd-form-item-td name="rectificationRemindType" :colspan="3" />
              <sd-form-item-td :hidden="true" name="orgId" />
            </tr>
          </table>
        </template>
      </sd-detail-form>
    </audit-form-top-banner>
  </span>
  <!-- </div> -->
</template>

<script>
import { Message } from 'ant-design-vue'
import axios from '@/common/services/axios-instance'
import auditFormTopBanner from '../../components/audit-form-top-banner'
import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
import auditAdvancedGroup from '../../components/audit-advanced-group.vue'
import auditRemindConfigService from './audit-remind-config-service'
import auditRemindSetting from './audit-remind-setting'
import components from './_import-components/audit-remind-config-import'

export default {
  name: 'AuditRemindConfig',
  metaInfo: {
    title: '整改提醒',
  },
  components: {
    ...components,
    auditFormTopBanner,
    auditRemindSetting,
    auditAdvancedGroup,
  },
  mixins: [auditAdvancedGroupMixins],
  data() {
    return {
      recordId: null,
      key: 0,
      basicExpand: true,
      TxExpand: true,
      CqtxExpand: true,
    }
  },
  created() {
    this.init()
  },
  methods: {
    saved() {
      Message.success({ content: '保存成功！' }, 1).then(() => {})
    },
    // 保存
    saveForm() {
      this.$refs.docform.saveBtnClick()
    },

    init() {
      axios({
        url: `api/xcoa-mobile/v1/iam-audit-frame-item/getAuditOrgId`,
      }).then((resMm) => {
        if (resMm.data) {
          const params = { auditOrgId: resMm.data }
          auditRemindConfigService.findIamAuditRemindConfigEntity(params).then((res) => {
            if (res.data) {
              this.recordId = res.data.id
              this.key++
            }
          })
        }
      })
    },

    // 频率
    changeFeedbackFrequency(value) {
      if (value === 1) {
        // 月
      } else if (value === 2) {
        // 季
      } else if (value === 3) {
        // 半年
      } else if (value === 4) {
        // 年
      }
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
@import '@/webflow/sd-flow-form.scss';
.remind-table {
  table-layout: auto !important;
  :global(.ant-form-item-label) {
    width: 15% !important;
  }
}
.remindconfig {
  :global(.ant-layout) {
    background: #fff;
  }
  :global(.ant-layout-header) {
    background: #fff;
  }
  :global(.close-btn_audit-form-top-banner_product) {
    display: none;
  }
}
</style>
