<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"
                 status-icon>
          <div class="step">
            <h6 class="step-name mb-7">办理账户</h6>
            <el-form-item label="提供材料"
                          prop="accountMaterials">
              <el-checkbox-group v-model="form.accountMaterials">
                <el-checkbox v-for="(item, i) in config[0]?.recordChildren[0]?.subject?.itemList"
                             :key="i"
                             :label="item.itemId">{{ item.options }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
            <el-form-item label="发放账户"
                          prop="sendingAccount">
              <el-radio v-model="form.sendingAccount"
                        :label="46">借记卡或放款专户</el-radio>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">贷款申请</h6>
            <el-form-item label="申请方式"
                          prop="loanApplicationMethod">
              <el-checkbox-group 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">
                <p class="field-name">借款人材料</p>
                <div class="flex items-center mb-3">
                  <el-checkbox-group v-model="form.borrowerMaterial">
                    <el-checkbox :label="config[1]?.recordChildren[1]?.recordChildren[0].id">{{ config[1]?.recordChildren[1]?.recordChildren[0].name }}</el-checkbox>
                  </el-checkbox-group>
                  <el-select v-show="(info.productType && form.borrowerMaterial?.includes(316)) || (!info.productType && form.borrowerMaterial?.includes(314))"
                             class="ml-5"
                             v-model="form.borrowerMaterialSelect"
                             placeholder="请选择">
                    <el-option v-for="item in config[1]?.recordChildren[1]?.recordChildren[1]?.subject?.itemList"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <el-checkbox-group v-model="form.borrowerMaterial">
                  <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>

                <!-- 企业 -->
                <template v-if="info.productType">
                  <p class="field-name mt-5">企业材料</p>
                  <div>
                    <el-checkbox-group 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>
                  </div>
                  <p class="field-name mt-5">抵押物</p>
                  <div>
                    <el-checkbox-group 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>
                  </div>
                </template>
                <!-- 个人 -->
                <template v-else>
                  <p class="field-name mt-5">配偶材料</p>
                  <div>
                    <el-checkbox-group v-model="form.mateMaterial">
                      <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>
                  </div>
                  <p class="field-name mt-5">经营类材料</p>
                  <div>
                    <el-checkbox-group v-model="form.businessMaterials">
                      <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>
                  </div>
                </template>
                <p class="field-name mt-5">补充材料</p>
                <div>
                  <el-checkbox-group v-model="form.supplementaryMaterials">
                    <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>
                </div>

              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">系统跑批准入风控策略</h6>
            <el-form-item label="跑批对象"
                          prop="runBatchObject">
              <el-checkbox-group v-model="form.runBatchObject">
                <el-checkbox v-for="(item, i) in config[2]?.recordChildren[0]?.subject?.itemList"
                             :key="i"
                             :label="item.itemId">{{ item.options }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
            <el-form-item label="准入策略"
                          prop="accessStrategy">
              <el-checkbox-group v-model="form.accessStrategy">
                <el-checkbox v-for="(item, i) in config[2]?.recordChildren[1]?.subject?.itemList"
                             :key="i"
                             :label="item.itemId">{{ item.options }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
            <el-form-item label="信用评分策略"
                          label-width="130px"
                          prop="personalCreditScoringStrategiesCheck">
              <div class="flex-1">
                <div class="flex items-center mb-3">
                  <el-checkbox v-model="form.personalCreditScoringStrategiesCheck"
                               label="个人信用评分策略" />
                  <el-select v-show="form.personalCreditScoringStrategiesCheck"
                             class="ml-5"
                             v-model="form.personalCreditScoringStrategies"
                             placeholder="请选择">
                    <el-option v-for="item in config[2]?.recordChildren[2]?.subject?.itemList[0]?.children"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <div class="flex items-center">
                  <el-checkbox v-model="form.corporateCreditScoringStrategiesCheck"
                               label="企业信用评分策略" />
                  <el-select v-show="form.corporateCreditScoringStrategiesCheck"
                             class="ml-5"
                             v-model="form.corporateCreditScoringStrategies"
                             placeholder="请选择">
                    <el-option v-for="item in config[2]?.recordChildren[2]?.subject?.itemList[1]?.children"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
              </div>
            </el-form-item>
            <el-form-item label="风险度策略"
                          prop="riskDegreeStrategy">
              <el-checkbox-group 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>
            </el-form-item>
            <el-form-item label="利率定价模型"
                          label-width="130px"
                          prop="interestRatePricingModelCheck"
                          :rules="[
              { required: true, message: '请选择利率定价模型', trigger: 'change' },
              {
                asyncValidator: async (rule, value, callback) => {
                  if (value && !form.interestRatePricingModel) {
                    callback(`请选择${info.productType ? '企业' : '个人'}额度模型`)
                  } else {
                    callback()
                  }
                },
              },
            ]">
              <div class="flex-1">
                <div class="flex items-center mb-3">
                  <el-checkbox v-model="form.interestRatePricingModelCheck"
                               :label="(info.productType ? '企业' : '个人') + '额度模型'" />
                  <el-select v-show="form.interestRatePricingModelCheck"
                             class="ml-5"
                             v-model="form.interestRatePricingModel"
                             placeholder="请选择">
                    <el-option v-for="item in config[2]?.recordChildren[4]?.recordChildren[1]?.subject?.itemList"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <el-checkbox v-model="form.individualInterestRateModel"
                             :label="103">{{ info.productType ? '企业' : '个人' }}利率模型</el-checkbox>
              </div>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">尽职调查</h6>
            <el-form-item label="尽调方式"
                          prop="dueDiligenceMode">
              <el-radio-group v-model="form.dueDiligenceMode">
                <el-radio v-for="(item, i) in config[3]?.recordChildren[0]?.subject?.itemList"
                          :key="i"
                          :label="item.itemId">{{ item.options }}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="尽调内容"
                          prop="dueDiligenceContent">
              <el-checkbox-group 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>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">贷款审查</h6>
            <el-form-item label="审查内容"
                          prop="reviewContent">
              <el-radio v-model="form.reviewContent"
                        :label="114">所有基本材料</el-radio>
            </el-form-item>
            <el-form-item label="审查签字"
                          prop="reviewSignature">
              <el-radio v-model="form.reviewSignature"
                        :label="115">《用信调查申报表》</el-radio>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">贷款审批</h6>
            <el-form-item label="审批内容"
                          prop="reviewApproveContent">
              <el-radio v-model="form.reviewApproveContent"
                        :label="116">以上所有材料</el-radio>
            </el-form-item>
            <el-form-item label="审批签字"
                          prop="approvalSignature">
              <el-radio v-model="form.approvalSignature"
                        :label="117">《用信调查申报表》</el-radio>
            </el-form-item>
          </div>
          <div class="step">
            <h6 class="step-name mb-7">签订合同</h6>
            <el-form-item label="提供的材料"
                          prop="contractMaterials">
              <el-radio v-model="form.contractMaterials"
                        :label="117">抵押物所有权证明</el-radio>
            </el-form-item>
            <el-form-item label="合同模板">
              <div class="flex-1">
                <div class="flex items-center mb-3">
                  <el-checkbox v-model="form.loanContractCheck"
                               label="借贷合同" />
                  <el-select v-show="form.loanContractCheck"
                             class="ml-5"
                             v-model="form.loanContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.subject?.itemList[0]?.children"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <div class="flex items-center mb-3">
                  <el-checkbox v-model="form.mortgageContractCheck"
                               label="抵押合同" />
                  <el-select v-show="form.mortgageContractCheck"
                             class="ml-5"
                             v-model="form.mortgageContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.subject?.itemList[1]?.children"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <div class="flex items-center mb-3">
                  <el-checkbox v-model="form.pledgeContractCheck"
                               label="质押合同" />
                  <el-select v-show="form.pledgeContractCheck"
                             class="ml-5"
                             v-model="form.pledgeContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.subject?.itemList[2]?.children"
                               :key="item.itemId"
                               :label="item.options"
                               :value="item.itemId" />
                  </el-select>
                </div>
                <div class="flex items-center">
                  <el-checkbox v-model="form.guaranteeContractCheck"
                               label="担保合同" />
                  <el-select v-show="form.guaranteeContractCheck"
                             class="ml-5"
                             v-model="form.guaranteeContract"
                             placeholder="请选择">
                    <el-option v-for="item in config[6]?.recordChildren[1]?.subject?.itemList[3]?.children"
                               :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">
              <el-checkbox-group v-model="form.selectionStrategy">
                <el-checkbox v-for="(item, i) in info.productType ? config[7]?.recordChildren[0]?.subject?.itemList : config[7]?.subject?.itemList"
                             :key="i"
                             :label="item.itemId">{{ item.options }}</el-checkbox>
              </el-checkbox-group>
            </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="产品要素"
                   name="tab2">
        <info />
      </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 } from '@/api/bank';
import { getProcessInformationBasedOnRoles, addOperation } from '@/api/judgment';
import { useRouter, useRoute } from 'vue-router';
import { handleId } from '@/utils/common';
import Info from './Info.vue';
import Cookies from 'js-cookie';

const emit = defineEmits(['getList']);
interface RuleForm {
  accessStrategy: any;
  accountMaterials: any;
  approvalSignature?: any;
  bankProductsId: any;
  borrowerMaterial: any;
  borrowerMaterialSelect: any;
  businessMaterials: any;
  collateral: any;
  contractMaterials: any;
  corporateCreditScoringStrategiesCheck: boolean;
  corporateCreditScoringStrategies: any;
  corporateInterestRateModel: any;
  dueDiligenceContent: any;
  dueDiligenceMode: any;
  enterpriseMaterial: any;
  enterpriseQuotaModel: any;
  guaranteeContract: any;
  individualInterestRateModel: any;
  interestRatePricingModelCheck: boolean;
  interestRatePricingModel: any;
  loanApplicationMethod: any;
  loanContract: any;
  mateMaterial: any;
  materialsForLoanApproval: any;
  mortgageContract: any;
  personalCreditScoringStrategiesCheck: boolean;
  personalCreditScoringStrategies: any;
  pledgeContractCheck: boolean;
  pledgeContract: any;
  reviewApproveContent: any;
  reviewContent: any;
  reviewSignature: any;
  riskDegreeStrategy: any;
  runBatchObject: any;
  selectionStrategy: any;
  sendingAccount: any;
  supplementaryMaterials: any;
}

const router = useRouter();
const route = useRoute();
const id = computed(() => +route.query.id);
const projectId = +Cookies.get('sand-projectId');
const levelId = +Cookies.get('sand-level');
const curTab = ref<string>('tab1');
const config = ref<any[]>([]);
const info = ref<Record<string, any>>({});
const formRef = ref<FormInstance>();
const form = reactive<RuleForm>({
  checkPointId: levelId,
  projectId,
  accessStrategy: [],
  accountMaterials: [],
  approvalSignature: [],
  bankProductsId: computed(() => +route.query.id),
  borrowerMaterial: [],
  borrowerMaterialSelect: '',
  businessMaterials: [],
  collateral: [],
  contractMaterials: [],
  corporateCreditScoringStrategiesCheck: false,
  corporateCreditScoringStrategies: '',
  corporateInterestRateModel: [],
  dueDiligenceContent: [],
  dueDiligenceMode: '',
  enterpriseMaterial: [],
  enterpriseQuotaModel: '',
  guaranteeContract: '',
  individualInterestRateModel: [],
  interestRatePricingModelCheck: false,
  interestRatePricingModel: '',
  loanApplicationMethod: [],
  loanContract: '',
  mateMaterial: [],
  materialsForLoanApproval: [],
  mortgageContract: '',
  personalCreditScoringStrategiesCheck: false,
  personalCreditScoringStrategies: '',
  pledgeContractCheck: false,
  pledgeContract: '',
  reviewApproveContent: [],
  reviewContent: '',
  reviewSignature: [],
  riskDegreeStrategy: [],
  runBatchObject: [],
  selectionStrategy: [],
  sendingAccount: '',
  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 getDetail = async () => {
  if (id.value) {
    try {
      const { data } = await findById(id.value);
      info.value = data;
      getConfig();
    } finally {
    }
  }
};
watch(
  () => route.query,
  () => {
    getDetail();
  },
  {
    immediate: true,
  },
);
onMounted(() => {});
// 提交
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 (((isEnterprise && param.borrowerMaterial?.includes(316)) || (!isEnterprise && param.borrowerMaterial?.includes(314))) && !param.borrowerMaterialSelect)
          return ElMessage.error('请选择借款申请表');
        if (
          (param.personalCreditScoringStrategiesCheck && !param.personalCreditScoringStrategies) ||
          (param.corporateCreditScoringStrategiesCheck && !param.corporateCreditScoringStrategies)
        )
          return ElMessage.error('请选择信用评分策略');
        if (param.loanContractCheck && !param.loanContract) return ElMessage.error('请选择借贷合同');
        if (param.mortgageContractCheck && !param.mortgageContract) return ElMessage.error('请选择抵押合同');
        if (param.pledgeContractCheck && !param.pledgeContract) return ElMessage.error('请选择质押合同');
        if (param.guaranteeContractCheck && !param.guaranteeContract) return ElMessage.error('请选择担保合同');

        param.accessStrategy = param.accessStrategy.join();
        if ((isEnterprise && param.borrowerMaterial?.includes(316)) || (!isEnterprise && param.borrowerMaterial?.includes(314)))
          param.borrowerMaterial.splice(1, 0, param.borrowerMaterialSelect);
        param.borrowerMaterial = param.borrowerMaterial.join();
        param.accountMaterials = param.accountMaterials.join();
        param.approvalSignature = param.approvalSignature[0];
        // 企业
        // if (isEnterprise) {
        param.collateral = param.collateral.join();
        param.enterpriseMaterial = param.enterpriseMaterial.join();
        param.corporateInterestRateModel = param.corporateInterestRateModel.join();
        param.materialsForLoanApproval = param.materialsForLoanApproval.join();
        // } else {
        // 个人
        param.businessMaterials = param.businessMaterials.join();
        param.mateMaterial = param.mateMaterial.join();
        param.individualInterestRateModel = param.individualInterestRateModel.join();
        // }
        if (!param.personalCreditScoringStrategiesCheck) param.personalCreditScoringStrategies = '';
        if (!param.corporateCreditScoringStrategiesCheck) param.corporateCreditScoringStrategies = '';
        if (!param.interestRatePricingModelCheck) param.interestRatePricingModel = '';

        if (!param.loanContractCheck) param.loanContract = '';
        if (!param.mortgageContractCheck) param.mortgageContract = '';
        if (!param.pledgeContractCheck) param.pledgeContract = '';
        if (!param.guaranteeContractCheck) param.guaranteeContract = '';

        param.contractMaterials = param.contractMaterials[0];
        param.dueDiligenceContent = param.dueDiligenceContent.join();
        param.loanApplicationMethod = param.loanApplicationMethod.join();
        param.reviewApproveContent = param.reviewApproveContent[0];
        // if (param.reviewContent) param.reviewContent = 114;
        param.reviewSignature = param.reviewSignature[0] || '';
        param.riskDegreeStrategy = param.riskDegreeStrategy.join();
        param.runBatchObject = param.runBatchObject.join();
        param.selectionStrategy = param.selectionStrategy.join();
        param.supplementaryMaterials = param.supplementaryMaterials.join();

        if (info.value.riskControlDetails) {
          param.id = info.value.riskControlDetails.id;
          await riskUpdate(param);
          addRecord(param);
        } else {
          await riskSave(param);
          addRecord(param);
        }

        ElMessage.success('提交成功！');
        emit('getList', 1);
      } 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,${data.productType ? 71 : 70}`; // 1，关卡id，角色（这个页面是风控经理配置风控），个人/企业（70/71）
  const lcRule: Array<Record<string, any>> = [];

  // 企业
  if (isEnterprise) {
    lcRule.push(
      handleId(120, 44, data.accountMaterials, preIds + ',112,120', 1),
      handleId(121, 45, 162, preIds + ',112,121', 1),
      handleId(122, 46, data.loanApplicationMethod, preIds + ',113,122', 1),
      handleId(123, 47, data.borrowerMaterial, preIds + ',113,123', 1),
      handleId(124, 48, data.collateral, preIds + ',113,124', 1),
      handleId(125, 49, data.businessMaterials, preIds + ',113,125', 1),
      handleId(126, 50, data.supplementaryMaterials, preIds + ',113,126', 1),

      handleId(127, 51, data.runBatchObject, preIds + ',114,127', 1),
      handleId(128, 52, data.accessStrategy, preIds + ',114,128', 1),
    );
    data.personalCreditScoringStrategiesCheck && lcRule.push(handleId(129, 53, '240,' + data.personalCreditScoringStrategies, preIds + ',114,129', 1));
    data.corporateCreditScoringStrategiesCheck && lcRule.push(handleId(129, 53, '241,' + data.corporateCreditScoringStrategies, preIds + ',114,129', 1));

    lcRule.push(handleId(130, 54, data.riskDegreeStrategy, preIds + ',114,130', 1));
    data.interestRatePricingModelCheck && lcRule.push(handleId(131, 55, '247,' + data.interestRatePricingModel, preIds + ',114,131', 1));
    data.individualInterestRateModel && lcRule.push(handleId(131, 55, data.individualInterestRateModel, preIds + ',114,131', 1));

    lcRule.push(
      handleId(132, 56, data.dueDiligenceMode, preIds + ',115,132', 1),
      handleId(133, 57, data.dueDiligenceContent, preIds + ',115,133', 1),
      handleId(134, 58, data.reviewContent, preIds + ',116,134', 1),
      handleId(135, 59, data.reviewSignature, preIds + ',116,135', 1),
      handleId(136, 60, data.reviewApproveContent, preIds + ',117,136', 1),
      handleId(137, 61, data.approvalSignature, preIds + ',117,137', 1),
      handleId(138, 62, data.contractMaterials, preIds + ',118,138', 1),
    );
    data.loanContract && lcRule.push(handleId(139, 63, data.loanContract, preIds + ',118,139', 1));
    data.mortgageContract && lcRule.push(handleId(139, 63, data.mortgageContract, preIds + ',118,139', 1));
    data.pledgeContract && lcRule.push(handleId(139, 63, data.pledgeContract, preIds + ',118,139', 1));
    data.guaranteeContract && lcRule.push(handleId(139, 63, data.guaranteeContract, preIds + ',118,139', 1));
    lcRule.push(handleId(140, 64, data.selectionStrategy, preIds + ',119,140', 1));
  } else {
    lcRule.push(
      handleId(75, 20, data.accountMaterials, preIds + ',72,75', 1),
      handleId(76, 21, 46, preIds + ',72,76', 1),
      handleId(77, 22, data.loanApplicationMethod, preIds + ',73,77', 1),
      handleId(78, 23, data.borrowerMaterial, preIds + ',73,78', 1),
      handleId(79, 24, data.mateMaterial, preIds + ',73,79', 1),
      handleId(80, 25, data.businessMaterials, preIds + ',73,80', 1),
      handleId(81, 26, data.supplementaryMaterials, preIds + ',73,81', 1),
      handleId(82, 27, data.runBatchObject, preIds + ',74,82', 1),
      handleId(83, 28, data.accessStrategy, preIds + ',74,83', 1),
    );

    lcRule.push(handleId(1044, 282, data.personalCreditScoringStrategiesCheck ? 683 : 684, preIds + ',74,1046,1044', 1));
    // data.personalCreditScoringStrategiesCheck && lcRule.push(handleId(1045, 283, data.personalCreditScoringStrategies, preIds + ',74,1046,1045', 1));
    data.corporateCreditScoringStrategiesCheck && lcRule.push(handleId(84, 29, '95,' + data.corporateCreditScoringStrategies, preIds + ',74,84', 1));

    lcRule.push(handleId(85, 30, data.riskDegreeStrategy, preIds + ',74,85', 1));
    data.interestRatePricingModelCheck && lcRule.push(handleId(86, 31, '102,' + data.interestRatePricingModel, preIds + ',74,86', 1));
    data.individualInterestRateModel && lcRule.push(handleId(86, 31, data.individualInterestRateModel, preIds + ',74,86', 1));

    lcRule.push(
      handleId(88, 32, data.dueDiligenceMode, preIds + ',87,88', 1),
      handleId(89, 33, data.dueDiligenceContent, preIds + ',87,89', 1),
      handleId(91, 34, data.reviewContent, preIds + ',90,91', 1),
      handleId(92, 35, data.reviewSignature, preIds + ',90,92', 1),
      handleId(94, 36, data.reviewApproveContent, preIds + ',93,94', 1),
      handleId(95, 37, data.approvalSignature, preIds + ',93,95', 1),
      handleId(97, 38, data.contractMaterials, preIds + ',96,97', 1),
    );
    data.loanContract && lcRule.push(handleId(98, 39, data.loanContract, preIds + ',96,98', 1));
    data.mortgageContract && lcRule.push(handleId(98, 39, data.mortgageContract, preIds + ',96,98', 1));
    data.pledgeContract && lcRule.push(handleId(98, 39, data.pledgeContract, preIds + ',96,98', 1));
    data.guaranteeContract && lcRule.push(handleId(98, 39, data.guaranteeContract, preIds + ',96,98', 1));
    lcRule.push(handleId(99, 40, data.selectionStrategy, preIds + ',99', 1));
  }

  await addOperation({
    checkpointId: levelId,
    parentId: preIds,
    lcJudgmentRuleReq: lcRule,
    projectId,
  });
};
</script>

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