正在显示
3 个修改的文件
包含
31 行增加
和
3 行删除
@@ -207,7 +207,7 @@ type excelTableHeader struct { | @@ -207,7 +207,7 @@ type excelTableHeader struct { | ||
207 | Level4 string | 207 | Level4 string |
208 | } | 208 | } |
209 | 209 | ||
210 | -func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) ([]byte, error) { | 210 | +func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) (*excelize.File, error) { |
211 | transactionContext, err := factory.CreateTransactionContext(nil) | 211 | transactionContext, err := factory.CreateTransactionContext(nil) |
212 | if err != nil { | 212 | if err != nil { |
213 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 213 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -413,6 +413,5 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy | @@ -413,6 +413,5 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy | ||
413 | } | 413 | } |
414 | } | 414 | } |
415 | } | 415 | } |
416 | - | ||
417 | - return nil, nil | 416 | + return xlsxFile, nil |
418 | } | 417 | } |
1 | package controllers | 1 | package controllers |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
5 | + | ||
4 | "github.com/linmadan/egglib-go/core/application" | 6 | "github.com/linmadan/egglib-go/core/application" |
5 | "github.com/linmadan/egglib-go/web/beego" | 7 | "github.com/linmadan/egglib-go/web/beego" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
@@ -320,3 +322,29 @@ func (c *StaffAssessController) ListAssessContentCycleDay() { | @@ -320,3 +322,29 @@ func (c *StaffAssessController) ListAssessContentCycleDay() { | ||
320 | data, err := srv.ListUserAssessContentCycleDay(paramReq) | 322 | data, err := srv.ListUserAssessContentCycleDay(paramReq) |
321 | c.Response(data, err) | 323 | c.Response(data, err) |
322 | } | 324 | } |
325 | + | ||
326 | +//根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件 | ||
327 | +func (c *StaffAssessController) ExportAssessContentCycleDay() { | ||
328 | + srv := service.NewStaffAssessServeice() | ||
329 | + paramReq := &query.ListAssessContentCycleDay{} | ||
330 | + err := c.BindJSON(paramReq) | ||
331 | + if err != nil { | ||
332 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
333 | + c.Response(nil, e) | ||
334 | + return | ||
335 | + } | ||
336 | + userReq := middlewares.GetUser(c.Ctx) | ||
337 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
338 | + paramReq.OperaterId = int(userReq.UserId) | ||
339 | + data, err := srv.ExportUserAssess(paramReq) | ||
340 | + if err != nil { | ||
341 | + c.Response(nil, err) | ||
342 | + } | ||
343 | + fileName := fmt.Sprintf("每日绩效汇总%s", paramReq.BeginDay) | ||
344 | + c.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName) | ||
345 | + c.Ctx.Output.Header("Content-Description", "FileTransfer") | ||
346 | + c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") | ||
347 | + c.Ctx.Output.Header("Content-Transfer-Encoding", "binary") | ||
348 | + c.Ctx.Output.Header("Expires", "0") | ||
349 | + data.Write(c.Ctx.ResponseWriter) | ||
350 | +} |
@@ -16,6 +16,7 @@ func init() { | @@ -16,6 +16,7 @@ func init() { | ||
16 | web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表 | 16 | web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表 |
17 | web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期 | 17 | web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期 |
18 | web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表 | 18 | web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表 |
19 | + web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表 | ||
19 | ) | 20 | ) |
20 | // /v1/staff-assess/self/me/list | 21 | // /v1/staff-assess/self/me/list |
21 | assessNS := web.NewNamespace("/v1/staff-assess", | 22 | assessNS := web.NewNamespace("/v1/staff-assess", |
-
请 注册 或 登录 后发表评论