金融产品设计及数字化营销沙盘

316 lines
10 KiB

1 year ago
<template>
<el-table class="c-table"
:data="form"
:max-height="height"
:span-method="span"
border>
<el-table-column prop="name"
label="指标"
min-width="150"
align="center">
</el-table-column>
<el-table-column label="规则"
min-width="250"
align="center">
<template #default="{ row }">
<!-- 大病报销 || 贫困户 -->
<div v-if="row.stRecordId == 161 || row.stRecordId == 164"
class="flex items-center">
<span class="whitespace-nowrap">{{ row?.recordChildren[row.span ? 1 : 0]?.name }}</span>
<div class="w-[90px] ">
<el-select class="mx-2"
v-model="row.symbol">
<el-option v-for="item in symbols"
:key="item"
:label="item.name"
:value="item.name" />
</el-select>
</div>
<el-input class="w-[80px]"
v-model="row.num"></el-input>
<span class="ml-2 whitespace-nowrap">万元</span>
</div>
<!-- 大龄未婚 -->
<div v-else-if="row.stRecordId == 167"
class="flex items-center">
<template v-if="row.span">
<span class="whitespace-nowrap">且近一年</span>
<div class="w-[90px] ">
<el-select class="mx-2"
v-model="row.had">
<el-option value="有" />
<el-option value="无" />
1 year ago
</el-select>
</div>
<span class="ml-2 whitespace-nowrap">缴纳过社保或公积金</span>
</template>
<template v-else>
<span class="whitespace-nowrap">未婚且年龄</span>
<div class="w-[90px] ">
<el-select class="mx-2"
v-model="row.symbol">
<el-option v-for="item in symbols"
:key="item"
:label="item.name"
:value="item.name" />
</el-select>
</div>
<el-input class="w-[80px]"
v-model="row.num"></el-input>
<span class="ml-2 whitespace-nowrap">,</span>
<el-select class="w-[80px] ml-2"
v-model="row.had">
<el-option value="有" />
<el-option value="无" />
1 year ago
</el-select>
<span class="ml-2 whitespace-nowrap">固定资产</span>
</template>
</div>
<span v-else>{{ '命中' + row.name }}</span>
</template>
</el-table-column>
<el-table-column label="本人命中进黑名单"
width="140"
align="center">
<template #default="{ row }">
<el-checkbox v-model="row.personalHitBlacklist"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="配偶命中拒入"
width="140"
align="center">
<template #default="{ row }">
<el-checkbox v-model="row.mateHitRejected"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="父母/子女命中拒入"
width="150"
align="center">
<template #default="{ row }">
<el-checkbox v-model="row.parentsHitRejected"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="其它家庭成员命中拒入"
width="170"
align="center">
<template #default="{ row }">
<el-checkbox v-model="row.otherFamilyMembersHitRejected"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="企业大股东命中拒入"
width="160"
align="center">
<template #default="{ row }">
<el-checkbox v-model="row.corporateMajorityHitRejected"></el-checkbox>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end">
<div class="submit"
@click="submit">确认完成配置</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed, watch, onMounted } from 'vue';
1 year ago
import { ElMessage } from 'element-plus';
import { accessStrategyGovernmentBlacklistFind, accessStrategyGovernmentBlacklistSave } from '@/api/model';
1 year ago
import { getProcessInformationBasedOnRoles, addOperation } from '@/api/judgment';
import type { TableColumnCtx } from 'element-plus';
import { useRouter, useRoute } from 'vue-router';
import { handleId } from '@/utils/common';
import Cookies from 'js-cookie';
1 year ago
const router = useRouter();
const route = useRoute();
1 year ago
const projectId = +Cookies.get('sand-projectId');
const levelId = +Cookies.get('sand-level');
1 year ago
const form = ref<Record<string, any>[]>([]);
1 year ago
const info = ref<Record<string, any>[]>([]);
1 year ago
const height = window.innerHeight - 270;
const symbols = <Record<string, any>[]>[
{
name: '>=',
},
{
name: '<',
},
{
name: '>',
},
{
name: '==',
},
{
name: '<=',
},
];
// 配置项
const getConfig = async () => {
const { process } = await getProcessInformationBasedOnRoles(150);
const result = [];
process.map((e) => {
1 year ago
const cur = info.value.find((n) => n.stRecordId === e.id);
let num = cur?.ruleOne.match(/\d+/g);
let symbol = cur?.ruleOne.match(/[<>=]+/g);
let had = cur?.ruleOne.match(/[有无]+/g);
1 year ago
let temp = {
checkpointId: levelId,
projectId,
1 year ago
name: e.name,
recordChildren: e.recordChildren,
isRule: isRule(e.id) ? 1 : 0,
1 year ago
corporateMajorityHitRejected: !!cur?.corporateMajorityHitRejected,
mateHitRejected: !!cur?.mateHitRejected,
otherFamilyMembersHitRejected: !!cur?.otherFamilyMembersHitRejected,
parentsHitRejected: !!cur?.parentsHitRejected,
personalHitBlacklist: !!cur?.personalHitBlacklist,
1 year ago
symbol: isRule(e.id) && symbol?.length ? symbol[0] : '>=',
had: e.id === 167 && had?.length ? had[0] : '',
1 year ago
num: isRule(e.id) && num?.length ? num[0] : '',
1 year ago
ruleOne: '',
ruleTwo: '',
1 year ago
subjectId: e.subjectId,
1 year ago
stRecordId: e.id,
};
result.push(temp);
if (isRule(e.id)) {
temp = JSON.parse(JSON.stringify(temp));
temp.span = 1;
1 year ago
num = cur?.ruleTwo.match(/\d+/g);
if (num?.length) temp.num = num[0];
symbol = cur?.ruleTwo.match(/[<>=]+/g);
if (symbol?.length) temp.symbol = symbol[0];
if (e.id === 167) temp.had = cur?.ruleTwo;
1 year ago
result.push(temp);
}
});
form.value = result;
};
// 详情
const getDetail = async () => {
1 year ago
try {
const { data } = await accessStrategyGovernmentBlacklistFind(levelId, projectId);
info.value = data;
getConfig();
} finally {
1 year ago
}
};
1 year ago
1 year ago
watch(
() => route.query,
() => {
1 year ago
getDetail();
1 year ago
},
{
immediate: true,
},
);
// 判断是否是3个有输入框的指标
const isRule = (rule: number): boolean => {
return rule === 161 || rule === 164 || rule === 167;
};
interface SpanMethodProps {
row: Record<string, any>;
column: TableColumnCtx<Record<string, any>>;
rowIndex: number;
columnIndex: number;
}
// 表格合并
const span = ({ row, column, rowIndex, columnIndex }: SpanMethodProps) => {
if (columnIndex === 0 || columnIndex === 2 || columnIndex === 3 || columnIndex === 4 || columnIndex === 5 || columnIndex === 6) {
if (rowIndex === 4 || rowIndex === 6 || rowIndex === 8) {
return {
rowspan: 2,
colspan: 1,
};
} else if (rowIndex === 5 || rowIndex === 7 || rowIndex === 9) {
return {
rowspan: 0,
colspan: 0,
};
}
}
};
// 提交
const submit = async () => {
let param = JSON.parse(JSON.stringify(form.value));
param.map((e, i) => {
1 year ago
if (info.value.length) e.id = info.value.find((n) => n.stRecordId === e.stRecordId)?.id;
1 year ago
e.corporateMajorityHitRejected = +e.corporateMajorityHitRejected;
e.mateHitRejected = +e.mateHitRejected;
e.otherFamilyMembersHitRejected = +e.otherFamilyMembersHitRejected;
e.parentsHitRejected = +e.parentsHitRejected;
e.personalHitBlacklist = +e.personalHitBlacklist;
if (e.stRecordId == 161 || e.stRecordId == 164) {
if (e.span) {
// 这里是合并表格,详情那里多加了一行,这里数据要放到一行去
param[i - 1].ruleTwo = e.symbol + e.num;
1 year ago
} else {
e.ruleOne = e.symbol + e.num;
}
} else if (e.stRecordId == 167) {
if (e.span) {
// 这里是合并表格,详情那里多加了一行,这里数据要放到一行去
param[i - 1].ruleTwo = e.had;
} else {
e.ruleOne = e.symbol + e.num + ',' + e.had;
}
1 year ago
}
});
param = param.filter((e) => !e.span);
const recordParam = JSON.parse(JSON.stringify(param));
param.map((e) => {
delete e.recordChildren;
1 year ago
delete e.had;
delete e.name;
delete e.symbol;
delete e.num;
});
1 year ago
await accessStrategyGovernmentBlacklistSave({ governmentBlacklistList: param });
addRecord(recordParam);
getDetail();
1 year ago
ElMessage.success('提交成功!');
};
// 新增判分记录
1 year ago
const addRecord = async (data: Record<string, any>) => {
const preIds = `1,${Cookies.get('sand-level')},42,67,147,150`; // 1,关卡id,角色(这个页面是风控经理策略)
const rule = <Record<string, any>[]>[];
1 year ago
data.map((e, i) => {
1 year ago
if (isRule(e.stRecordId)) {
e?.recordChildren.map((n, j) => {
rule.push(handleId(n.id, e.subjectId, j ? e.ruleTwo : e.ruleOne, preIds + ',' + e.stRecordId + ',' + n.id, 5));
});
}
1 year ago
const temp = [];
e.personalHitBlacklist && temp.push(300);
e.mateHitRejected && temp.push(301);
e.parentsHitRejected && temp.push(302);
e.otherFamilyMembersHitRejected && temp.push(303);
e.corporateMajorityHitRejected && temp.push(304);
1 year ago
rule.push(handleId(e.stRecordId, e.subjectId, temp.join(), preIds + ',' + e.stRecordId, 1));
});
1 year ago
await addOperation({
1 year ago
checkpointId: +Cookies.get('sand-level'),
1 year ago
parentId: preIds,
lcJudgmentRuleReq: rule,
1 year ago
projectId,
1 year ago
});
};
</script>
<style lang="scss" scoped>
@import url(../../../styles/form.scss);
.c-table {
:deep(.el-input__inner) {
@apply px-2;
}
}
</style>