luogang hace 2 meses
padre
commit
c86f260f37
Se han modificado 2 ficheros con 65 adiciones y 22 borrados
  1. 2 1
      plus-ui-ts/src/views/device/event/index.vue
  2. 63 21
      plus-ui-ts/src/views/index.vue

+ 2 - 1
plus-ui-ts/src/views/device/event/index.vue

@@ -51,7 +51,8 @@
           <template #default="{ row }">
             <span v-if="row.status == 3" style="color: #5f86fd">已上报</span>
             <span v-else-if="row.status == 1" style="color: #26c768">已解决</span>
-            <span v-else style="color: #ff6124">未解决</span>
+            <span v-else-if="row.status == 2" style="color: #ff6124">未解决</span>
+            <span v-else>{{ event_status.filter((item) => item.value == row.status)[0]?.label }}</span>
           </template>
         </el-table-column>
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width">

+ 63 - 21
plus-ui-ts/src/views/index.vue

@@ -140,7 +140,8 @@
             <template #default="{ row }">
               <span v-if="row.status == 3" style="color: #5f86fd">已上报</span>
               <span v-else-if="row.status == 1" style="color: #26c768">已解决</span>
-              <span v-else style="color: #ff6124">未解决</span>
+              <span v-else-if="row.status == 2" style="color: #ff6124">未解决</span>
+              <span v-else>{{ event_status.filter((item) => item.value == row.status)[0]?.label }}</span>
             </template>
           </el-table-column>
           <el-table-column width="60">
@@ -163,6 +164,12 @@
       </div>
     </div>
     <el-dialog v-model="dialog.visible" :title="dialog.title" width="1000px" top="0" append-to-body @close="dialogClose">
+      <template #title>
+        <div style="display: flex; justify-content: space-between; align-items: center; padding-right: 30px">
+          <span>事件详情</span>
+          <el-button @click="saveClick">保存</el-button>
+        </div>
+      </template>
       <div class="dialog-loading-warp">
         <el-form ref="addFormRef" :model="form" label-position="top" label-width="90px" label-suffix=":">
           <el-row :gutter="20">
@@ -327,6 +334,7 @@ const handleCreated = (editor) => {
 };
 const showReport = ref(false);
 const reportFormRef = ref(null);
+const reportTime = ref('');
 const queryParams = ref({
   pageNum: 1,
   pageSize: 15,
@@ -749,7 +757,7 @@ const showDetails = (row) => {
         });
       });
       const { content, ext2 } = form.value;
-      if (content && ext2.reportTime) {
+      if (content && base64Decoded(content) && ext2.reportTime) {
         showReport.value = true;
         dealReportData(base64Decoded(content), ext2.reportTime);
       }
@@ -771,6 +779,7 @@ const generateClick = () => {
       showReport.value = true;
       const { report, time } = JSON.parse(msg).data.outputs;
       const reportHtml = report.replace(/```/g, '').replace(/html\n/, '');
+      reportTime.value = time;
       updateEvent({
         id: form.value.id,
         content: base64Encoded(reportHtml),
@@ -786,6 +795,40 @@ const generateClick = () => {
     }
   });
 };
+const saveClick = async () => {
+  const { ext2, createTime, level, status, addr } = form.value;
+  const params = {
+    id: form.value.id,
+    createTime,
+    level,
+    status,
+    addr,
+    ext2: JSON.stringify({
+      ...ext2
+    })
+  };
+  if (showReport.value) {
+    let htmlcontent = '';
+    const text = editorRef.value.getText();
+    if (text) {
+      htmlcontent = editorRef.value.getHtml();
+    }
+    await updateEvent({
+      ...params,
+      content: base64Encoded(htmlcontent),
+      ext2: JSON.stringify({
+        ...ext2,
+        reportTime: reportTime.value
+      })
+    });
+  } else {
+    await updateEvent(params);
+  }
+  getList();
+  getStat();
+  getEventTypeOptions();
+  proxy?.$modal.msgSuccess('保存成功');
+};
 const extractDate = (dateStr) => {
   // 统一处理两种格式的正则表达式
   const match = dateStr.match(/(\d{4})[^\d]*(\d{1,2})[^\d]*(\d{1,2})/);
@@ -855,25 +898,24 @@ const dialogClose = () => {
   dialog.loading && dialog.loading.close();
 };
 const formSubmit = async (field, obj = '') => {
-  const { id } = form.value;
-  const params = {
-    id
-  };
-  if (obj) {
-    params[obj] = form.value[obj];
-    params[obj] = JSON.stringify(params[obj]);
-  } else {
-    params[field] = form.value[field];
-  }
-
-  await updateEvent(params);
-  getList();
-  if (field === 'status') {
-    getStat();
-  }
-  if (field === 'ext2.lx') {
-    getEventTypeOptions();
-  }
+  // const { id } = form.value;
+  // const params = {
+  //   id
+  // };
+  // if (obj) {
+  //   params[obj] = form.value[obj];
+  //   params[obj] = JSON.stringify(params[obj]);
+  // } else {
+  //   params[field] = form.value[field];
+  // }
+  // await updateEvent(params);
+  // getList();
+  // if (field === 'status') {
+  //   getStat();
+  // }
+  // if (field === 'ext2.lx') {
+  //   getEventTypeOptions();
+  // }
 };
 </script>
 <style lang="scss" scoped>