浏览代码

导出目录

lining 6 年之前
父节点
当前提交
caae16d53a

+ 43 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/oilcatalog.go

@@ -5,6 +5,8 @@ import (
 	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/utils"
 	"encoding/json"
+	"github.com/tealeg/xlsx"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -170,4 +172,45 @@ func (this *OilCatalogController) UpdateEntity() {
 		this.Data["json"] = &errinfo
 		this.ServeJSON()
 	}
+}
+
+// @Title get 导出ex
+// @Description get SampleType by token
+// @Success 200 {object} sampletype.SampleType
+// @router /exportexcelall [get]
+func (this *OilCatalogController) ExportExcelAll() {
+
+	CardTitle := this.GetString("CardTitle")
+	CatalogType := this.GetString("CatalogType")
+
+	svc := oilcatalog.GetOilCatalogService(utils.DBE)
+	var list []oilcatalog.OilCatalog
+	where := "CatalogType=" + CatalogType
+	svc.GetEntities(&list, where)
+
+	filetitle := "大港油田" + CardTitle + "目录"
+	showcolumnarr := "序号,企业名称,业务范围,有效期起,有效期止,备注"
+
+	f := xlsx.NewFile()
+	sheet, _ := f.AddSheet(filetitle)
+	cellname := strings.Split(showcolumnarr, ",")
+	row := sheet.AddRow()
+	row.WriteSlice(&cellname, -1)
+
+	for idx, item := range list {
+		datastring := strconv.Itoa(idx + 1) + "," + item.CompanyName + "," + item.Business + "," + utils.ToStr(item.ValidityFrom.Format("2006-01-02")) + "," +
+			utils.ToStr(item.ValidityFrom.Format("2006-01-02")) + item.Remark
+		cellname := strings.Split(datastring, ",")
+		row := sheet.AddRow()
+		row.WriteSlice(&cellname, -1)
+	}
+	for c, cl := 0, len(sheet.Cols); c < cl; c++ {
+		sheet.Cols[c].Width = 20
+	}
+	dir := "static/file/excel/report/" + this.GetAccode()
+	SaveDirectory(dir)
+	path := dir + "/" + utils.TimeFormat(time.Now(), "20060102") + filetitle + ".xlsx"
+	f.Save(path)
+	this.Data["json"] = this.Ctx.Request.Host + "/" + path
+	this.ServeJSON()
 }

+ 3 - 131
src/dashoo.cn/frontend_web/src/api/oilsupplier/oilcatalog.js

@@ -6,65 +6,6 @@ export default {
       params: params
     })
   },
-  getCertList (CreateOn, params, myAxios) {
-    return myAxios({
-      url: '/supplier/certlist?CreateOn=' + CreateOn,
-      method: 'GET',
-      params: params
-    })
-  },
-  getJZPSCertList (CreateOn, params, myAxios) {
-    return myAxios({
-      url: '/supplier/jzps_certlist?CreateOn=' + CreateOn,
-      method: 'GET',
-      params: params
-    })
-  },
-  getStoreList (CreateOn, params, myAxios) {
-    return myAxios({
-      url: '/supplier/storelist?CreateOn=' + CreateOn,
-      method: 'GET',
-      params: params
-    })
-  },
-  getMyTasks (CreateOn, params, myAxios) {
-    return myAxios({
-      url: '/supplier/mytasks?CreateOn=' + CreateOn,
-      method: 'GET',
-      params: params
-    })
-  },
-  getDictList (myAxios) {
-    return myAxios({
-      url: '/supplier/dictlist/',
-      method: 'GET'
-    })
-  },
-  getDictListByStatus (params, myAxios) {
-    return myAxios({
-      url: '/supplier/dictlistbystatus/',
-      method: 'GET',
-      params: params
-    })
-  },
-  getEntity (entityId, myAxios) {
-    return myAxios({
-      url: '/supplier/get/' + entityId,
-      method: 'GET'
-    })
-  },
-  getEntityAndCert (certId, myAxios) {
-    return myAxios({
-      url: '/supplier/getandcert/' + certId,
-      method: 'GET'
-    })
-  },
-  getEntityByName (name, typeCode, myAxios) {
-    return myAxios({
-      url: '/supplier/getbyname?typecode=' + typeCode + '&name=' + name,
-      method: 'GET'
-    })
-  },
   addEntity (formData, myAxios) {
     return myAxios({
       url: '/oilcatalog/add',
@@ -79,86 +20,17 @@ export default {
       data: formData
     })
   },
-  updateNumberEntity (entityId, formData, myAxios) {
-    return myAxios({
-      url: '/supplier/updatenumber/' + entityId,
-      method: 'post',
-      data: formData
-    })
-  },
   deleteEntity (entityId, myAxios) {
     return myAxios({
       url: '/oilcatalog/delete/' + entityId,
       method: 'delete'
     })
   },
-  deleteAllEntity (entityId, supplierTypeCode, myAxios) {
-    return myAxios({
-      url: '/supplier/deleteall/' + entityId + '/' + supplierTypeCode,
-      method: 'delete'
-    })
-  },
-  isCanApply (typeCode, myAxios) {
-    return myAxios({
-      url: '/supplier/iscanapply/' + typeCode,
-      method: 'get'
-    })
-  },
-  isCanUpdateSupplier (supplierid, myAxios) {
+  exportExcelAll (params, myAxios) {
     return myAxios({
-      url: '/supplier/iscanupdatesupplier/' + supplierid,
-      method: 'get'
-    })
-  },
-  getAuditerByDept (deptId, auditstepcode, myAxios) {
-    return myAxios({
-      url: '/supplier/getauditerbydept/' + deptId + '?auditstepcode=' + auditstepcode,
-      method: 'GET'
-    })
-  },
-  getFirAuditerByDept (deptId, auditstepcode, myAxios) {
-    return myAxios({
-      url: '/supplier/getfirauditerbydept/' + deptId + '?auditstepcode=' + auditstepcode,
-      method: 'GET'
-    })
-  },
-  getAuditerByFirst (firstId, auditstepcode, myAxios) {
-    return myAxios({
-      url: '/supplier/getauditerbyfirst/' + firstId + '?auditstepcode=' + auditstepcode,
-      method: 'GET'
-    })
-  },
-  getAuditerByDeptAndNoLogin (params, myAxios) {
-    return myAxios({
-      url: '/supplier/getauditerbydeptandnologin',
-      method: 'GET',
-      params: params
-    })
-  },
-  getTodoList (params, myAxios) {
-    return myAxios({
-      url: '/todolist/gettodolist/',
-      method: 'GET',
+      url: '/oilcatalog/exportexcelall',
+      method: 'get',
       params: params
     })
-  },
-  getMyTaskFinished (params, myAxios) {
-    return myAxios({
-      url: '/todolist/getmytaskfinishedlist/',
-      method: 'GET',
-      params: params
-    })
-  },
-  getJurisdiction (myAxios) {
-    return myAxios({
-      url: '/supplier/getjurisdiction',
-      method: 'GET'
-    })
-  },
-  getEntityByCommercialNo (commercialNo, myAxios) {
-    return myAxios({
-      url: '/supplier/getentitybycommercialno/' + commercialNo,
-      method: 'GET'
-    })
   }
 }

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

@@ -4,7 +4,7 @@
       <el-breadcrumb-item :to="{ path: '/' }">平台首页</el-breadcrumb-item>
       <el-breadcrumb-item>大港油田{{cardTitle}}目录</el-breadcrumb-item>
     </el-breadcrumb>
-    <el-card class="box-card" style="height: calc(100vh - 115px);">
+    <el-card class="box-card" style="height: calc(100vh - 115px);" v-loading="loading">
       <div slot="header">
         <span>
           <i class="icon icon-table2"></i> 大港油田{{cardTitle}}目录
@@ -33,6 +33,7 @@
           </el-form-item>
           <el-form-item>
             <el-button type="primary" size="mini" @click="addOilcatalog">添加</el-button>
+            <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="exportExcel">导出</el-button>
           </el-form-item>
         </el-form>
       </div>
@@ -135,6 +136,7 @@
         catalogType: '',
         addShowTitle: '添加目录',
         addshow: false,
+        loading: false,
 
         // 分页参数
         size: 10,
@@ -213,6 +215,24 @@
     },
 
     methods: {
+      exportExcel () {
+        console.log(this.entityList)
+        if (this.entityList == null || this.entityList.length <= 0) {
+          this.$message({
+            type: 'warning',
+            message: '没有数据可以导出'
+          })
+        }
+        this.loading = true
+        let params = {
+          CardTitle: this.cardTitle,
+          CatalogType: this.formData.CatalogType
+        }
+        api.exportExcelAll(params, this.$axios).then(res => {
+          this.loading = false
+          window.location = 'http://' + res.data
+        })
+      },
       addOilcatalog () {
         this.addshow = true
         this.formData.Id = ''