AIManage/src/views/simulationEvaluation/components/addStep4.vue

263 lines
7.2 KiB
Vue
Raw Normal View History

2024-06-26 00:20:39 +08:00
<template>
2024-09-15 16:27:31 +08:00
<el-card style="margin-top: 12px" class="simulation-add-add-step41">
2024-07-18 00:13:00 +08:00
<template #header>已选择模型</template>
<el-row class="model-info">
<el-col :span="8">
<span>模型名称:</span>
<span>{{ modelInfo.model_name }}</span>
</el-col>
<el-col :span="8">
<span>模型类型:</span>
2024-08-03 23:08:28 +08:00
<span>{{ modelInfo.modl_net_type }}</span>
2024-07-18 00:13:00 +08:00
</el-col>
<el-col :span="8">
<span>互联名称:</span>
<span>{{ modelInfo.connection_name }}</span>
</el-col>
</el-row>
</el-card>
2024-09-15 16:27:31 +08:00
<el-card style="margin-top: 12px; position: relative" class="simulation-add-add-step42">
2024-07-18 00:13:00 +08:00
<template #header>
<span>设备选择</span>
<el-form ref="queryFormRef" :inline="true" style="
flex-grow: 1;
text-align: right;
position: absolute;
top: 4px;
right: 0px;
">
<el-form-item>
<el-button type="primary" @click="handleQuery">
<i-ep-refresh />刷新</el-button>
</el-form-item>
</el-form>
</template>
2024-09-27 23:35:14 +08:00
<el-table v-loading="loading" ref="dataTb" :data="info.tableData" stripe @row-click="doRowClick">
2024-09-23 23:05:21 +08:00
<el-table-column width="55" >
2024-07-18 00:13:00 +08:00
<template #default="scope">
2024-09-23 23:05:21 +08:00
<el-radio v-model="modelSelection" :label="scope.row.id + ''" :disabled="scope.row.working_state!='idle'"
@change="handleChange(scope.row)">&nbsp;</el-radio>
2024-07-18 00:13:00 +08:00
</template>
</el-table-column>
<el-table-column label="设备名称" align="left" prop="device_name" />
<el-table-column label="AI芯片信息" align="left" prop="hardware_chip" />
<el-table-column label="已部署模型名称" align="left" prop="deployed_model_name" width="120" />
<el-table-column label="已部署模型网络类型" align="left" prop="deployed_model_net_type" />
<el-table-column label="部署时间" align="left" prop="deployed_time" width="160" />
<el-table-column label="量化和编译参数" align="left" prop="tool_params_name" width="160">
<template #default="scope">
2024-09-23 23:05:21 +08:00
<span class="args-state state-2 command" @click.stop="doChoice(scope.row)" v-if="scope.row.working_state=='idle'">{{
2024-08-20 20:39:44 +08:00
scope.row.tool_params_name ? scope.row.tool_params_name : "请选择" }}</span>
2024-07-18 00:13:00 +08:00
</template>
</el-table-column>
<el-table-column label="设备状态" align="center" width="100">
<template #default="scope">
2024-08-05 23:37:01 +08:00
<span :class="'device-state state-1'" v-if="scope.row.available"></span>
<span :class="'device-state state-2'" v-else></span>
<el-popover placement="bottom-start" :width="400" trigger="hover" v-if="!scope.row.available"
class="state-icon" :content="scope.row.available_reason">
<template #reference>
<i-ep-warning style="color: var(--el-color-danger);" />
</template>
</el-popover>
2024-07-18 00:13:00 +08:00
</template>
</el-table-column>
2024-08-17 23:06:31 +08:00
<el-table-column label="操作" align="center" width="100">
<template #default="scope">
2024-09-23 23:05:21 +08:00
<el-button type="primary" @click="doCompile(scope.row)" text v-if="scope.row.working_state=='idle'"
2024-08-20 23:16:55 +08:00
size="default">部署</el-button>
2024-08-17 23:06:31 +08:00
<span v-else style="color: #888;">部署</span>
</template>
</el-table-column>
2024-07-18 00:13:00 +08:00
</el-table>
<div v-if="info.state > 0" class="remark"></div>
</el-card>
2024-06-26 00:20:39 +08:00
2024-07-18 00:13:00 +08:00
<div style="margin-top: 12px;font-size: 12px;font-weight: bold;margin-left: 8px;">
编译结果
</div>
<el-card style="" class="simulation-add-add-step33">
<div class="scroll log-content">
<div v-for="(it, idx) in info.logs" :key="idx" class="log-item" :class="it.type">
{{ it.msg }}
</div>
</div>
</el-card>
2024-07-19 00:41:51 +08:00
<choiceToolsParamDlg ref="choiceToolParamDlg" @success="doChoiceSuccess" />
2024-06-26 00:20:39 +08:00
</template>
<script setup>
2024-07-18 00:13:00 +08:00
import taskApi from "@/api/task";
2024-07-19 00:41:51 +08:00
import choiceToolsParamDlg from './choiceToolsParamDlg.vue';
2024-09-23 23:05:21 +08:00
const modelSelection = ref("")//单选id
const emit = defineEmits(["compile","selection"]);
2024-07-18 00:13:00 +08:00
const props = defineProps({
modelInfo: {
type: Object,
require: true,
default: null,
},
});
let dataTb = ref();
2024-07-19 00:41:51 +08:00
let choiceToolParamDlg = ref();
2024-07-17 00:30:15 +08:00
const loading = ref(false); // 加载状态
2024-07-18 00:13:00 +08:00
const doRowClick = (row, a, b) => {
if (b.target.classList.contains("el-checkbox__inner")) {
return;
}
if (row.available) {
row.checked = !row.checked;
}
};
2024-09-23 23:05:21 +08:00
const handleChange = (row) => {
if (!row.tool_params_id) {
ElMessage.error("请选择工具链运行参数列表!");
modelSelection.value="";
2024-09-27 23:35:14 +08:00
emit("selection")
2024-09-23 23:05:21 +08:00
return;
}
modelSelection.value = row.device_id + "";
2024-09-27 23:35:14 +08:00
emit("selection")
2024-09-23 23:05:21 +08:00
}
2024-07-18 00:13:00 +08:00
const info = reactive({
tableData: [],
state: 0,
logs: [],
2024-09-27 23:35:14 +08:00
editItem: null
2024-07-18 00:13:00 +08:00
});
2024-08-20 23:16:55 +08:00
const doCompile = (row) => {
if (!row.tool_params_id) {
ElMessage.error("请选择工具链运行参数列表!");
return;
}
emit("compile", row);
}
2024-07-19 00:41:51 +08:00
const doChoice = row => {
info.editItem = row;
choiceToolParamDlg.value.showDialog(row);
}
const doChoiceSuccess = item => {
info.editItem.tool_params_id = item.params_id
info.editItem.tool_params_name = item.params_name
2024-09-27 23:35:14 +08:00
window.toolCahce['d_'+info.editItem.device_id]={
params_id:item.params_id,
params_name:item.params_name
}
2024-07-19 00:41:51 +08:00
}
2024-06-26 00:20:39 +08:00
/** 查询 */
2024-07-18 00:13:00 +08:00
function handleQuery() {
loading.value = true;
let m = props.modelInfo;
taskApi
.availableDevices({
connection_id: m.connection_id,
model_id: m.model_id,
})
.then((d) => {
loading.value = false;
info.tableData = (d.data.data.available_device_list || []).map((it) => {
it.id = it.device_id;
it.checked = false;
2024-09-27 23:35:14 +08:00
let key="d_"+it.device_id;
let o=window.toolCahce[key];
if(o){
it.tool_params_id=it.tool_params_id||o.params_id;
it.tool_params_name=it.tool_params_name||o.params_name;
}
2024-07-18 00:13:00 +08:00
return it;
});
2024-07-17 00:30:15 +08:00
});
2024-06-26 00:20:39 +08:00
}
2024-06-26 23:58:18 +08:00
const checkForm = () => {
2024-09-24 23:52:42 +08:00
if (modelSelection.value) {
let tmps = info.tableData.filter(d => d.device_id == modelSelection.value);
return tmps.length > 0 ? tmps[0] : null;
}
return null;
2024-07-18 00:13:00 +08:00
};
const updateState = (s) => {
info.state = s;
2024-09-24 23:52:42 +08:00
2024-06-26 23:58:18 +08:00
};
2024-07-18 00:13:00 +08:00
const updateLogs = (logs) => {
info.logs = logs;
};
2024-09-27 23:35:14 +08:00
const returnData = (d) => {
if(d){
modelSelection.value=""+d.device_id
}
}
2024-07-18 00:13:00 +08:00
onMounted(() => {
handleQuery();
2024-07-17 00:30:15 +08:00
});
2024-06-26 23:58:18 +08:00
defineExpose({
2024-07-18 00:13:00 +08:00
checkForm,
updateState,
updateLogs,
2024-09-27 23:35:14 +08:00
returnData
2024-07-18 00:13:00 +08:00
});
2024-06-26 00:20:39 +08:00
</script>
2024-07-18 00:13:00 +08:00
2024-06-26 23:58:18 +08:00
<style lang="scss" scoped>
.model-info {
2024-07-18 00:13:00 +08:00
font-size: 12px;
color: #666;
}
.remark {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: #00000033;
z-index: 99;
}
.log-content {
max-height: 200px;
overflow-y: auto;
.log-item {
2024-06-26 00:20:39 +08:00
font-size: 12px;
2024-06-26 23:58:18 +08:00
color: #666;
2024-07-18 00:13:00 +08:00
border-bottom: dotted 1px #ccc;
line-height: 24px;
2024-06-26 23:58:18 +08:00
2024-07-18 00:13:00 +08:00
&.info {
color: var(--el-color-primary);
}
2024-06-26 23:58:18 +08:00
2024-07-18 00:13:00 +08:00
&.success {
color: var(--el-color-success);
}
}
}
</style>
<style lang="scss">
2024-09-15 16:27:31 +08:00
.simulation-add-add-step42 {
2024-07-18 00:13:00 +08:00
.device-state {
&.state-1 {
color: var(--el-color-primary);
2024-06-26 23:58:18 +08:00
}
2024-07-18 00:13:00 +08:00
&.state-2 {
2024-08-05 23:37:01 +08:00
color: var(--el-color-danger);
2024-06-26 23:58:18 +08:00
}
2024-07-18 00:13:00 +08:00
}
.args-state {
&.state-2 {
color: var(--el-color-primary);
2024-06-26 23:58:18 +08:00
}
2024-07-18 00:13:00 +08:00
}
.result-state {
color: var(--el-color-danger);
}
2024-06-26 00:20:39 +08:00
}
2024-07-18 00:13:00 +08:00
</style>