Bladeren bron

新任命入库回显

Xiao_123 2 maanden geleden
bovenliggende
commit
b4f53d5bda
1 gewijzigde bestanden met toevoegingen van 25 en 15 verwijderingen
  1. 25 15
      src/views/menduner/system/talentMap/maintenance/gather/components/store.vue

+ 25 - 15
src/views/menduner/system/talentMap/maintenance/gather/components/store.vue

@@ -109,7 +109,7 @@ const showPage = (html) => {
   html = html.replace(/data-src/g, 'src')
     .replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/g, '')
     .replace(/https/g, 'http')
-  
+
   nextTick(() => {
     const iframe = document.getElementById('MyIframe')
     if (!iframe) return
@@ -125,16 +125,17 @@ const showPage = (html) => {
     let iwindow = iframe.contentWindow;
     iframe.addEventListener('load',function () {
       let idoc = iwindow.document;
-      let img = idoc.getElementsByTagName('img')[0];
-      if (img) {
-        if (img.width >= img.height) {
-          img.width = iframe.clientWidth / 2
-          let top = (iframe.clientHeight - img.height) / 2
-          img.style.marginTop = top + "px"
-        } else {
-          img.height = iframe.clientHeight / 2
-          let left = (iframe.clientWidth - img.width) / 2
-          img.style.marginLeft = left + "px"
+      let imgs = idoc.getElementsByTagName('img')
+      for (let i in imgs) {
+        const img = imgs[i]
+        if (img) {
+          if (img.width >= img.height) {
+            img.width = iframe.clientWidth / 2
+          } else {
+            img.height = iframe.clientHeight / 2
+            let left = (iframe.clientWidth - img.width) / 2
+            img.style.marginLeft = left + "px"
+          }
         }
       }
     })
@@ -155,7 +156,19 @@ const dealData = async (type, data) => {
   }
   if (type === '新任命') {
     await nextTick()
-    showPage(marked(data.originText))
+    const response = await fetch(data.minio_path)
+    const text = await response.text()
+
+    const doc = `
+      <!DOCTYPE html>
+      <html class="">
+        <head></head>
+        <body>
+          ${marked(text)}
+        </body>
+      </html>
+    `
+    showPage(doc)
   }
 }
 
@@ -232,8 +245,6 @@ const handleTagClick = (index) => {
 // 监听表单变化,同步更新originData中对应的数据
 watch(() => FormPageRef.value?.formQuery, (newVal) => {
   if (tagCurrentIndex.value !== null && originData.value && originData.value.length > tagCurrentIndex.value) {
-    // 保留原始pic_url
-    // const { pic_url } = originData.value[tagCurrentIndex.value]
     originData.value[tagCurrentIndex.value].data = { ...newVal }
   }
 }, { deep: true })
@@ -256,7 +267,6 @@ const handleStore = async () => {
       if (tagList.value[i].checked) results.push(talent) // 只提交勾选的数据
     }
   }
-  // console.log(originData.value, 'store')
 
   await message.confirm('是否对当前选中的人才进行入库?')