huahaiyan před 6 roky
rodič
revize
63b215ecaa

+ 49 - 2
src/dashoo.cn/backend/api/business/workflow/ActivitiService.go

@@ -35,8 +35,8 @@ func GetActivitiService(xormEngine *xorm.Engine) *ActivitiService {
 	//s.BaseUrl = "http://192.168.0.165:8081/api/acti"
 	s.BaseUrl = "http://47.92.212.59:8080/acti-api/api/acti"
 	//s.BaseUrl = "http://192.168.0.171:8081/api/acti"
-	s.AposeUrl = "http://47.92.212.59:8080/acti-api/api/apose"
-	s.OriginUrl = "http://192.168.0.166:8081/api"
+	s.AposeUrl = "http://192.168.0.171:8081/api/apose"
+	s.OriginUrl = "http://192.168.0.171:8081/api"
 	//s.OriginUrl = "http://47.92.212.59:8080/acti-api/api"
 	//s.AposeUrl = "http://localhost:8081/api/apose"
 	//s.AposeUrl = "http://192.168.0.171:8081/api/apose"
@@ -253,6 +253,53 @@ func (this *ActivitiService) ExcelToPdf(addressUrl string) string {
 	return retDocUrl
 }
 
+func (this *ActivitiService) WordToPdf(addressUrl string) string {
+	var aposeVM AposeVM
+	aposeVM.AddressUrl = addressUrl
+	fmt.Println("==addressUrl===", addressUrl)
+	jsonParam, err := json.Marshal(aposeVM)
+	if err != nil {
+		fmt.Println(err, "生成json字符串错误")
+	}
+	params := string(jsonParam)
+	//token = Authorization(this.Username, this.Password)
+	retVal := this.Post2("/word-to-pdf", params, "")
+	if retVal.StatusCode != 200 {
+		return ""
+	}
+	//pdfByte, err := ioutil.ReadAll(retVal.Body)
+	//ioutil.WriteFile("E:\aa.pdf", pdfByte, 777)
+	//模板下载到服务器
+	_dir := utils.Cfg.MustValue("file", "tmplateDir") + "pdf"
+	utils.CreatePath(_dir)
+	_dir += "/tmp_" + strconv.Itoa(int(time.Now().Unix())) + ".pdf"
+	raw := retVal.Body
+	defer raw.Close()
+
+	file, err := os.Create(_dir)
+	defer file.Close()
+	writer := bufio.NewWriter(file)
+	defer writer.Flush()
+	body, err := ioutil.ReadAll(raw)
+	writer.Write(body)
+
+	if err != nil {
+		return ""
+	}
+	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, err := sw.Upload(retVal.Body, "tmp.pdf", int64(len(pdfByte)), "", "")
+	_, _, fID, err := sw.UploadFile(_dir, "", "")
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(_dir)
+	fmt.Println("==retDocUrl==", retDocUrl)
+	return retDocUrl
+}
+
 
 func (this *ActivitiService) FillWordTemplate(datas map[string]interface{}, templateUrl string, fileName string) string {
 	var wordTempVM WordTemplateVM

+ 14 - 0
src/dashoo.cn/backend/api/controllers/lims/limsdataentry.go

@@ -4317,3 +4317,17 @@ func (this *LimsDataEntryController) ExcelToPdf() {
 	this.Data["json"] = pdfUrl
 	this.ServeJSON()
 }
+
+// @Title post
+// @Description word to pdf
+// @Success 200 {string} pdfurl
+// @router /word-to-pdf [post]
+func (this *LimsDataEntryController) WordToPdf() {
+	var model workflow.AposeVM
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	svcActiviti := workflow.GetActivitiService(utils.DBE)
+	pdfUrl := svcActiviti.WordToPdf(model.AddressUrl)
+	this.Data["json"] = pdfUrl
+	this.ServeJSON()
+}

+ 4 - 1
src/dashoo.cn/frontend_web/src/pages/lims/dataentry/alltask.vue

@@ -569,6 +569,7 @@
           })*/
       },
       ViewDocPdf(row) {
+        console.log("--------row---",row)
         api.docexport(row.Id, this.$axios)
           .then(res => {
             // response
@@ -588,8 +589,10 @@
         let queryParams = {
           key: row.DocKey,
           docurl: DocAddress,
-          dataentryId: row.Id
+          dataentryId: row.Id,
+          docname : row.DocName
         }
+        console.log("---queryParams-----",queryParams)
         _this.$router.push({
           path: '/lims/dataentry/docviewframe',
           query: queryParams

+ 4 - 1
src/dashoo.cn/frontend_web/src/pages/lims/dataentry/docviewframe.vue

@@ -32,6 +32,7 @@
     data() {
       return {
         key: '',
+        docname: '',
         buttonshow : true,
         edit: true,
         currentdate: '',
@@ -47,7 +48,9 @@
     created() {
       this.key = this.$route.query.key+''+Date.parse(new Date())
       this.docurl = this.$route.query.docurl
-      this.iframeSrc = "./pdfshow?key=" + this.key + "&docurl=http://" + this.docurl
+      this.docname = this.$route.query.docname
+      console.log("-----this.docname----",this.docname)
+      this.iframeSrc = "./pdfshow?key=" + this.key + "&docurl=http://" + this.docurl +"&docname=" + this.docname
 
     },
     methods: {

+ 2 - 1
src/dashoo.cn/frontend_web/src/pages/lims/dataentry/index.vue

@@ -572,7 +572,8 @@
         let queryParams = {
           key: row.EId,
           docurl: DocAddress,
-          dataentryId: row.Id
+          dataentryId: row.Id,
+          docname : row.DocName
         }
         _this.$router.push({
           path: '/lims/dataentry/showreportframe',

+ 19 - 8
src/dashoo.cn/frontend_web/src/pages/lims/dataentry/pdfshow.vue

@@ -16,22 +16,33 @@
     data() {
       return {
         baseurl: process.env.baseURL,
-        docurl:''
+        docurl: '',
+        docname: '',
+        docnamear: ''
       }
     },
     created() {
       this.docurl = this.$route.query.docurl
-
+      this.docname = this.$route.query.docname
       let _this = this
       let params = {
         addressUrl: this.docurl
       }
-      this.$axios.post('limsdataentry/excel-to-pdf', params)
-        .then(function (res) {
-          window.location.href = "http://" + res.data
-          //_this.showPDF(url)
-        })
-
+      this.docnamear = this.docname.split(".")
+      console.log("-----this.docnamear[1]---",this.docnamear[1])
+      if (this.docnamear[1] == "xlsx") {
+        this.$axios.post('limsdataentry/excel-to-pdf', params)
+          .then(function (res) {
+            window.location.href = "http://" + res.data
+            //_this.showPDF(url)
+          })
+      } else {
+        this.$axios.post('limsdataentry/word-to-pdf', params)
+          .then(function (res) {
+            window.location.href = "http://" + res.data
+            //_this.showPDF(url)
+          })
+      }
     },
     mounted() {
       // initial data

+ 2 - 1
src/dashoo.cn/frontend_web/src/pages/lims/dataentry/tacktodo.vue

@@ -638,7 +638,8 @@
         let queryParams = {
           key: row.DocKey,
           docurl: DocAddress,
-          dataentryId: row.Id
+          dataentryId: row.Id,
+          docname : row.DocName
         }
         _this.$router.push({
           path: '/lims/dataentry/docviewframe',