apply.js 1.0 KB

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 绩效申请表
  7. const apply = {
  8. user_id: { type: String }, // 用户id
  9. user_name: { type: String }, // 用户名
  10. title: { type: String }, // 标题
  11. apply_year: { type: String }, // 申请年度
  12. project_info: { type: Object }, // 项目信息
  13. apply_index: { type: Array }, // 绩效指标
  14. status: { type: String, default: '0' }, // 0:草稿,1:待审中,2:审核通过,3:审核拒绝
  15. record: { type: Array }, // 记录
  16. excel: { type: Object }, // excel数据
  17. remark: { type: String },
  18. };
  19. const schema = new Schema(apply, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.index({ user_id: 1 });
  22. schema.index({ user_name: 1 });
  23. schema.index({ 'meta.createdAt': 1 });
  24. schema.plugin(metaPlugin);
  25. module.exports = app => {
  26. const { mongoose } = app;
  27. return mongoose.model('Apply', schema, 'apply');
  28. };