lining před 6 roky
rodič
revize
d1bc0005e5

+ 1 - 0
src/dashoo.cn/backend/api/conf/app.conf

@@ -11,6 +11,7 @@ EnableDocs = true
 apiurl=http://121.42.244.228:10015/v1
 dataapiurl=http://121.42.244.228:18010/v1
 orderurl=http://uid.labsop.cn:8182/worker/2
+localIP =
 
 #临沂
 #orderurl=http:/188.188.30.89:8182/worker/2

+ 77 - 3
src/dashoo.cn/backend/api/controllers/oilsupplier/select.go

@@ -897,7 +897,7 @@ func (this *SelectController) GetTotalList() {
 	this.ServeJSON()
 }
 
-// @Title 导出营业执照
+// @Title 导出资质图片
 // @Description
 // @Success 200 {object}
 // @router /getallbusinesslicense [get]
@@ -911,7 +911,7 @@ func (this *SelectController) GetAllBusinessLicense() {
 	where := "1=1"
 	svc.GetEntities(&supplierList, where)
 	_dir := utils.Cfg.MustValue("file", "tmplateDir") + needFileType
-	downFileUrl := "http://10.76.248.23"
+	downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
 	for _,item := range supplierList {
 		var supplierFile supplierfile.OilSupplierFile
 		where := "SupplierId=" + strconv.Itoa(item.Id) + " and NeedFileType='" + needFileType + "'"
@@ -946,7 +946,7 @@ func (this *SelectController) GetAllBusinessLicense() {
 
 	}
 	os.Remove(destZip)
-	os.Remove(_dir)
+	os.RemoveAll(_dir)
 	var errinfo ErrorDataInfo
 	errinfo.Code = 0
 	errinfo.Item = retDocUrl
@@ -955,6 +955,80 @@ func (this *SelectController) GetAllBusinessLicense() {
 
 }
 
+// @Title 导出企业资质图片
+// @Description
+// @Success 200 {object}
+// @router /getallbusinesslicensebyid [get]
+func (this *SelectController) GetBusinessLicenseById() {
+
+	SupplierId := this.GetString("SupplierId")
+	SupplierName := this.GetString("SupplierName")
+	SupplierTypeCode := this.GetString("SupTypeCode")
+
+	svc := supplier.GetOilSupplierService(utils.DBE)
+
+	_dir := utils.Cfg.MustValue("file", "tmplateDir") + SupplierName
+	downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
+	var supplierFile []supplierfile.OilSupplierFile
+	where := "SupplierId=" + SupplierId
+	svc.GetEntities(&supplierFile, where)
+
+	var errinfo ErrorDataInfo
+	if len(supplierFile) == 0 {
+		errinfo.Code = -1
+		errinfo.Message = "该公司没有可导出的资质!"
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+	for _,item := range supplierFile {
+		fileArr := strings.Split(item.FileName, ".")
+		fileUrl := strings.Split(item.FileUrl, "|")
+		if len(fileUrl) == 2 && len(fileArr) == 2 {
+			utils.DownloadFile( downFileUrl + fileUrl[0], item.NeedFileType + "." + fileArr[1] , _dir)
+		}
+	}
+
+	//Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip")
+
+	f1,_ := os.Open(_dir)
+	var files = []*os.File{f1}
+	if SupplierTypeCode == "01" {
+		SupplierTypeCode = "WZ"
+	} else if SupplierTypeCode == "02" {
+		SupplierTypeCode = "JS"
+	} else if SupplierTypeCode == "03" {
+		SupplierTypeCode = "JF"
+	} else {
+		SupplierTypeCode = ""
+	}
+	destZipName := SupplierName +  time.Now().Format("2006-01-02") + SupplierTypeCode
+	destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip"
+	err := Compress(files, destZip)
+
+	retDocUrl := ""
+	if err == nil {
+		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(destZip, "", "")
+		retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+
+	}
+	err = os.RemoveAll(destZip)
+	fmt.Println(err)
+	err = os.RemoveAll(_dir)
+	fmt.Println(err)
+
+	errinfo.Code = 0
+	errinfo.Item = retDocUrl
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+
+}
+
 func Compress(files []*os.File, dest string) error {
 	d, _ := os.Create(dest)
 	defer d.Close()

+ 7 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/select.js

@@ -62,5 +62,12 @@ export default {
       method: 'get',
       params: params
     })
+  },
+  getBusinessLicenseById (params, myAxios) {
+    return myAxios({
+      url: '/select/getallbusinesslicensebyid',
+      method: 'get',
+      params: params
+    })
   }
 }

+ 7 - 0
src/dashoo.cn/frontend_web/src/pages/select/companyselect/index.vue

@@ -784,6 +784,8 @@
     <el-dialog :visible.sync="dialogVisibleSubFile" width="80%">
       <subfile-list ref="subfileListRef"
                         :SupplierId="SupplierId"
+                        :SupplierName="SupplierName"
+                        :SupTypeCode="SupplierTypeCode"
                         height="360px"
                         style="margin-top: 20px"></subfile-list>
 
@@ -1007,10 +1009,12 @@ export default {
     },
     exportBusinessLicense () {
       this.dialogImportSubFile = false
+      this.loading = true
       let params = {
         NeedFileType: this.importData.Name
       }
       api.getAllBusinessLicense(params, this.$axios).then(res => {
+        this.loading = false
         if (res.data.code === 0) {
           let docurl = res.data.item
           // 内网服务器专用
@@ -1027,9 +1031,12 @@ export default {
       this.getCertSub()
     },
     openfilelist (row) {
+      console.log(row)
       let _this = this
       _this.dialogVisibleSubFile = true
       _this.SupplierId = row.Id
+      _this.SupplierName = row.SupplierName
+      _this.SupplierTypeCode = row.SupplierTypeCode
     },
     opencertsub (row) {
       this.certsubList = []

+ 39 - 1
src/dashoo.cn/frontend_web/src/pages/select/components/subfilelist.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <el-card class="box-card" style="margin-top: 10px;">
+    <el-card class="box-card" style="margin-top: 10px;" v-loading="importloading">
       <div slot="header" class="clearfix">
         <span style="font-weight: bold"> 企业资质</span>
         <span style="float: right;">
@@ -19,6 +19,7 @@
             </el-form-item>
             <el-form-item>
               <el-button type="primary" size="mini" style="margin-left: 8px" @click="search">查询</el-button>
+              <el-button type="primary" size="mini" style="margin-left: 8px" @click="importfile()">资质导出</el-button>
             </el-form-item>
           </el-form>
         </span>
@@ -61,6 +62,7 @@
   import {
     mapGetters
   } from 'vuex'
+  import api from '@/api/oilsupplier/select'
 
   export default {
     name: 'SubfileList1',
@@ -73,10 +75,19 @@
       SupplierId: {
         type: Number,
         default: 0
+      },
+      SupplierName: {
+        type: String,
+        default: ''
+      },
+      SupTypeCode: {
+        type: String,
+        default: ''
       }
     },
     data () {
       return {
+        importloading: false,
         size: 10,
         currentPage: 1,
         currentItemCount: 0,
@@ -103,6 +114,33 @@
       this.initData()
     },
     methods: {
+      importfile () {
+        this.importloading = true
+        let params = {
+          SupplierId: this.SupplierId,
+          SupplierName: this.SupplierName,
+          SupTypeCode: this.SupTypeCode
+        }
+        console.log(params)
+        api.getBusinessLicenseById(params, this.$axios).then(res => {
+          this.importloading = false
+          if (res.data.code === 0) {
+            let docurl = res.data.item
+            // 内网服务器专用
+            if (process.client && docurl.indexOf('upfile') === 0) {
+              const myDomain = window.location.host
+              location.href = 'http://' + myDomain + '/' + docurl
+            } else {
+              location.href = 'http://' + docurl
+            }
+          } else {
+            this.$message({
+              type: 'warning',
+              message: res.data.message
+            })
+          }
+        })
+      },
       search () {
         this.initData()
       },