<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: 300px" />
            <col />
            <col style="width: 300px" />
            <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="'项目编号'">
              {{ model.projectCode }}
            </sd-form-item-td>
            <!-- 整改责任主体名称 -->
            <sd-form-item-td name="auditedUnitName" readonly :label="'整改责任主体'">
              {{ model.auditedUnitName }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 整改责任主体联系人名称 -->
            <sd-form-item-td name="auditedContactsName" readonly>
              {{ model.auditedContactsName }}
            </sd-form-item-td>
            <!-- 整改跟踪人名称 -->
            <sd-form-item-td name="resppersonsName" :label="'整改跟踪人'">
              {{ model.resppersonsName }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!--  整改要求 -->
            <sd-form-item-td name="requirement" :colspan="3" readonly>
              {{ model.requirement }}
            </sd-form-item-td>
          </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> -->
          <tr>
            <!-- 审计发现标题 -->
            <sd-form-item-td name="findingTitle" readonly :label="'问题名称（定性描述）'">
              {{ model.findingTitle }}
            </sd-form-item-td>
            <!-- 审计发现编号 -->
            <sd-form-item-td name="findingCode" readonly :label="'问题编号'">
              {{ model.findingCode }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!--  审计问题描述 -->
            <sd-form-item-td name="findDesc" :colspan="3" readonly :label="'问题描述'">
              {{ model.findDesc }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 审计问题类别 -->
            <!-- <sd-form-item-td name="findType" readonly :label="'问题类别'">
              {{ model.findType }}
            </sd-form-item-td> -->
            <!-- 是否属于审计意见书问题 -->
            <sd-form-item-td name="giveOpinion">
              {{ model.giveOpinion }}
            </sd-form-item-td>
            <!-- 问题分类 -->
            <sd-form-item-td name="problemCategoryFunction" readonly :label="'问题类别'" />
          </tr>
          <tr>
            <!-- 审计处理意见 -->
            <sd-form-item-td name="handleSuggestion" :colspan="3" readonly :label="'审计处理意见'">
              {{ model.handleSuggestion }}
            </sd-form-item-td>
          </tr>
          <tr>
            <!--  问题下发时间-->
            <sd-form-item-td name="creationTime" :colspan="3" readonly :label="'问题下发时间'">
              {{ model.creationTime }}
            </sd-form-item-td>
          </tr>
        </table>

        <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: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>
          <tr>
            <!-- 整改责任部门 -->
            <sd-form-item-td name="responsibleDeptName" :label="'整改责任部门'" />
            <!-- 直接责任人 -->
            <sd-form-item-td name="directResponsible" :label="'直接责任人'" />
          </tr>
          <tr>
            <!-- 领导责任人 -->
            <sd-form-item-td name="leaderResponsible" :label="'领导责任人'" />
            <!-- 共同责任部门 -->
            <sd-form-item-td name="commonDutyDepart" :label="'共同责任部门'" />
          </tr>
        </table>

        <table>
          <tr>
            <td style="padding-left: 5px; border: none">
              <audit-advanced-group
                :expand="findExpand"
                :expand-str="'findExpand'"
                :group-label="'整改落实'"
                tablestyle="''"
                :findinfoeditable="findinfoeditable"
                @changedClick="changedClick"
              ></audit-advanced-group>
            </td>
          </tr>
        </table>

        <table v-show="findExpand">
          <colgroup>
            <col style="width: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>

          <tr>
            <!-- 整改状态 -->
            <sd-form-item-td name="rectState" :label="'整改状态'">
              <a-select
                v-model="model.rectState"
                :allow-clear="true"
                :options="fields.rectState.attr.selectListItem"
                @change="handlerRectState(model, $event, fields)"
              ></a-select>
            </sd-form-item-td>
            <!-- {{ model.rectType }} -->
            <!-- 整改类别 -->
            <sd-form-item-td name="rectType" :label="'问题类型'">
              <a-select
                v-model="model.rectType"
                :allow-clear="true"
                @change="handlerRectType(model, model.rectType, fields)"
              >
                <a-select-option
                  v-for="item in fields.rectType.attr.selectListItem.filter((itc) =>
                    ['01', '02', '03'].includes(itc.value)
                  )"
                  :key="item.value"
                  :value="item.value"
                >
                  {{ item.label }}
                </a-select-option>
              </a-select>
            </sd-form-item-td>
          </tr>
          <tr>
            <sd-form-item-td
              name="rectMeasure"
              :colspan="3"
              :label="
                model.rectType === '03' || model.rectType === '02'
                  ? '整体计划整改措施'
                  : '计划整改措施'
              "
            >
              <template>
                <a-textarea v-if="fourShow" v-model="model.rectMeasure" :rows="3" />
                <span v-else read-only>{{ model.rectMeasure }}</span>
              </template>
            </sd-form-item-td>
          </tr>
          <tr>
            <sd-form-item-td name="rectRemark" :colspan="3" :label="'整改责任考核方案'">
              <template v-slot>
                <a-textarea
                  v-if="fourShow"
                  v-model="model.rectRemark"
                  :auto-size="{ minRows: 3, maxRows: 3 }"
                ></a-textarea>
                <span v-else read-only>{{ model.rectRemark }}</span>
              </template>
            </sd-form-item-td>
          </tr>
          <tr v-if="model.rectType === '02' || model.rectType === '03'">
            <sd-form-item-td name="supportMaterial" :colspan="3" :label="'阶段性目标'">
              <a-textarea v-if="fourShow" v-model="model.supportMaterial" :rows="3" />
              <span v-else read-only>{{ model.supportMaterial }}</span>
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 计划完成日期 -->
            <!-- @change="handlerFinash(model, $event, fields)" -->
            <sd-form-item-td
              v-if="model.rectType === '01' || model.rectType === '02' || model.rectType === '03'"
              :colspan="3"
              name="draftFinishDate"
              :label="model.rectType === '01' ? '计划完成日期' : '阶段性目标计划完成日期'"
              :required="model.rectType === '03' || model.rectType === '02'"
            >
              <span v-if="model.rectType === '01' || !fourShow">{{
                model.draftFinishDate | sdDateFormat('YYYY-MM-DD')
              }}</span>
            </sd-form-item-td>
          </tr>

          <tr>
            <!-- 措施执行情况-->
            <sd-form-item-td
              name="draftRectMeasure"
              :colspan="3"
              :label="
                model.rectType === '03' || model.rectType === '02'
                  ? '阶段性措施执行情况'
                  : '措施执行情况'
              "
            >
              <a-textarea v-model="model.draftRectMeasure" :rows="3" />
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 附件 -->
            <sd-form-item-td name="attachment" :colspan="3" :label="'支撑性材料'" />
          </tr>
          <tr v-show="isShow1">
            <!--是否完成当年整改阶段目标 （审计部审批环节显示）-->
            <sd-form-item-td name="whetherFinishTarget" :label="'是否完成当年整改阶段目标'" />
          </tr>
          <tr v-show="!isedit1">
            <!--是否完成当年整改阶段目标 (只读) -->
            <sd-form-item-td name="whetherFinishTarget" :label="'是否完成当年整改阶段目标'">
              <span read-only>{{ fnget(model.whetherFinishTarget) }}</span>
            </sd-form-item-td>
          </tr>

          <tr v-show="isShow2">
            <!--是否经过部委会同意 -->
            <sd-form-item-td name="whetherAgree" :label="'是否经过部委会同意'" />
          </tr>
          <tr v-show="!isedit2">
            <!--是否经过部委会同意 (只读)-->
            <sd-form-item-td name="whetherAgree" :label="'是否经过部委会同意'">
              <span read-only>{{ fnget(model.whetherAgree) }}</span>
            </sd-form-item-td>
          </tr>
          <tr>
            <!-- 整改完成日期 系统自动 -->
            <sd-form-item-td name="finishDate" :label="'实际整改完成日期'">
              <span>{{ model.finishDate | sdDateFormat('YYYY-MM-DD') }}</span>
            </sd-form-item-td>
          </tr>
        </table>

        <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: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>
          <tr>
            <!--  调整会计账目（万元） -->
            <sd-form-item-td name="adjustAccountAccounts" :label="'调整会计账目'" />
            <!-- 收回资金（万元） -->
            <sd-form-item-td name="recoveryFunds" :label="'收回资金：增加收入金额'" />
          </tr>
          <tr>
            <!--  其中：避免损失浪费数额（万元） -->
            <sd-form-item-td
              name="avoidingWasteAmount"
              :label="'收回资金：督促清理往来款项收回资金'"
            />
            <!-- 核减投资额（万元） -->
            <sd-form-item-td name="reduceInvestmentAmount" :label="'收回资金：其他'" />
          </tr>
          <tr>
            <!--  节约成本数额（万元） -->
            <sd-form-item-td
              name="costSavingAmount"
              :label="'挽回损失：节约成本费用（开支）金额'"
            />
            <!-- 其中：工程投资审减额 （万元） -->
            <sd-form-item-td name="engineeringReduction" :label="'挽回损失：工程审减金额'" />
          </tr>
          <tr>
            <!--  清退个人不当得利（万元） -->
            <sd-form-item-td name="improperClearanceAmount" :label="'挽回损失：清退不当得利'" />
            <!--  挽回损失数额（万元） -->
            <sd-form-item-td name="recoveryLossAmount" :label="'挽回损失：其他'" />
          </tr>
          <tr>
            <!-- 归还原资金渠道（万元） -->
            <sd-form-item-td name="repaymentChannels" :label="'归还原资金渠道'" />
            <!-- 补缴税费（万元） -->
            <sd-form-item-td name="paymentTaxesFees" :label="'补缴税费'" />
          </tr>
          <tr>
            <!-- 其他（万元） -->
            <sd-form-item-td name="otherAmount" :label="'其他'" />
          </tr>
        </table>

        <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: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>
          <tr>
            <!--  新建制度、流程、标准（项） -->
            <sd-form-item-td name="newItems" :label="'新建制度、流程、标准（项）'" />
            <!-- 修订制度、流程、标准（项） -->
            <sd-form-item-td name="reviseItems" :label="'修订制度、流程、标准（项）'" />
          </tr>
          <!--  优化完善业务流程 -->
          <!-- 完善机制 -->
          <!-- <tr>
            <sd-form-item-td name="optimizeBusinessProcesses" :label="'优化完善业务流程'" />
            <sd-form-item-td name="improveMechanism" :label="'完善机制'" />
          </tr>
          <tr>
            <sd-form-item-td name="otherItems" :label="'其他'" />
          </tr> -->
          <!-- 其他 -->
        </table>

        <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: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>
          <tr>
            <!--  办结工程结算项目数（个） -->
            <sd-form-item-td name="completionProjectNumber" :label="'办结工程结算项目数（个）'" />
            <!-- 办结竣工决算项目数（个） -->
            <sd-form-item-td
              name="completionSettlementAmount"
              :label="'办结竣工决算项目数（个）'"
            />
          </tr>
        </table>

        <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: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>
          <!--  追责问责（人次） -->
          <!-- 经济处罚数额（万元） -->
          <!-- <tr>
            <sd-form-item-td name="accountability" :label="'追责问责（人次）'" />
            <sd-form-item-td name="amountEconomicPenalty" :label="'经济处罚数额（万元）'" />
          </tr> -->
          <tr>
            <!--  移送纪检监察部门案件线索（件） -->
            <sd-form-item-td name="transferMonitorClue" :label="'移送纪检监察部门案件线索（件）'" />
            <!-- 实际查处案件数量（件） -->
            <!-- <sd-form-item-td name="actualCaseNumber" :label="'实际查处案件数量（件）'" /> -->
          </tr>
          <tr>
            <!--  移送纪检监察线索说明（单移送） -->
            <sd-form-item-td
              name="transferMonitorSingle"
              :colspan="3"
              :label="'移送纪检监察线索说明（单移送）'"
            >
              <a-textarea v-model="model.transferMonitorSingle" :rows="3" />
            </sd-form-item-td>
          </tr>
          <tr>
            <!--  移送纪检监察线索说明（双移送） -->
            <sd-form-item-td
              name="transferMonitorDouble"
              :colspan="3"
              :label="'移送纪检监察线索说明（双移送）'"
            >
              <a-textarea v-model="model.transferMonitorDouble" :rows="3" />
            </sd-form-item-td>
          </tr>
          <!--  给予党纪处分（人次） -->
          <!-- 给予政务处分（人次） -->
          <!-- <tr>
            <sd-form-item-td name="disciplinaryPunishment" :label="'给予党纪处分（人次）'" />
            <sd-form-item-td name="administrativeSanctions" :label="'给予政务处分（人次）'" />
          </tr> -->
          <!--  员工奖惩（人次） -->
          <!-- 给予经济处罚（人次） -->
          <!-- <tr>
            <sd-form-item-td name="employeeIncentive" :label="'员工奖惩（人次）'" />
            <sd-form-item-td name="economicPunishment" :label="'给予经济处罚（人次）'" />
          </tr> -->
          <!--  给予违规追责组织处理（人次） -->
          <!-- 安全生产惩处（人次） -->
          <!-- <tr>
            <sd-form-item-td name="givePunishment" :label="'给予违规追责组织处理（人次）'" />
            <sd-form-item-td name="safeProducePunished" :label="'安全生产惩处（人次）'" />
          </tr> -->
          <!-- <tr> -->
          <!-- 给予组织处理（人次） -->
          <!-- <sd-form-item-td name="organizationalTreatment" :label="'给予组织处理（人次）'" /> -->
          <!-- 生态环保违法违规行为惩（人次） -->
          <!-- <sd-form-item-td
              name="ecologyViolationPunished"
              :label="'生态环保违法违规行为惩（人次）'"
            /> -->
          <!-- </tr> -->
          <tr>
            <!-- 是否重启 -->
            <sd-form-item-td name="whetherReboot" :hidden="true" />
            <!-- 重启次数 -->
            <sd-form-item-td name="rebootNumber" :hidden="true" />
          </tr>
        </table>

        <table>
          <tr
            ><td :colspan="4">
              <sd-form-item name="spicRectViolationsPersonEntitys" :label="null">
                <template v-slot:read-and-edit="{ editable }">
                  <audit-advanced-group
                    :expand="moneyExpand"
                    :expand-str="'moneyExpand'"
                    :group-label="'违规追责人次'"
                    tablestyle="''"
                    @changedClick="changedClick"
                  >
                    <template>
                      <XmChildTable
                        v-show="moneyExpand"
                        ref="moneyData"
                        v-model="model.spicRectViolationsPersonEntitys"
                        :class="$style.deptPlanChild"
                        :label="null"
                        :columns="columns1"
                        :colspan="4"
                        :read-only="!editable"
                        name="spicRectViolationsPersonEntitys"
                        :changeflag="true"
                        :fields="
                          [
                            {
                              caption: '序号',
                              name: 'sortNum',
                              dataType: 'sortNum',
                            },
                          ].concat(
                            Array.from(fields.spicRectViolationsPersonEntitys.attr.dync).slice(2)
                          )
                        "
                        @change="changetablemoney1"
                      >
                        <!-- input-form 表示这部分是子表组件的form插槽 -->
                        <template v-slot:form="{ model }">
                          <table>
                            <tr><sd-form-item-td name="projectId" :hidden="true" /></tr>
                            <tr><sd-form-item-td name="rectId" :hidden="true" /></tr>
                            <tr><sd-form-item-td name="id" :hidden="true" /></tr>
                            <tr><sd-form-item-td name="dealWay" /></tr>
                            <tr><sd-form-item-td name="personTimes" /></tr>
                          </table>
                        </template>
                      </XmChildTable>
                    </template>
                  </audit-advanced-group>
                </template>
              </sd-form-item>
            </td>
          </tr>
          <tr v-show="moneyExpand">
            <sd-form-item-td :label="null" name="reservestring1" :colspan="4">
              <template v-slot:read-and-edit="{ editable }">
                <table style="width: 100%">
                  <tr
                    ><td
                      v-if="editable"
                      style="width: 60px; border: none"
                      class="ant-form-item-label ant-form-item-label"
                    ></td
                    ><td
                      style="width: 80px; border: none"
                      class="ant-form-item-label ant-form-item-label"
                    ></td
                    ><td
                      style="width: 50%; border: none"
                      class="ant-form-item-label ant-form-item-label"
                      ><label title="合计" class=""> 合计 </label></td
                    ><td style="border: none; border-left: 1px solid #e8e8e8"
                      ><span>{{ model.reservestring1 }}</span></td
                    ></tr
                  >
                </table>
              </template>
            </sd-form-item-td>
          </tr>
        </table>

        <table v-show="findExpand">
          <colgroup>
            <col style="width: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>
          <tr>
            <!-- 经济处罚数额（万元） -->
            <sd-form-item-td name="amountEconomicPenalty" :label="'经济处罚数额（万元）'" />
          </tr>
        </table>

        <table>
          <tr
            ><td :colspan="4">
              <sd-form-item name="spicRectPunishmentEntitys" :label="null">
                <template v-slot:read-and-edit="{ editable }">
                  <audit-advanced-group
                    :expand="moneyExpand"
                    :expand-str="'moneyExpand'"
                    :group-label="'审计建议给予党纪、政务和内部纪律处分'"
                    tablestyle="''"
                    @changedClick="changedClick"
                  >
                    <template>
                      <XmChildTable
                        v-show="moneyExpand"
                        ref="moneyData"
                        v-model="model.spicRectPunishmentEntitys"
                        :class="$style.deptPlanChild"
                        :label="null"
                        :columns="columns2"
                        :colspan="4"
                        :read-only="!editable"
                        name="spicRectPunishmentEntitys"
                        :changeflag="true"
                        :fields="
                          [
                            {
                              caption: '序号',
                              name: 'sortNum',
                              dataType: 'sortNum',
                            },
                          ].concat(Array.from(fields.spicRectPunishmentEntitys.attr.dync).slice(2))
                        "
                        @change="changetablemoney2"
                      >
                        <!-- input-form 表示这部分是子表组件的form插槽 -->
                        <template v-slot:form="{ model }">
                          <table>
                            <tr><sd-form-item-td name="projectId" :hidden="true" /></tr>
                            <tr><sd-form-item-td name="rectId" :hidden="true" /></tr>
                            <tr><sd-form-item-td name="id" :hidden="true" /></tr>
                            <tr><sd-form-item-td name="dealManner" /></tr>
                            <tr><sd-form-item-td name="personNumber" /></tr>
                          </table>
                        </template>
                      </XmChildTable>
                    </template>
                  </audit-advanced-group>
                </template>
              </sd-form-item>
            </td>
          </tr>
          <tr v-show="moneyExpand">
            <sd-form-item-td :label="null" name="reservestring2" :colspan="4">
              <template v-slot:read-and-edit="{ editable }">
                <table style="width: 100%">
                  <tr
                    ><td
                      v-if="editable"
                      style="width: 60px; border: none"
                      class="ant-form-item-label ant-form-item-label"
                    ></td
                    ><td
                      style="width: 80px; border: none"
                      class="ant-form-item-label ant-form-item-label"
                    ></td
                    ><td
                      style="width: 50%; border: none"
                      class="ant-form-item-label ant-form-item-label"
                      ><label title="合计" class=""> 合计 </label></td
                    ><td style="border: none; border-left: 1px solid #e8e8e8"
                      ><span>{{ model.reservestring2 }}</span></td
                    ></tr
                  >
                </table>
              </template>
            </sd-form-item-td>
          </tr>
        </table>

        <table v-show="findExpand">
          <colgroup>
            <col style="width: 300px" />
            <col />
            <col style="width: 300px" />
            <col
          /></colgroup>
          <tr>
            <!-- 向司法机关移送或报告案件线索 -->
            <sd-form-item-td name="accountability" :label="'向司法机关移送或报告案件线索'" />
            <!-- 其中：涉案人员 -->
            <sd-form-item-td name="otherItems" :label="'其中：涉案人员'" />
          </tr>
          <tr>
            <!--  其它重要整改成效（文字描述） -->
            <sd-form-item-td
              name="importantRectEffect"
              :colspan="3"
              :label="'其它重要整改成效（文字描述）'"
            >
              <a-textarea v-model="model.importantRectEffect" :rows="3"
            /></sd-form-item-td>
          </tr>
        </table>

        <table>
          <tr
            ><td :colspan="4">
              <sd-form-item name="spicRectHistoryList" :label="null">
                <template v-slot:read-and-edit="{ editable }">
                  <audit-advanced-group
                    :expand="historyExpand"
                    :expand-str="'historyExpand'"
                    :group-label="'历史反馈记录'"
                    tablestyle="''"
                  >
                    <template>
                      <XmChildTable
                        v-show="historyExpand"
                        ref="historyData"
                        v-model="model.spicRectHistoryList"
                        :class="$style.deptPlanChild"
                        :label="null"
                        :columns="columns3"
                        :colspan="4"
                        :read-only="!editable"
                        name="spicRectHistoryList"
                        :changeflag="true"
                        :fields="
                          [].concat(Array.from(fields.spicRectHistoryList.attr.dync).slice(2))
                        "
                      >
                      </XmChildTable>
                    </template>
                  </audit-advanced-group>
                </template>
              </sd-form-item>
            </td>
          </tr>
        </table>
      </template>
    </sd-webflow>
  </div>
</template>

<script>
import moment from 'moment'
import { Modal } from 'ant-design-vue'
import axios from '@/common/services/axios-instance'
import auditAdvancedGroup from '@product/iam/components/audit-advanced-group.vue'
import XmChildTable from '@product/iam/components/xm-child-table.vue'
import auditAdvancedGroupMixins from '@product/iam/components/audit-advanced-group-mixins'
import components from './_import-components/spic-questionfeedback-form-import'

const columns1 = [
  {
    title: '序号',
    dataIndex: 'sortNum',
    customRender: (text, record, index) => `${index + 1}`,
    width: '80px',
  },
  {
    title: '处理方式',
    dataIndex: 'dealWay',
    width: '38%',
  },
  {
    title: '人次',
    dataIndex: 'personTimes',
    width: '38%',
  },
]
const columns2 = [
  {
    title: '序号',
    dataIndex: 'sortNum',
    customRender: (text, record, index) => `${index + 1}`,
    width: '80px',
  },
  {
    title: '处理方式',
    dataIndex: 'dealManner',
    width: '38%',
  },
  {
    title: '人次',
    dataIndex: 'personNumber',
    width: '38%',
  },
]

const columns3 = [
  {
    title: '序号',
    dataIndex: 'sortNum',
    customRender: (text, record, index) => `${index + 1}`,
    width: '80px',
  },
  {
    title: '阶段性计划完成日期',
    dataIndex: 'draftFinishDate',
    width: '20%',
  },
  {
    title: '阶段性目标',
    dataIndex: 'supportMaterial',
    width: '20%',
  },
  {
    title: '阶段性措施执行情况',
    dataIndex: 'draftRectMeasure',
    width: '40%',
  },
  {
    title: '阶段性实际完成日期',
    dataIndex: 'actualFinishDate',
    width: '40%',
  },
]
export default {
  name: 'SpicQuestionfeedbackForm',
  metaInfo: {
    title: '审计问题反馈',
  },
  components: {
    ...components,
    auditAdvancedGroup,
    XmChildTable,
  },
  mixins: [auditAdvancedGroupMixins],
  data() {
    return {
      visibleRectMeasure: false, // 控制整改措施
      visibleDraftRectMeasure: false, // 控制拟整改措施
      findinfoeditable: false, // 控制是否编辑显示
      findinfolookable: false, // 控制整改措施查看
      findinfodraftlook: false, // 控制拟整改措施查看
      visibleDate: '', // 控制拟整改完成日期
      projectId: '',
      infoExpand: true,
      findExpand: true,
      groupId: '',
      rectTypeOptions: [],
      futureDate: '',
      moneyExpand: true,
      historyExpand: true,
      columns1,
      columns2,
      isShow1: false,
      isedit1: true,
      isShow2: false,
      isedit2: true,
      fourShow: true,
      isOtherPeople: false, // 是否是其他人反馈环节点击
      // startButton: false, // 转其他人反馈环节-> 开始
    }
  },
  mounted() {
    // debugger
    // 初始化数据字典信息
    this.initDictionaryInfo()
    let query = {}
    if (this.$route.query.extParams) {
      query = JSON.parse(this.$route.query.extParams)
    } else {
      query = {
        id: this.$refs.flow.getFieldValue('id'),
      }
    }
    axios({
      url: `api/xcoa-mobile/v1/spicrectfeedback/getInfoById?id=${query.id}`,
      method: 'get',
    }).then((res) => {
      this.$refs.flow.setFieldValue('projectName', res.data.projectName)
      this.$refs.flow.setFieldValue('projectCode', res.data.projectCode)
      this.$refs.flow.setFieldValue('projectSource', res.data.projectSource)
      this.$refs.flow.setFieldValue('auditedUnitCode', res.data.auditedUnitCode)
      this.$refs.flow.setFieldValue('auditedUnitName', res.data.auditedUnitName)
      this.$refs.flow.setFieldValue('auditedContactsAccount', res.data.auditedContactsAccount)
      this.$refs.flow.setFieldValue('auditedContactsName', res.data.auditedContactsName)
      this.$refs.flow.setFieldValue('resppersonsAccount', res.data.resppersonsAccount)
      this.$refs.flow.setFieldValue('resppersonsName', res.data.resppersonsName)
      this.$refs.flow.setFieldValue('requirement', res.data.requirement)
      this.$refs.flow.setFieldValue('findingTitle', res.data.findingTitle)
      this.$refs.flow.setFieldValue('findingCode', res.data.findingCode)
      this.$refs.flow.setFieldValue('findType', res.data.findType)
      this.$refs.flow.setFieldValue('findDesc', res.data.findDesc)
      this.$refs.flow.setFieldValue('handleSuggestion', res.data.handleSuggestion)
      // this.$refs.flow.setFieldValue('amountProblem', res.data.amountProblem)creationTime
      this.$refs.flow.setFieldValue('creationTime', res.data.creationTime)
      this.$refs.flow.setFieldValue('problemCategoryFunction', res.data.problemCategoryFunction)
      this.$refs.flow.setFieldValue('giveOpinion', res.data.giveOpinion)
    })

    if (this.$refs.flow.FlowData.mode === 'VIEW') {
      // 只读时，是否完成当年整改阶段目标 和 是否经过部委会同意 显示
      this.isedit1 = false
      this.isedit2 = false
    }
    const stepName = this.$refs.flow.FlowData.processActiveLogInfo[0].stepName
    // if (stepName === '开始') {
    //   const rectType = this.$refs.flow.getFieldValue('rectType')
    //   if (rectType === '02' || rectType === '03') {
    //     const rectMeasure = this.$refs.flow.getFieldValue('rectMeasure')
    //     const rectRemark = this.$refs.flow.getFieldValue('rectRemark')
    //     const supportMaterial = this.$refs.flow.getFieldValue('supportMaterial')
    //     const draftFinishDate = this.$refs.flow.getFieldValue('draftFinishDate')
    //     if (
    //       (rectMeasure !== '' || rectMeasure !== null || rectMeasure !== undefined) &&
    //       (rectRemark !== '' || rectRemark !== null || rectRemark !== undefined) &&
    //       (supportMaterial !== '' || supportMaterial !== null || supportMaterial !== undefined) &&
    //       (draftFinishDate !== '' || draftFinishDate !== null || draftFinishDate !== undefined)
    //     ) {
    //       this.fourShow = false
    //     }
    //   }
    // }
    if (
      this.$refs.flow.FlowData.attrs.rectquestion$isShow1 !== undefined &&
      this.$refs.flow.FlowData.attrs.rectquestion$isShow2 !== undefined
    ) {
      const show1 = this.$refs.flow.FlowData.attrs.rectquestion$isShow1
      // 判断是否是 分阶段整改和持续整改
      const rectType = this.$refs.flow.getFieldValue('rectType')
      // rectState 整改状态
      const rectState = this.$refs.flow.getFieldValue('rectState')
      // 0 不显示 1 显示
      if (show1 === '1' && (rectType === '02' || rectType === '03')) {
        // console.log('--校验判断 开始环节隐藏 是否完成当年整改阶段目标 字段')
        this.isShow1 = true
      } else if (show1 === '0') {
        this.isShow1 = false
      }
      const show2 = this.$refs.flow.FlowData.attrs.rectquestion$isShow2
      if (show2 === '1' && rectState === '04') {
        this.isShow2 = true
      } else if (show2 === '0') {
        this.isShow2 = false
      }
      return Promise.resolve(true)
    }
  },
  methods: {
    handlerRectState(model, val, fields) {
      const a = 0
      // if (val === '01') {
      // if (new Date().valueOf() >= model.draftFinishDate?.valueOf()) {
      // fields.isTrue.value = '1'
      // model.isTrue = '1'
      // fields.isTrue.readonly = true
      // fields.overdueReason.required = true
      // } else {
      // fields.isTrue.value = '0'
      // model.isTrue = '0'
      // }
      // } else if (val === '03') {
      // fields.rectMeasure.required = true
      // fields.finishDate.required = true
      // } else if (val === '04') {
      // fields.finishDate.required = true
      // fields.rectMeasure.required = false
      // } else {
      // fields.rectMeasure.required = false
      // fields.finishDate.required = false
      // }
    },
    changetablemoney1(data) {
      let money = 0
      if (!data) return
      data.forEach((item, index) => {
        // item.sortNum = index + 1
        if (item.personTimes !== undefined) {
          money = money + parseFloat(item.personTimes)
        }
      })
      this.$refs.flow.setFieldValue(
        'reservestring1',
        this.getTotal1(data) ? this.getTotal1(data).toString() : ''
      )
    },
    changetablemoney2(data) {
      let money = 0
      if (!data) return
      data.forEach((item, index) => {
        // item.sortNum = index + 1
        if (item.personNumber !== undefined) {
          money = money + parseFloat(item.personNumber)
        }
      })
      this.$refs.flow.setFieldValue(
        'reservestring2',
        this.getTotal2(data) ? this.getTotal2(data).toString() : ''
      )
    },
    handlerRectType(model, val, fields) {
      if (val === '01') {
        const currentDate = new Date()
        currentDate.setDate(currentDate.getDate() + 60)
        var date = new Date(currentDate)
        var timestamp = date.getTime()
        model.draftFinishDate = timestamp
        this.findinfolookable = true
        fields.rectMeasure.required = false
        fields.rectRemark.required = false
        fields.supportMaterial.required = false
        fields.draftFinishDate.required = false
      } else if (val === '02') {
        // 问题类型选择“分阶段整改、持续整改”时校验 计划整改措施、整改责任考核方案、阶段性目标（按季度） 必填
        fields.rectMeasure.required = true
        fields.rectRemark.required = true
        fields.supportMaterial.required = true
        fields.draftFinishDate.required = true
      } else if (val === '03') {
        fields.rectMeasure.required = true
        fields.rectRemark.required = true
        fields.supportMaterial.required = true
        fields.draftFinishDate.required = true
      }
    },
    // handlerFinash(model, val, fields) {
    //   if (model.rectState === '01') {
    //     if (new Date().valueOf() >= val?.valueOf()) {
    //       fields.isTrue.value = '1'
    //       model.isTrue = '1'
    //       fields.isTrue.readonly = true

    //       fields.overdueReason.required = true
    //     } else {
    //       fields.isTrue.value = '0'
    //       model.isTrue = '0'
    //     }
    //   }
    // },

    // validForm() {},

    initDictionaryInfo() {
      // 获取审计流程下拉框信息
      axios({
        url: 'api/xcoa-mobile/v1/iam-law/dictionary?key=RECT_TYPE',
        method: 'get',
      }).then((res) => {
        if (res.status === 200) {
          // this.item = res.data
          var newArr = []
          res.data.forEach((item) => {
            // console.log(item)
            if (item.id === '01' || item.id === '02' || item.id === '03') {
              newArr.push(item)
            }
          })
          this.rectTypeOptions = newArr
        }
      })
    },
    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
      }
    },
    fngetjson(data) {
      if (data !== undefined && data !== '') {
        if (typeof JSON.parse(data) === 'object') {
          return JSON.parse(data).text
        } else {
          return data
        }
      } else {
        return ''
      }
    },
    rtgetjson(data) {
      var name = ''
      if (data !== undefined && data !== '') {
        var arr = JSON.parse(data)
        name = arr[0].name
        // if (arr[0].id === '01') {
        //   this.findinfolookable = true // 整改措施查看
        // } else {
        //   this.findinfodraftlook = true // 拟整改措施查看
        // }
        return name
      } else {
        return ''
      }
    },
    fnget(data) {
      var name = ''
      if (data !== undefined && data !== '') {
        if (data === '1') {
          name = '是'
        } else {
          name = '否'
        }
        return name
      } else {
        return ''
      }
    },
    actionBtnClick(evt, { button, FlowData }) {
      // debugger
      evt.waitUntil(
        new Promise((resolve, reject) => {
          if (button.buttonId === 'G_1_QUESTION_FEED_BACK.9') {
            // 开始-> 转其他人反馈环节
            this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
              return item.name === 'rectState'
            }).required = false

            this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
              return item.name === 'rectType'
            }).required = false

            this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
              return item.name === 'draftRectMeasure'
            }).required = false

            this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
              return item.name === 'transferMonitorSingle'
            }).required = false
            this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
              return item.name === 'transferMonitorDouble'
            }).required = false
            this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
              return item.name === 'importantRectEffect'
            }).required = false
          }
          if (button.buttonId === 'G_1_QUESTION_FEED_BACK.1') {
            // 开始-> 跟踪人环节
            const rectState = this.$refs.flow.getFieldValue('rectState') // 整改状态
            const rectType = this.$refs.flow.getFieldValue('rectType') // 问题类型
            const draftRectMeasure = this.$refs.flow.getFieldValue('draftRectMeasure') // 措施执行情况
            const transferMonitorSingle = this.$refs.flow.getFieldValue('transferMonitorSingle') // 移送纪检监察线索说明（单移送）
            const transferMonitorDouble = this.$refs.flow.getFieldValue('transferMonitorDouble') // 移送纪检监察线索说明（双移送）
            const importantRectEffect = this.$refs.flow.getFieldValue('importantRectEffect') // 其它重要整改成效（文字描述）
            if (rectState === '' || rectState === null || rectState === undefined) {
              this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
                return item.name === 'rectState'
              }).required = true
            }
            if (rectType === '' || rectType === null || rectType === undefined) {
              this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
                return item.name === 'rectType'
              }).required = true
            }
            if (
              draftRectMeasure === '' ||
              draftRectMeasure === null ||
              draftRectMeasure === undefined
            ) {
              this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
                return item.name === 'draftRectMeasure'
              }).required = true
            }
            if (
              transferMonitorSingle === '' ||
              transferMonitorSingle === null ||
              transferMonitorSingle === undefined
            ) {
              this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
                return item.name === 'transferMonitorSingle'
              }).required = true
            }
            if (
              transferMonitorDouble === '' ||
              transferMonitorDouble === null ||
              transferMonitorDouble === undefined
            ) {
              this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
                return item.name === 'transferMonitorDouble'
              }).required = true
            }
            if (
              importantRectEffect === '' ||
              importantRectEffect === null ||
              importantRectEffect === undefined
            ) {
              this.$refs.flow.FlowData.processFormData.processFormPropertyValues.find((item) => {
                return item.name === 'importantRectEffect'
              }).required = true
            }
          }
          if (
            button.buttonId === 'G_1_QUESTION_FEED_BACK.7' ||
            button.buttonId === 'G_1_QUESTION_FEED_BACK.6' ||
            button.buttonId === 'G_1_QUESTION_FEED_BACK.8' ||
            button.buttonId === 'G_1_QUESTION_FEED_BACK.5'
          ) {
            const whetherFinishTarget = this.$refs.flow.getFieldValue('whetherFinishTarget')
            const rectType = this.$refs.flow.getFieldValue('rectType')
            let flag = true
            if (
              (whetherFinishTarget === '' ||
                whetherFinishTarget === null ||
                whetherFinishTarget === undefined) &&
              (rectType === '02' || rectType === '03')
            ) {
              flag = false
            }

            if (!flag) {
              Modal.warning({
                title: '提示',
                content: '请勾选是否完成当年整改阶段目标后进行审批',
              })
              evt.preventDefault()
            }
          }
          if (button.buttonId === 'G_1_QUESTION_FEED_BACK.5' && button.buttonName === '整改销号') {
            // 验证此字段必须选择“是”，否则提示用户“特殊销号的问题需经过部委会同意，请勾选为是确认后进行审批
            const whetherAgree = this.$refs.flow.getFieldValue('whetherAgree')
            const rectState = this.$refs.flow.getFieldValue('rectState')
            let flag = true
            if (
              (whetherAgree === '' ||
                whetherAgree === null ||
                whetherAgree === undefined ||
                whetherAgree === '0') &&
              rectState === '04'
            ) {
              flag = false
            }
            if (!flag) {
              Modal.warning({
                title: '提示',
                content: '特殊销号的问题需经过部委会同意，请勾选为是确认后进行审批',
              })
              evt.preventDefault()
            }
          }
          resolve()
        })
      )
    },
  },
}
</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>
