repair.js 1.1 KB

12345678910111213141516171819202122232425262728
  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. const dateNow = function () {
  6. return moment().format("YYYY-MM-DD");
  7. };
  8. // 维修单
  9. const RepairSchema = {
  10. name: { type: String, required: false, maxLength: 200 }, // 维修项目名
  11. type: { type: String, required: false, maxLength: 200 }, // 类型
  12. parts: { type: String, required: false, maxLength: 200 }, // 配件
  13. jobdate: { type: String, required: false, maxLength: 200 }, // 工时
  14. totalmoney: { type: String, required: false, maxLength: 200 }, // 合计
  15. create_data: { type: String, required: false, maxLength: 200, default: dateNow }, // 来店时间
  16. finish_date: { type: String, required: false, maxLength: 200 }, // 交车时间
  17. uid: { type: String, required: true, maxLength: 500 }, // 所属用户id
  18. // ref:'Company',关联数据
  19. };
  20. const schema = new Schema(RepairSchema, { toJSON: { virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Repair', schema, 'repair');
  26. };