lining 6 éve
szülő
commit
abc32c6532

+ 14 - 1
src/dashoo.cn/backend/api/controllers/oilsupplier/basisbuild.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/tealeg/xlsx"
+	"os"
 	"reflect"
 	"strings"
 	"time"
@@ -17,6 +18,7 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/basisbuild"
 	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/utils"
+	. "github.com/linxGnu/goseaweedfs"
 )
 
 type OilBasisBuildController struct {
@@ -417,7 +419,18 @@ func (this *OilBasisBuildController) ExportExcelAll() {
 	SaveDirectory(dir)
 	path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
 	f.Save(path)
-	this.Data["json"] = this.Ctx.Request.Host + "/" + path
+	var sw *Seaweed
+	var filer []string
+	if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
+		filer = []string{_filer}
+	}
+	sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
+	_, _, fID, _ := sw.UploadFile(path, "", "")
+
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(path)
+	fmt.Println("==retDocWatermarkUrl==", retDocUrl)
+	this.Data["json"] = retDocUrl
 	this.ServeJSON()
 	elapsed := time.Since(t)
 	fmt.Println(elapsed)

+ 26 - 2
src/dashoo.cn/backend/api/controllers/oilsupplier/goodsaptitude.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/tealeg/xlsx"
+	"os"
 	"reflect"
 	"strconv"
 	"strings"
@@ -18,6 +19,7 @@ import (
 	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/business2/userRole"
 	"dashoo.cn/utils"
+	. "github.com/linxGnu/goseaweedfs"
 )
 
 type OilGoodsAptitudeController struct {
@@ -961,7 +963,18 @@ func (this *OilGoodsAptitudeController) ExportExcelAll() {
 	SaveDirectory(dir)
 	path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
 	f.Save(path)
-	this.Data["json"] = this.Ctx.Request.Host + "/" + path
+	var sw *Seaweed
+	var filer []string
+	if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
+		filer = []string{_filer}
+	}
+	sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
+	_, _, fID, _ := sw.UploadFile(path, "", "")
+
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(path)
+	fmt.Println("==retDocWatermarkUrl==", retDocUrl)
+	this.Data["json"] = retDocUrl
 	this.ServeJSON()
 	elapsed := time.Since(t)
 	fmt.Println(elapsed)
@@ -1041,7 +1054,18 @@ func (this *OilGoodsAptitudeController) ExportExcelAll2019() {
 	SaveDirectory(dir)
 	path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
 	f.Save(path)
-	this.Data["json"] = this.Ctx.Request.Host + "/" + path
+	var sw *Seaweed
+	var filer []string
+	if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
+		filer = []string{_filer}
+	}
+	sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
+	_, _, fID, _ := sw.UploadFile(path, "", "")
+
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(path)
+	fmt.Println("==retDocWatermarkUrl==", retDocUrl)
+	this.Data["json"] = retDocUrl
 	this.ServeJSON()
 	elapsed := time.Since(t)
 	fmt.Println(elapsed)

+ 15 - 1
src/dashoo.cn/backend/api/controllers/oilsupplier/oilcatalog.go

@@ -7,10 +7,13 @@ import (
 	"dashoo.cn/business2/permission"
 	"dashoo.cn/utils"
 	"encoding/json"
+	"fmt"
 	"github.com/tealeg/xlsx"
+	"os"
 	"strconv"
 	"strings"
 	"time"
+	. "github.com/linxGnu/goseaweedfs"
 )
 
 type OilCatalogController struct {
@@ -220,7 +223,18 @@ func (this *OilCatalogController) ExportExcelAll() {
 	SaveDirectory(dir)
 	path := dir + "/" + utils.TimeFormat(time.Now(), "20060102") + filetitle + ".xlsx"
 	f.Save(path)
-	this.Data["json"] = this.Ctx.Request.Host + "/" + path
+	var sw *Seaweed
+	var filer []string
+	if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
+		filer = []string{_filer}
+	}
+	sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
+	_, _, fID, _ := sw.UploadFile(path, "", "")
+
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(path)
+	fmt.Println("==retDocWatermarkUrl==", retDocUrl)
+	this.Data["json"] = retDocUrl
 	this.ServeJSON()
 }
 

+ 14 - 1
src/dashoo.cn/backend/api/controllers/oilsupplier/technologyservice.go

@@ -5,6 +5,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/tealeg/xlsx"
+	"os"
 	"reflect"
 	"strconv"
 	"strings"
@@ -19,6 +20,7 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/technologyservice"
 	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/utils"
+	. "github.com/linxGnu/goseaweedfs"
 )
 
 type OilTechnologyServiceController struct {
@@ -696,7 +698,18 @@ func (this *OilTechnologyServiceController) ExportExcelAll() {
 	SaveDirectory(dir)
 	path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
 	f.Save(path)
-	this.Data["json"] = this.Ctx.Request.Host + "/" + path
+	var sw *Seaweed
+	var filer []string
+	if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
+		filer = []string{_filer}
+	}
+	sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
+	_, _, fID, _ := sw.UploadFile(path, "", "")
+
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(path)
+	fmt.Println("==retDocWatermarkUrl==", retDocUrl)
+	this.Data["json"] = retDocUrl
 	this.ServeJSON()
 	elapsed := time.Since(t)
 	fmt.Println(elapsed)

+ 8 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/basisbuild/index.vue

@@ -409,7 +409,14 @@
         }
         api.exportExcelAll(params, this.$axios).then(res => {
           this.loading = false
-          window.location = 'http://' + res.data
+          let docurl = res.data
+          // 内网服务器专用
+          if (process.client && docurl.indexOf('upfile') === 0) {
+            const myDomain = window.location.host
+            location.href = 'http://' + myDomain + '/' + docurl
+          } else {
+            location.href = 'http://' + docurl
+          }
         })
       },
       searchCommand(command) {

+ 8 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/goodsaptitude/index.vue

@@ -599,7 +599,14 @@
         }
         api.exportExcelAll(params, this.$axios).then(res => {
           this.loading = false
-          window.location = 'http://' + res.data
+          let docurl = res.data
+          // 内网服务器专用
+          if (process.client && docurl.indexOf('upfile') === 0) {
+            const myDomain = window.location.host
+            location.href = 'http://' + myDomain + '/' + docurl
+          } else {
+            location.href = 'http://' + docurl
+          }
         })
       },
       initTableHeader () {

+ 8 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/goodsaptitude2019/index.vue

@@ -259,7 +259,14 @@ export default {
       }
       api.exportExcelAll2019(params, this.$axios).then(res => {
         this.loading = false
-        window.location = 'http://' + res.data
+        let docurl = res.data
+        // 内网服务器专用
+        if (process.client && docurl.indexOf('upfile') === 0) {
+          const myDomain = window.location.host
+          location.href = 'http://' + myDomain + '/' + docurl
+        } else {
+          location.href = 'http://' + docurl
+        }
       })
     },
     initTableHeader () {

+ 9 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/oilcatalog/index.vue

@@ -248,6 +248,7 @@
             type: 'warning',
             message: '没有数据可以导出'
           })
+          return
         }
         this.loading = true
         let params = {
@@ -256,7 +257,14 @@
         }
         api.exportExcelAll(params, this.$axios).then(res => {
           this.loading = false
-          window.location = 'http://' + res.data
+          let docurl = res.data
+          // 内网服务器专用
+          if (process.client && docurl.indexOf('upfile') === 0) {
+            const myDomain = window.location.host
+            location.href = 'http://' + myDomain + '/' + docurl
+          } else {
+            location.href = 'http://' + docurl
+          }
         })
       },
       addOilcatalog () {

+ 8 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/technologyservice/index.vue

@@ -524,7 +524,14 @@
         }
         api.exportExcelAll(params, this.$axios).then(res => {
           this.loading = false
-          window.location = 'http://' + res.data
+          let docurl = res.data
+          // 内网服务器专用
+          if (process.client && docurl.indexOf('upfile') === 0) {
+            const myDomain = window.location.host
+            location.href = 'http://' + myDomain + '/' + docurl
+          } else {
+            location.href = 'http://' + docurl
+          }
         })
       },
       Name1Change(val) {