diff --git a/src/apis/alert/api.js b/src/apis/alert/api.js index 3bf0021..5211af0 100644 --- a/src/apis/alert/api.js +++ b/src/apis/alert/api.js @@ -16,6 +16,7 @@ export const GET_OUTLIERS_DEVLIST_API = `api/Alarm/GetDevList`; // 取得設備 export const GET_OUTLIERS_POINTS_API = `api/Alarm/GetAlarmPoints`; // 取得點位 export const POST_OUTLIERS_SETTING_API = `api/Alarm/SaveAlarmSetting`; // 新增與修改 export const DELETE_OUTLIERS_SETTING_API = `api/Alarm/DeleteAlarmSetting`; // 刪除 +export const GET_FACTOR_API = `api/Alarm/GetFactor` export const GET_ALERT_SCHEDULE_LIST_API = `api/Alarm/GetAlarmSchedule`; export const POST_ALERT_SCHEDULE = `api/Alarm/SaveAlarmSchedule`; diff --git a/src/apis/alert/index.js b/src/apis/alert/index.js index 796f356..4b7e3f3 100644 --- a/src/apis/alert/index.js +++ b/src/apis/alert/index.js @@ -16,7 +16,8 @@ import { GET_SHOW_ALERT_API, GET_ALERT_SCHEDULE_LIST_API, POST_ALERT_SCHEDULE, - DELETE_ALERT_SCHEDULE + DELETE_ALERT_SCHEDULE, + GET_FACTOR_API } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apihandler"; @@ -153,6 +154,15 @@ export const getOutliersPoints = async (id) => { }); }; +export const getFactors = async () => { + const res = await instance.post(GET_FACTOR_API); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + export const postOutliersSetting = async (data) => { const res = await instance.post(POST_OUTLIERS_SETTING_API, data); diff --git a/src/views/alert/components/AlertSetting/AlertOutliersTable.vue b/src/views/alert/components/AlertSetting/AlertOutliersTable.vue index 4e68a16..a36b50b 100644 --- a/src/views/alert/components/AlertSetting/AlertOutliersTable.vue +++ b/src/views/alert/components/AlertSetting/AlertOutliersTable.vue @@ -1,6 +1,12 @@ 異常設定 - - + { - {{ record.enable === 1 ? '是' : '否' }} + {{ record.enable === 1 ? "是" : "否" }} {{ record.warning_method }} - - {{ record.warning_time }} - {{ record[column.key] }} diff --git a/src/views/alert/components/AlertSetting/AlertOutliersTableAddModal.vue b/src/views/alert/components/AlertSetting/AlertOutliersTableAddModal.vue index 2815a9d..b1a4d9a 100644 --- a/src/views/alert/components/AlertSetting/AlertOutliersTableAddModal.vue +++ b/src/views/alert/components/AlertSetting/AlertOutliersTableAddModal.vue @@ -20,18 +20,19 @@ const props = defineProps({ const form = ref(null); const formState = ref({ - "id": 0, - "device_number": "", - "device_name_tag": searchParams.value?.subSys_id, - "points": "", - "enable": 0, - "is_bool": 1, - "factor": null, - "highLimit": null, - "lowLimit": null, - "highDelay": null, - "lowDelay": null, - "notices": [] + id: 0, + device_number: "", + device_name_tag: searchParams.value?.subSys_id, + points: "", + enable: 0, + factor: 1, + alarm_value: "", + delay: 0, + highLimit: null, + lowLimit: null, + highDelay: null, + lowDelay: null, + notices: [], }); let scheme = yup.object({ @@ -45,12 +46,12 @@ let scheme = yup.object({ lowDelay: yup.number().nullable(), }); -const { formErrorMsg, handleSubmit, handleErrorReset } = - useFormErrorMessage(scheme.value); +const { formErrorMsg, handleSubmit, handleErrorReset } = useFormErrorMessage( + scheme.value +); const SaveCheckAuth = ref([]); -const isBool = ref(1); -const factorData = ref([]); +const factorNum = ref(1); watch( () => props.editRecord, @@ -61,28 +62,15 @@ watch( }; SaveCheckAuth.value = newValue.notices ? [...newValue.notices] : []; - if (newValue.points) { - onPointsChange(newValue.points); + if (newValue.factor) { + onFactorsChange(newValue.factor); } } } ); -const onPointsChange = (selectedPoint) => { - const pointData = props.OptionsData.alarmPoints.find(p => p.points === selectedPoint); - if (pointData) { - isBool.value = pointData.is_bool; - formState.value.is_bool = pointData.is_bool; - if (pointData.factor && Array.isArray(pointData.factor)) { - factorData.value = pointData.factor.map((d) => ({ - ...d, - key: d.id - }));; - } else { - factorData.value = []; - formState.value.factor = 0; - } - } +const onFactorsChange = (selectedFactor) => { + factorNum.value = selectedFactor; }; const onNoticesChange = (value, checked) => { @@ -117,89 +105,151 @@ const closeModal = () => { formState.value = {}; handleErrorReset(); props.onCancel(); - factorData.value = []; - isBool.value = 1; + factorNum.value = 1; }; - 新增 - + - + 設備名稱 - + {{ formErrorMsg.device_number }} - + - + 項目 - + {{ formErrorMsg.points }} - + - - 狀態 - - - 警示時間 - {formState.schedule_id = null}">清除 - - + 限定條件 - - - 上限(>=) - - - 下限(<=) - - - - - 上限持續秒數 - - - 下限持續秒數 - - + + 狀態 + + + + + 上限(>=) + + + 下限(<=) + + + + + 上限持續秒數 + + + 下限持續秒數 + + + + + + 警示值 + + + - - 警示方式 - - + 警示方式 + - + 取消 - + 確定 diff --git a/src/views/alert/components/AlertSetting/AlertSetting.vue b/src/views/alert/components/AlertSetting/AlertSetting.vue index 830338c..8340015 100644 --- a/src/views/alert/components/AlertSetting/AlertSetting.vue +++ b/src/views/alert/components/AlertSetting/AlertSetting.vue @@ -36,7 +36,7 @@ provide("notify_table", { timesList, noticeList, timesListData }); - +
- 警示方式 -
警示方式