Jelajahi Sumber

Merge branch 'master' of http://git.xt.wenhq.top:8083/hs/JtjAi

wenhongquan 3 bulan lalu
induk
melakukan
f101ab0439

+ 24 - 13
plus-ui-ts/src/views/index.vue

@@ -288,7 +288,7 @@
     </el-dialog>
   </div>
 </template>
-<script setup lang="ts">
+<script setup>
 import { Search } from '@element-plus/icons-vue';
 import BaseChart from '@/components/BaseChart/index.vue';
 import monitorIcon from '@/assets/images/monitor.svg';
@@ -317,8 +317,8 @@ const marks = ref([
     latitude: 32.01094988629638
   }
 ]);
-const { event_level } = toRefs<any>(proxy?.useDict('event_level'));
-const { event_status } = toRefs<any>(proxy?.useDict('event_status'));
+const { event_level } = toRefs(proxy?.useDict('event_level'));
+const { event_status } = toRefs(proxy?.useDict('event_status'));
 const editorRef = shallowRef();
 const editorConfig = { placeholder: '请输入内容...' };
 // 内容 HTML
@@ -345,7 +345,7 @@ const dialog = reactive({
   title: '事件详情',
   loading: null
 });
-const form = ref<any>({});
+const form = ref({});
 const statData = reactive({
   monthCount: undefined,
   monthAlready: undefined,
@@ -477,11 +477,7 @@ onMounted(() => {
       console.log(e.latlng);
     });
     showMarks();
-
-  }catch (e) {
-
-  }
-
+  } catch (e) {}
 
   getList();
   getStat();
@@ -496,7 +492,7 @@ const getList = async () => {
     queryParams.value.params.endCreateTime = undefined;
   }
   const res = await listEvent(queryParams.value);
-  eventList.value = res.rows.map((item: any) => ({
+  eventList.value = res.rows.map((item) => ({
     ...item,
     status: item.status || '2',
     createTimeFormat: dateFormat(new Date(item.createTime), 'yyyy-MM-dd'),
@@ -544,7 +540,7 @@ const getStat = async () => {
   statData.not = res.rows.filter((item) => item.status == '2' || item.status === null).length;
   statData.report = res.rows.filter((item) => item.status == '3').length;
 };
-const getTimeRange = (unit = 'day', options: any = {}) => {
+const getTimeRange = (unit = 'day', options = {}) => {
   const now = new Date();
   const { firstDayOfWeek = 1 } = options;
 
@@ -744,11 +740,23 @@ const generateClick = () => {
     }
   });
 };
+const extractDate = (dateStr) => {
+  // 统一处理两种格式的正则表达式
+  const match = dateStr.match(/(\d{4})[^\d]*(\d{1,2})[^\d]*(\d{1,2})/);
+
+  if (!match) return null;
+
+  return {
+    year: parseInt(match[1]),
+    month: parseInt(match[2]),
+    day: parseInt(match[3])
+  };
+};
 const dealReportData = async (reportHtml, time) => {
   const res = await proxy?.getConfigKey('report_seq');
   reportSeq.value = Number(res.data);
   valueHtml.value = reportHtml;
-  const [year, month, day] = time.split(' ')[0].split('-');
+  const { year, month, day } = extractDate(time);
   reportForm.year = year;
   reportForm.month = month;
   reportForm.day = day;
@@ -776,7 +784,10 @@ const htmlToPdfFn = async () => {
       reportForm.title = title;
       reportForm.content = contents.join('');
       //import.meta.env.VITE_APP_ENV === 'development' ? 'loadFile/generate' :
-      const url = `${import.meta.env.VITE_APP_BASE_HOST}/generate`;
+      let url = `${import.meta.env.VITE_APP_BASE_HOST}/generate`;
+      if (import.meta.env.DEV) {
+        url = 'loadFile/generate';
+      }
       downloadFile(url, {
         method: 'POST',
         data: reportForm,

+ 1 - 0
uni-jtjai/package.json

@@ -66,6 +66,7 @@
     "@wangeditor/editor-for-vue": "^5.1.12",
     "axios": "^1.6.8",
     "dplayer": "^1.27.1",
+    "crypto-js": "4.2.0",
     "echarts": "^5.6.0",
     "file-saver": "^2.0.5",
     "html-docx-js-typescript": "^0.1.5",

+ 8 - 0
uni-jtjai/pnpm-lock.yaml

@@ -71,6 +71,9 @@ importers:
       axios:
         specifier: ^1.6.8
         version: 1.9.0
+      crypto-js:
+        specifier: 4.2.0
+        version: 4.2.0
       dplayer:
         specifier: ^1.27.1
         version: 1.27.1
@@ -2942,6 +2945,9 @@ packages:
     resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
     engines: {node: '>= 8'}
 
+  crypto-js@4.2.0:
+    resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}
+
   css-font-size-keywords@1.0.0:
     resolution: {integrity: sha512-Q+svMDbMlelgCfH/RVDKtTDaf5021O486ZThQPIpahnIjUkMUslC+WuOQSWTgGSrNCH08Y7tYNEmmy0hkfMI8Q==}
 
@@ -10286,6 +10292,8 @@ snapshots:
       shebang-command: 2.0.0
       which: 2.0.2
 
+  crypto-js@4.2.0: {}
+
   css-font-size-keywords@1.0.0: {}
 
   css-font-stretch-keywords@1.0.1: {}

+ 7 - 0
uni-jtjai/src/api/modules/event.js

@@ -23,6 +23,13 @@ export default {
       method: 'get'
     })
   },
+  API_EVENT_UPDATE(data) {
+    return request({
+      url: '/system/event',
+      method: 'put',
+      data
+    })
+  },
   API_EVENT_GEN(id) {
     return request({
       url: `/system/event/generate/${id}`,

+ 1 - 1
uni-jtjai/src/pages/index/index.vue

@@ -569,7 +569,7 @@
   }
   const showDetails = (row) => {
     uni.navigateTo({
-      url: `/pages/index/info?event=${JSON.stringify(row)}`
+      url: `/pages/index/info?id=${row.id}`
     })
   }
   const initPieChart = () => {

+ 69 - 31
uni-jtjai/src/pages/index/info.vue

@@ -122,9 +122,11 @@
   import DPlayer from 'dplayer'
   import { useMessage, useToast } from 'wot-design-uni'
   import { downloadFile } from '@/utils/download.js'
+  import { encodeBase64, decodeBase64 } from '@/utils/cryptoJs.js'
   const message = useMessage('wd-message-box-slot')
   const toast = useToast()
-  const { API_EVENT_GEN, API_CONFIG_GET, API_CONFIG_UPDATE } = useRequest()
+  const { API_EVENT_GEN, API_EVENT_GET, API_EVENT_UPDATE, API_CONFIG_GET, API_CONFIG_UPDATE } =
+    useRequest()
   const editorCtx = ref({})
   const valueHtml = ref('')
   const reportFormRef = ref(null)
@@ -173,27 +175,39 @@
     type: 'pdf'
   })
   onLoad(async (data) => {
-    form.value = JSON.parse(data.event)
-    let imgList = []
-    let videoList = []
-    if (form.value.ext1 && form.value.ext1.length) {
-      videoList = form.value.ext1
-        .filter((item) => item.includes('mp4'))
-        .map((item) => `http://jtjai.xt.wenhq.top:8083/api/oss/local/upload/${item}`)
-      imgList = form.value.ext1
-        .filter((item) => !item.includes('mp4'))
-        .map((item) => `http://jtjai.xt.wenhq.top:8083/api/oss/local/upload/${item}`)
-    }
-    Object.assign(form.value, { imgList, videoList })
-    nextTick(() => {
-      form.value.videoList.forEach((item, index) => {
-        new DPlayer({
-          container: document.getElementById(`dplayer${index}`),
-          video: {
-            url: item
-          }
+    API_EVENT_GET(data.id).then(({ code, data }) => {
+      if (code === 200) {
+        data.ext1 = JSON.parse(data.ext1) || []
+        data.ext2 = JSON.parse(data.ext2) || {}
+        data.status = data.status || '2'
+        let imgList = []
+        let videoList = []
+        if (data.ext1 && data.ext1.length) {
+          videoList = data.ext1
+            .filter((item) => item.includes('mp4'))
+            .map((item) => `${import.meta.env.VITE_APP_API_BASEURL}/api/oss/local/upload/${item}`)
+          imgList = data.ext1
+            .filter((item) => !item.includes('mp4'))
+            .map((item) => `${import.meta.env.VITE_APP_API_BASEURL}/api/oss/local/upload/${item}`)
+        }
+        form.value = data
+        Object.assign(form.value, { imgList, videoList })
+        nextTick(() => {
+          form.value.videoList.forEach((item, index) => {
+            new DPlayer({
+              container: document.getElementById(`dplayer${index}`),
+              video: {
+                url: item
+              }
+            })
+          })
         })
-      })
+        const { content, ext2 } = form.value
+        if (content) {
+          showReport.value = true
+          dealReportData(decodeBase64(content), ext2.reportTime)
+        }
+      }
     })
   })
   const generateClick = () => {
@@ -203,23 +217,47 @@
       if (code === 200 && msg) {
         showReport.value = true
         const { report, time } = JSON.parse(msg).data.outputs
-        const res = await API_CONFIG_GET('report_seq')
-        reportSeq.value = Number(res.data)
-        valueHtml.value = report.replace(/```/g, '').replace(/html\n/, '')
-        const [year, month, day] = time.split(' ')[0].split('-')
-        reportForm.year = year
-        reportForm.month = month
-        reportForm.day = day
-        reportForm.seq = reportSeq.value
-        editorCtx.value.setContents({
-          html: valueHtml.value
+        const reportHtml = report.replace(/```/g, '').replace(/html\n/, '')
+        API_EVENT_UPDATE({
+          id: form.value.id,
+          content: encodeBase64(reportHtml),
+          ext2: JSON.stringify({
+            ...form.value.ext2,
+            reportTime: time
+          })
         })
+        dealReportData(reportHtml, time)
         toast.success('报告生成成功')
       } else {
         toast.error('报告生成失败')
       }
     })
   }
+  const extractDate = (dateStr) => {
+    // 统一处理两种格式的正则表达式
+    const match = dateStr.match(/(\d{4})[^\d]*(\d{1,2})[^\d]*(\d{1,2})/)
+
+    if (!match) return null
+
+    return {
+      year: parseInt(match[1]),
+      month: parseInt(match[2]),
+      day: parseInt(match[3])
+    }
+  }
+  const dealReportData = async (reportHtml, time) => {
+    const res = await API_CONFIG_GET('report_seq')
+    reportSeq.value = Number(res.data)
+    valueHtml.value = reportHtml
+    const { year, month, day } = extractDate(time)
+    reportForm.year = year
+    reportForm.month = month
+    reportForm.day = day
+    reportForm.seq = reportSeq.value
+    editorCtx.value.setContents({
+      html: valueHtml.value
+    })
+  }
   const extractTitleAndContents = (htmlString) => {
     // 提取标题(从 <h2><strong> 中获取)
     const titleMatch = htmlString.match(/<h2[^>]*>.*?<strong>(.*?)<\/strong>.*?<\/h2>/is)

+ 10 - 0
uni-jtjai/src/utils/cryptoJs.js

@@ -0,0 +1,10 @@
+import CryptoJS from 'crypto-js'
+
+// base64加密
+export const encodeBase64 = (text) => {
+  return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text))
+}
+// base64解密
+export const decodeBase64 = (text) => {
+  return CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(text)).toString()
+}