|
|
@ -33,6 +33,7 @@ import { |
|
|
|
} from '@/api/alert/model/models' |
|
|
|
import { getExaHistorys } from '@/api/alert/exa/index' |
|
|
|
import { useECharts } from '@/hooks/web/useECharts' |
|
|
|
import { useMessage } from '@/hooks/web/useMessage' |
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
components: { |
|
|
@ -58,6 +59,7 @@ export default defineComponent({ |
|
|
|
ASpin: Spin, |
|
|
|
}, |
|
|
|
setup() { |
|
|
|
const { createMessage } = useMessage() |
|
|
|
const route = useRoute() |
|
|
|
const id = route.params.id |
|
|
|
const model = ref(null) |
|
|
@ -150,14 +152,6 @@ export default defineComponent({ |
|
|
|
) |
|
|
|
historyList.value = sampleData.map((item, index) => { |
|
|
|
const point = model.value?.pointInfo[index] |
|
|
|
const bias = item.map((t, i) => { |
|
|
|
if ( |
|
|
|
Math.abs(t - reconData[index][i]) |
|
|
|
> model.value.para.Model_info.QCUL_99_line[i] |
|
|
|
) |
|
|
|
return 1 |
|
|
|
else return null |
|
|
|
}) |
|
|
|
return { |
|
|
|
data: [ |
|
|
|
item.map((t, i) => { |
|
|
@ -166,9 +160,6 @@ export default defineComponent({ |
|
|
|
reconData[index].map((t, i) => { |
|
|
|
return [xData[i], t] |
|
|
|
}), |
|
|
|
bias.map((t, i) => { |
|
|
|
return [xData[i], t] |
|
|
|
}), |
|
|
|
], |
|
|
|
name: `${index + 1}.${point?.description}(${point?.pointId})`, |
|
|
|
} |
|
|
@ -316,6 +307,7 @@ export default defineComponent({ |
|
|
|
isInitBrush.value = true |
|
|
|
} |
|
|
|
}) |
|
|
|
updateModelInfoDebounced() |
|
|
|
} |
|
|
|
}, 300) |
|
|
|
|
|
|
@ -353,26 +345,11 @@ export default defineComponent({ |
|
|
|
} |
|
|
|
|
|
|
|
// 防抖更新 |
|
|
|
const updateModelInfoDebounced = debounce((val) => { |
|
|
|
const updateModelInfoDebounced = debounce(() => { |
|
|
|
const val = toRaw(model.value) |
|
|
|
if (val && val.id) |
|
|
|
updateModelInfo(val) |
|
|
|
}, 500) |
|
|
|
const modelInfoBack = ref(null) |
|
|
|
// 监听 model 变化 |
|
|
|
watch( |
|
|
|
model, |
|
|
|
(newVal, oldVal) => { |
|
|
|
if (modelInfoBack.value === null) { |
|
|
|
modelInfoBack.value = JSON.stringify(newVal) |
|
|
|
return |
|
|
|
} |
|
|
|
if (JSON.stringify(newVal) === modelInfoBack.value) |
|
|
|
return |
|
|
|
modelInfoBack.value = JSON.stringify(newVal) |
|
|
|
updateModelInfoDebounced(newVal) |
|
|
|
}, |
|
|
|
{ deep: true }, |
|
|
|
) |
|
|
|
|
|
|
|
function handleDeleteTrainTime(index: number) { |
|
|
|
if (!model.value?.trainTime) |
|
|
@ -397,6 +374,12 @@ export default defineComponent({ |
|
|
|
isInitBrush.value = true |
|
|
|
} |
|
|
|
}) |
|
|
|
updateModelInfoDebounced() |
|
|
|
} |
|
|
|
async function clearModel() { |
|
|
|
model.value.para = null |
|
|
|
updateModelInfoDebounced() |
|
|
|
await getHistory() |
|
|
|
} |
|
|
|
|
|
|
|
async function trainModel() { |
|
|
@ -437,10 +420,19 @@ export default defineComponent({ |
|
|
|
smote: true, |
|
|
|
} |
|
|
|
spinning.value = true |
|
|
|
const response = await trainModelApi(params) |
|
|
|
model.value.para = response |
|
|
|
model.value.principal = response.Model_info.K |
|
|
|
getTestData() |
|
|
|
try { |
|
|
|
const response = await trainModelApi(params) |
|
|
|
model.value.para = response |
|
|
|
model.value.principal = response.Model_info.K |
|
|
|
updateModelInfoDebounced() |
|
|
|
getTestData() |
|
|
|
createMessage.success('模型训练成功') |
|
|
|
} |
|
|
|
catch (error) { |
|
|
|
console.error('模型训练失败:', error) |
|
|
|
createMessage.error('模型训练失败') |
|
|
|
} |
|
|
|
|
|
|
|
spinning.value = false |
|
|
|
} |
|
|
|
const editForm = ref({ |
|
|
@ -465,6 +457,7 @@ export default defineComponent({ |
|
|
|
dead: editForm.value.dead, |
|
|
|
limit: editForm.value.limit, |
|
|
|
} |
|
|
|
updateModelInfoDebounced() |
|
|
|
pointEditRecord.Upper = editForm.value.Upper |
|
|
|
pointEditRecord.Lower = editForm.value.Lower |
|
|
|
pointEditRecord.lowerBound = editForm.value.lowerBound |
|
|
@ -507,6 +500,7 @@ export default defineComponent({ |
|
|
|
function handleEditMode() { |
|
|
|
// 这里可以添加编辑模式的逻辑 |
|
|
|
model.value.alarmmodelset = mode.value |
|
|
|
updateModelInfoDebounced() |
|
|
|
closeEditMode() |
|
|
|
} |
|
|
|
|
|
|
@ -536,6 +530,7 @@ export default defineComponent({ |
|
|
|
handleEditMode, |
|
|
|
mode, |
|
|
|
spinning, |
|
|
|
clearModel, |
|
|
|
} |
|
|
|
}, |
|
|
|
}) |
|
|
@ -667,6 +662,13 @@ export default defineComponent({ |
|
|
|
> |
|
|
|
模型训练 |
|
|
|
</a-button> |
|
|
|
<a-button |
|
|
|
type="primary" |
|
|
|
style="margin-left: 10px" |
|
|
|
@click="clearModel" |
|
|
|
> |
|
|
|
清除训练结果 |
|
|
|
</a-button> |
|
|
|
</div> |
|
|
|
<a-divider /> |
|
|
|
<a-spin :spinning="spinning" size="large"> |
|
|
|