12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 'use strict';
- const Controller = require('egg').Controller;
- class RecordController extends Controller {
- async list() {
- const {ctx, service} = this;
- let query = ctx.request.query;
- let ret = await service.record.adminList(query);
- ctx.adminOK(ret);
- }
- async detail() {
- const {ctx, service} = this;
- let query = ctx.request.query;
- let ret = await service.record.detail(query);
- ctx.adminOK(ret);
- }
- async delete() {
- const {ctx, service} = this;
- let id = ctx.request.query.id;
- let ret = await service.record.delete(id);
- ctx.adminOK(ret, "删除成功");
- }
- async edit() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.record.edit( data );
- ctx.adminOK(ret, "更新成功");
- }
- async add() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.record.add( data );
- ctx.adminOK(ret, "添加成功");
- }
- async exportXls() {
- const {ctx, service} = this;
- ctx.set("Content-Type", "application/vnd.openxmlformats");
- ctx.set("Content-Disposition","attachment;filename*=UTF-8 xx.xlsx");
- let ret = await service.record.exportXls( ctx.request.query );
- ctx.body = ret;
- }
- async itemExportXls() {
- const {ctx, service} = this;
- ctx.set("Content-Type", "application/vnd.openxmlformats");
- ctx.set("Content-Disposition","attachment;filename*=UTF-8 xx.xlsx");
- let ret = await service.record.itemExportXls( ctx.request.query );
- ctx.body = ret;
- }
- }
- module.exports = RecordController;
|