|
@@ -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)
|