Browse Source

前后:hse导入改成post,加异常捕获

wd 4 năm trước cách đây
mục cha
commit
25642f6a3f

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

@@ -23,3 +23,7 @@ type HSEScore struct {
 	ModifiedUserId int       `xorm:"comment('修改者编号') INT(11)"`
 	ModifiedBy     string    `xorm:"comment('修改者') VARCHAR(50)"`
 }
+
+type HSEUrl struct {
+	ExcelUrl       string
+}

+ 18 - 3
src/dashoo.cn/backend/api/controllers/oilsupplier/hsescore.go

@@ -175,12 +175,27 @@ func (this *HSEScoreController) GetSupplierHSEList() {
 // @Title get 导入excel
 // @Description 导入excel
 // @Success 200 {object} controllers.Request
-// @router /importExcel [get]
+// @router /importExcel [post]
 func (this *HSEScoreController) ImportExcel() {
-	url := this.GetString("ExcelUrl")
-	//var errLineNum string
 	var errinfo ErrorDataInfo
 
+	defer func() {
+		if err := recover(); err != nil {
+			log.Println("HSE导入err", err)
+			errinfo.Message = "导入失败! 导入文件不匹配模板!"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		}
+	}()
+	var hseUrl hsescore.HSEUrl
+	var jsonBlob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonBlob, &hseUrl)
+	//url := this.GetString("ExcelUrl")
+	url := hseUrl.ExcelUrl
+	//var errLineNum string
+
 	if url == "" {
 		errinfo.Message = "文件不能为空"
 		errinfo.Code = -2

+ 2 - 2
src/dashoo.cn/frontend_web/src/api/hsescore/hsescore.js

@@ -3,8 +3,8 @@ export default {
   importExcel (params, myAxios) {
     return myAxios({
       url: '/hse/importExcel',
-      method: 'get',
-      params: params
+      method: 'post',
+      data: params
     })
   },
   // 列表