|
|
@@ -74,11 +74,25 @@
|
|
|
</view>
|
|
|
<view class="info-item">
|
|
|
<text class="info-label">分项完成系数<text style="color: red;">*</text></text>
|
|
|
- <input class="info-input" type="digit" :value="itemCompletionFactorStr" @input="onItemCompletionFactorChange" placeholder="请输入分项完成系数" />
|
|
|
+ <input
|
|
|
+ class="info-input"
|
|
|
+ type="digit"
|
|
|
+ :value="getItemCompletionFactorDisplayValue()"
|
|
|
+ @input="onItemCompletionFactorInput"
|
|
|
+ @blur="formatItemCompletionFactor()"
|
|
|
+ placeholder="请输入分项完成系数"
|
|
|
+ />
|
|
|
</view>
|
|
|
<view class="info-item">
|
|
|
<text class="info-label">分项完成系数和<text style="color: red;">*</text></text>
|
|
|
- <input class="info-input" type="digit" :value="itemCompletionFactorSumStr" @input="onItemCompletionFactorSumChange" placeholder="请输入分项完成系数和" />
|
|
|
+ <input
|
|
|
+ class="info-input"
|
|
|
+ type="digit"
|
|
|
+ :value="getItemCompletionFactorSumDisplayValue()"
|
|
|
+ @input="onItemCompletionFactorSumInput"
|
|
|
+ @blur="formatItemCompletionFactorSum()"
|
|
|
+ placeholder="请输入分项完成系数和"
|
|
|
+ />
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -124,7 +138,7 @@
|
|
|
<!-- 得分明细 -->
|
|
|
<view class="info-card">
|
|
|
<view class="form-item">
|
|
|
- <text class="label">得分明细 ({{ isMixedZeroNonZeroInspectionTypes() ? '最少可评总分: ' : '可自评总分: ' }}{{ getSelfEvaluationTotalScore() == 0 ? '未规定' : getSelfEvaluationTotalScore().toFixed(2) + '分' }}, 已自评总分: {{ selfEvaluatedTotalScore.toFixed(2) }}分)</text>
|
|
|
+ <text class="label">得分明细 ({{ isMixedZeroNonZeroInspectionTypes() ? '最少可评总分: ' : '可自评总分: ' }}{{ getSelfEvaluationTotalScore() == 0 ? '未规定' : (getSelfEvaluationTotalScore() != null ? getSelfEvaluationTotalScore().toFixed(2) : '0.00') + '分' }}, 已自评总分: {{ selfEvaluatedTotalScore != null ? selfEvaluatedTotalScore.toFixed(2) : '0.00' }}分)</text>
|
|
|
</view>
|
|
|
<view v-for="(person, index) in selfEvaluationForm.scorePersonList as UTSJSONObject[]" :key="index" class="person-score-item">
|
|
|
<view class="person-info">
|
|
|
@@ -138,7 +152,7 @@
|
|
|
type="digit"
|
|
|
:value="getPersonScore(person, 'selfScore')"
|
|
|
@input="onScoreInput($event, index, 'selfScore')"
|
|
|
- @blur="onScoreChange"
|
|
|
+ @blur="formatScoreInput(index, 'selfScore');onScoreChange"
|
|
|
placeholder="0.00"
|
|
|
/>
|
|
|
</view>
|
|
|
@@ -150,7 +164,7 @@
|
|
|
type="digit"
|
|
|
:value="getPersonScore(person, 'extraScore')"
|
|
|
@input="onScoreInput($event, index, 'extraScore')"
|
|
|
- @blur="onScoreChange"
|
|
|
+ @blur="formatScoreInput(index, 'extraScore');onScoreChange"
|
|
|
placeholder="0.00"
|
|
|
/>
|
|
|
</view>
|
|
|
@@ -175,7 +189,7 @@
|
|
|
type="digit"
|
|
|
:value="getPersonScore(person, 'extraScore')"
|
|
|
@input="onScoreInput($event, index, 'extraScore')"
|
|
|
- @blur="onScoreChange"
|
|
|
+ @blur="formatScoreInput(index, 'extraScore');onScoreChange"
|
|
|
placeholder="0.00"
|
|
|
/>
|
|
|
</view>
|
|
|
@@ -255,16 +269,20 @@ type SelfEvaluationFormData = {
|
|
|
extraWork: string
|
|
|
maintenanceType: string | null
|
|
|
inspectionType: string[]
|
|
|
- itemCompletionFactor: number
|
|
|
- itemCompletionFactorSum: number
|
|
|
+ itemCompletionFactor: number | null
|
|
|
+ itemCompletionFactorSum: number | null
|
|
|
scorePersonList: UTSJSONObject[]
|
|
|
wwryNum: number
|
|
|
wlryNum: number
|
|
|
}
|
|
|
|
|
|
// 用于input绑定的字符串中转
|
|
|
-let itemCompletionFactorStr = ref<string>('1.0')
|
|
|
-let itemCompletionFactorSumStr = ref<string>('1.0')
|
|
|
+let itemCompletionFactorStr = ref<string>('')
|
|
|
+let itemCompletionFactorSumStr = ref<string>('')
|
|
|
+
|
|
|
+// 临时存储分项完成系数的原始输入值
|
|
|
+const tempItemCompletionFactorInput = ref<string>('')
|
|
|
+const tempItemCompletionFactorSumInput = ref<string>('')
|
|
|
|
|
|
// 添加响应式变量来跟踪已自评总分
|
|
|
let selfEvaluatedTotalScore = ref<number>(0)
|
|
|
@@ -280,8 +298,8 @@ const selfEvaluationForm = ref<SelfEvaluationFormData>({
|
|
|
extraWork: '',
|
|
|
maintenanceType: null,
|
|
|
inspectionType: [],
|
|
|
- itemCompletionFactor: 1.0,
|
|
|
- itemCompletionFactorSum: 1.0,
|
|
|
+ itemCompletionFactor: null,
|
|
|
+ itemCompletionFactorSum: null,
|
|
|
scorePersonList: [],
|
|
|
wwryNum: 0,
|
|
|
wlryNum: 0
|
|
|
@@ -321,7 +339,6 @@ function getSelfEvaluatedTotalScore(): number {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- console.log("getSelfEvaluatedTotalScore==",totalSelfScore)
|
|
|
return totalSelfScore
|
|
|
}
|
|
|
|
|
|
@@ -334,7 +351,6 @@ function updateSelfEvaluatedTotalScore(): void {
|
|
|
function updateTotalScores(): void {
|
|
|
const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[]
|
|
|
if (scorePersonList == null || scorePersonList.length == 0) return
|
|
|
- console.log("scorePersonList",scorePersonList);
|
|
|
for (let i = 0; i < scorePersonList.length; i++) {
|
|
|
const person = scorePersonList[i]
|
|
|
const selfScoreVal = person.get('selfScore')
|
|
|
@@ -381,29 +397,29 @@ function updateTotalScores(): void {
|
|
|
if (selfScoreVal != null && extraScoreVal != null) {
|
|
|
const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
|
|
|
const extraScore = typeof extraScoreVal == 'number' ? extraScoreVal : (extraScoreVal != '' ? parseFloat(extraScoreVal as string) : 0)
|
|
|
- person.set('totalScore', selfScore + extraScore)
|
|
|
+ person.set('totalScore', (selfScore + extraScore).toFixed(2))
|
|
|
} else if (selfScoreVal != null) {
|
|
|
// 如果只有自评分,没有额外工分
|
|
|
const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
|
|
|
- person.set('totalScore', selfScore)
|
|
|
+ person.set('totalScore', selfScore.toFixed(2))
|
|
|
}
|
|
|
} else if (isMaintenanceOrderType && hasOtherOrQitaType) {
|
|
|
// 维保工单且维保类型包含其他/其它时,总分 = 自评分 + 额外工分
|
|
|
if (selfScoreVal != null && extraScoreVal != null) {
|
|
|
const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
|
|
|
const extraScore = typeof extraScoreVal == 'number' ? extraScoreVal : (extraScoreVal != '' ? parseFloat(extraScoreVal as string) : 0)
|
|
|
- person.set('totalScore', selfScore + extraScore)
|
|
|
+ person.set('totalScore', (selfScore + extraScore).toFixed(2))
|
|
|
} else if (selfScoreVal != null) {
|
|
|
// 如果只有自评分,没有额外工分
|
|
|
const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
|
|
|
- person.set('totalScore', selfScore)
|
|
|
+ person.set('totalScore', selfScore.toFixed(2))
|
|
|
}
|
|
|
} else {
|
|
|
// 其他情况只显示自评分
|
|
|
if (selfScoreVal != null) {
|
|
|
const selfScore = typeof selfScoreVal == 'number' ? selfScoreVal : (selfScoreVal != '' ? parseFloat(selfScoreVal as string) : 0)
|
|
|
if (!isNaN(selfScore)) {
|
|
|
- person.set('totalScore', selfScore)
|
|
|
+ person.set('totalScore', selfScore.toFixed(2))
|
|
|
}
|
|
|
} else {
|
|
|
person.set('totalScore', 0)
|
|
|
@@ -412,8 +428,8 @@ function updateTotalScores(): void {
|
|
|
}
|
|
|
|
|
|
// 同步分项完成系数和显示
|
|
|
- itemCompletionFactorStr.value = selfEvaluationForm.value.itemCompletionFactor.toFixed(2)
|
|
|
- itemCompletionFactorSumStr.value = selfEvaluationForm.value.itemCompletionFactorSum.toFixed(2)
|
|
|
+ itemCompletionFactorStr.value = selfEvaluationForm.value.itemCompletionFactor != null ? selfEvaluationForm.value.itemCompletionFactor.toFixed(2) : ''
|
|
|
+ itemCompletionFactorSumStr.value = selfEvaluationForm.value.itemCompletionFactorSum != null ? selfEvaluationForm.value.itemCompletionFactorSum.toFixed(2) : ''
|
|
|
|
|
|
// 更新已自评总分显示
|
|
|
updateSelfEvaluatedTotalScore()
|
|
|
@@ -493,21 +509,16 @@ function isMixedZeroNonZeroInspectionTypes(): boolean {
|
|
|
|
|
|
// 获取工单总分
|
|
|
function getTotalScore(): number {
|
|
|
- console.log("getTotalScore 开始执行");
|
|
|
- console.log("订单类型:", selfEvaluationForm.value.orderType);
|
|
|
let totalScore = 0;
|
|
|
|
|
|
if (selfEvaluationForm.value.orderType == '1') {
|
|
|
// 维修工单:根据检修类型获取总分
|
|
|
- console.log("处理维修工单,维护类型:", selfEvaluationForm.value.maintenanceType);
|
|
|
- console.log("维护类型选项数量:", maintenanceTypeOptions.value.length);
|
|
|
for (let i = 0; i < maintenanceTypeOptions.value.length; i++) {
|
|
|
const typeOption = maintenanceTypeOptions.value[i]
|
|
|
if (typeOption.value == selfEvaluationForm.value.maintenanceType) {
|
|
|
// 从标签中提取分数
|
|
|
const regex = /\((\d+(\.\d+)?)分\)/
|
|
|
const match = typeOption.label.match(regex)
|
|
|
- console.log("正则匹配结果:", match);
|
|
|
if (match != null && match.length > 1 && match[1] != null) {
|
|
|
totalScore = parseFloat(match[1] as string);
|
|
|
break;
|
|
|
@@ -516,12 +527,12 @@ function isMixedZeroNonZeroInspectionTypes(): boolean {
|
|
|
}
|
|
|
} else if (selfEvaluationForm.value.orderType == '2') {
|
|
|
// 维保工单:根据选中的维保类型和分项完成系数获取总分
|
|
|
- console.log("处理维保工单");
|
|
|
- console.log("分项完成系数:", selfEvaluationForm.value.itemCompletionFactor);
|
|
|
- console.log("维保类型选项数量:", inspectionTypeOptions.value.length);
|
|
|
- console.log("选中的维保类型:", selfEvaluationForm.value.inspectionType);
|
|
|
+ // 检查分项完成系数是否为null,如果是null则视为无效
|
|
|
+ if (selfEvaluationForm.value.itemCompletionFactor == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- const completionFactor = selfEvaluationForm.value.itemCompletionFactor != null ? selfEvaluationForm.value.itemCompletionFactor : 1;
|
|
|
+ const completionFactor = selfEvaluationForm.value.itemCompletionFactor;
|
|
|
|
|
|
// 获取选中的维保项目(现在是多选)
|
|
|
const selectedInspectionTypes: string[] = selfEvaluationForm.value.inspectionType != null ? selfEvaluationForm.value.inspectionType : [];
|
|
|
@@ -530,7 +541,6 @@ function isMixedZeroNonZeroInspectionTypes(): boolean {
|
|
|
let totalScoreFromDB = 0; // 默认值
|
|
|
|
|
|
if (Array.isArray(selectedInspectionTypes) && selectedInspectionTypes.length > 0) {
|
|
|
- console.log("开始遍历选中的维保类型:", selectedInspectionTypes);
|
|
|
for (let i = 0; i < selectedInspectionTypes.length; i++) {
|
|
|
const typeId = selectedInspectionTypes[i];
|
|
|
for (let j = 0; j < inspectionTypeOptions.value.length; j++) {
|
|
|
@@ -545,64 +555,45 @@ function isMixedZeroNonZeroInspectionTypes(): boolean {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- console.log("没有选中的维保类型或不是数组");
|
|
|
}
|
|
|
|
|
|
// 计算总分:总分 = 所有选中维保类型组合的总得分 * 分项完成系数
|
|
|
totalScore = totalScoreFromDB * completionFactor;
|
|
|
- console.log("计算后的总分:", totalScore, "= 数据库总分:", totalScoreFromDB, "* 系数:", completionFactor);
|
|
|
}
|
|
|
-
|
|
|
- console.log("getTotalScore 最终返回:", totalScore);
|
|
|
return totalScore;
|
|
|
}
|
|
|
|
|
|
// 获取可自评总分
|
|
|
function getSelfEvaluationTotalScore(): number {
|
|
|
- console.log("== getSelfEvaluationTotalScore 开始执行 ==");
|
|
|
- console.log("订单类型:", selfEvaluationForm.value.orderType);
|
|
|
- console.log("人员列表长度:", selfEvaluationForm.value.scorePersonList.length);
|
|
|
-
|
|
|
// 获取工单总分
|
|
|
const totalScore = getTotalScore();
|
|
|
- console.log("获取到的工单总分:", totalScore);
|
|
|
|
|
|
// 如果总分为0,返回0
|
|
|
if (totalScore == 0) {
|
|
|
- console.log("工单总分为0,进入特殊处理逻辑");
|
|
|
|
|
|
// 特殊处理:对于维保工单且多选维保类型的情况,如果存在零分和非零分的混合情况
|
|
|
if (selfEvaluationForm.value.orderType == '2' && Array.isArray(selfEvaluationForm.value.inspectionType) && selfEvaluationForm.value.inspectionType.length > 1) {
|
|
|
- console.log("维保工单且多选维保类型,检查零分和非零分混合情况");
|
|
|
-
|
|
|
+
|
|
|
// 获取选中的维保类型
|
|
|
const selectedInspectionTypes: string[] = selfEvaluationForm.value.inspectionType != null ? selfEvaluationForm.value.inspectionType : [];
|
|
|
- console.log("选中的维保类型:", selectedInspectionTypes);
|
|
|
-
|
|
|
+
|
|
|
// 计算所有选中维保类型的非零分值
|
|
|
let minScoreFromDB = 0; // 非零分值总和
|
|
|
let hasZeroScore = false; // 是否存在零分
|
|
|
|
|
|
if (Array.isArray(selectedInspectionTypes) && selectedInspectionTypes.length > 0) {
|
|
|
- console.log("开始遍历选中的维保类型以计算非零分值");
|
|
|
for (let i = 0; i < selectedInspectionTypes.length; i++) {
|
|
|
const typeId = selectedInspectionTypes[i];
|
|
|
- console.log("检查维保类型ID:", typeId);
|
|
|
for (let j = 0; j < inspectionTypeOptions.value.length; j++) {
|
|
|
const selectedType = inspectionTypeOptions.value[j];
|
|
|
const inspectionTypeId = selectedType.get('inspectionTypeId');
|
|
|
const score = selectedType.get('score');
|
|
|
- console.log("比较ID:", inspectionTypeId, "与", typeId, "分数:", score);
|
|
|
// 使用toString()方法确保类型一致进行匹配
|
|
|
if ((inspectionTypeId as number).toString() == typeId) {
|
|
|
if (score != null && typeof score == 'number') {
|
|
|
- console.log("找到匹配项,分数:", score);
|
|
|
if (score == 0) {
|
|
|
- console.log("发现零分项");
|
|
|
hasZeroScore = true;
|
|
|
} else if (score > 0) {
|
|
|
- console.log("发现非零分项,增加到minScoreFromDB:", score);
|
|
|
minScoreFromDB += score;
|
|
|
}
|
|
|
}
|
|
|
@@ -611,23 +602,16 @@ function isMixedZeroNonZeroInspectionTypes(): boolean {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log("检查结果 - 有零分:", hasZeroScore, "非零分总和:", minScoreFromDB);
|
|
|
-
|
|
|
// 如果存在零分且存在非零分的情况,返回非零分的总和加上工作负责人的0.5分
|
|
|
if (hasZeroScore && minScoreFromDB > 0) {
|
|
|
const completionFactor = selfEvaluationForm.value.itemCompletionFactor != null ? selfEvaluationForm.value.itemCompletionFactor : 1;
|
|
|
const result = (minScoreFromDB * completionFactor) + 0.5;
|
|
|
- console.log("零分非零分混合情况,返回结果:", result, "= (非零分:", minScoreFromDB, "* 系数:", completionFactor, ") + 0.5");
|
|
|
return result;
|
|
|
- } else {
|
|
|
- console.log("不符合零分非零分混合条件,hasZeroScore:", hasZeroScore, "minScoreFromDB:", minScoreFromDB);
|
|
|
}
|
|
|
}
|
|
|
- console.log("工单总分为0,返回0");
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
- console.log("工单总分不为0,检查是否存在工作负责人");
|
|
|
+
|
|
|
// 检查是否存在工作负责人
|
|
|
const scorePersonList = selfEvaluationForm.value.scorePersonList as UTSJSONObject[];
|
|
|
for (let i = 0; i < scorePersonList.length; i++) {
|
|
|
@@ -639,8 +623,7 @@ function isMixedZeroNonZeroInspectionTypes(): boolean {
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- console.log("未找到工作负责人,返回原总分:", totalScore);
|
|
|
+
|
|
|
return totalScore;
|
|
|
}
|
|
|
|
|
|
@@ -671,7 +654,7 @@ function validatePersonScore(score: string, fieldName: string): string | null {
|
|
|
|
|
|
// 字段验证函数
|
|
|
function validateField(fieldName: string, value: any): string | null {
|
|
|
- console.log('验证字段:', fieldName, '值:', value);
|
|
|
+ console.log('验证字段:', fieldName, '值:', value, '类型:', typeof value);
|
|
|
// 根据字段名称确定验证规则
|
|
|
if (fieldName == 'workSummary') {
|
|
|
// 验证工作/维保总结
|
|
|
@@ -691,28 +674,40 @@ function validateField(fieldName: string, value: any): string | null {
|
|
|
return "请选择维保类型";
|
|
|
}
|
|
|
} else if (fieldName == 'itemCompletionFactor') {
|
|
|
- // 验证分项完成系数
|
|
|
- if (value == null || value == '') {
|
|
|
+ // 验证分项完成系数
|
|
|
+ if (value == null || value == '') {
|
|
|
return "分项完成系数不能为空";
|
|
|
}
|
|
|
// 验证数值范围
|
|
|
+ let numValue: number;
|
|
|
if (typeof value == 'string' && value != '') {
|
|
|
- const numValue = parseFloat(value);
|
|
|
- if (isNaN(numValue) || numValue < 0 || numValue > 1) {
|
|
|
- return '分项完成系数必须在0到1之间';
|
|
|
- }
|
|
|
+ numValue = parseFloat(value);
|
|
|
+ } else if (typeof value == 'number') {
|
|
|
+ numValue = value;
|
|
|
+ } else {
|
|
|
+ return "分项完成系数类型错误";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isNaN(numValue) || numValue < 0 || numValue > 1) {
|
|
|
+ return '分项完成系数必须在0到1之间';
|
|
|
}
|
|
|
} else if (fieldName == 'itemCompletionFactorSum') {
|
|
|
- // 验证分项完成系数和
|
|
|
- if (value == null || value == '') {
|
|
|
+ // 验证分项完成系数和
|
|
|
+ if (value == null || value == '') {
|
|
|
return "分项完成系数和不能为空";
|
|
|
}
|
|
|
// 验证数值范围
|
|
|
+ let numValue: number;
|
|
|
if (typeof value == 'string' && value != '') {
|
|
|
- const numValue = parseFloat(value);
|
|
|
- if (isNaN(numValue) || numValue < 0 || numValue > 1) {
|
|
|
- return '分项完成系数和必须在0到1之间';
|
|
|
- }
|
|
|
+ numValue = parseFloat(value);
|
|
|
+ } else if (typeof value == 'number') {
|
|
|
+ numValue = value;
|
|
|
+ } else {
|
|
|
+ return "分项完成系数和类型错误";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isNaN(numValue) || numValue < 0 || numValue > 1) {
|
|
|
+ return '分项完成系数和必须在0到1之间';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -895,9 +890,6 @@ function validateForm(): any {
|
|
|
if (selfEvaluationForm.value.orderType == '1') {
|
|
|
console.log('验证维修工单的检修类型');
|
|
|
console.log('当前maintenanceType值:', selfEvaluationForm.value.maintenanceType, '类型:', typeof selfEvaluationForm.value.maintenanceType);
|
|
|
- console.log('maintenanceType == null:', selfEvaluationForm.value.maintenanceType == null);
|
|
|
- console.log('maintenanceType == null:', selfEvaluationForm.value.maintenanceType == null);
|
|
|
- console.log('maintenanceType == :', selfEvaluationForm.value.maintenanceType == '');
|
|
|
|
|
|
let validationMessage: string | null = null;
|
|
|
try {
|
|
|
@@ -912,16 +904,11 @@ function validateForm(): any {
|
|
|
const result = new UTSJSONObject();
|
|
|
result.set('valid', false);
|
|
|
result.set('message', validationMessage);
|
|
|
- console.log('准备返回验证失败结果');
|
|
|
return result;
|
|
|
- } else {
|
|
|
- console.log('检修类型验证通过');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 验证总结内容(这个也必须在前面验证)
|
|
|
- console.log('验证工作总结,内容:', selfEvaluationForm.value.workSummary);
|
|
|
- console.log('工作总结内容长度:', selfEvaluationForm.value.workSummary?.length ?? 0);
|
|
|
+ // 验证总结内容
|
|
|
let summaryValidation: string | null = null;
|
|
|
try {
|
|
|
summaryValidation = validateField('workSummary', selfEvaluationForm.value.workSummary as any);
|
|
|
@@ -929,9 +916,7 @@ function validateForm(): any {
|
|
|
console.error('工作总结验证过程中出现异常:', error);
|
|
|
summaryValidation = '工作总结验证失败';
|
|
|
}
|
|
|
- console.log('工作总结验证结果:', summaryValidation);
|
|
|
if (summaryValidation != null) {
|
|
|
- console.log('工作总结验证失败:', summaryValidation);
|
|
|
const result = new UTSJSONObject();
|
|
|
result.set('valid', false);
|
|
|
result.set('message', summaryValidation);
|
|
|
@@ -941,7 +926,6 @@ function validateForm(): any {
|
|
|
// 验证工单类型为2(维保工单)时的分项完成系数
|
|
|
if (selfEvaluationForm.value.orderType == '2') {
|
|
|
// 检查分项完成系数是否为空字符串(即用户清空了输入框)
|
|
|
- console.log("itemCompletionFactorStr.value",itemCompletionFactorStr.value)
|
|
|
if (itemCompletionFactorStr.value == '') {
|
|
|
const result = new UTSJSONObject();
|
|
|
result.set('valid', false);
|
|
|
@@ -953,7 +937,6 @@ function validateForm(): any {
|
|
|
try {
|
|
|
validationMessage = validateField('itemCompletionFactor', selfEvaluationForm.value.itemCompletionFactor as any);
|
|
|
} catch (error: any) {
|
|
|
- console.error('分项完成系数验证过程中出现异常:', error);
|
|
|
validationMessage = '分项完成系数验证失败';
|
|
|
}
|
|
|
if (validationMessage != null) {
|
|
|
@@ -965,7 +948,6 @@ function validateForm(): any {
|
|
|
|
|
|
// 验证分项完成系数和
|
|
|
// 检查分项完成系数和是否为空字符串(即用户清空了输入框)
|
|
|
- console.log("itemCompletionFactorSumStr.value",itemCompletionFactorSumStr.value)
|
|
|
if (itemCompletionFactorSumStr.value == '') {
|
|
|
const result = new UTSJSONObject();
|
|
|
result.set('valid', false);
|
|
|
@@ -977,7 +959,6 @@ function validateForm(): any {
|
|
|
try {
|
|
|
validationMessage = validateField('itemCompletionFactorSum', selfEvaluationForm.value.itemCompletionFactorSum as any);
|
|
|
} catch (error: any) {
|
|
|
- console.error('分项完成系数和验证过程中出现异常:', error);
|
|
|
validationMessage = '分项完成系数和验证失败';
|
|
|
}
|
|
|
if (validationMessage != null) {
|
|
|
@@ -1086,13 +1067,9 @@ async function loadInspectionTypeOptions() {
|
|
|
if (orderType.value == '2') {
|
|
|
// 根据风机型号获取维保类型选项
|
|
|
const fanType = selfEvaluationForm.value.model; // 使用风机型号
|
|
|
- console.log('准备加载维保类型选项,风机型号:', fanType);
|
|
|
|
|
|
if (fanType != null && fanType != '') {
|
|
|
- console.log('正在调用listInspectionTypesByFanType,参数:', fanType as string);
|
|
|
const response: any = await listInspectionTypesByFanType(fanType as string);
|
|
|
- console.log('API响应:', response);
|
|
|
-
|
|
|
const resultObj = response as UTSJSONObject;
|
|
|
const code = resultObj.get('code') as number;
|
|
|
|
|
|
@@ -1101,7 +1078,6 @@ async function loadInspectionTypeOptions() {
|
|
|
|
|
|
if (data != null && Array.isArray(data)) {
|
|
|
inspectionTypeOptions.value = data;
|
|
|
- console.log('维保类型选项加载成功,数量:', data.length);
|
|
|
}
|
|
|
} else {
|
|
|
console.error('API返回错误码:', code);
|
|
|
@@ -1125,8 +1101,6 @@ async function loadOrderDetail() {
|
|
|
})
|
|
|
|
|
|
const response: any = await getOrderScoreDetail(orderType.value, id.value)
|
|
|
- console.log("工单详情response==")
|
|
|
- console.log(response)
|
|
|
const resultObj = response as UTSJSONObject
|
|
|
const code = resultObj.get('code') as number
|
|
|
|
|
|
@@ -1148,8 +1122,8 @@ async function loadOrderDetail() {
|
|
|
(Array.isArray(data.get('inspectionType')) ?
|
|
|
data.get('inspectionType') as string[] :
|
|
|
(((data.get('inspectionType') as string | null)?.split(',') ?? []) as string[])) : [],
|
|
|
- itemCompletionFactor: (data.get('itemCompletionFactor') as number | null) ?? 1.0,
|
|
|
- itemCompletionFactorSum: (data.get('itemCompletionFactorSum') as number | null) ?? 1.0,
|
|
|
+ itemCompletionFactor: (data.get('itemCompletionFactor') as number | null),
|
|
|
+ itemCompletionFactorSum: (data.get('itemCompletionFactorSum') as number | null),
|
|
|
scorePersonList: orderType.value == '1' ?
|
|
|
((data.get('repairOrderPersonList') as UTSJSONObject[] | null) ?? []) :
|
|
|
((data.get('workOrderPersonList') as UTSJSONObject[] | null) ?? []),
|
|
|
@@ -1173,9 +1147,9 @@ async function loadOrderDetail() {
|
|
|
}
|
|
|
} */
|
|
|
|
|
|
- // 初始化字符串中转值
|
|
|
- itemCompletionFactorStr.value = formData.itemCompletionFactor.toFixed(2)
|
|
|
- itemCompletionFactorSumStr.value = formData.itemCompletionFactorSum.toFixed(2)
|
|
|
+ // 初始化字符串中转值,处理可能为null的情况
|
|
|
+ itemCompletionFactorStr.value = formData.itemCompletionFactor != null ? formData.itemCompletionFactor.toFixed(2) : ''
|
|
|
+ itemCompletionFactorSumStr.value = formData.itemCompletionFactorSum != null ? formData.itemCompletionFactorSum.toFixed(2) : ''
|
|
|
|
|
|
// 加载检修类型选项
|
|
|
if (orderType.value == '1') {
|
|
|
@@ -1286,59 +1260,214 @@ function onWorkSummaryInput(e: UniInputEvent) {
|
|
|
selfEvaluationForm.value.workSummary = value
|
|
|
}
|
|
|
|
|
|
-// 分项完成系数变化
|
|
|
-function onItemCompletionFactorChange(e: UniInputEvent) {
|
|
|
- const rawValue = e.detail?.value as string
|
|
|
+// 格式化分项完成系数输入值
|
|
|
+function formatItemCompletionFactor() {
|
|
|
+ const tempValue = tempItemCompletionFactorInput.value;
|
|
|
+ let finalValue: number | null = null; // 明确定义类型
|
|
|
|
|
|
- // 如果输入为空,设置为0
|
|
|
- if (rawValue == '') {
|
|
|
- selfEvaluationForm.value.itemCompletionFactor = 0
|
|
|
- itemCompletionFactorStr.value = ''
|
|
|
- } else {
|
|
|
- const val = parseFloat(rawValue)
|
|
|
+ if (tempValue.endsWith('.')) {
|
|
|
+ // 如果以点结尾,去除点号
|
|
|
+ const processedValue = tempValue.slice(0, -1);
|
|
|
|
|
|
- // 验证分项完成系数
|
|
|
- if (isNaN(val)) {
|
|
|
- console.warn('分项完成系数必须为数字')
|
|
|
- return
|
|
|
+ if (processedValue != '') {
|
|
|
+ const numValue = parseFloat(processedValue);
|
|
|
+
|
|
|
+ if (!isNaN(numValue) && isFinite(numValue)) {
|
|
|
+ if (numValue >= 0 && numValue <= 1) {
|
|
|
+ finalValue = numValue;
|
|
|
+ } else {
|
|
|
+ finalValue = numValue > 1 ? 1 : 0; // 根据数值大小决定边界值
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finalValue = 1; // 默认值
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 去掉点后为空,设为null
|
|
|
+ finalValue = null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 正常数值处理
|
|
|
+ const currentValue = selfEvaluationForm.value.itemCompletionFactor;
|
|
|
+ if (currentValue != null && typeof currentValue == 'number') {
|
|
|
+ // 格式化小数位数
|
|
|
+ const currentStr = currentValue.toString();
|
|
|
+ const parts = currentStr.split('.');
|
|
|
+ if (parts.length > 1 && parts[1] != null && parts[1].length > 2) {
|
|
|
+ // 创建一个局部变量确保类型安全
|
|
|
+ const valueToFormat: number = currentValue;
|
|
|
+ finalValue = parseFloat(valueToFormat.toFixed(2));
|
|
|
+ } else {
|
|
|
+ finalValue = currentValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新数值
|
|
|
+ selfEvaluationForm.value.itemCompletionFactor = finalValue;
|
|
|
+
|
|
|
+ // 同步更新临时输入值为格式化后的字符串显示
|
|
|
+ if (finalValue != null) {
|
|
|
+ tempItemCompletionFactorInput.value = finalValue.toString();
|
|
|
+ } else {
|
|
|
+ tempItemCompletionFactorInput.value = '';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function onItemCompletionFactorInput(e: UniInputEvent) {
|
|
|
+ const value = e.detail?.value as string;
|
|
|
+
|
|
|
+ // 更新临时输入值
|
|
|
+ tempItemCompletionFactorInput.value = value;
|
|
|
+
|
|
|
+ // 检查输入值是否为空
|
|
|
+ if (value == '') {
|
|
|
+ selfEvaluationForm.value.itemCompletionFactor = null;
|
|
|
+ } else {
|
|
|
+ // 检查是否为中间输入状态(如 '0.' 等以点结尾的数字)
|
|
|
+ if (value.endsWith('.')) {
|
|
|
+ // 如果是中间输入状态,不更新数值,保持原有值
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- /* if (val < 0 || val > 1) {
|
|
|
- console.warn('分项完成系数必须在0到1之间')
|
|
|
- return
|
|
|
- } */
|
|
|
+ // 验证输入值是否为有效数字
|
|
|
+ const numValue = parseFloat(value);
|
|
|
+ if (!isNaN(numValue) && isFinite(numValue)) {
|
|
|
+ if( numValue >= 0 && numValue <= 1){
|
|
|
+ // 在input事件中直接使用解析后的数值
|
|
|
+ selfEvaluationForm.value.itemCompletionFactor = numValue;
|
|
|
+ } else {
|
|
|
+ // 当超出范围时,设置实际值为边界值
|
|
|
+ selfEvaluationForm.value.itemCompletionFactor = numValue > 1 ? 1 : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新可自评总分显示
|
|
|
+ //updateSelfEvaluatedTotalScore();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ calculateScores();
|
|
|
+}
|
|
|
+
|
|
|
+// 获取分项完成系数显示值
|
|
|
+function getItemCompletionFactorDisplayValue(): string {
|
|
|
+ // 优先返回临时输入值,确保输入过程中的显示与用户操作一致
|
|
|
+ if (tempItemCompletionFactorInput.value != null && tempItemCompletionFactorInput.value != '') {
|
|
|
+ return tempItemCompletionFactorInput.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 否则返回格式化后的数值
|
|
|
+ const value = selfEvaluationForm.value.itemCompletionFactor;
|
|
|
+ if (value == null) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (typeof value == 'number') {
|
|
|
+ return value.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ return value as string;
|
|
|
+}
|
|
|
+
|
|
|
+// 格式化分项完成系数和输入值
|
|
|
+function formatItemCompletionFactorSum() {
|
|
|
+ const tempValue = tempItemCompletionFactorSumInput.value;
|
|
|
+ let finalValue: number | null = null; // 明确定义类型
|
|
|
+
|
|
|
+ if (tempValue.endsWith('.')) {
|
|
|
+ // 如果以点结尾,去除点号
|
|
|
+ const processedValue = tempValue.slice(0, -1);
|
|
|
|
|
|
- selfEvaluationForm.value.itemCompletionFactor = val
|
|
|
- itemCompletionFactorStr.value = rawValue
|
|
|
+ if (processedValue != '') {
|
|
|
+ const numValue = parseFloat(processedValue);
|
|
|
+
|
|
|
+ if (!isNaN(numValue) && isFinite(numValue)) {
|
|
|
+ if (numValue >= 0 && numValue <= 1) {
|
|
|
+ finalValue = numValue;
|
|
|
+ } else {
|
|
|
+ finalValue = numValue > 1 ? 1 : 0; // 根据数值大小决定边界值
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finalValue = 1; // 默认值
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 去掉点后为空,设为null
|
|
|
+ finalValue = null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 正常数值处理
|
|
|
+ const currentValue = selfEvaluationForm.value.itemCompletionFactorSum;
|
|
|
+ if (currentValue != null && typeof currentValue == 'number') {
|
|
|
+ // 格式化小数位数
|
|
|
+ const currentStr = currentValue.toString();
|
|
|
+ const parts = currentStr.split('.');
|
|
|
+ if (parts.length > 1 && parts[1] != null && parts[1].length > 2) {
|
|
|
+ // 创建一个局部变量确保类型安全
|
|
|
+ const valueToFormat: number = currentValue;
|
|
|
+ finalValue = parseFloat(valueToFormat.toFixed(2));
|
|
|
+ } else {
|
|
|
+ finalValue = currentValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新数值
|
|
|
+ selfEvaluationForm.value.itemCompletionFactorSum = finalValue;
|
|
|
+
|
|
|
+ // 同步更新临时输入值为格式化后的字符串显示
|
|
|
+ if (finalValue != null) {
|
|
|
+ tempItemCompletionFactorSumInput.value = finalValue.toString();
|
|
|
+ } else {
|
|
|
+ tempItemCompletionFactorSumInput.value = '';
|
|
|
}
|
|
|
- calculateScores()
|
|
|
}
|
|
|
|
|
|
-// 分项完成系数和变化
|
|
|
-function onItemCompletionFactorSumChange(e: UniInputEvent) {
|
|
|
- const rawValue = e.detail?.value as string
|
|
|
+function onItemCompletionFactorSumInput(e: UniInputEvent) {
|
|
|
+ const value = e.detail?.value as string;
|
|
|
+
|
|
|
+ // 更新临时输入值
|
|
|
+ tempItemCompletionFactorSumInput.value = value;
|
|
|
|
|
|
- // 如果输入为空,设置为0
|
|
|
- if (rawValue == '') {
|
|
|
- selfEvaluationForm.value.itemCompletionFactorSum = 0
|
|
|
- itemCompletionFactorSumStr.value = ''
|
|
|
+ // 检查输入值是否为空
|
|
|
+ if (value == '') {
|
|
|
+ selfEvaluationForm.value.itemCompletionFactorSum = null;
|
|
|
} else {
|
|
|
- const val = parseFloat(rawValue)
|
|
|
-
|
|
|
- // 验证分项完成系数和
|
|
|
- if (isNaN(val)) {
|
|
|
- console.warn('分项完成系数和必须为数字')
|
|
|
- return
|
|
|
+ // 检查是否为中间输入状态(如 '0.' 等以点结尾的数字)
|
|
|
+ if (value.endsWith('.')) {
|
|
|
+ // 如果是中间输入状态,不更新数值,保持原有值
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- /* if (val < 0 || val > 1) {
|
|
|
- console.warn('分项完成系数和必须在0到1之间')
|
|
|
- return
|
|
|
- } */
|
|
|
-
|
|
|
- selfEvaluationForm.value.itemCompletionFactorSum = val
|
|
|
- itemCompletionFactorSumStr.value = rawValue
|
|
|
+ // 验证输入值是否为有效数字
|
|
|
+ const numValue = parseFloat(value);
|
|
|
+ if (!isNaN(numValue) && isFinite(numValue)) {
|
|
|
+ if( numValue >= 0 && numValue <= 1){
|
|
|
+ // 在input事件中直接使用解析后的数值
|
|
|
+ selfEvaluationForm.value.itemCompletionFactorSum = numValue;
|
|
|
+ } else {
|
|
|
+ // 当超出范围时,设置实际值为边界值
|
|
|
+ selfEvaluationForm.value.itemCompletionFactorSum = numValue > 1 ? 1 : 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 获取分项完成系数和显示值
|
|
|
+function getItemCompletionFactorSumDisplayValue(): string {
|
|
|
+ // 优先返回临时输入值,确保输入过程中的显示与用户操作一致
|
|
|
+ if (tempItemCompletionFactorSumInput.value != null && tempItemCompletionFactorSumInput.value != '') {
|
|
|
+ return tempItemCompletionFactorSumInput.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 否则返回格式化后的数值
|
|
|
+ const value = selfEvaluationForm.value.itemCompletionFactorSum;
|
|
|
+ if (value == null) {
|
|
|
+ return '';
|
|
|
}
|
|
|
+
|
|
|
+ if (typeof value == 'number') {
|
|
|
+ return value.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ return value as string;
|
|
|
}
|
|
|
|
|
|
// 额外工作总结变化
|
|
|
@@ -1418,7 +1547,6 @@ function setPersonScore(person: UTSJSONObject, field: string, value: string) {
|
|
|
// 通用评分输入处理
|
|
|
function onScoreInput(e: UniInputEvent, index: number, field: string) {
|
|
|
const value = e.detail?.value as string
|
|
|
- console.log(field + "输入 - 值:", value, "索引:", index)
|
|
|
|
|
|
if (index >= 0 && index < selfEvaluationForm.value.scorePersonList.length) {
|
|
|
const person = selfEvaluationForm.value.scorePersonList[index] as UTSJSONObject
|
|
|
@@ -1448,12 +1576,32 @@ function onScoreInput(e: UniInputEvent, index: number, field: string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 格式化评分输入值
|
|
|
+function formatScoreInput(index: number, field: string) {
|
|
|
+ if (index >= 0 && index < selfEvaluationForm.value.scorePersonList.length) {
|
|
|
+ const person = selfEvaluationForm.value.scorePersonList[index] as UTSJSONObject
|
|
|
+ if (person != null) {
|
|
|
+ const value = person.get(field as string);
|
|
|
+ if (typeof value == 'number') {
|
|
|
+ // 检查数值的小数位数是否超过2位
|
|
|
+ const parts = value.toString().split('.');
|
|
|
+ if (parts.length > 1) { // 确保有小数部分
|
|
|
+ const decimalPart = parts[1];
|
|
|
+ if (decimalPart != null && decimalPart.length > 2) {
|
|
|
+ // 如果小数位数超过2位,使用格式化后的值
|
|
|
+ const formattedValue = parseFloat((value as number).toFixed(2));
|
|
|
+ person.set(field as string, formattedValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 分数变化
|
|
|
function onScoreChange() {
|
|
|
updateTotalScores()
|
|
|
updateSelfEvaluatedTotalScore() // 更新已自评总分显示
|
|
|
- // 确保已自评总分在分数变化后被重新计算
|
|
|
- console.log("分数变化,当前已自评总分:", getSelfEvaluatedTotalScore())
|
|
|
}
|
|
|
|
|
|
// 返回按钮事件
|
|
|
@@ -1575,7 +1723,7 @@ async function submitSelfEvaluationForm(): Promise<void> {
|
|
|
.container {
|
|
|
flex: 1;
|
|
|
background-color: #e8f0f9;
|
|
|
- height: 100vh;
|
|
|
+ //height: 100vh;
|
|
|
}
|
|
|
|
|
|
.header {
|
|
|
@@ -1630,6 +1778,7 @@ async function submitSelfEvaluationForm(): Promise<void> {
|
|
|
border: 1rpx solid #e0e0e0;
|
|
|
border-radius: 8rpx;
|
|
|
padding: 10rpx;
|
|
|
+ text-align: right;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1692,7 +1841,7 @@ async function submitSelfEvaluationForm(): Promise<void> {
|
|
|
.selected-values {
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
|
- gap: 10rpx;
|
|
|
+ //gap: 10rpx;
|
|
|
}
|
|
|
|
|
|
.selected-value-tag {
|
|
|
@@ -1723,7 +1872,7 @@ async function submitSelfEvaluationForm(): Promise<void> {
|
|
|
.score-inputs {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
- gap: 15rpx;
|
|
|
+ //gap: 15rpx;
|
|
|
}
|
|
|
|
|
|
.score-item {
|