|
@@ -2,6 +2,8 @@
|
|
|
import { ref, reactive } from "vue";
|
|
|
import { ElMessageBox, ElMessage } from "element-plus";
|
|
|
import { calculator } from "./evaluate";
|
|
|
+import { getIndexInfo } from "@/api/templateInfo";
|
|
|
+import { conditionVerify } from "@/api/formula";
|
|
|
import type { DrawerProps, FormItemProps, FormProps } from "element-plus";
|
|
|
// const itemLabelPosition = ref<FormItemProps["labelPosition"]>("");
|
|
|
const drawer = ref(false);
|
|
@@ -20,18 +22,51 @@ const params = reactive({
|
|
|
dimId: "",
|
|
|
indId: "",
|
|
|
valueInput: "",
|
|
|
- scoreStandard: "",
|
|
|
+ scoreStandard: 0,
|
|
|
remark: "",
|
|
|
scoreRule: "",
|
|
|
targetValue: "",
|
|
|
finalValue: "",
|
|
|
+ formulaType: 0,
|
|
|
challengeValue: "",
|
|
|
startValue: "",
|
|
|
datasoure: "",
|
|
|
weight: "",
|
|
|
scoreValue: "",
|
|
|
- formula: ""
|
|
|
+ formula: {
|
|
|
+ noConditionFormula: ""
|
|
|
+ }
|
|
|
});
|
|
|
+// 详情信息
|
|
|
+const getIndexInfoApi = async id => {
|
|
|
+ const { data, code, msg } = await getIndexInfo(id);
|
|
|
+ // console.log("1111", data);
|
|
|
+ if (code === 200) {
|
|
|
+ Object.assign(params, data);
|
|
|
+ if (isValidJSON(data.formula)) {
|
|
|
+ params.formula = JSON.parse(data.formula);
|
|
|
+ }
|
|
|
+ console.log("params", params);
|
|
|
+ } else {
|
|
|
+ ElMessage.error(msg);
|
|
|
+ }
|
|
|
+};
|
|
|
+const conditionVerifyApi = async () => {
|
|
|
+ let formula = JSON.stringify(params.formula);
|
|
|
+ const { code, msg } = await conditionVerify({
|
|
|
+ formulaType: params.formulaType,
|
|
|
+ formula
|
|
|
+ });
|
|
|
+};
|
|
|
+// 判断是否为json
|
|
|
+function isValidJSON(str) {
|
|
|
+ try {
|
|
|
+ JSON.parse(str);
|
|
|
+ return true; // 如果解析成功,返回true
|
|
|
+ } catch (e) {
|
|
|
+ return false; // 如果解析失败,返回false
|
|
|
+ }
|
|
|
+}
|
|
|
const handleClose = (done: () => void) => {
|
|
|
ElMessageBox.confirm("配置项未保存,确认关闭", {
|
|
|
type: "warning"
|
|
@@ -57,31 +92,22 @@ function confirmClick() {
|
|
|
}
|
|
|
const open = row => {
|
|
|
drawer.value = true;
|
|
|
+ // console.log("row", row.id);
|
|
|
+ getIndexInfoApi(row.id);
|
|
|
};
|
|
|
const editShow = ref(true);
|
|
|
defineExpose({
|
|
|
open
|
|
|
});
|
|
|
const timer = ref("");
|
|
|
-// 评分方式------------------------
|
|
|
-const options = [
|
|
|
- {
|
|
|
- value: "1",
|
|
|
- label: "手动输入方式"
|
|
|
- },
|
|
|
- {
|
|
|
- value: "2",
|
|
|
- label: "公式自动计算"
|
|
|
- }
|
|
|
-];
|
|
|
// 公式计算
|
|
|
const compute = [
|
|
|
{
|
|
|
- value: "1",
|
|
|
+ value: 0,
|
|
|
label: "无公式计算"
|
|
|
},
|
|
|
{
|
|
|
- value: "2",
|
|
|
+ value: 1,
|
|
|
label: "多公式计算"
|
|
|
}
|
|
|
];
|
|
@@ -103,20 +129,25 @@ const rolesList = reactive({
|
|
|
});
|
|
|
const lookRoles = item => {
|
|
|
bgColor.value = item.id;
|
|
|
+ params.formula.noConditionFormula =
|
|
|
+ params.formula.noConditionFormula + item.name;
|
|
|
};
|
|
|
// 字符拼接
|
|
|
const countNumber = (item: string) => {
|
|
|
- rolesList.value = rolesList.value + item;
|
|
|
+ params.formula.noConditionFormula = params.formula.noConditionFormula + item;
|
|
|
};
|
|
|
// 清除
|
|
|
const remove = () => {
|
|
|
- if (rolesList.value.length > 0) {
|
|
|
- rolesList.value = rolesList.value.slice(0, -1);
|
|
|
+ if (params.formula.noConditionFormula.length > 0) {
|
|
|
+ params.formula.noConditionFormula = params.formula.noConditionFormula.slice(
|
|
|
+ 0,
|
|
|
+ -1
|
|
|
+ );
|
|
|
}
|
|
|
};
|
|
|
// 清空
|
|
|
const removeVoid = () => {
|
|
|
- rolesList.value = "";
|
|
|
+ params.formula.noConditionFormula = "";
|
|
|
};
|
|
|
// 计算确认
|
|
|
const count = item => {
|
|
@@ -312,36 +343,25 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
</template>
|
|
|
<template #default>
|
|
|
<div>
|
|
|
- <el-form
|
|
|
- label-position="top"
|
|
|
- label-width="auto"
|
|
|
- :model="formLabelAlign"
|
|
|
- >
|
|
|
+ <el-form label-position="top" label-width="auto" :model="params">
|
|
|
<el-form-item label="完成值录入人" label-position="top">
|
|
|
- <el-select v-model="formLabelAlign.grade" placeholder="请选择">
|
|
|
- <el-option label="考核人" value="0" />
|
|
|
- <el-option label="上级" value="1" />
|
|
|
- <el-option label="指定人员" value="2" />
|
|
|
- <el-option label="考核管理员" value="3" />
|
|
|
- <el-option label="指标自动采集" value="4" />
|
|
|
+ <el-select v-model="params.valueInput" placeholder="请选择">
|
|
|
+ <el-option label="考核人" :value="0" />
|
|
|
+ <el-option label="上级" :value="1" />
|
|
|
+ <el-option label="指定人员" :value="2" />
|
|
|
+ <el-option label="考核管理员" :value="3" />
|
|
|
+ <el-option label="指标自动采集" :value="4" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="评分方式" label-position="top">
|
|
|
- <el-select v-model="formLabelAlign.grade" placeholder="请选择">
|
|
|
- <el-option
|
|
|
- v-for="item in options"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- />
|
|
|
+ <el-select v-model="params.scoreStandard" placeholder="请选择">
|
|
|
+ <el-option label="手动输入" :value="0" />
|
|
|
+ <el-option label="公式自动计算" :value="1" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <div v-if="formLabelAlign.grade === '2'">
|
|
|
+ <div v-if="params.scoreStandard === 1">
|
|
|
<el-form-item label="公式类型" label-position="top">
|
|
|
- <el-select
|
|
|
- v-model="formLabelAlign.compute"
|
|
|
- placeholder="请选择"
|
|
|
- >
|
|
|
+ <el-select v-model="params.formulaType" placeholder="请选择">
|
|
|
<el-option
|
|
|
v-for="item in compute"
|
|
|
:key="item.value"
|
|
@@ -351,7 +371,7 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
- v-if="formLabelAlign.compute === '1'"
|
|
|
+ v-if="params.formulaType === 0"
|
|
|
label="公式设置"
|
|
|
label-position="top"
|
|
|
>
|
|
@@ -359,12 +379,14 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
<div>
|
|
|
<el-text>得分 =</el-text>
|
|
|
<el-input
|
|
|
- v-model="rolesList.num"
|
|
|
+ v-model="params.scoreValue"
|
|
|
class="ml-2 mr-2"
|
|
|
style="width: 240px"
|
|
|
/>
|
|
|
<el-text>
|
|
|
- <el-button type="primary">公式验证</el-button>
|
|
|
+ <el-button type="primary" @click="conditionVerifyApi"
|
|
|
+ >公式验证</el-button
|
|
|
+ >
|
|
|
</el-text>
|
|
|
</div>
|
|
|
<div
|
|
@@ -373,13 +395,13 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
>
|
|
|
<div class="w-1/3 h-60 pl-1 bg-white rounded-md">
|
|
|
<div class="w-[100%] text-xs mt-2">
|
|
|
- <div><el-text type="info">::变量</el-text></div>
|
|
|
+ <div><el-text type="info">:::变量</el-text></div>
|
|
|
</div>
|
|
|
<div v-for="item in rolesList.data" :key="item.id">
|
|
|
<div
|
|
|
:class="[
|
|
|
'cursor-pointer text-xs mt-1',
|
|
|
- { 'bg-blue-200': bgColor === item.id }
|
|
|
+ { bgBack: bgColor === item.id }
|
|
|
]"
|
|
|
@click="lookRoles(item)"
|
|
|
>
|
|
@@ -392,7 +414,7 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
<div class="p-1"><el-text>得分 = </el-text></div>
|
|
|
<!-- style="height: 95px" -->
|
|
|
<el-input
|
|
|
- v-model="rolesList.value"
|
|
|
+ v-model="params.formula.noConditionFormula"
|
|
|
:rows="3"
|
|
|
disabled
|
|
|
type="textarea"
|
|
@@ -674,7 +696,7 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
@click="addItemDataList(index, itemList.value)"
|
|
|
>
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
- 添加条件
|
|
|
+ 添加子条件
|
|
|
</el-text>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -717,6 +739,10 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
background-color: #409eff;
|
|
|
}
|
|
|
|
|
|
+.bgBack {
|
|
|
+ background-color: #f3f3f3;
|
|
|
+}
|
|
|
+
|
|
|
.text_border {
|
|
|
display: flex;
|
|
|
align-items: center;
|