<template>
  <sd-webflow ref="flow" @actionBtnClick="actionBtnClick">
    <template v-slot:form="{ model, fields, FlowData }">
      <table>
        <tr>
          <td style="padding-left:5px;border:none">
            <audit-advanced-group
              :expand="findExpand"
              :expand-str="'findExpand'"
              :group-label="'审计发现_基本信息'"
              tablestyle="''"
              @changedClick="changedClick"
            ></audit-advanced-group>
          </td>
        </tr>
      </table>

      <table v-show="findExpand">
        <colgroup>
          <col style="width: 180px;"/>
          <col />
          <col style="width: 180px;"/>
          <col
        /></colgroup>
        <tr>
          <!-- 审计发现标题 -->
          <sd-form-item-td name="findTitle" :label="'问题名称（定性描述）'">{{
            model.findTitle
          }}</sd-form-item-td>
          <!-- 审计发现编号 -->
          <sd-form-item-td name="findCode" :label="'问题编号'">{{
            model.findCode
          }}</sd-form-item-td>
        </tr>
        <tr>
          <!-- 审计发现类别 -->
          <!-- <sd-form-item-td name="findType" >
            {{ model.findType }}
          </sd-form-item-td> -->
          <!-- 问题分类 -->
          <sd-form-item-td name="problemCategoryFunction" readonly :label="'问题分类'">
            {{ model.problemCategoryFunction }}
          </sd-form-item-td>
        </tr>
        <tr>
          <!-- 审计发现描述 -->
          <sd-form-item-td name="findDesc" :label="'问题描述'" :colspan="3">{{
            model.findDesc
          }}</sd-form-item-td>
        </tr>
      </table>

      <table>
        <tr>
          <td style="padding-left:5px;border:none">
            <audit-advanced-group
              :expand="delayExpand"
              :expand-str="'delayExpand'"
              :group-label="'审计发现_延期申请'"
              tablestyle="''"
              @changedClick="changedClick"
            ></audit-advanced-group>
          </td>
        </tr>
      </table>

      <table v-show="delayExpand">
        <colgroup>
          <col style="width: 180px;"/>
          <col />
          <col style="width: 180px;"/>
          <col
        /></colgroup>
        <sd-form-item-td name="rectFeedbackId" :hidden="true" />
        <sd-form-item-td name="projectId" :hidden="true" />
        <tr>
          <!-- 原预计整改完成日期(拟整改完成日期) -->
          <sd-form-item-td name="draftFinishDate" :label="'原预计整改完成日期'">
            <!-- {{ model.draftFinishDate }} -->
            <template v-slot:read-and-edit="{ editable }">
              <span>{{ model.draftFinishDate | sdDateFormat('YYYY-MM-DD') }}</span>
            </template>
          </sd-form-item-td>
          <!-- 申请延至日期 -->
          <sd-form-item-td name="delayDate" />
        </tr>
        <tr>
          <!-- 申请延期说明 -->
          <sd-form-item-td name="delayDesc" :colspan="3">
            <a-textarea v-model="model.delayDesc" :rows="3" />
          </sd-form-item-td>
        </tr>
        <tr>
          <!-- 附件 -->
          <sd-form-item-td name="attachment" :colspan="3" />
        </tr>
      </table>
    </template>
  </sd-webflow>
</template>

<script>
import axios from '@/common/services/axios-instance'
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/spic-rectifydelay-form-import'

export default {
  name: 'SpicRectifydelayForm',
  metaInfo: {
    title: '整改延期申请反馈',
  },
  components: {
    ...components,
    auditAdvancedGroup,
  },
  mixins: [auditAdvancedGroupMixins],
  data() {
    return {
      findExpand: true,
      delayExpand: true,
      flag: true,
      attachments: [],
    }
  },
  mounted() {
    let query = {}
    if (this.$route.query.extParams) {
      query = JSON.parse(this.$route.query.extParams)
    } else {
      query = {
        rectFeedbackId: this.$refs.flow.getFieldValue('rectFeedbackId'),
      }
    }
    // 获取问题信息
    axios({
      url: `api/xcoa-mobile/v1/spicrectfeedback/getInfoById?id=${query.rectFeedbackId}`,
      method: 'get',
    }).then((res) => {
      this.$refs.flow.setFieldValue('findTitle', res.data.findingTitle)
      this.$refs.flow.setFieldValue('findCode', res.data.findingCode)
      this.$refs.flow.setFieldValue('findType', res.data.findType)
      this.$refs.flow.setFieldValue('findDesc', res.data.findDesc)
      this.$refs.flow.setFieldValue('problemCategoryFunction', res.data.problemCategoryFunction)
      this.$refs.flow.setFieldValue('draftFinishDate', res.data.draftFinishDate)
      this.$refs.flow.setFieldValue('title', res.data.findingTitle + '的整改延期申请')
    })
  },
  methods: {
    actionBtnClick(evt, { button, FlowData }) {
      evt.waitUntil(
        new Promise((resolve, reject) => {
          resolve()
        })
      )
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.files {
  height: 30px;
  overflow: hidden;
  .files-name {
    float: left;
  }
  .files-btn {
    float: right;
    button {
      margin-right: 20px;
    }
  }
}
</style>
