<template>
  <div>
    <el-tabs v-model="curTab"
             @tab-click="tabChange">
      <el-tab-pane label="配置风控"
                   name="tab1">
        <el-form ref="formRef"
                 :model="form"
                 label-width="120px"
                 label-suffix="："
                 class="form h-[calc(100vh-230px)] pr-1 overflow-auto"
                 status-icon>
          <!-- <div class="h-[calc(100vh-170px)] pr-1 overflow-auto"> -->
          <div class="step">
            <h6 class="step-name mb-7">办理账户</h6>
            <el-form-item label="提供材料"
                          prop="accountMaterials">
              <div>
                <div class="radio-wrap flex-col items-start mb-1">
                  <el-radio-group v-model="form.provideMaterialSelectedStatus">
                    <el-radio v-for="(item, i) in whethers"
                              :key="i"
                              :label="item.id">{{ item.name }}</el-radio>
                  </el-radio-group>
                </div>
                <template v-if="form.provideMaterialSelectedStatus === 797">
                  <p class="tips">选择需要提供的申请人材料（至少选一样）</p>
                  <el-checkbox-group v-if="config.length"
                                     v-model="form.accountMaterials">
                    <el-checkbox v-for="(item, i) in config[0]?.recordChildren[0]?.recordChildren[1]?.subject?.itemList"
                                 :key="i"
                                 :label="item.itemId">{{ item.options }}</el-checkbox>
                  </el-checkbox-group>
                </template>
              </div>
            </el-form-item>
            <el-form-item label="发放账户"
                          prop="sendingAccount">
              <div>
                <div class="radio-wrap flex-col items-start">
                  <el-radio-group v-if="config.length"
                                  v-model="form.issueAccountSelectStatus">
                    <el-radio v-for="(item, i) in config[0]?.recordChildren[1]?.recordChildren[1]?.subject?.itemList"
                              :key="i"
                              :label="item.itemId">{{ item.options }}</el-radio>
                  </el-radio-group>
                </div>
                <template v-if="form.issueAccountSelectStatus === 801 && config.length">
                  <p class="tips">选择需要发放的账户（至少选一样）</p>

                  <el-checkbox-group v-model="form.sendingAccount">
                    <el-checkbox v-for="(item, i) in config[0]?.recordChildren[1]?.recordChildren[0]?.subject?.itemList"
                                 :key="i"
                                 :label="item.itemId">{{ item.options }}</el-checkbox>
                  </el-checkbox-group>

                </template>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">贷款申请</h6>
            <el-form-item label="申请方式"
                          prop="loanApplicationMethod">
              <p class="mr-5 text-xs text-[#666]">选择申请方式（至少选一样）</p>
              <el-checkbox-group v-if="config.length"
                                 style="font-size: 14px"
                                 v-model="form.loanApplicationMethod">
                <el-checkbox v-for="(item, i) in config[1]?.recordChildren[0]?.subject?.itemList"
                             :key="i"
                             :label="item.itemId">{{ item.options }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
            <el-form-item label="提供材料"
                          prop="borrowerMaterial">
              <div class="flex-1">
                <div>
                  <p class="field-name mb-0">借款人材料</p>
                  <div class="radio-wrap flex-col items-start">
                    <el-radio-group v-model="form.borrowerMaterialSelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div v-if="form.borrowerMaterialSelectedStatus === 797">
                  <p class="my-2 text-xs text-[#666]">选择需要提供的借款人材料（至少选一样）</p>
                  <el-checkbox-group v-if="config.length"
                                     v-model="form.borrowerMaterial"
                                     @change="denyAll('borrowerMaterial', 770)">
                    <el-checkbox v-for="(item, i) in config[1]?.recordChildren[1]?.recordChildren[0]?.subject?.itemList"
                                 :key="i"
                                 :label="item.itemId">{{ item.options }}</el-checkbox>
                  </el-checkbox-group>
                </div>

                <!-- 企业 -->
                <template v-if="info.productType">
                  <p class="field-name mt-5">企业材料</p>
                  <div>
                    <div class="radio-wrap flex-col items-start mb-2">
                      <el-radio-group v-model="form.enterpriseMaterialSelectedStatus">
                        <el-radio v-for="(item, i) in whethers"
                                  :key="i"
                                  :label="item.id">{{ item.name }}</el-radio>
                      </el-radio-group>
                    </div>

                    <template v-if="form.enterpriseMaterialSelectedStatus === 797">
                      <p class="tips">选择需要提供的企业材料（至少选一样）</p>
                      <el-checkbox-group v-if="config.length"
                                         v-model="form.enterpriseMaterial">
                        <el-checkbox v-for="(item, i) in config[1]?.recordChildren[2]?.subject?.itemList"
                                     :key="i"
                                     :label="item.itemId">{{ item.options }}</el-checkbox>
                      </el-checkbox-group>
                    </template>
                  </div>
                  <p class="field-name mt-5">抵押物</p>
                  <div>
                    <div class="radio-wrap flex-col items-start mb-2">
                      <el-radio-group v-model="form.mortgagedPropertySelectedStatus">
                        <el-radio v-for="(item, i) in whethers"
                                  :key="i"
                                  :label="item.id">{{ item.name }}</el-radio>
                      </el-radio-group>
                    </div>
                    <template v-if="form.mortgagedPropertySelectedStatus === 797">
                      <p class="tips">选择需要提供的抵押物材料（至少选一样）</p>
                      <el-checkbox-group v-if="config.length"
                                         v-model="form.collateral">
                        <el-checkbox v-for="(item, i) in config[1]?.recordChildren[3]?.subject?.itemList"
                                     :key="i"
                                     :label="item.itemId">{{ item.options }}</el-checkbox>
                      </el-checkbox-group>
                    </template>
                  </div>
                </template>
                <!-- 个人 -->
                <template v-else>
                  <p class="field-name mt-5 mb-0">配偶材料</p>
                  <div>
                    <div class="radio-wrap flex-col items-start mb-1">
                      <el-radio-group v-model="form.mateMaterialSelectedStatus">
                        <el-radio v-for="(item, i) in whethers"
                                  :key="i"
                                  :label="item.id">{{ item.name }}</el-radio>
                      </el-radio-group>
                    </div>

                    <template v-if="form.mateMaterialSelectedStatus === 797">
                      <p class="tips">选择需要提供的配偶材料（至少选一样）</p>
                      <el-checkbox-group v-if="config.length"
                                         v-model="form.mateMaterial"
                                         @change="denyAll('mateMaterial', 350)">
                        <el-checkbox v-for="(item, i) in config[1]?.recordChildren[2]?.subject?.itemList"
                                     :key="i"
                                     :label="item.itemId">{{ item.options }}</el-checkbox>
                      </el-checkbox-group>
                    </template>
                  </div>
                  <p class="field-name mt-5">经营类材料</p>
                  <div>
                    <div class="radio-wrap flex-col items-start mb-1">
                      <el-radio-group v-model="form.businessMaterialsSelectedStatus">
                        <el-radio v-for="(item, i) in whethers"
                                  :key="i"
                                  :label="item.id">{{ item.name }}</el-radio>
                      </el-radio-group>
                    </div>

                    <template v-if="form.businessMaterialsSelectedStatus === 797">
                      <p class="tips">选择需要提供的经营类材料（至少选一样）</p>
                      <el-checkbox-group v-if="config.length"
                                         v-model="form.businessMaterials"
                                         @change="denyAll('businessMaterials', 351)">
                        <el-checkbox v-for="(item, i) in config[1]?.recordChildren[3]?.subject?.itemList"
                                     :key="i"
                                     :label="item.itemId">{{ item.options }}</el-checkbox>
                      </el-checkbox-group>
                    </template>
                  </div>
                </template>
                <p class="field-name mt-5">补充材料</p>
                <div>
                  <div class="radio-wrap flex-col items-start mb-1">
                    <el-radio-group v-model="form.supplementMaterialSelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>

                  <template v-if="form.supplementMaterialSelectedStatus === 797">
                    <p class="tips">选择需要提供的补充材料（至少选一样）</p>
                    <el-checkbox-group v-if="config.length"
                                       v-model="form.supplementaryMaterials"
                                       @change="denyAll('supplementaryMaterials', 352)">
                      <el-checkbox v-for="(item, i) in config[1]?.recordChildren[4]?.subject?.itemList"
                                   :key="i"
                                   :label="item.itemId">{{ item.options }}</el-checkbox>
                    </el-checkbox-group>
                  </template>
                </div>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">系统跑批准入风控策略</h6>
            <el-form-item label="跑批对象"
                          prop="runBatchObject">
              <div>
                <div class="radio-wrap flex-col items-start mb-2">
                  <el-radio-group v-if="config.length"
                                  v-model="form.runBatchObjectSelectedStatus">
                    <el-radio v-for="(item, i) in config[2]?.recordChildren[0]?.recordChildren[1]?.subject?.itemList"
                              :key="i"
                              :label="item.itemId">{{ item.options }}</el-radio>
                  </el-radio-group>
                </div>
                <template v-if="form.runBatchObjectSelectedStatus === 803">
                  <p class="tips">选择需要跑批的对象（至少选一样）</p>
                  <el-checkbox-group v-if="config.length"
                                     v-model="form.runBatchObject">
                    <el-checkbox v-for="(item, i) in config[2]?.recordChildren[0]?.recordChildren[0]?.subject?.itemList"
                                 :key="i"
                                 :label="item.itemId">{{ item.options }}</el-checkbox>
                  </el-checkbox-group>
                </template>
              </div>
            </el-form-item>
            <el-form-item label="准入策略"
                          prop="accessStrategy">
              <div>
                <div class="radio-wrap flex-col items-start mb-2">
                  <el-radio-group v-if="config.length"
                                  v-model="form.accessPolicySelectedStatus">
                    <el-radio v-for="(item, i) in config[2]?.recordChildren[1]?.recordChildren[1]?.subject?.itemList"
                              :key="i"
                              :label="item.itemId">{{ item.options }}</el-radio>
                  </el-radio-group>
                </div>
                <template v-if="form.accessPolicySelectedStatus === 803">
                  <p class="tips">选择需要跑批的准入策略（至少选一样）</p>
                  <el-checkbox-group v-if="config.length"
                                     v-model="form.accessStrategy">
                    <el-checkbox v-for="(item, i) in config[2]?.recordChildren[1]?.recordChildren[0]?.subject?.itemList"
                                 :key="i"
                                 :label="item.itemId">{{ item.options }}</el-checkbox>
                  </el-checkbox-group>
                </template>
              </div>
            </el-form-item>
            <el-form-item label="信用评分策略"
                          label-width="130px"
                          prop="personalCreditScoringStrategySelectedStatus">
              <div class="flex-1">
                <div class="flex items-center mb-3">
                  <div class="radio-wrap">
                    <span class="label">个人信用评分策略</span>
                    <el-radio-group v-model="form.personalCreditScoringStrategySelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>

                  <el-select v-if="form.personalCreditScoringStrategySelectedStatus === 797"
                             class="ml-5"
                             v-model="form.personalCreditScoringStrategies"
                             placeholder="请选择">
                    <el-option v-for="item in credits.filter(e => !e.scoringObject)"
                               :key="item"
                               :value="item.scoreCardName" />
                  </el-select>
                </div>
                <div class="flex items-center">
                  <div class="radio-wrap">
                    <span class="label">企业信用评分策略</span>
                    <el-radio-group v-model="form.enterpriseCreditScoringStrategySelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>

                  <el-select v-if="form.enterpriseCreditScoringStrategySelectedStatus === 797"
                             class="ml-5"
                             v-model="form.corporateCreditScoringStrategies"
                             placeholder="请选择">
                    <el-option v-for="item in credits.filter(e => e.scoringObject)"
                               :key="item"
                               :value="item.scoreCardName" />
                  </el-select>
                </div>
              </div>
            </el-form-item>
            <el-form-item label="风险度策略"
                          prop="riskDegreeStrategy">
              <div class="flex items-center h-[34px]">
                <el-radio-group v-if="config.length"
                                class="mr-10"
                                v-model="form.riskDegreePolicySelectedStatus">
                  <el-radio v-for="(item, i) in config[2]?.recordChildren[3]?.recordChildren[1]?.subject?.itemList"
                            :key="i"
                            :label="item.itemId">{{ item.options }}</el-radio>
                </el-radio-group>

                <el-checkbox-group v-if="form.riskDegreePolicySelectedStatus === 803 && config.length"
                                   style="font-size: 14px"
                                   v-model="form.riskDegreeStrategy">
                  <el-checkbox v-for="(item, i) in config[2]?.recordChildren[3]?.subject?.itemList"
                               :key="i"
                               :label="item.itemId">{{ item.options }}</el-checkbox>
                </el-checkbox-group>
              </div>

            </el-form-item>
            <el-form-item label="利率定价模型"
                          label-width="130px"
                          prop="individualCreditModelSelectedStatus">
              <div class="flex-1">
                <div class="flex items-center mb-3">
                  <div class="radio-wrap">
                    <span class="label">{{ (info.productType ? '企业' : '个人') + '额度模型' }}</span>
                    <el-radio-group v-if="config.length"
                                    v-model="form.individualCreditModelSelectedStatus">
                      <el-radio v-for="(item, i) in config[2]?.recordChildren[3]?.recordChildren[1]?.subject?.itemList"
                                :key="i"
                                :label="item.itemId">{{ item.options }}</el-radio>
                    </el-radio-group>
                  </div>
                  <el-select v-if="form.individualCreditModelSelectedStatus === 803 && config.length"
                             class="ml-5"
                             v-model="form.interestRatePricingModel"
                             placeholder="请选择">
                    <el-option v-for="item in config[2]?.recordChildren[4]?.recordChildren[1]?.recordChildren[1]?.subject?.itemList"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>

                <div class="radio-wrap">
                  <span class="label">{{ (info.productType ? '企业' : '个人') + '利率模型' }}</span>
                  <el-radio-group v-if="config.length"
                                  v-model="form.individualInterestRateModel">
                    <el-radio v-for="(item, i) in config[2]?.recordChildren[4]?.recordChildren[0]?.subject?.itemList"
                              :key="i"
                              :label="item.itemId">{{ item.options }}</el-radio>
                  </el-radio-group>
                </div>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">尽职调查</h6>
            <el-form-item label="尽调方式"
                          prop="dueDiligenceMode">
              <div>
                <p class="tips leading-[32px]">选择尽调方式（至少选一样）</p>
                <el-checkbox-group v-if="config.length"
                                   v-model="form.dueDiligenceMode">
                  <el-checkbox v-for="(item, i) in config[3]?.recordChildren[0]?.subject?.itemList"
                               :key="i"
                               :label="item.itemId">{{ item.options }}</el-checkbox>
                </el-checkbox-group>
              </div>
            </el-form-item>
            <el-form-item label="尽调内容"
                          prop="dueDiligenceContent">
              <div>
                <p class="tips leading-[32px]">选择尽调内容（至少选一样）</p>
                <el-checkbox-group v-if="config.length"
                                   v-model="form.dueDiligenceContent">
                  <el-checkbox v-for="(item, i) in config[3]?.recordChildren[1]?.subject?.itemList"
                               :key="i"
                               :label="item.itemId">{{ item.options }}</el-checkbox>
                </el-checkbox-group>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">贷款审查</h6>
            <el-form-item label="审查内容"
                          prop="reviewContent">
              <div>
                <p class="tips leading-[32px]">选择审查材料（至少选一样）</p>
                <el-checkbox-group v-if="config.length"
                                   v-model="form.reviewContent">
                  <el-checkbox v-for="(item, i) in config[4]?.recordChildren[0]?.subject?.itemList"
                               :key="i"
                               :label="item.itemId">{{ item.options }}</el-checkbox>
                </el-checkbox-group>
              </div>
            </el-form-item>
            <el-form-item label="审查签字"
                          prop="reviewSignature">
              <div>
                <p class="tips leading-[32px]">选择签字表单（至少选一样）</p>
                <el-radio v-model="form.reviewSignature"
                          :label="info.productType ? 262 : 115">《用信调查申报表》</el-radio>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">贷款审批</h6>
            <el-form-item label="审批内容"
                          prop="reviewApproveContent">
              <div>
                <p class="tips leading-[32px]">选择审批材料（至少选一样）</p>
                <el-checkbox-group v-if="config.length"
                                   v-model="form.reviewApproveContent">
                  <el-checkbox v-for="(item, i) in config[5]?.recordChildren[0]?.subject?.itemList"
                               :key="i"
                               :label="item.itemId">{{ item.options }}</el-checkbox>
                </el-checkbox-group>
              </div>
            </el-form-item>
            <el-form-item label="审批签字"
                          prop="approvalSignature">
              <div>
                <p class="tips leading-[32px]">选择签字表单（至少选一样）</p>
                <el-radio v-model="form.approvalSignature"
                          :label="info.productType ? 264 : 117">《用信调查申报表》</el-radio>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">签订合同</h6>
            <el-form-item label="提供的材料"
                          prop="contractMaterials">
              <div>
                <div class="radio-wrap mr-5">
                  <el-radio-group v-model="form.contractSupplyMaterialsSelectedStatus">
                    <el-radio v-for="(item, i) in whethers"
                              :key="i"
                              :label="item.id">{{ item.name }}</el-radio>
                  </el-radio-group>
                </div>
                <el-radio v-if="form.contractSupplyMaterialsSelectedStatus === 797"
                          v-model="form.contractMaterials"
                          :label="info.productType ? 265 : 118">抵押物所有权证明</el-radio>
              </div>
            </el-form-item>
            <el-form-item label="合同模板">
              <div class="flex-1">
                <div class="flex items-center mb-3">
                  <div class="radio-wrap">
                    <span class="label">借贷合同</span>
                    <el-radio-group v-model="form.loanContractSelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>

                  <el-select v-if="form.loanContractSelectedStatus === 797 && config.length"
                             class="ml-5"
                             v-model="form.loanContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.recordChildren[0]?.recordChildren[0]?.subject?.itemList"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <div class="flex items-center mb-3">
                  <div class="radio-wrap">
                    <span class="label">抵押合同</span>
                    <el-radio-group v-model="form.mortgageContractSelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>

                  <el-select v-if="form.mortgageContractSelectedStatus === 797 && config.length"
                             class="ml-5"
                             v-model="form.mortgageContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.recordChildren[1]?.recordChildren[0]?.subject?.itemList"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <div class="flex items-center mb-3">
                  <div class="radio-wrap">
                    <span class="label">质押合同</span>
                    <el-radio-group v-model="form.pledgeContractSelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>
                  <el-select v-if="form.pledgeContractSelectedStatus === 797 && config.length"
                             class="ml-5"
                             v-model="form.pledgeContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.recordChildren[2]?.recordChildren[0]?.subject?.itemList"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <div class="flex items-center">
                  <div class="radio-wrap">
                    <span class="label">担保合同</span>
                    <el-radio-group v-model="form.guaranteeContractSelectedStatus">
                      <el-radio v-for="(item, i) in whethers"
                                :key="i"
                                :label="item.id">{{ item.name }}</el-radio>
                    </el-radio-group>
                  </div>
                  <el-select v-if="form.guaranteeContractSelectedStatus === 797 && config.length"
                             class="ml-5"
                             v-model="form.guaranteeContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.recordChildren[3]?.recordChildren[0]?.subject?.itemList"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">贷后管理</h6>
            <el-form-item label="选择策略"
                          prop="selectionStrategy">
              <div>
                <div class="radio-wrap flex-col items-start mb-1">
                  <el-radio-group v-if="config.length"
                                  v-model="form.postLoanManagementSelectPolicySelectStatus">
                    <el-radio v-for="(item, i) in config[2]?.recordChildren[0]?.recordChildren[1]?.subject?.itemList"
                              :key="i"
                              :label="item.itemId">{{ item.options }}</el-radio>
                  </el-radio-group>
                </div>
                <template v-if="form.postLoanManagementSelectPolicySelectStatus === 803">
                  <p class="tips">选择策略（至少选一样）</p>
                  <el-checkbox-group v-if="(info.productType && config.length && config[7]?.recordChildren) || (!info.productType && config.length && config[7]?.recordChildren)"
                                     v-model="form.selectionStrategy">
                    <el-checkbox v-for="(item, i) in info.productType ? config[7]?.recordChildren[0]?.recordChildren[1]?.subject?.itemList : config[7]?.recordChildren[0]?.subject?.itemList"
                                 :key="i"
                                 :label="item.itemId">{{ item.options }}</el-checkbox>
                  </el-checkbox-group>
                </template>
              </div>
            </el-form-item>
          </div>
        </el-form>
        <div class="forms step-form">
          <div class="flex justify-end">
            <div class="submit"
                 @click="submit(formRef)">完成，提交审批</div>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane :label="info.approvalTime ? '产品详情' : '产品要素'"
                   name="tab2">
        <div class="h-[calc(100vh-170px)] pr-1 overflow-auto">
          <info />
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, computed, watch, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import type { TabsPaneContext, FormInstance } from 'element-plus';
import { findById, riskSave, riskUpdate, riskControlDetailsAreDisplayed } from '@/api/bank';
import { getProcessInformationBasedOnRoles, addOperation } from '@/api/judgment';
import { listCredit } from '@/api/model';
import { useRouter, useRoute } from 'vue-router';
import { handleId, getIds, getUsername } from '@/utils/common';
import Info from './Info.vue';
import Cookies from 'js-cookie';

const emit = defineEmits(['getList']);
interface RuleForm {
  accessPolicySelectedStatus?: number;
  accessStrategy?: number[];
  provideMaterialSelectedStatus?: number;
  accountMaterials?: number[];
  approvalSignature?: number;
  bankProductsId?: number;
  borrowerMaterialSelectedStatus?: number;
  borrowerMaterial?: number[];
  businessMaterialsSelectedStatus?: number;
  businessMaterials?: number[];
  mortgagedPropertySelectedStatus?: number;
  collateral?: number[];
  contractSupplyMaterialsSelectedStatus?: number;
  contractMaterials?: number;
  enterpriseCreditScoringStrategySelectedStatus?: number;
  corporateCreditScoringStrategies?: string;
  corporateInterestRateModel?: number[];
  dueDiligenceContent?: number[];
  dueDiligenceMode?: number[];
  enterpriseMaterialSelectedStatus?: number;
  enterpriseMaterial?: number[];
  guaranteeContractSelectedStatus?: number;
  guaranteeContract?: number;
  individualInterestRateModel?: number;
  individualCreditModelSelectedStatus?: number;
  interestRatePricingModel?: number;
  loanApplicationMethod?: number[];
  loanContractSelectedStatus?: number;
  loanContract?: number;
  mateMaterialSelectedStatus?: number;
  mateMaterial?: number[];
  materialsForLoanApproval?: number[];
  mortgageContractSelectedStatus?: number;
  mortgageContract?: number;
  personalCreditScoringStrategySelectedStatus?: number;
  personalCreditScoringStrategies?: number;
  pledgeContractSelectedStatus?: number;
  pledgeContract?: number;
  reviewApproveContent?: number[];
  reviewContent?: number[];
  reviewSignature?: number;
  riskDegreePolicySelectedStatus?: number;
  riskDegreeStrategy?: number[];
  runBatchObjectSelectedStatus?: number;
  runBatchObject?: number[];
  postLoanManagementSelectPolicySelectStatus?: number;
  selectionStrategy?: number[];
  issueAccountSelectStatus?: number;
  sendingAccount?: number[];
  supplementMaterialSelectedStatus?: number;
  supplementaryMaterials?: number[];
}
const router = useRouter();
const route = useRoute();
const id = computed(() => +route.query.id);
const curTab = ref<string>(route.query.show ? 'tab2' : 'tab1');
const config = ref<any[]>([]);
const credits = ref<Record<string, any>[]>([]);
const info = ref<Record<string, any>>({});
const whethers = ref<Record<string, any>>([
  {
    id: 797,
    name: '需要提供',
  },
  {
    id: 798,
    name: '无需提供',
  },
]);
const formRef = ref<FormInstance>();
const userName = ref<string>();
let form = reactive<RuleForm>({
  ...getIds(),
  accessPolicySelectedStatus: '',
  accessStrategy: [],
  provideMaterialSelectedStatus: '',
  accountMaterials: [],
  approvalSignature: '',
  bankProductsId: computed(() => +route.query.id),
  borrowerMaterialSelectedStatus: '',
  borrowerMaterial: [],
  businessMaterialsSelectedStatus: '',
  businessMaterials: [],
  mortgagedPropertySelectedStatus: '',
  collateral: [],
  contractSupplyMaterialsSelectedStatus: '',
  contractMaterials: '',
  enterpriseCreditScoringStrategySelectedStatus: '',
  corporateCreditScoringStrategies: '',
  corporateInterestRateModel: [],
  dueDiligenceContent: [],
  dueDiligenceMode: [],
  enterpriseMaterialSelectedStatus: '',
  enterpriseMaterial: [],
  guaranteeContractSelectedStatus: '',
  guaranteeContract: '',
  individualInterestRateModel: '',
  individualCreditModelSelectedStatus: '',
  interestRatePricingModel: '',
  loanApplicationMethod: [],
  loanContractSelectedStatus: '',
  loanContract: '',
  mateMaterialSelectedStatus: '',
  mateMaterial: [],
  materialsForLoanApproval: [],
  mortgageContractSelectedStatus: '',
  mortgageContract: '',
  personalCreditScoringStrategySelectedStatus: '',
  personalCreditScoringStrategies: '',
  pledgeContractSelectedStatus: '',
  pledgeContract: '',
  reviewApproveContent: [],
  reviewContent: [],
  reviewSignature: '',
  riskDegreePolicySelectedStatus: '',
  riskDegreeStrategy: [],
  runBatchObjectSelectedStatus: '',
  runBatchObject: [],
  postLoanManagementSelectPolicySelectStatus: '',
  selectionStrategy: [],
  issueAccountSelectStatus: '',
  sendingAccount: [],
  supplementMaterialSelectedStatus: '',
  supplementaryMaterials: [],
});

// tab切换回调
const tabChange = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event);
};
// 配置项
const getConfig = async () => {
  const { process } = await getProcessInformationBasedOnRoles(info.value.productType ? 71 : 70); // 个人70，企业71
  config.value = process;

  const { data } = await listCredit({
    ...getIds(),
    pageNum: 1,
    pageSize: 1000,
  });
  credits.value = [
    {
      scoringObject: 0,
      scoreCardName: '个人信用评分策略',
    },
    {
      scoringObject: 0,
      scoreCardName: '个人评分-评级贷',
    },
    {
      scoringObject: 0,
      scoreCardName: '个人标准评分卡',
    },
    {
      scoringObject: 1,
      scoreCardName: '企业标准评分卡',
    },
    {
      scoringObject: 1,
      scoreCardName: '大型企业评分卡',
    },
    {
      scoringObject: 1,
      scoreCardName: '小型企业评分卡',
    },
    ...data,
  ];
};
// 详情
const getDetail = async () => {
  userName.value = await getUsername();
  if (id.value) {
    try {
      // 查询产品要素详情
      const { data } = await findById(id.value);
      info.value = data;
      getConfig();

      // 只返回id的详情
      const res = await riskControlDetailsAreDisplayed(id.value);
      const e = res.data;
      e.interestRatePricingModel = e?.interestRatePricingModel?.length ? e.interestRatePricingModel[0] : '';
      e.individualInterestRateModel = e?.individualInterestRateModel?.length ? e.individualInterestRateModel[0] : '';
      e.reviewSignature = e?.reviewSignature?.length ? e.reviewSignature[0] : '';
      e.approvalSignature = e?.approvalSignature?.length ? e.approvalSignature[0] : '';

      e.loanContract = e?.loanContract?.length ? e.loanContract[0] : '';
      e.mortgageContract = e?.mortgageContract?.length ? e.mortgageContract[0] : '';
      e.pledgeContract = e?.pledgeContract?.length ? e.pledgeContract[0] : '';
      e.guaranteeContract = e?.guaranteeContract?.length ? e.guaranteeContract[0] : '';
      e.contractMaterials = e.contractMaterials ? +e.contractMaterials : '';
      delete e.enterpriseQuotaModel;
      form = Object.assign(form, e);
    } finally {
    }
  }
};
// 无需材料互斥(选择了无需的选项，则取消选择所有该字段的其他选项)
const denyAll = (field: string, denyId: number) => {
  if (form[field].includes(denyId)) form[field] = [denyId];
};
watch(
  () => route.query,
  () => {
    getDetail();
  },
  {
    immediate: true,
  },
);
// 提交
const submit = async (formEl: FormInstance | undefined) => {
  if (!formEl) return;
  await formEl.validate(async (valid, fields) => {
    if (valid) {
      try {
        const isEnterprise = info.value.productType === 1;
        const param = JSON.parse(JSON.stringify(form));

        if (param.provideMaterialSelectedStatus === 797 && !param.accountMaterials.length) return ElMessage.error('请选择需要提供的申请人材料');
        if (param.issueAccountSelectStatus === 801 && !param.sendingAccount.length) return ElMessage.error('请选择需要发放的账户');
        if (!param.loanApplicationMethod.length) return ElMessage.error('请选择申请方式');
        if (param.borrowerMaterialSelectedStatus === 797 && !param.borrowerMaterial.length) return ElMessage.error('请选择借款人材料');

        if (isEnterprise) {
          // 企业
          if (param.enterpriseMaterialSelectedStatus === 797 && !param.enterpriseMaterial.length) return ElMessage.error('请选择需要提供的企业材料');
          if (param.mortgagedPropertySelectedStatus === 797 && !param.collateral.length) return ElMessage.error('请选择需要提供的抵押物材料');
        } else {
          // 个人
          if (param.mateMaterialSelectedStatus === 797 && !param.mateMaterial.length) return ElMessage.error('请选择需要提供的配偶材料');
          if (param.businessMaterialsSelectedStatus === 797 && !param.businessMaterials.length) return ElMessage.error('请选择需要提供的经营类材料');
        }

        if (param.supplementMaterialSelectedStatus === 797 && !param.supplementaryMaterials.length) return ElMessage.error('请选择需要提供的补充材料');
        if (param.runBatchObjectSelectedStatus === 803 && !param.runBatchObject.length) return ElMessage.error('请选择需要跑批的对象');
        if (param.accessPolicySelectedStatus === 803 && !param.accessStrategy.length) return ElMessage.error('请选择需要跑批的准入策略');
        if (!param.dueDiligenceMode.length) return ElMessage.error('请选择尽调方式');
        if (!param.dueDiligenceContent.length) return ElMessage.error('请选择尽调内容');
        if (!param.reviewContent.length) return ElMessage.error('请选择审查材料');
        if (!param.reviewSignature) return ElMessage.error('请选择签字表单');
        if (!param.reviewApproveContent.length) return ElMessage.error('请选择审批材料');
        if (!param.approvalSignature) return ElMessage.error('请选择签字表单');
        if (param.postLoanManagementSelectPolicySelectStatus === 803 && !param.selectionStrategy.length) return ElMessage.error('请选择策略');

        param.accessStrategy = param.accessPolicySelectedStatus === 803 ? param.accessStrategy.join() : '';
        param.borrowerMaterial = param.borrowerMaterialSelectedStatus === 797 ? param.borrowerMaterial.join() : '';
        param.accountMaterials = param.provideMaterialSelectedStatus === 797 ? param.accountMaterials.join() : '';
        param.sendingAccount = param.issueAccountSelectStatus === 801 ? param.sendingAccount.join() : '';
        // 企业
        param.collateral = param.mortgagedPropertySelectedStatus === 797 ? param.collateral.join() : '';
        param.enterpriseMaterial = param.enterpriseMaterialSelectedStatus === 797 ? param.enterpriseMaterial.join() : '';
        param.corporateInterestRateModel = param.corporateInterestRateModel.join();
        param.materialsForLoanApproval = param.materialsForLoanApproval.join();
        // 个人
        param.businessMaterials = param.businessMaterialsSelectedStatus === 797 ? param.businessMaterials.join() : '';
        param.mateMaterial = param.mateMaterialSelectedStatus === 797 ? param.mateMaterial.join() : '';
        if (param.personalCreditScoringStrategySelectedStatus !== 797) param.personalCreditScoringStrategies = '';
        if (param.enterpriseCreditScoringStrategySelectedStatus !== 797) param.corporateCreditScoringStrategies = '';
        if (param.individualCreditModelSelectedStatus !== 803) param.interestRatePricingModel = '';

        if (param.loanContractSelectedStatus !== 797) param.loanContract = '';
        if (param.mortgageContractSelectedStatus !== 797) param.mortgageContract = '';
        if (param.pledgeContractSelectedStatus !== 797) param.pledgeContract = '';
        if (param.guaranteeContractSelectedStatus !== 797) param.guaranteeContract = '';

        param.dueDiligenceMode = param.dueDiligenceMode.join();
        param.dueDiligenceContent = param.dueDiligenceContent.join();
        param.reviewContent = param.reviewContent.join();
        param.reviewApproveContent = param.reviewApproveContent.join();
        param.loanApplicationMethod = param.loanApplicationMethod.join();
        param.riskDegreeStrategy = param.riskDegreePolicySelectedStatus === 803 ? param.riskDegreeStrategy.join() : '';
        param.runBatchObject = param.runBatchObjectSelectedStatus === 803 ? param.runBatchObject.join() : '';
        param.selectionStrategy = param.postLoanManagementSelectPolicySelectStatus === 803 ? param.selectionStrategy.join() : '';
        param.supplementaryMaterials = param.supplementMaterialSelectedStatus === 797 ? param.supplementaryMaterials.join() : '';
        if (param.contractSupplyMaterialsSelectedStatus !== 797) param.contractMaterials = '';
        if (info.value.riskControlDetails) {
          param.id = info.value.riskControlDetails.id;
          await riskUpdate(param);
          addRecord(param);
        } else {
          await riskSave(param);
          addRecord(param);
        }
        router.push(`/product/bank/detail?type=${route.query.type || ''}&i=${route.query.i}&role=${route.query.role}&id=${id.value}`);
        ElMessage.success('提交成功！');
        emit('getList');
      } finally {
      }
    } else {
      console.log('error submit!', fields);
    }
  });
};
// 新增判分记录
const addRecord = async (data: Record<string, any>) => {
  const isEnterprise = info.value.productType === 1;
  const preIds = `1,${Cookies.get('sand-level')},42,66,${isEnterprise ? 71 : 70}`; // 1，关卡id，角色（这个页面是风控经理配置风控），个人/企业（70/71）
  const lcRule: Array<Record<string, any>> = [];

  // 企业
  if (isEnterprise) {
    data.provideMaterialSelectedStatus && lcRule.push(handleId(1246, 325, data.provideMaterialSelectedStatus, preIds + ',112,120,1246', 1));
    data.accountMaterials && lcRule.push(handleId(1254, 44, data.accountMaterials, preIds + ',112,120,1254', 1));
    data.issueAccountSelectStatus && lcRule.push(handleId(1257, 326, data.issueAccountSelectStatus, preIds + ',112,121,1257', 1));
    data.sendingAccount && lcRule.push(handleId(1255, 45, data.sendingAccount, preIds + ',112,121,1255', 1));
    data.loanApplicationMethod && lcRule.push(handleId(122, 46, data.loanApplicationMethod, preIds + ',113,122', 1));

    data.enterpriseMaterialSelectedStatus && lcRule.push(handleId(1294, 325, data.enterpriseMaterialSelectedStatus, preIds + ',113,124,1294', 1));
    data.enterpriseMaterial && lcRule.push(handleId(1258, 48, data.enterpriseMaterial, preIds + ',113,124,1258', 1));

    form.borrowerMaterialSelectedStatus && lcRule.push(handleId(1294, 325, form.borrowerMaterialSelectedStatus, preIds + ',113,123,1294', 1));
    const borrowerMaterial = [];
    form.borrowerMaterial.forEach((e) => {
      borrowerMaterial.push(e);
    });
    borrowerMaterial.length && lcRule.push(handleId(316, 47, borrowerMaterial.join(), preIds + ',113,123,316', 1));

    data.mortgagedPropertySelectedStatus && lcRule.push(handleId(1294, 325, data.mortgagedPropertySelectedStatus, preIds + ',113,125,1294', 1));
    data.collateral && lcRule.push(handleId(1259, 49, data.collateral, preIds + ',113,125,1259', 1));

    data.supplementMaterialSelectedStatus && lcRule.push(handleId(1294, 325, data.supplementMaterialSelectedStatus, preIds + ',113,126,1294', 1));
    data.supplementaryMaterials && lcRule.push(handleId(1260, 50, data.supplementaryMaterials, preIds + ',113,126,1260', 1));

    data.runBatchObjectSelectedStatus && lcRule.push(handleId(1302, 327, data.runBatchObjectSelectedStatus, preIds + ',114,127,1302', 1));
    data.runBatchObject && lcRule.push(handleId(1261, 51, data.runBatchObject, preIds + ',114,127,1261', 1));

    data.accessPolicySelectedStatus && lcRule.push(handleId(1302, 327, data.accessPolicySelectedStatus, preIds + ',114,128,1302', 1));
    data.accessStrategy && lcRule.push(handleId(1262, 52, data.accessStrategy, preIds + ',114,128,1262', 1));

    data.personalCreditScoringStrategySelectedStatus && lcRule.push(handleId(1306, 325, data.personalCreditScoringStrategySelectedStatus, preIds + ',114,129,1046,1306', 1));
    data.personalCreditScoringStrategies && lcRule.push(handleId(1307, 329, data.personalCreditScoringStrategies, preIds + ',114,129,1046,1307', 3));
    data.enterpriseCreditScoringStrategySelectedStatus && lcRule.push(handleId(1306, 325, data.enterpriseCreditScoringStrategySelectedStatus, preIds + ',114,129,1047,1306', 1));
    data.corporateCreditScoringStrategies && lcRule.push(handleId(1307, 329, data.corporateCreditScoringStrategies, preIds + ',114,129,1047,1307', 3));

    data.riskDegreePolicySelectedStatus && lcRule.push(handleId(1302, 327, data.riskDegreePolicySelectedStatus, preIds + ',114,130,1302', 1));
    data.riskDegreeStrategy && lcRule.push(handleId(1301, 54, data.riskDegreeStrategy, preIds + ',114,130,1301', 1));

    data.individualCreditModelSelectedStatus && lcRule.push(handleId(1302, 327, data.individualCreditModelSelectedStatus, preIds + ',114,131,305,1302', 1));
    data.interestRatePricingModel && lcRule.push(handleId(1314, 55, data.interestRatePricingModel, preIds + ',114,131,305,1314', 1));
    data.individualInterestRateModel && lcRule.push(handleId(304, 327, data.individualInterestRateModel, preIds + ',114,131,304', 1));

    data.dueDiligenceMode && lcRule.push(handleId(132, 56, data.dueDiligenceMode, preIds + ',115,132', 1));
    data.dueDiligenceContent && lcRule.push(handleId(133, 57, data.dueDiligenceContent, preIds + ',115,133', 1));
    data.reviewContent && lcRule.push(handleId(134, 58, data.reviewContent, preIds + ',116,134', 1));
    data.reviewSignature && lcRule.push(handleId(135, 59, data.reviewSignature, preIds + ',116,135', 1));
    data.reviewApproveContent && lcRule.push(handleId(136, 60, data.reviewApproveContent, preIds + ',117,136', 1));
    data.approvalSignature && lcRule.push(handleId(137, 61, data.approvalSignature, preIds + ',117,137', 1));

    data.contractSupplyMaterialsSelectedStatus && lcRule.push(handleId(1264, 325, data.contractSupplyMaterialsSelectedStatus, preIds + ',118,138,1264', 1));
    data.contractMaterials && lcRule.push(handleId(1263, 62, data.contractMaterials, preIds + ',118,138,1263', 1));

    data.loanContractSelectedStatus && lcRule.push(handleId(1273, 325, data.loanContractSelectedStatus, preIds + ',118,139,306,1273', 1));
    data.loanContract && lcRule.push(handleId(1269, 63, data.loanContract, preIds + ',118,139,306,1269', 1));

    data.mortgageContractSelectedStatus && lcRule.push(handleId(1273, 325, data.mortgageContractSelectedStatus, preIds + ',118,139,307,1273', 1));
    data.mortgageContract && lcRule.push(handleId(1270, 142, data.mortgageContract, preIds + ',118,139,307,1270', 1));

    data.pledgeContractSelectedStatus && lcRule.push(handleId(1273, 325, data.pledgeContractSelectedStatus, preIds + ',118,139,308,1273', 1));
    data.pledgeContract && lcRule.push(handleId(1271, 143, data.pledgeContract, preIds + ',118,139,308,1271', 1));

    data.guaranteeContractSelectedStatus && lcRule.push(handleId(1273, 325, data.guaranteeContractSelectedStatus, preIds + ',118,139,309,1273', 1));
    data.guaranteeContract && lcRule.push(handleId(1272, 144, data.guaranteeContract, preIds + ',118,139,309,1272', 1));

    data.postLoanManagementSelectPolicySelectStatus && lcRule.push(handleId(1302, 327, data.postLoanManagementSelectPolicySelectStatus, preIds + ',119,140,1302', 1));
    data.selectionStrategy && lcRule.push(handleId(1315, 64, data.selectionStrategy, preIds + ',119,140,1315', 1));
  } else {
    data.provideMaterialSelectedStatus && lcRule.push(handleId(1294, 325, data.provideMaterialSelectedStatus, preIds + ',72,75,1294', 1));
    data.accountMaterials && lcRule.push(handleId(1295, 20, data.accountMaterials, preIds + ',72,75,1295', 1));

    data.issueAccountSelectStatus && lcRule.push(handleId(1312, 326, data.issueAccountSelectStatus, preIds + ',72,76,1312', 1));
    data.sendingAccount && lcRule.push(handleId(1296, 21, data.sendingAccount, preIds + ',72,76,1296', 1));
    data.loanApplicationMethod && lcRule.push(handleId(1289, 22, data.loanApplicationMethod, preIds + ',73,77,1289', 1));

    form.borrowerMaterialSelectedStatus && lcRule.push(handleId(1294, 325, form.borrowerMaterialSelectedStatus, preIds + ',73,78,1294', 1));
    const borrowerMaterial = [];
    form.borrowerMaterial.forEach((e) => {
      borrowerMaterial.push(e);
    });
    borrowerMaterial.length && lcRule.push(handleId(314, 23, borrowerMaterial.join(), preIds + ',73,78,314', 1));

    data.mateMaterialSelectedStatus && lcRule.push(handleId(1294, 325, data.mateMaterialSelectedStatus, preIds + ',73,79,1294', 1));
    data.mateMaterial && lcRule.push(handleId(1291, 24, data.mateMaterial, preIds + ',73,79,1291', 1));

    data.businessMaterialsSelectedStatus && lcRule.push(handleId(1294, 325, data.businessMaterialsSelectedStatus, preIds + ',73,80,1294', 1));
    data.businessMaterials && lcRule.push(handleId(1292, 25, data.businessMaterials, preIds + ',73,80,1292', 1));

    data.supplementMaterialSelectedStatus && lcRule.push(handleId(1294, 325, data.supplementMaterialSelectedStatus, preIds + ',73,81,1294', 1));
    data.supplementaryMaterials && lcRule.push(handleId(1293, 26, data.supplementaryMaterials, preIds + ',73,81,1293', 1));

    data.runBatchObjectSelectedStatus && lcRule.push(handleId(1302, 327, data.runBatchObjectSelectedStatus, preIds + ',74,82,1302', 1));
    data.runBatchObject && lcRule.push(handleId(1297, 27, data.runBatchObject, preIds + ',74,82,1297', 1));

    data.accessPolicySelectedStatus && lcRule.push(handleId(1302, 327, data.accessPolicySelectedStatus, preIds + ',74,83,1302', 1));
    data.accessStrategy && lcRule.push(handleId(1298, 28, data.accessStrategy, preIds + ',74,83,1298', 1));

    data.personalCreditScoringStrategySelectedStatus && lcRule.push(handleId(1306, 325, data.personalCreditScoringStrategySelectedStatus, preIds + ',74,84,1304,1306', 1));
    data.personalCreditScoringStrategies && lcRule.push(handleId(1307, 329, data.personalCreditScoringStrategies, preIds + ',74,84,1304,1307', 3));
    data.enterpriseCreditScoringStrategySelectedStatus && lcRule.push(handleId(1306, 325, data.enterpriseCreditScoringStrategySelectedStatus, preIds + ',74,84,1305,1306', 1));
    data.corporateCreditScoringStrategies && lcRule.push(handleId(1307, 329, data.corporateCreditScoringStrategies, preIds + ',74,84,1305,1307', 3));

    data.riskDegreePolicySelectedStatus && lcRule.push(handleId(1302, 327, data.riskDegreePolicySelectedStatus, preIds + ',74,85,1302', 1));
    data.riskDegreeStrategy && lcRule.push(handleId(1300, 30, data.riskDegreeStrategy, preIds + ',74,85,1300', 1));

    data.individualCreditModelSelectedStatus && lcRule.push(handleId(1302, 327, data.individualCreditModelSelectedStatus, preIds + ',74,86,1309,1302', 1));
    data.interestRatePricingModel && lcRule.push(handleId(1311, 141, data.interestRatePricingModel, preIds + ',74,86,1309,1311', 1));
    data.individualInterestRateModel && lcRule.push(handleId(1308, 327, data.individualInterestRateModel, preIds + ',74,86,1308', 1));

    data.dueDiligenceMode && lcRule.push(handleId(88, 32, data.dueDiligenceMode, preIds + ',87,88', 1));
    data.dueDiligenceContent && lcRule.push(handleId(89, 33, data.dueDiligenceContent, preIds + ',87,89', 1));
    data.reviewContent && lcRule.push(handleId(91, 34, data.reviewContent, preIds + ',90,91', 1));
    data.reviewSignature && lcRule.push(handleId(92, 35, data.reviewSignature, preIds + ',90,92', 1));
    data.reviewApproveContent && lcRule.push(handleId(94, 36, data.reviewApproveContent, preIds + ',93,94', 1));
    data.approvalSignature && lcRule.push(handleId(95, 37, data.approvalSignature, preIds + ',93,95', 1));

    data.contractSupplyMaterialsSelectedStatus && lcRule.push(handleId(1248, 325, data.contractSupplyMaterialsSelectedStatus, preIds + ',96,97,1248', 1));
    data.contractMaterials && lcRule.push(handleId(1247, 38, data.contractMaterials, preIds + ',96,97,1247', 1));

    data.loanContractSelectedStatus && lcRule.push(handleId(1253, 325, data.loanContractSelectedStatus, preIds + ',96,98,310,1253', 1));
    data.loanContract && lcRule.push(handleId(1249, 39, data.loanContract, preIds + ',96,98,310,1249', 1));

    data.mortgageContractSelectedStatus && lcRule.push(handleId(1253, 325, data.mortgageContractSelectedStatus, preIds + ',96,98,311,1253', 1));
    data.mortgageContract && lcRule.push(handleId(1250, 145, data.mortgageContract, preIds + ',96,98,311,1250', 1));

    data.pledgeContractSelectedStatus && lcRule.push(handleId(1253, 325, data.pledgeContractSelectedStatus, preIds + ',96,98,312,1253', 1));
    data.pledgeContract && lcRule.push(handleId(1251, 146, data.pledgeContract, preIds + ',96,98,312,1251', 1));

    data.guaranteeContractSelectedStatus && lcRule.push(handleId(1253, 325, data.guaranteeContractSelectedStatus, preIds + ',96,98,313,1253', 1));
    data.guaranteeContract && lcRule.push(handleId(1252, 147, data.guaranteeContract, preIds + ',96,98,313,1252', 1));

    data.postLoanManagementSelectPolicySelectStatus && lcRule.push(handleId(283, 327, data.postLoanManagementSelectPolicySelectStatus, preIds + ',99,283', 1));
    data.selectionStrategy && lcRule.push(handleId(281, 40, data.selectionStrategy, preIds + ',99,281', 1));
  }

  await addOperation({
    ...getIds(),
    parentId: preIds,
    lcJudgmentRuleReq: lcRule,
  });
};
</script>

<style lang="scss" scoped>
@import url(../../../styles/form.scss);
</style>
