瀏覽代碼

add unit_json export

xyh123999 2 年之前
父節點
當前提交
0c164ecf7e
共有 1 個文件被更改,包括 70 次插入8 次删除
  1. 70 8
      src/views/onlineForm/formRender/onlineFormMixins.js

+ 70 - 8
src/views/onlineForm/formRender/onlineFormMixins.js

@@ -1,12 +1,14 @@
 import { mapMutations } from 'vuex';
 import * as StaticDict from '@/staticDict';
+import { getToken } from '@/utils';
 import rules from '@/utils/validate.js';
 import { getOperationPermCode } from '../utils/index.js';
 import OnlineForm from '@/views/onlineForm/index.vue';
 import {
   OnlineFormController
 } from '@/api/onlineController.js';
-
+import axios from 'axios';
+import { uploadMixin } from '@/core/mixins';
 const OnlineFormMixins = {
   props: {
     formId: {
@@ -25,11 +27,14 @@ const OnlineFormMixins = {
       type: Object
     }
   },
+  mixins: [uploadMixin],
   data () {
     return {
       isLoading: true,
       formData: {},
       rules: {},
+      components_json:{},
+      component_movementjson:{},
       formConfig: {
         formType: undefined,
         formKind: undefined,
@@ -646,7 +651,7 @@ const OnlineFormMixins = {
         }
       }
     },
-    handlerOperation (operation, row, widget) {
+    async handlerOperation (operation, row, widget) {
       if (this.preview()) return;
       if (operation.formId != null) {
         OnlineFormController.view(this, {
@@ -773,15 +778,71 @@ const OnlineFormMixins = {
           }).catch(e => {});
         } else if (operation.type === this.SysCustomWidgetOperationType.EXPORT) {
          console.log('row :>> ', row);
-         console.log(' 导出成功');
-         //todo 找导出json文件的工具在此导出 以想定名称为文件名
+         let fileInfoStr = row.component_movementjson;
+         let fileInfoArr = JSON.parse(fileInfoStr);
+         let fileInfo = fileInfoArr[0]; // 假设只有一个文件
+       await  axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit',{
+          params:{
+            datasourceId: '1657931215497334784',
+            fieldName: 'component_movementjson',
+            asImage: false,
+            dataId: '1657943277879431168',
+            filename: 'db512fe1891042219ec61641625354da.json',
+            Authorization:  getToken(),
+            MenuId: '1657932967709773824'
+          }
+         })
+        .then(response => {
+           // 处理成功的响应
+           this.component_movementjson = response.data;
+                 })
+                .catch(error => {
+               // 处理错误
+               console.error(error);
+               });
+
+               fileInfoStr = row.components_json               ;
+              fileInfoArr = JSON.parse(fileInfoStr);
+              fileInfo = fileInfoArr[0]; // 假设只有一个文件
+           await    axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit',{
+                params:{
+                  datasourceId: '1657931215497334784',
+                  fieldName: 'components_json',
+                  asImage: false,
+                  dataId: '1657943277879431168',
+                  filename: fileInfo.filename,
+                  Authorization:  getToken(),
+                  MenuId: '1657932967709773824'
+                }
+               })
+              .then(response => {
+                 // 处理成功的响应
+                this.components_json = response.data;
+                       })
+                      .catch(error => {
+                     // 处理错误
+                     console.error(error);
+                     });
+                     console.log('components_json :>> ', this.components_json);
+                     console.log('component_movementjson :>> ', this.component_movementjson);
          const data = {
-          name: 'John',
-          age: 30,
-          email: 'john.doe@example.com',
+          id: row.id,
+          name: row.name,
+          type: row.type,
+          creator: row.creator,
+          createtime: row.createtime,
+          belong: row.belong,
+          health: row.health,
+          target: row.target,
+          team: row.team,
+          task: row.task,
+          component_movementid: row.component_movementid,
+          component_movementjson: this.component_movementjson,
+          components_cnt: row.components_cnt,
+          components_ids:row.components_ids,
+          components_json:this.components_json
         };
         const jsonData = JSON.stringify(data);
-        
         const blob = new Blob([jsonData], { type: 'application/json' });
         const url = URL.createObjectURL(blob);
         
@@ -804,6 +865,7 @@ const OnlineFormMixins = {
         })
       }
     },
+  
     getRelationTableData (tableWidget) {
       if (tableWidget.widgetType === this.SysCustomWidgetType.Table) {
         let table = tableWidget.table;