feat: 语音指标

This commit is contained in:
zhanghao 2026-02-02 10:37:39 +08:00
parent e6825f9869
commit d654e0a0e4
2 changed files with 137 additions and 66 deletions

View File

@ -2,10 +2,11 @@
<div class="score-table-container"> <div class="score-table-container">
<!-- 表头 --> <!-- 表头 -->
<div class="table-header"> <div class="table-header">
<div class="table-header-item">数值1</div> <div class="table-header-item">比较数值1</div>
<div class="table-header-item">符号</div> <div class="table-header-item">符号</div>
<div class="table-header-item">数值2</div> <div class="table-header-item">比较数值2</div>
<div class="table-header-item">分数</div> <div class="table-header-item">分数</div>
<div class="table-header-item">备注</div>
<div class="table-header-item">操作</div> <div class="table-header-item">操作</div>
</div> </div>
@ -13,25 +14,27 @@
<div class="table-body"> <div class="table-body">
<div v-for="(row, index) in tableData" :key="index" class="table-row"> <div v-for="(row, index) in tableData" :key="index" class="table-row">
<!-- 数值1 --> <!-- 数值1 -->
<el-input v-model="row.value1" placeholder="请输入..." class="table-cell-input"> <el-input :disabled="row.isDisabled" v-model="row.compareNum1" placeholder="请输入..." class="table-cell-input">
<template #append>ms</template> <template #append>{{ test(props.title) }}</template>
</el-input> </el-input>
<!-- 符号1 --> <!-- 符号1 -->
<el-select v-model="row.symbol1" class="table-cell-select"> <el-select :disabled="row.isDisabled" v-model="row.symbol" class="table-cell-select">
<el-option label="≤" value="le"></el-option> <el-option label="=" value="="></el-option>
<el-option label="<" value="lt"></el-option> <el-option label="≤" value="≤"></el-option>
<el-option label="≥" value="ge"></el-option> <el-option label="<" value="<"></el-option>
<el-option label=">" value="gt"></el-option> <el-option label="≥" value="≥"></el-option>
<el-option label=">" value=">"></el-option>
</el-select> </el-select>
<!-- 数值2 --> <!-- 数值2 -->
<el-input v-model="row.value2" class="table-cell-input"> <el-input :disabled="row.isDisabled" v-model="row.compareNum2" class="table-cell-input">
<template #append>ms</template> <template #append>{{ test(props.title) }}</template>
</el-input> </el-input>
<!-- 分数 --> <!-- 分数 -->
<el-input v-model="row.score" class="table-cell-input" /> <el-input :disabled="row.isDisabled" v-model="row.score" class="table-cell-input" />
<el-input :disabled="row.isDisabled" v-model="row.remark" class="table-cell-input" />
<!-- 操作按钮 --> <!-- 操作按钮 -->
<div class="table-cell-action"> <div class="table-cell-action">
@ -39,7 +42,18 @@
icon="Edit" icon="Edit"
size="small" size="small"
circle circle
@click="handleEdit(index)" v-if="row.isDisabled"
@click="handleEdit(row)"
class="action-btn edit-btn"
/>
<el-button
icon="CircleCheck"
size="small"
title="保存"
circle
v-if="!row.isDisabled"
@click="handleSave(row)"
class="action-btn edit-btn" class="action-btn edit-btn"
/> />
@ -57,7 +71,7 @@
icon="Delete" icon="Delete"
size="small" size="small"
circle circle
@click="handleDelete(index)" @click="handleDelete(row, index)"
class="action-btn del-btn" class="action-btn del-btn"
/> />
</div> </div>
@ -69,80 +83,137 @@
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { getIndicatorByParentId, deleteIndicator, addIndicator, updateIndicator } from "@/api/evaluate/indicator";
const props = defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
default: "", default: "唤醒时间"
}, },
indicatorId: {
type: Number,
default: 0
}
}); });
// //
const tableData = ref([ const tableData = ref([]);
{
value1: "",
symbol1: "",
indicator: props.title,
symbol2: "le",
value2: "700",
score: "100",
weight: "50",
},
{
value1: "700",
symbol1: "lt",
indicator: props.title,
symbol2: "le",
value2: "1000",
score: "80",
weight: "50",
},
{
value1: "1000",
symbol1: "lt",
indicator: props.title,
symbol2: "le",
value2: "1300",
score: "60",
weight: "50",
},
{
value1: "",
symbol1: "",
indicator: props.title,
symbol2: "gt",
value2: "1300",
score: "0",
weight: "50",
},
]);
// //
const handleEdit = (index) => { const handleEdit = (row) => {
console.log("编辑行:", index, tableData.value[index]); row.isDisabled = false
};
const handleSave = (row) => {
if (row.id) {
updateIndicator({
id: row.id,
compareNum1: row.compareNum1,
name: props.title,
symbol: row.symbol,
compareNum2: row.compareNum2,
score: row.score,
remark: row.remark,
parentId: props.indicatorId
}).then(res => {
if (res.code === 200) {
ElMessage.success("保存成功");
row.isDisabled = true
} else {
ElMessage.error(res.message || "保存失败");
}
})
} else {
addIndicator({
compareNum1: row.compareNum1,
symbol: row.symbol,
name: props.title,
level: 4,
compareNum2: row.compareNum2,
score: row.score,
remark: row.remark,
parentId: props.indicatorId
}).then(res => {
if (res.code === 200) {
ElMessage.success("保存成功");
row.id = res.data.id; // IDres.data.id
row.isDisabled = true
} else {
ElMessage.error(res.message || "保存失败");
}
})
}
}; };
// //
const handleAdd = () => { const handleAdd = () => {
tableData.value.push({ tableData.value.push({
value1: "", id: null,
symbol1: "", compareNum1: "",
indicator: props.title, symbol: "≤",
symbol2: "le", compareNum2: "",
value2: "",
score: "", score: "",
weight: "50", remark: "",
isDisabled: false
}); });
}; };
// //
const handleDelete = (index) => { const handleDelete = (row, index) => {
if (tableData.value.length <= 1) { if (tableData.value.length <= 1) {
ElMessage.warning("至少保留一行数据"); ElMessage.warning("至少保留一行数据");
return; return;
} }
tableData.value.splice(index, 1); if (row.id) {
deleteIndicator(row.id).then(res => {
if (res.code === 200) {
ElMessage.success("删除成功");
tableData.value.splice(index, 1);
} else {
ElMessage.error(res.message || "删除失败");
}
});
return;
} else {
tableData.value.splice(index, 1);
}
}; };
const getIndicatorByParentIdData = async (parentId) => {
try {
const res = await getIndicatorByParentId(parentId);
if (res.code === 200) {
tableData.value = res.data;
tableData.value.forEach(row => {
row.isDisabled = true; //
});
if (tableData.value.length === 0) {
//
handleAdd();
}
}
} catch (error) {
console.error("获取指标数据失败:", error);
}
};
const test = (title) => {
if (title.includes("时间")) {
return "ms";
} else if (title.includes("成功率") || title.includes("交互")) {
return "%";
} else if (title.includes("频度")) {
return "次/h";
} else {
return "";
}
};
onMounted(() => {
getIndicatorByParentIdData(props.indicatorId);
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -164,7 +235,7 @@ $font-medium: 500;
// //
.table-header { .table-header {
display: grid; display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-columns: repeat(6, minmax(0, 1fr));
gap: $gap-base; gap: $gap-base;
padding: $gap-base $padding-base; padding: $gap-base $padding-base;
background-color: $table-header-bg; background-color: $table-header-bg;
@ -185,7 +256,7 @@ $font-medium: 500;
.table-body { .table-body {
.table-row { .table-row {
display: grid; display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-columns: repeat(6, minmax(0, 1fr));
gap: $gap-base; gap: $gap-base;
padding: $gap-base * 1.5 $padding-base; padding: $gap-base * 1.5 $padding-base;
border-bottom: 1px solid $table-border-color; border-bottom: 1px solid $table-border-color;

View File

@ -33,7 +33,7 @@
<el-icon :size="12" style="margin-left: 5px; cursor: pointer;" @click="($event) => handleEditTab($event, item)"><Edit /></el-icon> <el-icon :size="12" style="margin-left: 5px; cursor: pointer;" @click="($event) => handleEditTab($event, item)"><Edit /></el-icon>
</span> </span>
</template> </template>
<ScoreTable :title="item.name" /> <ScoreTable :title="item.name" :indicatorId="item.id" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>