<template v-slot:form="{ model }">
  <!-- <sd-form ref="form" :init-values="values" style="flex:1"> -->
  <audit-form-top-banner :handel-save-form="saveForm" @handelSaveForm="saveForm">
    <sd-detail-form
      ref="docform"
      page-id="audit/rectPlanProject/iamWorkFindRectplan"
      :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
      :class="$style.form"
      @close="close(true)"
      @saved="saved"
      ><template v-slot="{ model, fields }">
        <table>
          <tr>
            <td style="padding-left:5px">
              <audit-advanced-group
                :expand="findinfoExpand"
                :expand-str="'findinfoExpand'"
                :group-label="'审计发现-基本信息'"
                tablestyle="''"
                @changedClick="changedClick"
              ></audit-advanced-group>
            </td>
          </tr>
        </table>

        <table v-show="findinfoExpand">
          <tr>
            <!-- 审计发现标题 -->
            <sd-form-item-td name="findingTitle">
              {{ model.findingTitle }}
            </sd-form-item-td>
            <!-- 审计发现编号 -->
            <sd-form-item-td name="findingCode">
              {{ model.findingCode }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 审计发现类别 -->
            <sd-form-item-td name="findType" :colspan="3">
              {{ JSON.parse(model.findType).text }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 审计发现描述 -->
            <sd-form-item-td name="findDesc" :colspan="3">
              {{ model.findDesc }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 审计建议描述 -->
            <sd-form-item-td name="suggestion" :colspan="3">
              {{ model.suggestion }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 问题责任部门 -->
            <sd-form-item-td name="responsibleDept">
              {{ model.responsibleDept }}
            </sd-form-item-td>
            <!-- 所属业务部 -->
            <sd-form-item-td name="businessProcess">
              {{ model.businessProcess }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 是否问责 -->
            <sd-form-item-td name="whetherOrderDuty">
              {{ model.whetherOrderDuty }}
            </sd-form-item-td>
            <!-- 问责要求 -->
            <sd-form-item-td name="orderDutyAsk">
              {{ model.orderDutyAsk }}
            </sd-form-item-td>
          </tr>
        </table>

        <table>
          <tr>
            <td style="padding-left:5px">
              <audit-advanced-group
                :expand="findinfoplanExpand"
                :expand-str="'findinfoplanExpand'"
                :group-label="'审计发现-整改计划'"
                tablestyle="''"
                @changedClick="changedClick"
              ></audit-advanced-group>
            </td>
          </tr>
        </table>

        <table v-show="findinfoplanExpand && findinfoeditable">
          <tr>
            <!-- 整改责任部门 -->
            <sd-form-item-td name="responsibleDeptName" />
            <!-- 直接责任人 -->
            <sd-form-item-td name="directResponsible" />
          </tr>
          <tr>
            <!-- 领导责任人 -->
            <sd-form-item-td name="leaderResponsible" />
            <!-- 共同责任部门 -->
            <sd-form-item-td name="commonDutyDepart" />
          </tr>
          <tr>
            <!-- 完成日期 -->
            <sd-form-item-td name="finishDate" :colspan="3" />
          </tr>
          <tr>
            <!-- 措施 -->
            <sd-form-item-td :colspan="3" name="measure" />
          </tr>
          <tr>
            <!-- 说明 -->
            <sd-form-item-td :colspan="3" name="remark" />
          </tr>
        </table>

        <table v-show="findinfoplanExpand && !findinfoeditable">
          <tr>
            <!-- 整改责任人 -->
            <sd-form-item-td name="responsibleDeptName">
              <span>{{ model.responsibleDeptName }}</span>
            </sd-form-item-td>
            <!-- 直接责任人 -->
            <sd-form-item-td name="directResponsible">
              <span>{{ model.directResponsible }}</span>
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 领导责任人 -->
            <sd-form-item-td name="leaderResponsible">
              <span>{{ model.leaderResponsible }}</span>
            </sd-form-item-td>
            <!-- 共同责任部门 -->
            <sd-form-item-td name="commonDutyDepart">
              <span>{{ model.commonDutyDepart }}</span>
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 完成日期 -->
            <sd-form-item-td name="finishDate" :colspan="3">
              <span>{{ model.finishDate }}</span>
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 措施 -->
            <sd-form-item-td :colspan="3" name="measure">
              <span>{{ model.measure }}</span>
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 说明 -->
            <sd-form-item-td :colspan="3" name="remark">
              <span>{{ model.remark }}</span>
            </sd-form-item-td>
          </tr>
        </table>

        <!-- </sd-form> -->
      </template>
    </sd-detail-form>
  </audit-form-top-banner>
</template>

<script>
import { Message } from 'ant-design-vue'
import axios from '@/common/services/axios-instance'
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 components from './_import-components/audit-rectfind-form-import'

export default {
  name: 'AuditRectfindForm',
  metaInfo: {
    title: 'AuditRectfindForm',
  },

  components: {
    ...components,
    auditFormTopBanner,
    auditAdvancedGroup,
  },
  data() {
    return {
      findinfoExpand: true,
      findinfoplanExpand: true,
      findinfoeditable: false,
      findId: '',
      mainId: '',
    }
  },
  created() {
    if (this.$route.query.findId) {
      this.findId = this.$route.query.findId
      axios({
        url:
          'api/xcoa-mobile/v1/page/wp/audit/work/reportFind/iamAuditReportFind?id=' + this.findId,
        method: 'get',
      }).then((res) => {
        // ,,,,,,
        const field = [
          'findingTitle',
          'findingCode',
          'findType',
          'findDesc',
          'suggestion',
          'responsibleDept',
          'businessProess',
        ]
        res.data.pageFormData.pageFieldInfos.forEach((item) => {
          console.log(item)
        })
      })
    }
    if (this.$route.query.id) {
      this.mainId = this.$route.query.id
    }
  },
  methods: {
    // 保存
    saveForm() {
      // this.$refs.docform.saveBtnClick()
    },
    close(flag) {
      crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
      window.close()
    },
    saved() {
      Message.success('保存成功', 1).then((res) => {
        // this.close(true)
      })
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
