fix: 修正告警影片路徑沒有顯示在維修單 modal 欄位中問題
This commit is contained in:
parent
5ff030dc40
commit
f990c302e5
@ -3,8 +3,8 @@ import { defineProps } from "vue";
|
|||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: String,
|
value: { type: [String, Number, Object, Array, Boolean, null], default: "" },
|
||||||
value: String,
|
name: { type: String, required: true },
|
||||||
items: Array,
|
items: Array,
|
||||||
isLabelExist: {
|
isLabelExist: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -14,11 +14,11 @@ options: [
|
|||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
options: Array,
|
options: Array,
|
||||||
name: String,
|
value: { type: [String, Number, Object, Array, Boolean, null], default: "" },
|
||||||
|
name: { type: String, required: true },
|
||||||
Attribute: String,
|
Attribute: String,
|
||||||
onChange: Function,
|
onChange: Function,
|
||||||
selectClass: String,
|
selectClass: String,
|
||||||
value: String || Number,
|
|
||||||
isTopLabelExist: {
|
isTopLabelExist: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: String,
|
value: { type: [String, Number, Object, Array, Boolean, null], default: "" },
|
||||||
value: String,
|
name: { type: String, required: true },
|
||||||
placeholder: String,
|
placeholder: String,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -248,7 +248,8 @@
|
|||||||
"saturday": "星期六",
|
"saturday": "星期六",
|
||||||
"schedule_name": "时段名称",
|
"schedule_name": "时段名称",
|
||||||
"schedule_content": "时段内容",
|
"schedule_content": "时段内容",
|
||||||
"reorganization": "MQTT 告警重整"
|
"reorganization": "MQTT 告警重整",
|
||||||
|
"maintenance": "保养"
|
||||||
},
|
},
|
||||||
"operation": {
|
"operation": {
|
||||||
"title": "运维管理",
|
"title": "运维管理",
|
||||||
|
@ -248,7 +248,8 @@
|
|||||||
"saturday": "星期六",
|
"saturday": "星期六",
|
||||||
"schedule_name": "時段名稱",
|
"schedule_name": "時段名稱",
|
||||||
"schedule_content": "時段內容",
|
"schedule_content": "時段內容",
|
||||||
"reorganization": "MQTT 告警重整"
|
"reorganization": "MQTT 告警重整",
|
||||||
|
"maintenance": "保養"
|
||||||
},
|
},
|
||||||
"operation": {
|
"operation": {
|
||||||
"title": "運維管理",
|
"title": "運維管理",
|
||||||
|
@ -248,7 +248,8 @@
|
|||||||
"saturday": "Saturday",
|
"saturday": "Saturday",
|
||||||
"schedule_name": "Time period name",
|
"schedule_name": "Time period name",
|
||||||
"schedule_content": "Time period content",
|
"schedule_content": "Time period content",
|
||||||
"reorganization": "MQTT Alarm Reorganization"
|
"reorganization": "MQTT Alarm Reorganization",
|
||||||
|
"maintenance": "Upkeep"
|
||||||
},
|
},
|
||||||
"operation": {
|
"operation": {
|
||||||
"title": "Operation And Maintenance Management",
|
"title": "Operation And Maintenance Management",
|
||||||
|
@ -51,7 +51,7 @@ export const draggable = {
|
|||||||
install(app) {
|
install(app) {
|
||||||
app.directive("draggable", {
|
app.directive("draggable", {
|
||||||
mounted: (el, binding, vnode, prevVnode) => {
|
mounted: (el, binding, vnode, prevVnode) => {
|
||||||
console.log("draggable", $(`#${el.id}`).draggable);
|
// console.log("draggable", $(`#${el.id}`).draggable);
|
||||||
if (binding.value) {
|
if (binding.value) {
|
||||||
if ($(`#${el.id}`).draggable) {
|
if ($(`#${el.id}`).draggable) {
|
||||||
$(`#${el.id}`).draggable({
|
$(`#${el.id}`).draggable({
|
||||||
|
@ -75,21 +75,43 @@ const search = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const openModal = async (record) => {
|
const openModal = async (record) => {
|
||||||
try {
|
try {
|
||||||
if (record.formId) {
|
if (record.formId) {
|
||||||
const res = await getOperationEditRecord(record.formId);
|
const res = await getOperationEditRecord(record.formId);
|
||||||
|
|
||||||
|
// 統一從物件中抓可能的影片位址
|
||||||
|
const pickVideo = (obj = {}) =>
|
||||||
|
obj.video_url ?? obj.videoUrl ?? obj.video_path ?? obj.videoPath ?? "";
|
||||||
|
|
||||||
|
const videoFromDetail = pickVideo(res.data);
|
||||||
|
const videoFromRecord = pickVideo(record);
|
||||||
|
|
||||||
updateEditRecord({
|
updateEditRecord({
|
||||||
...res.data,
|
...res.data,
|
||||||
uuid: res.data.error_code,
|
uuid: res.data.error_code,
|
||||||
device_number: record.device_number,
|
device_number: record.device_number ?? res.data.device_number ?? "",
|
||||||
|
|
||||||
|
// 把影片欄位補齊(優先用詳細;沒有就用列表)
|
||||||
|
...(videoFromDetail
|
||||||
|
? { video_url: videoFromDetail }
|
||||||
|
: videoFromRecord
|
||||||
|
? { video_url: videoFromRecord }
|
||||||
|
: {}),
|
||||||
|
|
||||||
|
video_path: res.data.video_path ?? record.video_path ?? undefined,
|
||||||
|
videoUrl: res.data.videoUrl ?? record.videoUrl ?? undefined,
|
||||||
|
videoPath: res.data.videoPath ?? record.videoPath ?? undefined,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// 沒有 formId,直接把列表那筆 record(含 video_url)丟進去
|
||||||
updateEditRecord({
|
updateEditRecord({
|
||||||
...record,
|
...record,
|
||||||
uuid: record.id,
|
uuid: record.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
alert_action_item.showModal();
|
alert_action_item.showModal();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error opening modal:", error);
|
console.error("Error opening modal:", error);
|
||||||
|
@ -18,28 +18,7 @@ const { t } = useI18n();
|
|||||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
editRecord: Object,
|
editRecord: { type: Object, default: null },
|
||||||
});
|
|
||||||
|
|
||||||
/** ================= Debug Helpers ================= */
|
|
||||||
const debugLog = (label, payload) => {
|
|
||||||
try {
|
|
||||||
console.log(
|
|
||||||
`[AlertActionItem] ${label}:`,
|
|
||||||
JSON.parse(JSON.stringify(payload))
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(`[AlertActionItem] ${label}:`, payload);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 初始就印出整個 props 與 editRecord 內容
|
|
||||||
debugLog("props", props);
|
|
||||||
debugLog("initial props.editRecord", props?.editRecord);
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
debugLog("onMounted props", props);
|
|
||||||
debugLog("onMounted props.editRecord", props?.editRecord);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const form = ref(null);
|
const form = ref(null);
|
||||||
@ -94,8 +73,6 @@ const updateFileList = (files) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------- 告警影片儲存位置:顯示 API 的 video_url ----------------------
|
// ---------------------- 告警影片儲存位置:顯示 API 的 video_url ----------------------
|
||||||
// 重要:你的 <Input name="videoLocation" :value="..."> 會從 value[name] 取值
|
|
||||||
// 所以我們把 videoLocation 寫成 { videoLocation: string } 的物件
|
|
||||||
const videoLocation = ref({ videoLocation: "" });
|
const videoLocation = ref({ videoLocation: "" });
|
||||||
const showTooltip = ref(false);
|
const showTooltip = ref(false);
|
||||||
|
|
||||||
@ -188,7 +165,6 @@ const onCancel = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.editRecord,
|
() => props.editRecord,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
debugLog("watch props.editRecord changed", newVal);
|
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
for (let [key, value] of Object.entries(newVal)) {
|
for (let [key, value] of Object.entries(newVal)) {
|
||||||
if (key in formState.value) {
|
if (key in formState.value) {
|
||||||
@ -206,7 +182,6 @@ watch(
|
|||||||
// 取 API 回傳的影片位址(與 device_number 同來源物件)
|
// 取 API 回傳的影片位址(與 device_number 同來源物件)
|
||||||
videoLocation.value.videoLocation =
|
videoLocation.value.videoLocation =
|
||||||
newVal?.video_url ?? newVal?.videoUrl ?? newVal?.video_path ?? "";
|
newVal?.video_url ?? newVal?.videoUrl ?? newVal?.video_path ?? "";
|
||||||
debugLog("derived videoLocation", videoLocation.value.videoLocation);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
@ -218,7 +193,7 @@ watch(
|
|||||||
id="alert_action_item"
|
id="alert_action_item"
|
||||||
:title="t('alert.repair_order')"
|
:title="t('alert.repair_order')"
|
||||||
:onCancel="onCancel"
|
:onCancel="onCancel"
|
||||||
width="710"
|
:width="710"
|
||||||
>
|
>
|
||||||
<template #modalContent>
|
<template #modalContent>
|
||||||
<form
|
<form
|
||||||
|
@ -43,7 +43,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.loadRtspDevices();
|
await this.loadRtspDevices();
|
||||||
// ★ 設定近 7 天並立即查一次
|
// 設定近 7 天並立即查一次
|
||||||
this.setLast7Days();
|
this.setLast7Days();
|
||||||
if (this.selectedMainId) {
|
if (this.selectedMainId) {
|
||||||
await this.searchLogs();
|
await this.searchLogs();
|
||||||
@ -66,7 +66,7 @@ export default {
|
|||||||
.toISOString()
|
.toISOString()
|
||||||
.slice(0, 10);
|
.slice(0, 10);
|
||||||
},
|
},
|
||||||
// ★ 將查詢區間設為「近 7 天」
|
// 將查詢區間設為「近 7 天」
|
||||||
setLast7Days() {
|
setLast7Days() {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
|
Loading…
Reference in New Issue
Block a user