record.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. class RecordController extends Controller {
  4. async list() {
  5. const {ctx, service} = this;
  6. let query = ctx.request.query;
  7. let ret = await service.record.adminList(query);
  8. ctx.adminOK(ret);
  9. }
  10. async detail() {
  11. const {ctx, service} = this;
  12. let query = ctx.request.query;
  13. let ret = await service.record.detail(query);
  14. ctx.adminOK(ret);
  15. }
  16. async delete() {
  17. const {ctx, service} = this;
  18. let id = ctx.request.query.id;
  19. let ret = await service.record.delete(id);
  20. ctx.adminOK(ret, "删除成功");
  21. }
  22. async edit() {
  23. const {ctx, service} = this;
  24. let data = ctx.request.body;
  25. let ret = await service.record.edit( data );
  26. ctx.adminOK(ret, "更新成功");
  27. }
  28. async add() {
  29. const {ctx, service} = this;
  30. let data = ctx.request.body;
  31. let ret = await service.record.add( data );
  32. ctx.adminOK(ret, "添加成功");
  33. }
  34. async exportXls() {
  35. const {ctx, service} = this;
  36. ctx.set("Content-Type", "application/vnd.openxmlformats");
  37. ctx.set("Content-Disposition","attachment;filename*=UTF-8 xx.xlsx");
  38. let ret = await service.record.exportXls( ctx.request.query );
  39. ctx.body = ret;
  40. }
  41. async itemExportXls() {
  42. const {ctx, service} = this;
  43. ctx.set("Content-Type", "application/vnd.openxmlformats");
  44. ctx.set("Content-Disposition","attachment;filename*=UTF-8 xx.xlsx");
  45. let ret = await service.record.itemExportXls( ctx.request.query );
  46. ctx.body = ret;
  47. }
  48. }
  49. module.exports = RecordController;