Browse Source

前后:hse导入改成pdf

wd 4 years ago
parent
commit
ff9cebf754

+ 5 - 0
src/dashoo.cn/backend/api/business/oilsupplier/hsescore/hsescore.go

@@ -27,3 +27,8 @@ type HSEScore struct {
 type HSEUrl struct {
 	ExcelUrl       string
 }
+
+type HSEToPdf struct {
+	SupplierId int
+	Ip         string
+}

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

@@ -87,7 +87,7 @@ callbackHost=http://localhost:10091/api
 
 [HSE]
 #HSEUrl=http://weed1.labsop.cn:9390/6,04fc24a640a08b
-HSEUrl=http://weed1.labsop.cn:9390/2,04fc7ca35309ea
+HSEUrl=http://weed1.labsop.cn:9390/2,04fd6a6c3b3263
 
 [MsgUrl]
 msgUrl=http://api.dgyt.petrochina/jcfw/duanxin/v1.0/sendmsg

+ 12 - 6
src/dashoo.cn/backend/api/controllers/oilsupplier/hsescore.go

@@ -26,7 +26,7 @@ type printHseInfo struct {
 	SupplierName string
 	Name         string
 	StartTime    string
-	EndTime      string
+	End      string
 	ApplyTime    string
 }
 
@@ -528,7 +528,7 @@ func (this *HSEScoreController) DeleteHSEScore() {
 // @router /exportWord/:id [post]
 func (this *HSEScoreController) ExportWord() {
 	Id := this.Ctx.Input.Param(":id")
-	var model hsescore.HSEScore
+	var model hsescore.HSEToPdf
 	var jsonBlob = this.Ctx.Input.RequestBody
 	json.Unmarshal(jsonBlob, &model)
 	var errinfo ErrorDataInfo
@@ -549,7 +549,7 @@ func (this *HSEScoreController) ExportWord() {
 	printHseInfo.SupplierName = hse.SupplierName
 	printHseInfo.Name = hse.Name
 	printHseInfo.StartTime = hse.StartTime.Format("2006年01月02日")
-	printHseInfo.EndTime = hse.EndTime.Format("2006年01月02日")
+	printHseInfo.End = hse.EndTime.Format("2006年01月02日")
 	printHseInfo.ApplyTime = hse.ApplyTime.Format("2006年01月02日")
 	if hse.Id == 0 {
 		errinfo.Message = "打印失败"
@@ -563,11 +563,17 @@ func (this *HSEScoreController) ExportWord() {
 	fileName := "HSE培训合格证书.docx"
 
 	retDocUrl := svcActiviti.FillWordTemplate(dataMap, url, fileName)
+	// 转成pdf
+	if strings.Contains(retDocUrl, "upfile") {
+		retDocUrl = "http://" + model.Ip + "/" + retDocUrl
+	} else {
+		retDocUrl = "http://" + retDocUrl
+	}
+	pdfUrl := svcActiviti.WordToPdf(retDocUrl)
 	var datainfo ErrorDataInfo
 	datainfo.Code = 0
-	datainfo.Item = retDocUrl
-	datainfo.Message = "打印成功"
-	this.Data["json"] = &datainfo
+	//datainfo.Item = retDocUrl
+	this.Data["json"] = pdfUrl
 	this.ServeJSON()
 
 }

+ 9 - 13
src/dashoo.cn/frontend_web/src/pages/select/hsescore/index.vue

@@ -434,20 +434,16 @@ export default {
     download(row) {
       this.tableLoading = true
       let params = {
-        SupplierId: row.SupplierId
+        SupplierId: row.SupplierId,
+        Ip: window.location.host
       }
-      hseApi.exportWord(row.Id, params, this.$axios)
-        .then(res => {
-          // response
-          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
-            }
+      hseApi.exportWord(row.Id, params, this.$axios).then(res => {
+          // 内网服务器专用
+          if (process.client && res.data.indexOf('upfile') === 0) {
+            const myDomain = window.location.host
+            window.open('http://' + myDomain + '/' + res.data)
+          } else {
+            window.open('http://' + res.data)
           }
           this.tableLoading = false
         }).catch(err => {