Browse Source

添加上传文件

tangning 3 years ago
parent
commit
ec14c9dbe8

+ 7 - 1
index.html

@@ -8,10 +8,16 @@
       name="viewport"
       content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
     />
-
     <title><%= title %></title>
     <link rel="icon" href="/favicon.ico" />
+    <script async defer
+    data-app-id="7b5958d5-1ae6-4ad5-8a87-5fc8a4b92999" 
+    data-url="http://192.168.0.186:3000/api/collect" 
+    data-track-url="'http://192.168.0.186:3000/api/track" 
+    src="https://allreally.oss-cn-shenzhen.aliyuncs.com/wasm/test_legacy/medici.js">
+   </script>
   </head>
+
   <body>
     <script>
       (() => {

+ 8 - 5
src/api/order/index.ts

@@ -7,7 +7,7 @@ import {
   updateParams,
   getItemParams,
 } from './model';
-import { Result, UploadFileParams } from '/#/axios';
+import { Result, UploadFileParams, FileStream } from '/#/axios';
 
 enum Api {
   cameraList = '/newV4/service/manage/order/camera/list',
@@ -58,7 +58,7 @@ export const CameraItem = (params: getItemParams) =>
  */
 
 export const CameraExport = (params: PageParams) =>
-  defHttp.downloadFile<Result>({
+  defHttp.downloadFile<FileStream>({
     url: Api.cameraExport,
     params: params,
     // data: params,
@@ -74,7 +74,7 @@ export const CameraExport = (params: PageParams) =>
  */
 
 export const IncrementExport = (params: PageParams) =>
-  defHttp.get<Result>({
+  defHttp.downloadFile<FileStream>({
     url: Api.incrementExport,
     params: params,
     // data: params,
@@ -82,6 +82,7 @@ export const IncrementExport = (params: PageParams) =>
       // @ts-ignore
       ignoreCancelToken: true,
     },
+    responseType: 'blob'
   });
 
 export const IncrementList = (params: PageParams) =>
@@ -96,7 +97,7 @@ export const IncrementList = (params: PageParams) =>
   });
 
 export const DownExport = (params: PageParams) =>
-  defHttp.get<Result>({
+  defHttp.downloadFile<FileStream>({
     url: Api.downExport,
     params: params,
     // data: params,
@@ -104,6 +105,7 @@ export const DownExport = (params: PageParams) =>
       // @ts-ignore
       ignoreCancelToken: true,
     },
+    responseType: 'blob'
   });
 
 export const DownList = (params: PageParams) =>
@@ -127,13 +129,14 @@ export const InvoiceList = (params: PageParams) =>
   });
 
 export const InvoiceExport = (params: PageParams) =>
-  defHttp.post<InvoiceListResul>({
+  defHttp.downloadFile<FileStream>({
     url: Api.exportInvoice,
     params,
     headers: {
       // @ts-ignore
       ignoreCancelToken: true,
     },
+    responseType: 'blob'
   });
 
 export const InvoiceDetail = (params: PageParams) =>

+ 18 - 18
src/views/customer/modal/InfoModal.vue

@@ -77,7 +77,7 @@
           componentProps: {
             placeholder: '请输入',
             maxLength: 15,
-            onChange: (data) => {
+            onChange: () => {
               // console.log('data', data);
             },
           },
@@ -93,12 +93,13 @@
           componentProps: {
             placeholder: '请输入内容',
             maxLength: 200,
-            onChange: (data) => {
+            onChange: () => {
               // console.log('data', data);
             },
           },
         },
         {
+          field: 'topLogo',
           component: 'Divider',
           label: 'Logo信息',
           colProps: {
@@ -114,12 +115,9 @@
             api: uploadApi,
             maxNumber: 1,
             maxSize: 5,
-            fileFlow: true,
             accept: ['jpg', 'png'],
             afterFetch: function (data) {
-              console.log('uploadApi', data);
-              // Reflect.set(data, 'url', data.file);
-              // fileFlow.file = data.file;
+              Reflect.set(data, 'url', data.data);
               return data;
             },
           },
@@ -136,12 +134,9 @@
             api: uploadApi,
             maxNumber: 1,
             maxSize: 5,
-            fileFlow: true,
             accept: ['jpg', 'png'],
-            afterFetch: function (data) {
-              console.log('uploadApi', data);
-              // Reflect.set(data, 'url', data.file);
-              // fileFlow.file = data.file;
+            afterFetch: function (data) {              
+              Reflect.set(data, 'url', data.data);
               return data;
             },
           },
@@ -158,12 +153,9 @@
             api: uploadApi,
             maxNumber: 1,
             maxSize: 5,
-            fileFlow: true,
             accept: ['jpg', 'png'],
             afterFetch: function (data) {
-              console.log('uploadApi', data);
-              // Reflect.set(data, 'url', data.file);
-              // fileFlow.file = data.file;
+              Reflect.set(data, 'url', data.data);
               return data;
             },
           },
@@ -210,6 +202,9 @@
           modelRef.value = data;
           setFieldsValue({
             ...data,
+            floorLogo:data.floorLogo?[data.floorLogo]:[],
+            qrLogo:data.qrLogo?[data.qrLogo]:[],
+            topLogo:data.topLogo?[data.topLogo]:[],
           });
         }
       });
@@ -224,8 +219,13 @@
       const handleSubmit = async () => {
         try {
           const params = await validate();
-          const apiData = { ...params };
-          const res = await companyAdd(apiData);
+          const apiData = { 
+            ...params,
+            floorLogo:params.floorLogo && params.floorLogo[0],
+            qrLogo:params.qrLogo && params.qrLogo[0],
+            topLogo:params.topLogo && params.topLogo[0],
+           };
+          await companyAdd(apiData);
           closeModal();
           resetFields();
           emit('update');
@@ -234,7 +234,7 @@
           console.log('not passing', error);
         }
       };
-      function handleVisibleChange(v) {
+      function handleVisibleChange(_) {
         // console.log(v);
         // v && props.userData && nextTick(() => onDataReceive(props.userData));
       }

+ 1 - 1
src/views/invoice/index.vue

@@ -148,7 +148,7 @@
           content: () => h('span', '确定导出当前发票所有记录?'),
           onOk: async () => {
            const blodData:BlobPart =  await InvoiceExport(apiData);
-           downloadByData(blodData,'发票记录')
+           downloadByData(blodData.data,'发票记录.xls')
           },
         });
       }

+ 12 - 5
src/views/order/cameraList.vue

@@ -72,7 +72,7 @@
     },
     setup() {
       const { t } = useI18n();
-      const { createMessage } = useMessage();
+      const { createConfirm } = useMessage();
       const expandedItem = reactive({
 
       })
@@ -213,10 +213,17 @@
         console.log('点击了启用', record);
       }
       function exportExcel() {
-        CameraExport().then(res => {
-          console.log('handlerowClick',res)
-          downloadByData(res.data,'test.xls')
-        })
+        createConfirm({
+          iconType: 'warning',
+          title: () => h('span', '温馨提示'),
+          content: () => h('span', '确定导出的订单记录?'),
+          onOk: async () => {
+            CameraExport({}).then(res => {
+              console.log('handlerowClick',res)
+              downloadByData(res.data,'相机订单.xls')
+            })
+          },
+        });
       }
       function handlerowClick(record: Recordable, index, event){
         CameraItem({id:record.id}).then(res => {

+ 7 - 4
src/views/order/downloadList.vue

@@ -36,8 +36,8 @@
   import { Descriptions } from 'ant-design-vue';
   import { useI18n } from '/@/hooks/web/useI18n';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { Switch } from 'ant-design-vue';
   import { DownList,DownExport } from '/@/api/order'
+  import {  downloadByData, } from '/@/utils/file/download';
 
   export default defineComponent({
     components: { 
@@ -50,7 +50,7 @@
     },
     setup() {
       const { t } = useI18n();
-      const { createMessage,createConfirm } = useMessage();
+      const { createConfirm } = useMessage();
       const columns: BasicColumn[] = [
         {
           title: '时间',
@@ -172,9 +172,12 @@
         createConfirm({
           iconType: 'warning',
           title: () => h('span', '温馨提示'),
-          content: () => h('span', '确定当前标签下的订单记录?'),
+          content: () => h('span', '确定导出的订单记录?'),
           onOk: async () => {
-            await DownExport();
+            DownExport({}).then(res => {
+              console.log('handlerowClick',res)
+              downloadByData(res.data,'下载订单.xls')
+            })
           },
         });
       }

+ 5 - 2
src/views/order/equityList.vue

@@ -36,7 +36,7 @@
   import { Descriptions } from 'ant-design-vue';
   import { useI18n } from '/@/hooks/web/useI18n';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { Switch } from 'ant-design-vue';
+  import {  downloadByData, } from '/@/utils/file/download';
   import { IncrementList,IncrementExport } from '/@/api/order'
 
   export default defineComponent({
@@ -174,7 +174,10 @@
           title: () => h('span', '温馨提示'),
           content: () => h('span', '确定当前标签下的订单记录?'),
           onOk: async () => {
-            await IncrementExport();
+            IncrementExport({}).then(res => {
+              console.log('handlerowClick',res)
+              downloadByData(res.data,'权益订单.xls')
+            })
           },
         });
       }

+ 7 - 1
types/axios.d.ts

@@ -30,8 +30,14 @@ export interface Result<T = any> {
   type: 'success' | 'error' | 'warning';
   message: string;
   result: T;
+  data?: T;
+}
+//文件流
+export interface FileStream<T = any> {
+  message: string;
+  result?: BlobPart;
+  data: BlobPart;
 }
-
 // multipart/form-data: upload file
 export interface UploadFileParams {
   // Other parameters