feat: 语音指标
This commit is contained in:
parent
e6825f9869
commit
d654e0a0e4
@ -2,10 +2,11 @@
|
||||
<div class="score-table-container">
|
||||
<!-- 表头 -->
|
||||
<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">数值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>
|
||||
|
||||
@ -13,25 +14,27 @@
|
||||
<div class="table-body">
|
||||
<div v-for="(row, index) in tableData" :key="index" class="table-row">
|
||||
<!-- 数值1 -->
|
||||
<el-input v-model="row.value1" placeholder="请输入..." class="table-cell-input">
|
||||
<template #append>ms</template>
|
||||
<el-input :disabled="row.isDisabled" v-model="row.compareNum1" placeholder="请输入..." class="table-cell-input">
|
||||
<template #append>{{ test(props.title) }}</template>
|
||||
</el-input>
|
||||
|
||||
<!-- 符号1 -->
|
||||
<el-select v-model="row.symbol1" class="table-cell-select">
|
||||
<el-option label="≤" value="le"></el-option>
|
||||
<el-option label="<" value="lt"></el-option>
|
||||
<el-option label="≥" value="ge"></el-option>
|
||||
<el-option label=">" value="gt"></el-option>
|
||||
<el-select :disabled="row.isDisabled" v-model="row.symbol" class="table-cell-select">
|
||||
<el-option label="=" value="="></el-option>
|
||||
<el-option label="≤" value="≤"></el-option>
|
||||
<el-option label="<" value="<"></el-option>
|
||||
<el-option label="≥" value="≥"></el-option>
|
||||
<el-option label=">" value=">"></el-option>
|
||||
</el-select>
|
||||
|
||||
<!-- 数值2 -->
|
||||
<el-input v-model="row.value2" class="table-cell-input">
|
||||
<template #append>ms</template>
|
||||
<el-input :disabled="row.isDisabled" v-model="row.compareNum2" class="table-cell-input">
|
||||
<template #append>{{ test(props.title) }}</template>
|
||||
</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">
|
||||
@ -39,7 +42,18 @@
|
||||
icon="Edit"
|
||||
size="small"
|
||||
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"
|
||||
/>
|
||||
|
||||
@ -57,7 +71,7 @@
|
||||
icon="Delete"
|
||||
size="small"
|
||||
circle
|
||||
@click="handleDelete(index)"
|
||||
@click="handleDelete(row, index)"
|
||||
class="action-btn del-btn"
|
||||
/>
|
||||
</div>
|
||||
@ -69,80 +83,137 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { getIndicatorByParentId, deleteIndicator, addIndicator, updateIndicator } from "@/api/evaluate/indicator";
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "",
|
||||
default: "唤醒时间"
|
||||
},
|
||||
indicatorId: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化表格数据
|
||||
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 tableData = ref([]);
|
||||
|
||||
// 编辑行
|
||||
const handleEdit = (index) => {
|
||||
console.log("编辑行:", index, tableData.value[index]);
|
||||
const handleEdit = (row) => {
|
||||
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; // 假设返回的新ID在res.data.id中
|
||||
row.isDisabled = true
|
||||
} else {
|
||||
ElMessage.error(res.message || "保存失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// 添加新行
|
||||
const handleAdd = () => {
|
||||
tableData.value.push({
|
||||
value1: "",
|
||||
symbol1: "",
|
||||
indicator: props.title,
|
||||
symbol2: "le",
|
||||
value2: "",
|
||||
id: null,
|
||||
compareNum1: "",
|
||||
symbol: "≤",
|
||||
compareNum2: "",
|
||||
score: "",
|
||||
weight: "50",
|
||||
remark: "",
|
||||
isDisabled: false
|
||||
});
|
||||
};
|
||||
|
||||
// 删除行
|
||||
const handleDelete = (index) => {
|
||||
const handleDelete = (row, index) => {
|
||||
if (tableData.value.length <= 1) {
|
||||
ElMessage.warning("至少保留一行数据");
|
||||
return;
|
||||
}
|
||||
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>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -164,7 +235,7 @@ $font-medium: 500;
|
||||
// 表头样式
|
||||
.table-header {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: $gap-base;
|
||||
padding: $gap-base $padding-base;
|
||||
background-color: $table-header-bg;
|
||||
@ -185,7 +256,7 @@ $font-medium: 500;
|
||||
.table-body {
|
||||
.table-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: $gap-base;
|
||||
padding: $gap-base * 1.5 $padding-base;
|
||||
border-bottom: 1px solid $table-border-color;
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
<el-icon :size="12" style="margin-left: 5px; cursor: pointer;" @click="($event) => handleEditTab($event, item)"><Edit /></el-icon>
|
||||
</span>
|
||||
</template>
|
||||
<ScoreTable :title="item.name" />
|
||||
<ScoreTable :title="item.name" :indicatorId="item.id" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user