<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"
                                 @change="denyAll('accountMaterials', 769)">
                <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"
                                   @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>

                <!-- 企业 -->
                <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"
                                       @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>
                  </div>
                  <p class="field-name mt-5">经营类材料</p>
                  <div>
                    <el-checkbox-group 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>
                  </div>
                </template>
                <p class="field-name mt-5">补充材料</p>
                <div>
                  <el-checkbox-group 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>
                </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 credits.filter(e => !e.scoringObject)"
                               :key="item"
                               :value="item.scoreCardName" />
                    <el-option value="无" />
                  </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 credits.filter(e => e.scoringObject)"
                               :key="item"
                               :value="item.scoreCardName" />
                    <el-option value="无" />
                  </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">
              <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="info.productType ? 763 : 762">{{ 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="info.productType ? 261 : 114">{{ info.productType ? '所有基本信息' : '所有基本材料' }}</el-radio>
            </el-form-item>
            <el-form-item label="审查签字"
                          prop="reviewSignature">
              <el-radio v-model="form.reviewSignature"
                        :label="info.productType ? 262 : 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="info.productType ? 263 : 116">以上所有材料</el-radio>
            </el-form-item>
            <el-form-item label="审批签字"
                          prop="approvalSignature">
              <el-radio v-model="form.approvalSignature"
                        :label="info.productType ? 264 : 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="info.productType ? 265 : 118">抵押物所有权证明</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]?.recordChildren[0]?.subject?.itemList"
                               :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]?.recordChildren[1]?.subject?.itemList"
                               :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]?.recordChildren[2]?.subject?.itemList"
                               :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]?.recordChildren[3]?.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">
              <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 { listCredit } from '@/api/model';
import { useRouter, useRoute } from 'vue-router';
import { handleId, getIds } 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 credits = ref<Record<string, 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 { data } = await listCredit({
    checkpointId: levelId,
    projectId,
    pageNum: 1,
    pageSize: 1000,
  });
  credits.value = data;
};
// 详情
const getDetail = async () => {
  if (id.value) {
    try {
      const { data } = await findById(id.value);
      info.value = data;
      getConfig();
    } 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));

        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.collateral = param.collateral.join();
        param.enterpriseMaterial = param.enterpriseMaterial.join();
        param.corporateInterestRateModel = param.corporateInterestRateModel.join();
        param.materialsForLoanApproval = param.materialsForLoanApproval.join();
        // 个人
        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.dueDiligenceContent = param.dueDiligenceContent.join();
        param.loanApplicationMethod = param.loanApplicationMethod.join();
        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);
        }
        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.accountMaterials && lcRule.push(handleId(120, 44, data.accountMaterials, preIds + ',112,120', 1));
    data.sendingAccount && lcRule.push(handleId(121, 45, 162, preIds + ',112,121', 1));
    data.loanApplicationMethod && lcRule.push(handleId(122, 46, data.loanApplicationMethod, preIds + ',113,122', 1));
    data.enterpriseMaterial && lcRule.push(handleId(124, 48, data.enterpriseMaterial, preIds + ',113,124', 1));

    const borrowerMaterial = [];
    form.borrowerMaterial.forEach((e) => {
      e != 316 && borrowerMaterial.push(e);
    });
    borrowerMaterial.length && lcRule.push(handleId(316, 47, borrowerMaterial.join(), preIds + ',113,123,316', 1));
    data.borrowerMaterialSelect && lcRule.push(handleId(317, 149, data.borrowerMaterialSelect, preIds + ',113,123,317', 1));
    data.collateral && lcRule.push(handleId(125, 49, data.collateral, preIds + ',113,125', 1));
    data.supplementaryMaterials && lcRule.push(handleId(126, 50, data.supplementaryMaterials, preIds + ',113,126', 1));
    data.runBatchObject && lcRule.push(handleId(127, 51, data.runBatchObject, preIds + ',114,127', 1));
    data.accessStrategy && lcRule.push(handleId(128, 52, data.accessStrategy, preIds + ',114,128', 1));

    // 选择了无才需要给
    lcRule.push(handleId(1044, 302, data.personalCreditScoringStrategiesCheck ? 759 : 760, preIds + ',114,129,1046,1044', 1));
    lcRule.push(handleId(1044, 302, data.corporateCreditScoringStrategiesCheck ? 759 : 760, preIds + ',114,129,1047,1044', 1));
    lcRule.push(handleId(1045, 303, data.personalCreditScoringStrategies, preIds + ',114,129,1046,1045', 3));
    lcRule.push(handleId(1045, 303, data.corporateCreditScoringStrategies, preIds + ',114,129,1047,1045', 3));

    data.riskDegreeStrategy && lcRule.push(handleId(130, 54, data.riskDegreeStrategy, preIds + ',114,130', 1));
    data.interestRatePricingModelCheck && lcRule.push(handleId(305, 55, data.interestRatePricingModel, preIds + ',114,131,305', 1));
    data.individualInterestRateModel && lcRule.push(handleId(304, 305, 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.contractMaterials && lcRule.push(handleId(138, 62, data.contractMaterials, preIds + ',118,138', 1));

    data.loanContract && lcRule.push(handleId(306, 63, data.loanContract, preIds + ',118,139,306', 1));
    data.mortgageContract && lcRule.push(handleId(307, 142, data.mortgageContract, preIds + ',118,139,307', 1));
    data.pledgeContract && lcRule.push(handleId(308, 143, data.pledgeContract, preIds + ',118,139,308', 1));
    data.guaranteeContract && lcRule.push(handleId(309, 144, data.guaranteeContract, preIds + ',118,139,309', 1));
    data.selectionStrategy && lcRule.push(handleId(140, 64, data.selectionStrategy, preIds + ',119,140', 1));
  } else {
    data.accountMaterials && lcRule.push(handleId(75, 20, data.accountMaterials, preIds + ',72,75', 1));
    data.sendingAccount && lcRule.push(handleId(76, 21, 46, preIds + ',72,76', 1));
    data.loanApplicationMethod && lcRule.push(handleId(77, 22, data.loanApplicationMethod, preIds + ',73,77', 1));
    const borrowerMaterial = [];
    form.borrowerMaterial.forEach((e) => {
      e != 314 && borrowerMaterial.push(e);
    });
    borrowerMaterial.length && lcRule.push(handleId(314, 23, borrowerMaterial.join(), preIds + ',73,78,314', 1));
    data.borrowerMaterialSelect && lcRule.push(handleId(315, 148, data.borrowerMaterialSelect, preIds + ',73,78,315', 1));
    data.mateMaterial && lcRule.push(handleId(79, 24, data.mateMaterial, preIds + ',73,79', 1));
    data.businessMaterials && lcRule.push(handleId(80, 25, data.businessMaterials, preIds + ',73,80', 1));
    data.supplementaryMaterials && lcRule.push(handleId(81, 26, data.supplementaryMaterials, preIds + ',73,81', 1));
    data.runBatchObject && lcRule.push(handleId(82, 27, data.runBatchObject, preIds + ',74,82', 1));
    data.accessStrategy && lcRule.push(handleId(83, 28, data.accessStrategy, preIds + ',74,83', 1));

    // 选择了无才需要给
    lcRule.push(handleId(1044, 302, data.personalCreditScoringStrategiesCheck ? 759 : 760, preIds + ',74,84,1046,1044', 1));
    lcRule.push(handleId(1044, 302, data.corporateCreditScoringStrategiesCheck ? 759 : 760, preIds + ',74,84,1047,1044', 1));
    lcRule.push(handleId(1045, 303, data.personalCreditScoringStrategies, preIds + ',74,84,1046,1045', 3));
    lcRule.push(handleId(1045, 303, data.corporateCreditScoringStrategies, preIds + ',74,84,1047,1045', 3));

    data.riskDegreeStrategy && lcRule.push(handleId(85, 30, data.riskDegreeStrategy, preIds + ',74,85', 1));
    data.interestRatePricingModelCheck && lcRule.push(handleId(303, 141, data.interestRatePricingModel, preIds + ',74,86,303', 1));
    data.individualInterestRateModel && lcRule.push(handleId(302, 304, data.individualInterestRateModel, preIds + ',74,86,302', 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.contractMaterials && lcRule.push(handleId(97, 38, data.contractMaterials, preIds + ',96,97', 1));

    data.loanContract && lcRule.push(handleId(310, 39, data.loanContract, preIds + ',96,98,310', 1));
    data.mortgageContract && lcRule.push(handleId(311, 145, data.mortgageContract, preIds + ',96,98,311', 1));
    data.pledgeContract && lcRule.push(handleId(312, 146, data.pledgeContract, preIds + ',96,98,312', 1));
    data.guaranteeContract && lcRule.push(handleId(313, 147, data.guaranteeContract, preIds + ',96,98,313', 1));
    data.selectionStrategy && lcRule.push(handleId(99, 40, data.selectionStrategy, preIds + ',99', 1));
  }

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

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