<template>
  <div :class="[$style.odrForm, $style.rectprojectForm]">
    <sd-webflow
      ref="flow"
      :validate-form="validForm"
      :removed-tabs="['sdRelatedDoc']"
      @actionBtnClick="actionBtnClick"
    >
      <template v-slot:form="{ model, fields, FlowData }">
        <table>
          <tr>
            <td style="border:none">
              <audit-advanced-group
                :expand="infoExpand"
                :expand-str="'infoExpand'"
                :group-label="'整改跟踪单'"
                tablestyle="''"
                @changedClick="changedClick"
              ></audit-advanced-group>
            </td>
          </tr>
        </table>

        <table v-show="infoExpand">
          <colgroup>
            <col style="width: 180px;"/>
            <col />
            <col style="width: 180px;"/>
            <col
          /></colgroup>
          <tr>
            <!-- 项目名称 -->
            <sd-form-item-td name="projectName">
              <span>{{ model.projectName }}</span>
            </sd-form-item-td>
            <sd-form-item-td name="projectSource">
              <span>{{ model.projectSource }}</span>
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 项目code -->
            <sd-form-item-td name="projectCode" readonly :label="'项目编号'" />
            <!-- 整改责任主体名称 -->
            <sd-form-item-td name="auditedUnitName" readonly :label="'整改责任主体'" />
          </tr>
          <tr>
            <!-- 项目id -->
            <sd-form-item-td name="projectId" :colspan="3" :hidden="true" />
          </tr>
          <tr>
            <!-- 整改责任主体联系人名称 -->
            <sd-form-item-td name="auditedContactsName" readonly />
            <!-- 整改跟踪人名称 -->
            <sd-form-item-td name="resppersonsName" :label="'整改跟踪人'" />
          </tr>
          <tr>
            <!--  整改计划反馈截止日期 -->
            <sd-form-item-td name="expectFinishDate" :colspan="3" readonly />
          </tr>
          <tr>
            <!--  整改要求 -->
            <sd-form-item-td name="requirement" :colspan="3" readonly />
          </tr>
          <tr>
            <!-- 整改要求附件 -->
            <sd-form-item-td name="rectattach" :colspan="3">
              <template v-slot:read-and-edit="{ editable }">
                <sd-attachment
                  v-model="model.rectattach"
                  :read-only="true"
                  :group-id="JSON.parse(fields.rectattach.value).value"
                ></sd-attachment>
              </template>
            </sd-form-item-td>
          </tr>
        </table>

        <table>
          <tr
            ><td :colspan="4">
              <sd-form-item name="iamWorkRectCarryOutList" :label="null">
                <template v-slot:read-and-edit="{ editable }">
                  <audit-advanced-group
                    :expand="findExpand"
                    :expand-str="'findExpand'"
                    :group-label="'审计发现问题'"
                    @changedClick="changedClick"
                    ><template>
                      <!-- :read-only="FlowData.attrs.rectplanproject$findedit ? !editable : false" -->
                      <audit-rectchild-table
                        ref="findtable"
                        v-model="model.iamWorkRectCarryOutList"
                        label=""
                        :read-only="!editable"
                        :findinfoeditable="findinfoeditable"
                        :fields="
                          [
                            {
                              caption: '序号',
                              name: 'sortNum',
                              dataType: 'number',
                              attr: {},
                            },
                            {
                              caption: '操作',
                              name: 'opt',
                              dataType: 'action',
                              attr: {},
                            },
                          ].concat(Array.from(fields.iamWorkRectCarryOutList.attr.dync))
                        "
                        :columns="FlowData.attrs.rectplanproject$findedit ? Columnswcz : Columns"
                        :flagpage="true"
                        :fnrowclick="fnrowclick"
                      >
                        <template v-slot:opt="{ index }">
                          <a @click="fnlszg(index, $event)">落实整改</a>
                        </template>
                        <!-- form 表示这部分是子表组件的form插槽 -->
                        <template v-slot:form="{ 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>
                            <colgroup>
                              <col style="width: 12%;" />
                              <col style="width: 38%;" />
                              <col style="width: 12%;" />
                              <col style="width: 38%;" />
                            </colgroup>
                            <tr v-show="findinfoExpand">
                              <!-- 审计发现标题 -->
                              <sd-form-item-td
                                name="findingTitle"
                                :label="'审计发现标题'"
                                style="width:50%"
                              >
                                {{ model.findingTitle }}
                              </sd-form-item-td>
                              <!-- 审计发现编号 -->
                              <sd-form-item-td
                                name="findingCode"
                                :label="'审计发现编号'"
                                style="width:50%"
                              >
                                {{ model.findingCode }}
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfoExpand">
                              <!-- 审计发现类别 -->
                              <sd-form-item-td name="findType" :colspan="3">
                                <template v-slot:read-and-edit="{ editable }">
                                  {{ fngetjson(model.findType) }}
                                </template>
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfoExpand">
                              <!-- 审计发现描述 -->
                              <sd-form-item-td name="findDesc" :colspan="3">
                                {{ model.findDesc }}
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfoExpand">
                              <!-- 审计建议描述 -->
                              <sd-form-item-td name="suggestion" :colspan="3">
                                {{ model.suggestion }}
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfoExpand">
                              <!-- 问题责任部门 -->
                              <sd-form-item-td name="responsibleDept" :label="'问题责任部门'">
                                {{ model.responsibleDept }}
                              </sd-form-item-td>
                              <!-- 所属业务部 -->
                              <sd-form-item-td name="businessProcess">
                                <!-- {{ model.businessProcess }} -->
                                {{ fngetlabel(fields.businessProcess, model.businessProcess) }}
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfoExpand">
                              <!-- 是否问责 -->
                              <sd-form-item-td name="whetherOrderDuty">
                                <!-- {{ model.whetherOrderDuty }} -->
                                {{ fngetlabel(fields.whetherOrderDuty, model.whetherOrderDuty) }}
                              </sd-form-item-td>
                              <!-- 问责要求 -->
                              <sd-form-item-td name="orderDutyAsk">
                                {{ model.orderDutyAsk }}
                              </sd-form-item-td>
                            </tr>
                            <tr>
                              <td style="padding-left:5px" colspan="4">
                                <audit-advanced-group
                                  :expand="findinfoplanExpand"
                                  :expand-str="'findinfoplanExpand'"
                                  :group-label="'审计发现-整改计划信息'"
                                  tablestyle="''"
                                  @changedClick="changedClick"
                                ></audit-advanced-group>
                              </td>
                            </tr>
                            <tr v-show="findinfoplanExpand">
                              <!-- 整改责任人 -->
                              <sd-form-item-td
                                name="responsibleDeptName"
                                :label="'整改责任部门名称'"
                              >
                                <span>{{ model.responsibleDeptName }}</span>
                              </sd-form-item-td>
                              <!-- 直接责任人 -->
                              <sd-form-item-td name="directResponsible">
                                <span>{{ model.directResponsible }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfoplanExpand">
                              <!-- 领导责任人 -->
                              <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 v-show="findinfoplanExpand">
                              <!-- 完成日期 -->
                              <td class="ant-form-item-label ant-form-item-label"
                                ><label title="拟整改完成日期" class=""> 拟整改完成日期 </label></td
                              >
                              <td>
                                <span>{{ model.finishDate | sdDateFormat('YYYY-MM-DD') }}</span></td
                              >
                            </tr>
                            <tr v-show="findinfoplanExpand">
                              <!-- 措施 -->
                              <td class="ant-form-item-label ant-form-item-label"
                                ><label title="拟整改措施" class=""> 拟整改措施 </label></td
                              >
                              <td colspan="3">
                                <span>{{ model.measure }}</span></td
                              >
                            </tr>
                            <tr v-show="findinfoplanExpand">
                              <!-- 说明 -->
                              <sd-form-item-td :colspan="3" name="remark">
                                <span>{{ model.remark }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr>
                              <td style="padding-left:5px" colspan="4">
                                <audit-advanced-group
                                  :expand="findinfolsExpand"
                                  :expand-str="'findinfolsExpand'"
                                  :group-label="'审计发现-整改落实'"
                                  tablestyle="''"
                                  @changedClick="changedClick"
                                ></audit-advanced-group>
                              </td>
                            </tr>
                            <tr v-show="findinfolsExpand && !findinfoeditable">
                              <!--整改状态  -->
                              <td class="ant-form-item-label ant-form-item-label"
                                ><label title="整改状态" class=""> 整改状态 </label></td
                              >
                              <td>
                                <span>{{
                                  fngetlabel(fields.rectStatus, model.rectStatus)
                                }}</span></td
                              >
                              <!-- 整改完成日期 -->
                              <sd-form-item-td
                                v-if="model.rectStatus === '03'"
                                name="rectFinishDate"
                              >
                                <span>{{ model.rectFinishDate | sdDateFormat('YYYY-MM-DD') }}</span>
                              </sd-form-item-td> </tr
                            ><tr
                              v-show="
                                findinfolsExpand && !findinfoeditable && model.rectStatus === '01'
                              "
                            >
                              <!-- 是否超期未整改 -->
                              <sd-form-item-td name="isTrue">
                                <span>{{ fngetlabel(fields.isTrue, model.isTrue) }}</span>
                              </sd-form-item-td>

                              <!-- 超期原因 -->
                              <sd-form-item-td
                                v-if="model.isTrue === '1' || model.isTrue === 1"
                                name="overdueReason"
                              >
                                <span>{{ model.overdueReason }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr
                              v-if="
                                findinfolsExpand &&
                                  !findinfoeditable &&
                                  model.rectStatus !== '04' &&
                                  model.rectStatus !== '03'
                              "
                            >
                              <!-- 预计整改完成日期 -->
                              <sd-form-item-td name="expectedCompleteDate" :colspan="3">
                                <span>{{
                                  model.expectedCompleteDate | sdDateFormat('YYYY-MM-DD')
                                }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfolsExpand && !findinfoeditable">
                              <td class="ant-form-item-label ant-form-item-label"
                                ><label title="整改情况说明" class=""> 整改情况说明 </label></td
                              >
                              <td colspan="3">
                                <span>{{ model.description }}</span></td
                              >
                            </tr>
                            <tr v-show="findinfolsExpand && !findinfoeditable">
                              <!-- 完成日期 -->
                              <sd-form-item-td name="rectMoneyType">
                                <span>{{
                                  fngetlabel(fields.rectMoneyType, model.rectMoneyType)
                                }}</span>
                              </sd-form-item-td>
                              <sd-form-item-td name="rectMoneySum">
                                <span>{{ model.rectMoneySum }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfolsExpand && !findinfoeditable">
                              <!-- 成果利用 -->
                              <sd-form-item-td name="resultUse">
                                <span>{{ fngetlabel(fields.resultUse, model.resultUse) }}</span>
                              </sd-form-item-td>
                              <!-- 成果利用数量 -->
                              <sd-form-item-td name="resultUseSum">
                                <span>{{ model.resultUseSum }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfolsExpand && !findinfoeditable">
                              <!-- 处分信息 -->
                              <sd-form-item-td name="punishInfo">
                                <span>{{ fngetlabel(fields.punishInfo, model.punishInfo) }}</span>
                              </sd-form-item-td>
                              <!-- 处分人数 -->
                              <sd-form-item-td name="punishSum">
                                <span>{{ model.punishSum }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfolsExpand && !findinfoeditable">
                              <!-- 向司法机关移送或报案线索 -->
                              <sd-form-item-td name="transferToJustice">
                                <span>{{ model.transferToJustice }}</span>
                              </sd-form-item-td>
                              <!-- 涉案人员 -->
                              <sd-form-item-td name="personInvolved">
                                <span>{{ model.personInvolved }}</span>
                              </sd-form-item-td>
                            </tr>
                            <tr v-if="findinfolsExpand && !findinfoeditable">
                              <sd-form-item-td name="attachment" :colspan="3">
                                <template>
                                  <sd-attachment
                                    v-model="model.attachment"
                                    :group-id="groupId"
                                    :read-only="true"
                                  />
                                </template>
                              </sd-form-item-td>
                            </tr>
                            <!-- edit -->
                            <tr v-show="findinfolsExpand && findinfoeditable">
                              <!-- 整改状态 -->
                              <sd-form-item-td name="rectStatus" @change="changestatus(model)" />
                              <!-- 整改完成日期 -->
                              <sd-form-item-td
                                v-if="model.rectStatus === '03'"
                                name="rectFinishDate"
                              />
                            </tr>
                            <tr
                              v-if="
                                findinfolsExpand && findinfoeditable && model.rectStatus === '01'
                              "
                            >
                              <!-- 是否超期未整改 -->
                              <sd-form-item-td name="isTrue">
                                <span>{{ fngetlabel(fields.isTrue, model.isTrue) }}</span>
                              </sd-form-item-td>
                              <td
                                v-if="model.isTrue === '1' || model.isTrue === 1"
                                class="ant-form-item-label ant-form-item-label"
                                ><label title="超期原因" class="ant-form-item-required">
                                  超期原因
                                </label></td
                              >
                              <td v-if="model.isTrue === '1' || model.isTrue === 1">
                                <a-form-model-item
                                  prop="overdueReason"
                                  :label="null"
                                  :rules="[
                                    { required: true, message: '请输入超期原因', trigger: 'blur' },
                                  ]"
                                >
                                  <a-textarea v-model="model.overdueReason" :rows="3" />
                                </a-form-model-item>
                              </td>
                            </tr>
                            <tr
                              v-if="
                                findinfolsExpand &&
                                  findinfoeditable &&
                                  model.rectStatus !== '04' &&
                                  model.rectStatus !== '03'
                              "
                            >
                              <!-- 预计整改完成日期 -->
                              <sd-form-item-td name="expectedCompleteDate" :colspan="3" />
                            </tr>
                            <tr v-show="findinfolsExpand && findinfoeditable">
                              <!-- 整改情况说明 -->
                              <sd-form-item-td name="description" :colspan="3">
                                <a-textarea v-model="model.description" :rows="3" />
                              </sd-form-item-td>
                            </tr>
                            <tr v-show="findinfolsExpand && findinfoeditable">
                              <!-- 完成日期 -->
                              <sd-form-item-td name="rectMoneyType" />
                              <sd-form-item-td name="rectMoneySum" />
                            </tr>
                            <tr v-show="findinfolsExpand && findinfoeditable">
                              <!-- 成果利用 -->
                              <sd-form-item-td name="resultUse" />
                              <!-- 成果利用数量 -->
                              <sd-form-item-td name="resultUseSum" />
                            </tr>
                            <tr v-show="findinfolsExpand && findinfoeditable">
                              <!-- 处分信息 -->
                              <sd-form-item-td name="punishInfo" />
                              <!-- 处分人数 -->
                              <sd-form-item-td name="punishSum" />
                            </tr>
                            <tr v-show="findinfolsExpand && findinfoeditable">
                              <!-- 向司法机关移送或报案线索 -->
                              <sd-form-item-td name="transferToJustice" />
                              <!-- 涉案人员 -->
                              <sd-form-item-td name="personInvolved" />
                            </tr>
                            <tr v-if="findinfolsExpand && findinfoeditable">
                              <!-- 附件 -->
                              <sd-form-item-td name="attachment" :colspan="3">
                                <template v-slot:read-and-edit="{ editable }">
                                  <sd-attachment
                                    v-model="model.attachment"
                                    :group-id="
                                      typeof JSON.parse(fields.attachment.value) === 'object'
                                        ? JSON.parse(fields.attachment.value).value
                                        : fields.attachment.value
                                    "
                                    :read-only="!editable"
                                  />
                                </template>
                              </sd-form-item-td>
                            </tr>
                            <tr>
                              <td colspan="4" style="padding-left: 5px;">
                                <span style="color:#40a9ff">历史反馈记录</span>
                              </td>
                            </tr>
                            <tr>
                              <td :colspan="4" style="border:none">
                                <table style="width:100%">
                                  <tr>
                                    <td width="5.8%" style="text-align:center">序号</td
                                    ><td style="text-align:center">反馈日期</td
                                    ><td style="text-align:center">反馈状态</td>
                                  </tr>
                                  <tr
                                    v-for="(fk, index) in model.historyIamWorkRectCarryOutEntities"
                                    :key="index"
                                  >
                                    <td style="text-align:center">{{ index + 1 }}</td
                                    ><td style="text-align:center"
                                      ><a @click="fnopenfk(fngetnr(fk, 'id'))">{{
                                        fngetnr(fk, 'lastModifiedTime') | sdDateFormat('YYYY-MM-DD')
                                      }}</a></td
                                    ><td style="text-align:center">{{
                                      fngetlabel(fields.rectStatus, fngetnr(fk, 'rectStatus'))
                                    }}</td>
                                  </tr>
                                </table>
                              </td>
                            </tr>
                          </table>
                        </template>
                      </audit-rectchild-table>
                    </template>
                  </audit-advanced-group>
                </template>
                <!-- input-fieldName 表示这部分是子表行显示的插槽，fieldName是字段名 - ->
              <! -- <template v-slot:input-name="{ field, text }">
                <span>自定义{{ text }}</span>
              </template> -->
              </sd-form-item></td
            >
          </tr>
        </table>
      </template>
    </sd-webflow>
  </div>
</template>

<script>
import { Modal } from 'ant-design-vue'
import auditRectchildTable from '../rectplanproject/table/audit-rectchild-table.vue'
import auditAdvancedGroup from '../../components/audit-advanced-group.vue'
import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
import components from './_import-components/audit-rectfeedback-form-import'

export default {
  name: 'AuditRectfeedbackForm',
  metaInfo: {
    title: '整改反馈',
  },
  components: {
    ...components,
    auditAdvancedGroup,
    auditRectchildTable,
  },
  mixins: [auditAdvancedGroupMixins],
  data() {
    return {
      visibleY: false,
      visibleZ: false,
      projectId: '',
      infoExpand: true,
      findExpand: true,
      findinfoExpand: true,
      findinfoplanExpand: true,
      findinfoeditable: false,
      groupId: '',
      findrectfeedback: false,
      findinfolsExpand: true,
      Columns: [
        {
          title: '序号',
          dataIndex: 'sortNum',
          width: '80px',
          customRender: (text, record, index) => `${index + 1}`,
          sdHidden: false,
        },
        { title: '问题标题', dataIndex: 'findingTitle', sdHidden: false, width: '20%' },
        { title: '问题编号', dataIndex: 'findingCode', sdHidden: false, width: '200px' },
        { title: '拟整改完成日期', dataIndex: 'finishDate', sdHidden: false },
        { title: '整改状态', dataIndex: 'rectStatus', sdHidden: false, width: '100px' },
        { title: '整改完成日期', dataIndex: 'rectFinishDate', sdHidden: false },
        {
          title: '拟整情况说明',
          dataIndex: 'description',
          sdHidden: false,
          width: '25%',
        },
        {
          title: '操作',
          dataIndex: 'opt',
          sdHidden: true,
        },
      ],
      Columnswcz: [
        {
          title: '序号',
          dataIndex: 'sortNum',
          width: '80px',
          customRender: (text, record, index) => `${index + 1}`,
          sdHidden: false,
        },
        { title: '问题标题', dataIndex: 'findingTitle', sdHidden: false, width: '15%' },
        { title: '问题编号', dataIndex: 'findingCode', sdHidden: false, width: '200px' },
        { title: '拟整改完成日期', dataIndex: 'finishDate', sdHidden: false },
        { title: '整改状态', dataIndex: 'rectStatus', sdHidden: false, width: '100px' },
        { title: '整改完成日期', dataIndex: 'rectFinishDate', sdHidden: false },
        {
          title: '拟整情况说明',
          dataIndex: 'description',
          sdHidden: false,
          width: '20%',
        },
        {
          title: '操作',
          dataIndex: 'opt',
          sdHidden: false,
        },
      ],
      historycarryoutcolumns: [
        {
          title: '序号',
          dataIndex: 'sortNum',
          width: '50px',
          customRender: (text, record, index) => `${index + 1}`,
          sdHidden: false,
        },
        {
          title: '反馈日期',
          dataIndex: 'rectFinishDate',
          sdHidden: false,
        },
        {
          title: '反馈状态',
          dataIndex: 'rectStatus',
          sdHidden: false,
        },
        {
          dataIndex: 'rectFeedbackId',
          sdHidden: true,
        },
        {
          dataIndex: 'mark',
          sdHidden: true,
        },
      ],
    }
  },
  mounted() {
    if (this.$refs.flow.FlowData) {
      this.findrectfeedback = this.fngetfindedit()

      const obj = this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find(
        (item) => item.name === 'iamWorkRectCarryOutList'
      )
      const no = JSON.parse(obj.value)
      no.forEach((item) => {
        if (
          typeof item.attachment === 'string' &&
          typeof JSON.parse(item.attachment) !== 'object'
        ) {
          item.attachment = JSON.stringify({ value: parseFloat(item.attachment) + '' })
        }
        if (typeof item.isTrue === 'number') {
          item.isTrue = item.isTrue.toString()
        }
        // 转json格式，确保最后一次存的是可以直接格式化的json字符串
        if (typeof item.historyIamWorkRectCarryOutEntities === 'string') {
          item.historyIamWorkRectCarryOutEntitiesJson = JSON.parse(
            item.historyIamWorkRectCarryOutEntities
          )
        } else {
          item.historyIamWorkRectCarryOutEntitiesJson = item.historyIamWorkRectCarryOutEntities
        }

        while (typeof item.historyIamWorkRectCarryOutEntitiesJson === 'string') {
          item.historyIamWorkRectCarryOutEntitiesJson = JSON.parse(
            item.historyIamWorkRectCarryOutEntitiesJson
          )
        }
        // 在转换为json字符串
        item.historyIamWorkRectCarryOutEntities = JSON.stringify(
          item.historyIamWorkRectCarryOutEntitiesJson
        )
      })
      this.$refs.flow.setFieldValue('iamWorkRectCarryOutList', no)
      if (this.$refs.flow.getFieldValue('projectId') !== '') {
        this.projectId = this.$refs.flow.getFieldValue('projectId')
      }
    }
  },
  methods: {
    fngetlabel(obj, val) {
      if (obj.attr.selectListItem) {
        const o = obj.attr.selectListItem.find((item) => item.value === val)
        if (o) {
          return o.label
        } else {
          if (val !== undefined) {
            const o = obj.attr.selectListItem.find(
              (item) => item.value.toString() === val.toString()
            )
            if (o) {
              return o.label
            } else {
              return val
            }
          } else {
            return val
          }
        }
      } else {
        return val
      }
    },
    fngetfindedit() {
      if (this.$refs.flow !== undefined) {
        if (this.$refs.flow.FlowData.attrs.rectplanproject$findedit !== undefined) {
          if (this.$refs.flow.FlowData.attrs.rectplanproject$findedit === true) {
            return true
          } else {
            return false
          }
        } else {
          return false
        }
      } else {
        return false
      }
    },
    fngetjson(data) {
      if (data !== undefined && data !== '') {
        if (typeof JSON.parse(data) === 'object') {
          return JSON.parse(data).text
        } else {
          return data
        }
      } else {
        return ''
      }
    },
    validForm() {
      // return true
      const child = this.$refs.flow.getFieldValue('iamWorkRectCarryOutList')
      if (child === undefined || child.length === 0) {
        Modal.warning({
          title: '提示',
          content: '请增加至少一条审计发现问题!',
        })
        return Promise.resolve(false)
      }
      const findinfoeditable = this.$refs.flow.FlowData.attrs.rectplanproject$findedit
      if (findinfoeditable) {
        // console.log('--校验判断 是否动态子表填写完毕')
        let flag = true
        child.forEach((c) => {
          if (c.rectStatus === '' || c.rectStatus === null || c.rectStatus === undefined) {
            flag = false
          }
          if (c.description === '' || c.description === null || c.description === undefined) {
            flag = false
          }
        })
        if (flag) {
          return Promise.resolve(true)
        } else {
          Modal.warning({
            title: '提示',
            content: '请完善反馈列表中的信息!',
          })
          return Promise.resolve(false)
        }
      } else {
        return Promise.resolve(true)
      }
    },
    actionBtnClick(evt, { button, FlowData }) {},
    // 问题发现
    showselectfind() {
      this.$refs.selectfind.projectId = this.projectId
      if (this.projectId !== '') {
        this.$refs.selectfind.filterExpressions = [
          {
            dataType: 'long',
            name: 'projectId',
            op: 'eq',
            longValue: parseInt(this.projectId),
          },
        ]
      }
      this.visibleZ = !this.visibleZ
    },
    Selectedfind(keys, findlist) {
      findlist.forEach((item) => {
        item.findingTitle = item.findTitle
        item.findingCode = item.findCode
        item.responsibleDeptName = item.auditedUnitNames
      })
      this.$refs.flow.setFieldValue('iamWorkFindRectplanList', findlist)
    },
    // 项目选择器列表
    mxRelSelect() {
      this.visibleY = !this.visibleY
    },

    listMxSelected(keys, keyinfos, key) {
      this.projectId = keyinfos[0].id
      this.$refs.flow.setFieldValue('projectId', keyinfos[0].id)
      this.$refs.flow.setFieldValue('projectName', keyinfos[0].projectTitle)
      this.$refs.flow.setFieldValue('projectCode', keyinfos[0].projectCode)
      const unitsname = keyinfos[0].auditedUnitNames
      const unitscode = keyinfos[0].auditedUnitCodes
      const vname = unitsname.split(',')
      const vcode = unitscode.split(',')
      const vunits = []
      vname.forEach((item, index) => {
        vunits.push({
          type: 'Group',
          code: vcode[index].toString(),
          name: vname[index].toString(),
        })
      })
      this.$refs.flow.setFieldValue('auditedUnit', vunits)
      if (key === '1') {
        this.$refs.flow.setFieldValue('projectSource', '内部项目')
      } else {
        this.$refs.flow.setFieldValue('projectSource', '外部项目')
      }
    },
    fnlszg(index, event) {
      this.findinfoeditable = true
      this.$refs.findtable.editlsfk(index, true)
      event.stopPropagation()
    },
    fnrowclick(record) {
      this.findinfoeditable = false
      if (typeof record.attachment === 'object') {
        this.groupId = record.attachment.value
      } else if (typeof JSON.parse(record.attachment) === 'object') {
        this.groupId = JSON.parse(record.attachment).value
      } else {
        this.groupId = record.attachment
      }
    },
    fngetattach(obj) {
      if (typeof obj === 'object') {
        if (obj.length === 0) {
          return 0
        } else {
          return obj.value
        }
      } else {
        return obj
      }
    },
    changestatus(model) {
      const now = new Date()
      model.isTrue = '0'
      if (model.rectStatus === '01') {
        const rq = new Date(model.finishDate)
        if (rq < now) {
          model.isTrue = '1'
        }
        model.rectFinishDate = null
      } else if (model.rectStatus === '03') {
        model.expectedCompleteDate = null
      } else if (model.rectStatus === '04') {
        model.expectedCompleteDate = null
        model.rectFinishDate = null
      } else {
        model.rectFinishDate = null
      }
      if (model.isTrue === '0') {
        model.overdueReason = ''
      }
    },
    fnopenhistoryrecify() {
      return false
    },
    fnopenfk(id) {
      const url = '#/audit-question-feedback-form?record=' + id + '&history=1'
      window.open(url)
    },
    fngetnr(obj, item) {
      if (obj === undefined) {
        return ''
      } else {
        if (obj.length === undefined) {
          return obj[item]
        } else if (obj.length > 0) {
          return obj[obj.length - 1][item]
        } else {
          return ''
        }
      }
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.btnselect {
  position: relative;
  float: right;
  .batchselect {
    z-index: 100;
    margin-right: 190px;
  }
}
:global(.ant-modal-content) {
  :global(.ant-input-number) {
    width: 100%;
  }
}
</style>
