bill.js 983 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. // 结算单
  6. const Bill = {
  7. title: {
  8. type: String,
  9. maxLength: 200,
  10. default: `${moment().format('YYYY-MM-DD HH:mm:ss')}结算单`,
  11. }, // 结算单标题
  12. client: {
  13. type: String,
  14. required: true,
  15. maxLength: 200,
  16. field: { label: '客户/供应商id', filter: true, required: true },
  17. },
  18. ids: { type: Array },
  19. owner: { type: String, required: true }, // 创建人
  20. remark: { type: String, maxLength: 200 }, // 备注
  21. params: { type: Object }, // 额外参数
  22. create_time: {
  23. type: String,
  24. default: moment().format('YYYY-MM-DD HH:mm:ss'),
  25. },
  26. };
  27. const schema = new Schema(Bill, { toJSON: { virtuals: true } });
  28. schema.index({ id: 1 });
  29. schema.plugin(metaPlugin);
  30. module.exports = app => {
  31. const { mongoose } = app;
  32. return mongoose.model('Bill', schema, 'bill');
  33. };