|
@@ -51,12 +51,77 @@ const getIndexInfoApi = async id => {
|
|
|
ElMessage.error(msg);
|
|
|
}
|
|
|
};
|
|
|
+// 公式验证
|
|
|
+const dialogFormVisibleFormula = ref(false);
|
|
|
+const formulaForm = ref([]);
|
|
|
+const grade = ref();
|
|
|
const conditionVerifyApi = async () => {
|
|
|
- let formula = JSON.stringify(params.formula);
|
|
|
+ dialogFormVisibleFormula.value = true;
|
|
|
+ formulaForm.value = [];
|
|
|
+ grade.value = "";
|
|
|
+ console.log("params", params);
|
|
|
+
|
|
|
+ const keywords = ["完成值", "目标值", "门槛值", "挑战值", "增幅", "降幅"];
|
|
|
+ let str = params.formula.noConditionFormula;
|
|
|
+ // 创建一个正则表达式,匹配这些关键词
|
|
|
+ const regex = new RegExp(keywords.join("|"), "g");
|
|
|
+ // 提取字符串中的所有关键词
|
|
|
+ let matches = str.match(regex);
|
|
|
+ console.log("匹配到的关键词:", matches);
|
|
|
+ matches.forEach(matchItem => {
|
|
|
+ formulaForm.value.push({
|
|
|
+ name: matchItem,
|
|
|
+ value: ""
|
|
|
+ });
|
|
|
+ });
|
|
|
+ let result = str.replace(regex, match => {
|
|
|
+ return `${match}`;
|
|
|
+ });
|
|
|
+ console.log("formula", formulaForm.value);
|
|
|
+
|
|
|
+ // let formula = JSON.stringify(params.formula);
|
|
|
+ // const { code, msg } = await conditionVerify({
|
|
|
+ // formulaType: params.formulaType,
|
|
|
+ // formula
|
|
|
+ // });
|
|
|
+};
|
|
|
+// 计算
|
|
|
+const countComputed = async () => {
|
|
|
+ const formula = JSON.stringify(params.formula);
|
|
|
const { code, msg } = await conditionVerify({
|
|
|
formulaType: params.formulaType,
|
|
|
formula
|
|
|
});
|
|
|
+ if (code == 200) {
|
|
|
+ const keywords = ["完成值", "目标值", "门槛值", "挑战值", "增幅", "降幅"];
|
|
|
+ let str = params.formula.noConditionFormula;
|
|
|
+ // 创建一个正则表达式,匹配这些关键词
|
|
|
+ const regex = new RegExp(keywords.join("|"), "g");
|
|
|
+ let result = str.replace(regex, match => {
|
|
|
+ // 在 formulaForm.value 中查找匹配的项
|
|
|
+ let matchedItem = formulaForm.value.find(item => item.name === match);
|
|
|
+
|
|
|
+ // 如果找到匹配项,返回其 value,否则返回原始匹配值
|
|
|
+ if (matchedItem) {
|
|
|
+ return matchedItem.value; // 替换为对应的值
|
|
|
+ }
|
|
|
+ return match; // 如果没有匹配项,返回原始匹配值
|
|
|
+ });
|
|
|
+ calculator.calculate(result);
|
|
|
+ grade.value = calculator.get();
|
|
|
+ } else {
|
|
|
+ ElMessageBox.confirm("配置项未保存,确认关闭", {
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ dialogFormVisibleFormula.value = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // ElMessageBox.confirm("配置项未保存,确认关闭", {
|
|
|
+ // type: "warning"
|
|
|
+ // }).then(() => {
|
|
|
+
|
|
|
+ // })
|
|
|
+ // console.log();
|
|
|
};
|
|
|
// 判断是否为json
|
|
|
function isValidJSON(str) {
|
|
@@ -68,13 +133,14 @@ function isValidJSON(str) {
|
|
|
}
|
|
|
}
|
|
|
const handleClose = (done: () => void) => {
|
|
|
- ElMessageBox.confirm("配置项未保存,确认关闭", {
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- drawer.value = false;
|
|
|
- disabledValue.value = true;
|
|
|
- editShow.value = true;
|
|
|
- });
|
|
|
+ drawer.value = false;
|
|
|
+ disabledValue.value = true;
|
|
|
+ editShow.value = true;
|
|
|
+ // ElMessageBox.confirm("配置项未保存,确认关闭", {
|
|
|
+ // type: "warning"
|
|
|
+ // }).then(() => {
|
|
|
+
|
|
|
+ // });
|
|
|
};
|
|
|
function cancelClick() {
|
|
|
disabledValue.value = true;
|
|
@@ -222,110 +288,101 @@ const manyChange = reactive({
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
+const addmanyChange = reactive({
|
|
|
+ outerConditionValue: "",
|
|
|
+ innerConditionExpression: [
|
|
|
+ {
|
|
|
+ startValue: null,
|
|
|
+ endValue: null,
|
|
|
+ select: null,
|
|
|
+ comparisonStart: null,
|
|
|
+ comparisonEnd: null,
|
|
|
+ scoreRuleMoreInnerVO: [
|
|
|
+ {
|
|
|
+ innerConditionValue: null,
|
|
|
+ scoreRules: [
|
|
|
+ {
|
|
|
+ score: null,
|
|
|
+ startValue: null,
|
|
|
+ select: "",
|
|
|
+ endValue: null,
|
|
|
+ comparisonStart: null,
|
|
|
+ comparisonEnd: null
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+});
|
|
|
+// 添加子条件
|
|
|
+const addItemFormulaList = (item, index) => {
|
|
|
+ addmanyChange.innerConditionExpression[index].scoreRuleMoreInnerVO = [
|
|
|
+ {
|
|
|
+ innerConditionValue: null,
|
|
|
+ scoreRules: [
|
|
|
+ {
|
|
|
+ score: null,
|
|
|
+ startValue: null,
|
|
|
+ endValue: null,
|
|
|
+ select: null,
|
|
|
+ comparisonStart: null,
|
|
|
+ comparisonEnd: null
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ];
|
|
|
+};
|
|
|
+
|
|
|
const deleteItem = index => {
|
|
|
- if (manyChange.dataList.length > 1) {
|
|
|
- manyChange.dataList.splice(index, 1);
|
|
|
- } else {
|
|
|
- ElMessage({
|
|
|
- message: "必须保留一条计算规则",
|
|
|
- type: "warning"
|
|
|
- });
|
|
|
- }
|
|
|
+ addmanyChange.innerConditionExpression.splice(index, 1);
|
|
|
};
|
|
|
const dataleListItem = (index, indexList) => {
|
|
|
- if (manyChange.dataList[index].dataList.length > 1) {
|
|
|
- manyChange.dataList[index].dataList.splice(indexList, 1);
|
|
|
- } else {
|
|
|
- ElMessage({
|
|
|
- message: "必须保留一条计算规则",
|
|
|
- type: "warning"
|
|
|
- });
|
|
|
- }
|
|
|
+ addmanyChange.innerConditionExpression[
|
|
|
+ index
|
|
|
+ ].scoreRuleMoreInnerVO[0].scoreRules.splice(indexList, 1);
|
|
|
+};
|
|
|
+// 条件变量
|
|
|
+const dataleListItemAll = (item, index) => {
|
|
|
+ item.scoreRuleMoreInnerVO = [];
|
|
|
};
|
|
|
const addNewItem = () => {
|
|
|
- manyChange.dataList.push({
|
|
|
- compare: "0", // 比较符号
|
|
|
- compareList: [
|
|
|
- {
|
|
|
- value: "0",
|
|
|
- label: ">"
|
|
|
- },
|
|
|
- {
|
|
|
- value: "1",
|
|
|
- label: "≥"
|
|
|
- }
|
|
|
- ],
|
|
|
- formula: "0",
|
|
|
- formulaList: [
|
|
|
- {
|
|
|
- value: "0",
|
|
|
- label: "数值"
|
|
|
- },
|
|
|
- {
|
|
|
- value: "1",
|
|
|
- label: "公式"
|
|
|
- }
|
|
|
- ],
|
|
|
- value: "",
|
|
|
- newData: "",
|
|
|
- dataList: [
|
|
|
- {
|
|
|
- compare: "0", // 比较符号
|
|
|
- compareList: [
|
|
|
- {
|
|
|
- value: "0",
|
|
|
- label: ">"
|
|
|
- },
|
|
|
- {
|
|
|
- value: "1",
|
|
|
- label: "≥"
|
|
|
- }
|
|
|
- ],
|
|
|
- formula: "0",
|
|
|
- formulaList: [
|
|
|
- {
|
|
|
- value: "0",
|
|
|
- label: "数值"
|
|
|
- },
|
|
|
- {
|
|
|
- value: "1",
|
|
|
- label: "公式"
|
|
|
- }
|
|
|
- ],
|
|
|
- value: "",
|
|
|
- grade: ""
|
|
|
- }
|
|
|
- ]
|
|
|
+ addmanyChange.innerConditionExpression.push({
|
|
|
+ startValue: null,
|
|
|
+ endValue: null,
|
|
|
+ select: null,
|
|
|
+ comparisonStart: null,
|
|
|
+ comparisonEnd: null,
|
|
|
+ scoreRuleMoreInnerVO: []
|
|
|
});
|
|
|
};
|
|
|
-const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
- console.log(index, itemListValue);
|
|
|
- manyChange.dataList[index].dataList.push({
|
|
|
- title: itemListValue,
|
|
|
- compare: "0", // 比较符号
|
|
|
- compareList: [
|
|
|
- {
|
|
|
- value: "0",
|
|
|
- label: ">"
|
|
|
- },
|
|
|
- {
|
|
|
- value: "1",
|
|
|
- label: "≥"
|
|
|
- }
|
|
|
- ],
|
|
|
- formula: "0",
|
|
|
- formulaList: [
|
|
|
- {
|
|
|
- value: "0",
|
|
|
- label: "数值"
|
|
|
- },
|
|
|
- {
|
|
|
- value: "1",
|
|
|
- label: "公式"
|
|
|
- }
|
|
|
- ],
|
|
|
- value: "",
|
|
|
- grade: ""
|
|
|
+const addNewItemOldValue = item => {
|
|
|
+ addmanyChange.innerConditionExpression.push({
|
|
|
+ startValue: item.endValue,
|
|
|
+ select: null,
|
|
|
+ endValue: null,
|
|
|
+ comparisonStart: item.comparisonEnd,
|
|
|
+ comparisonEnd: null,
|
|
|
+ scoreRuleMoreInnerVO: []
|
|
|
+ });
|
|
|
+};
|
|
|
+const addItemDataList = (
|
|
|
+ index: number,
|
|
|
+ itemList: any,
|
|
|
+ indexList: number,
|
|
|
+ item
|
|
|
+) => {
|
|
|
+ console.log(index, itemList);
|
|
|
+ console.log(item);
|
|
|
+ addmanyChange.innerConditionExpression[
|
|
|
+ index
|
|
|
+ ].scoreRuleMoreInnerVO[0].scoreRules.push({
|
|
|
+ select: null,
|
|
|
+ score: null,
|
|
|
+ startValue: itemList.endValue,
|
|
|
+ endValue: null,
|
|
|
+ comparisonStart: itemList.comparisonEnd,
|
|
|
+ comparisonEnd: null
|
|
|
});
|
|
|
};
|
|
|
</script>
|
|
@@ -568,50 +625,49 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
<div class="flex items-center">
|
|
|
<el-text>条件填 = </el-text>
|
|
|
<el-input
|
|
|
- v-model="manyChange.newData"
|
|
|
+ v-model="addmanyChange.outerConditionValue"
|
|
|
class="ml-2"
|
|
|
style="width: 240px"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="w-full mt-2">
|
|
|
<div
|
|
|
- v-for="(item, index) in manyChange.dataList"
|
|
|
+ v-for="(
|
|
|
+ item, index
|
|
|
+ ) in addmanyChange.innerConditionExpression"
|
|
|
:key="index"
|
|
|
- class="flex items-center mb-4"
|
|
|
>
|
|
|
- <div>
|
|
|
+ <div class="mt-3">
|
|
|
<div class="flex">
|
|
|
<el-text class="w-[30px]" type="primary">
|
|
|
{{ index + 1 }}
|
|
|
</el-text>
|
|
|
+ <div class="w-[40px] ml-2">
|
|
|
+ {{ item.startValue }}
|
|
|
+ </div>
|
|
|
+ <div class="mr-2">
|
|
|
+ {{ item.comparisonStart }}
|
|
|
+ </div>
|
|
|
<div class="mr-2">条件值</div>
|
|
|
<el-select
|
|
|
- v-model="item.compare"
|
|
|
+ v-model="item.comparisonEnd"
|
|
|
style="width: 60px"
|
|
|
placeholder=""
|
|
|
>
|
|
|
- <el-option
|
|
|
- v-for="compareItem in item.compareList"
|
|
|
- :key="compareItem.value"
|
|
|
- :label="compareItem.label"
|
|
|
- :value="compareItem.value"
|
|
|
- />
|
|
|
+ <el-option label=">" value=">" />
|
|
|
+ <el-option label="≥" value="≥" />
|
|
|
</el-select>
|
|
|
<el-select
|
|
|
- v-model="item.formula"
|
|
|
+ v-model="item.select"
|
|
|
class="ml-2"
|
|
|
style="width: 80px"
|
|
|
placeholder=""
|
|
|
>
|
|
|
- <el-option
|
|
|
- v-for="formulaItem in item.formulaList"
|
|
|
- :key="formulaItem.value"
|
|
|
- :label="formulaItem.label"
|
|
|
- :value="formulaItem.value"
|
|
|
- />
|
|
|
+ <el-option label="数值" value="数值" />
|
|
|
+ <el-option label="公式" value="公式" />
|
|
|
</el-select>
|
|
|
<el-input
|
|
|
- v-model="item.value"
|
|
|
+ v-model="item.endValue"
|
|
|
class="ml-2 mr-5"
|
|
|
style="width: 80px"
|
|
|
/>
|
|
@@ -619,95 +675,143 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
<el-icon><Delete /></el-icon>
|
|
|
</el-text>
|
|
|
</div>
|
|
|
- <div class="flex mt-2 ml-7">
|
|
|
- <div class="mr-2">条件值{{ index + 1 }} =</div>
|
|
|
- <el-input
|
|
|
- v-model="item.value"
|
|
|
- class="ml-2"
|
|
|
- style="width: 240px"
|
|
|
- />
|
|
|
- </div>
|
|
|
<div
|
|
|
- v-for="(itemList, indexList) in item.dataList"
|
|
|
- :key="indexList"
|
|
|
+ v-for="(itemVO, indexOV) in item.scoreRuleMoreInnerVO"
|
|
|
+ :key="indexOV"
|
|
|
>
|
|
|
- <div class="flex mt-2 ml-7 items-center">
|
|
|
- <div class="text_border">{{ indexList + 1 }}</div>
|
|
|
- <!-- manyChange.dataList[index].dataList -->
|
|
|
- <div class="w-[40px] ml-2">
|
|
|
- {{ itemList?.title }}
|
|
|
- </div>
|
|
|
- <div class="mr-2">></div>
|
|
|
- <div class="mr-2">条件值{{ indexList + 1 }}</div>
|
|
|
- <el-select
|
|
|
- v-model="itemList.compare"
|
|
|
- style="width: 60px"
|
|
|
- placeholder=""
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="compareItem in itemList.compareList"
|
|
|
- :key="compareItem.value"
|
|
|
- :label="compareItem.label"
|
|
|
- :value="compareItem.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- <el-select
|
|
|
- v-model="itemList.formula"
|
|
|
- class="ml-2"
|
|
|
- style="width: 80px"
|
|
|
- placeholder=""
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="formulaItem in itemList.formulaList"
|
|
|
- :key="formulaItem.value"
|
|
|
- :label="formulaItem.label"
|
|
|
- :value="formulaItem.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
+ <div class="flex mt-2 ml-7">
|
|
|
+ <div class="mr-2">条件值{{ index + 1 }} =</div>
|
|
|
<el-input
|
|
|
- v-model="itemList.value"
|
|
|
+ v-model="itemVO.innerConditionValue"
|
|
|
class="ml-2"
|
|
|
- style="width: 80px"
|
|
|
+ style="width: 240px"
|
|
|
/>
|
|
|
- <div
|
|
|
- class="w-[100px] ml-2 mr-2 flex justify-between items-center"
|
|
|
- >
|
|
|
- <div>得分</div>
|
|
|
- <div>=</div>
|
|
|
- <el-input
|
|
|
- v-model="itemList.grade"
|
|
|
- class="ml-2"
|
|
|
- style="width: 50px"
|
|
|
- />
|
|
|
- </div>
|
|
|
<el-text
|
|
|
type="danger"
|
|
|
- @click="dataleListItem(index, indexList)"
|
|
|
+ @click="dataleListItemAll(item, index)"
|
|
|
>
|
|
|
<el-icon><Delete /></el-icon>
|
|
|
</el-text>
|
|
|
</div>
|
|
|
<div
|
|
|
- v-if="indexList + 1 == item.dataList.length"
|
|
|
- class="ml-7 mt-1 text-xs cursor-pointer"
|
|
|
+ v-for="(itemList, indexList) in itemVO.scoreRules"
|
|
|
+ :key="indexList"
|
|
|
>
|
|
|
- <el-text
|
|
|
- type="primary"
|
|
|
- @click="addItemDataList(index, itemList.value)"
|
|
|
+ <div class="flex mt-2 ml-7 items-center">
|
|
|
+ <div class="text_border">{{ indexList + 1 }}</div>
|
|
|
+ <!-- manyChange.dataList[index].dataList -->
|
|
|
+ <div class="w-[40px] ml-2">
|
|
|
+ {{ itemList.startValue }}
|
|
|
+ </div>
|
|
|
+ <div class="mr-2">
|
|
|
+ {{ itemList.comparisonStart }}
|
|
|
+ </div>
|
|
|
+ <div class="mr-2">条件值{{ index + 1 }}</div>
|
|
|
+ <el-select
|
|
|
+ v-model="itemList.comparisonEnd"
|
|
|
+ style="width: 60px"
|
|
|
+ placeholder=""
|
|
|
+ >
|
|
|
+ <el-option label=">" value=">" />
|
|
|
+ <el-option label="≥" value="≥" />
|
|
|
+ </el-select>
|
|
|
+ <el-select
|
|
|
+ v-model="itemList.select"
|
|
|
+ class="ml-2"
|
|
|
+ style="width: 80px"
|
|
|
+ placeholder=""
|
|
|
+ >
|
|
|
+ <el-option label="数值" value="数值" />
|
|
|
+ <el-option label="公式" value="公式" />
|
|
|
+ </el-select>
|
|
|
+ <el-input
|
|
|
+ v-model="itemList.endValue"
|
|
|
+ class="ml-2"
|
|
|
+ style="width: 80px"
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ class="w-[100px] ml-2 mr-2 flex justify-between items-center"
|
|
|
+ >
|
|
|
+ <div>得分</div>
|
|
|
+ <div>=</div>
|
|
|
+ <el-input
|
|
|
+ v-model="itemList.score"
|
|
|
+ class="ml-2"
|
|
|
+ style="width: 50px"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <el-text
|
|
|
+ type="danger"
|
|
|
+ @click="dataleListItem(index, indexList)"
|
|
|
+ >
|
|
|
+ <el-icon><Delete /></el-icon>
|
|
|
+ </el-text>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-if="indexList + 1 == itemVO.scoreRules.length"
|
|
|
+ class="ml-7 mt-1 text-xs cursor-pointer"
|
|
|
>
|
|
|
- <el-icon><Plus /></el-icon>
|
|
|
- 添加子条件
|
|
|
- </el-text>
|
|
|
+ <el-text
|
|
|
+ type="primary"
|
|
|
+ @click="
|
|
|
+ addItemDataList(
|
|
|
+ index,
|
|
|
+ itemList,
|
|
|
+ indexList,
|
|
|
+ item
|
|
|
+ )
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-icon><Plus /></el-icon>
|
|
|
+ 添加子条件
|
|
|
+ </el-text>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div
|
|
|
+ v-if="item?.scoreRuleMoreInnerVO?.length == 0"
|
|
|
+ class="ml-7 mt-1 text-xs cursor-pointer"
|
|
|
+ >
|
|
|
+ <el-text
|
|
|
+ type="primary"
|
|
|
+ @click="addItemFormulaList(item, index)"
|
|
|
+ >
|
|
|
+ <el-icon><Plus /></el-icon>
|
|
|
+ 添加子条件
|
|
|
+ </el-text>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-if="
|
|
|
+ addmanyChange.innerConditionExpression.length >= 1 &&
|
|
|
+ index + 1 ==
|
|
|
+ addmanyChange.innerConditionExpression.length
|
|
|
+ "
|
|
|
+ class="mt-5 text-xs cursor-pointer"
|
|
|
+ >
|
|
|
+ <el-text
|
|
|
+ type="primary"
|
|
|
+ @click="addNewItemOldValue(item)"
|
|
|
+ >
|
|
|
+ <el-icon><Plus /></el-icon>
|
|
|
+ 添加条件
|
|
|
+ </el-text>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="mt-5 text-xs cursor-pointer">
|
|
|
+ <div
|
|
|
+ v-if="addmanyChange.innerConditionExpression.length < 1"
|
|
|
+ class="mt-5 text-xs cursor-pointer"
|
|
|
+ >
|
|
|
<el-text type="primary" @click="addNewItem">
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
添加条件
|
|
|
</el-text>
|
|
|
</div>
|
|
|
+ <div class="float-right mr-8">
|
|
|
+ <el-button type="primary" @click="conditionVerifyApi"
|
|
|
+ >公式验证</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
@@ -722,6 +826,25 @@ const addItemDataList = (index: number, itemListValue: string) => {
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-drawer>
|
|
|
+ <!-- 公式验证 -->
|
|
|
+ <el-dialog v-model="dialogFormVisibleFormula" title="完成值" width="500">
|
|
|
+ <el-form :model="formulaForm">
|
|
|
+ <div v-for="(itemF, indexF) in formulaForm" :key="indexF">
|
|
|
+ <el-form-item :label="itemF.name">
|
|
|
+ <el-input v-model="itemF.value" autocomplete="off" />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <el-form-item label="得分">
|
|
|
+ <el-input v-model="grade" class="ml-3" autocomplete="off" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisibleFormula = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="countComputed"> 计算 </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<style lang="scss" scoped>
|