소스 검색

下载模板

lilei 2 년 전
부모
커밋
d42fc7b966
4개의 변경된 파일23개의 추가작업 그리고 15개의 파일을 삭제
  1. 9 0
      src/api/data.js
  2. 4 4
      src/libs/JGPrint.js
  3. 8 9
      src/views/salesReturnManagement/salesReturn/importGuideModal.vue
  4. 2 2
      vue.config.js

+ 9 - 0
src/api/data.js

@@ -155,4 +155,13 @@ export const printLogSave = (params) => {
     data: params,
     method: 'post'
   })
+}
+
+// 下载模板文件
+export const downLoadTemp = (params) => {
+  return axios({
+    url: `downLoad/temp/${params.type}`,
+    method: 'get',
+    responseType: 'blob'
+  })
 }

+ 4 - 4
src/libs/JGPrint.js

@@ -36,7 +36,7 @@ export const JGPrintTag = function (html, width, height, data) {
   LODOP.PRINT()
 }
 // 导出文件
-export const exportExcel = function(url,params,fileName,callback){
+export const exportExcel = function(url,params,fileName,callback,noShowTime){
   url(params).then(res => {
     if (res.type == 'application/json') {
       var reader = new FileReader()
@@ -49,16 +49,16 @@ export const exportExcel = function(url,params,fileName,callback){
       })
       reader.readAsText(res)
     } else {
-       downloadExcel(res,fileName)
+       downloadExcel(res,fileName,noShowTime)
     }
     callback()
   })
 }
 // 下载excel
-export const downloadExcel = function (data, fileName) {
+export const downloadExcel = function (data, fileName, noShowTime) {
   if (!data) { return }
   const a = moment().format('YYYYMMDDHHmmss')
-  const fname = fileName + a
+  const fname = noShowTime ? fileName : (fileName + a)
   const blob = new Blob([data], { type: 'application/vnd.ms-excel' })
   if (window.navigator && window.navigator.msSaveOrOpenBlob) {
     navigator.msSaveBlob(blob, fname + '.xlsx')

+ 8 - 9
src/views/salesReturnManagement/salesReturn/importGuideModal.vue

@@ -64,9 +64,10 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
+import { exportExcel } from '@/libs/JGPrint'
 import ChooseImportModal from './chooseImportModal.vue'
 import { Upload } from '@/components'
-import { salesReturnDownload } from '@/api/salesReturn'
+import { downLoadTemp } from '@/api/data'
 export default {
   name: 'SalesReturnImportGuideModal',
   mixins: [commonMixin],
@@ -122,15 +123,13 @@ export default {
       this.openImportModal = false
       this.isShow = false
     },
-    // 下载模板
+    //  导出
     handleExport () {
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/template/XiaoShouTuiHuoMingXiDaoRu.xlsx'
-      link.setAttribute('download', '销售退货导入模板' + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-      document.body.removeChild(link)
+      const _this = this
+      _this.spinning = true
+      exportExcel(downLoadTemp, { type: 'XSTHMX' }, '销售退货单产品导入模板', function () {
+        _this.spinning = false
+      }, true)
     }
   },
   watch: {

+ 2 - 2
vue.config.js

@@ -107,9 +107,9 @@ const vueConfig = {
     // If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        // target: 'http://192.168.0.183:8602/ocs-admin',
+        target: 'http://192.168.0.102:8602/ocs-admin',
         // target: 'https://t.ocs.360arrow.com/ocs-admin', //  Á·Ï°
-        target: 'http://p.ocs.360arrow.com/ocs-admin', //  Ô¤·¢²¼
+        // target: 'http://p.ocs.360arrow.com/ocs-admin', //  Ô¤·¢²¼
         ws: false,
         changeOrigin: true,
         pathRewrite: {