浏览代码

excel导入代理调整

CzRger 4 周之前
父节点
当前提交
979bc5bc7c
共有 2 个文件被更改,包括 20 次插入14 次删除
  1. 8 1
      src/views/form/business-model/excel-import.vue
  2. 12 13
      src/views/form/business-model/index.vue

+ 8 - 1
src/views/form/business-model/excel-import.vue

@@ -33,6 +33,7 @@
               :disabled="upload.isUploading"
               :on-progress="() => (upload.isUploading = true)"
               :on-success="handleFileSuccess"
+              :on-error="handleFileError"
               :before-upload="handleBeforeUpload"
               :auto-upload="false"
               :data="upload.data"
@@ -75,6 +76,7 @@ const state: any = reactive({
   loading: false,
   tempVal: '',
   uploaded: false,
+  apiProxy: inject('ApiProxy'),
 })
 const ref_upload = ref()
 /*** 用户导入参数 */
@@ -89,7 +91,7 @@ const upload = reactive({
     apiname: import.meta.env.VITE_API_NAME,
   },
   // 上传的地址
-  url: `${inject('ApiProxy')}/api/blade-dcms/hazardouschemicalscatalog/parseBusinessScope`,
+  url: `${state.apiProxy}/api/blade-dcms/hazardouschemicalscatalog/parseBusinessScope`,
 })
 watch(
   () => props.show,
@@ -127,6 +129,11 @@ const handleBeforeUpload = () => {
   })
 }
 /** 文件上传成功处理 */
+const handleFileError = (error) => {
+  ElMessage.error(error.message)
+  upload.isUploading = false
+}
+/** 文件上传成功处理 */
 const handleFileSuccess = (res, file, fileList) => {
   console.log(res, file, fileList)
   ElMessageBox.confirm(

+ 12 - 13
src/views/form/business-model/index.vue

@@ -339,7 +339,7 @@ onBeforeMount(() => {
   // ApisObject.config 接⼝配置信息 Object
   window.addEventListener('message', (e) => {
     const data = e.data
-    console.log(data)
+    console.log('二级表单接收到的数据:', data)
     if (data.type === 'getFormIframeData') {
       const { formItem, formData, userData, apis, payload } = data.data
       state.formMessage = JSON.parse(JSON.stringify(data.data))
@@ -361,18 +361,17 @@ onMounted(() => {
 })
 const initDictionary = () => {}
 const onConfirmIframe = (msgData) => {
-  window.parent.postMessage(
-    {
-      type: 'onConfirmIframe',
-      data: JSON.parse(
-        JSON.stringify({
-          ...state.formMessage,
-          msgData, // ⼆级⻚⾯数据
-        }),
-      ),
-    },
-    '*',
-  )
+  const send = {
+    type: 'onConfirmIframe',
+    data: JSON.parse(
+      JSON.stringify({
+        ...state.formMessage,
+        msgData: JSON.parse(JSON.stringify(msgData)), // ⼆级⻚⾯数据
+      }),
+    ),
+  }
+  console.log('二级表单发送的数据', send)
+  window.parent.postMessage(send, '*')
 }
 const onCloseIframe = () => {
   window.parent.postMessage(