zhengnaiwen_citu пре 3 месеци
родитељ
комит
025925f7dc

+ 3 - 3
src/api/dataOrigin.js

@@ -34,8 +34,8 @@ export function businessCardParse (data) {
 }
 
 // 非结构化数据源 更新名片
-export function updateBusinessCard (data) {
-  return http.put('/parse/business-cards', data)
+export function updateBusinessCard (data, id) {
+  return http.put(`/parse/business-cards/${id}`, data)
 }
 
 // 非结构化数据源 获取名片列表
@@ -50,5 +50,5 @@ export function updateBusinessCardStatus (data, id) {
 
 // 非结构化数据源 获取名片图片
 export function getBusinessCardImage (path) {
-  return http.defaultBlob(`/business-cards/image/${path}`, undefined, 'get')
+  return http.download(`/parse/business-cards/image/${path}`, undefined, 'get')
 }

+ 2 - 11
src/utils/request.js

@@ -112,23 +112,14 @@ const http = {
       }
     })
   },
-  download (url, params) {
-    return service.post(url, params, {
+  download (url, params, method = 'post') {
+    return service[method](url, params, {
       timeout: 10000,
       headers: {
         'Content-Type': 'application/json'
       },
       responseType: 'blob'
     })
-  },
-  defaultBlob (url, params, method = 'post', config = {
-    timeout: 10000,
-    headers: {
-      'Content-Type': 'application/json'
-    },
-    responseType: 'blob'
-  }) {
-    return service[method](url, params, config)
   }
 }
 export default http

+ 10 - 6
src/views/dataOrigin/unstructuredData/manualCollection/components/imageImportEdit.vue

@@ -125,10 +125,11 @@ import UploadBtn from '@/components/UploadBtn'
 import MDialog from '@/components/Dialog'
 import MCard from '@/components/MCard'
 import MForm from '@/components/MForm'
+// import { toBase64 } from '@/utils/file'
 import {
   businessCardParse,
   getBusinessCardImage,
-  updateBusinessCardStatus
+  updateBusinessCard
 } from '@/api/dataOrigin'
 export default {
   name: 'imageImportEdit',
@@ -207,10 +208,13 @@ export default {
       }
       // this.file = item.image_path
       try {
-        const { data } = await getBusinessCardImage(item.image_path)
-        this.file = data
-        this.previewUrl = new Blob([data], { type: 'image/jpeg' })
-        this.handlePreview(this.file)
+        const { data, name } = await getBusinessCardImage(item.image_path)
+        // const type = item.image_path.split('.').pop()
+        this.file = new File([data], name ?? item.image_path, { type: data.type })
+        // handleReadFile(data, type, files => {
+        //   // 返回blob
+        this.previewUrl = URL.createObjectURL(data)
+        // })
       } catch (error) {
         this.$snackbar.error(error)
       }
@@ -256,7 +260,7 @@ export default {
       }
       Object.assign(this.itemData, this.formQuery)
       try {
-        await updateBusinessCardStatus(this.itemData, this.id)
+        await updateBusinessCard(this.itemData, this.id)
         this.$snackbar.success('更新成功')
       } catch (error) {
         this.$snackbar.error(error)