compilation.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * 编办管理数据模型
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/7/28
  6. * @version
  7. */
  8. import mongoose from "mongoose";
  9. let Schema = mongoose.Schema;
  10. let collectionName = 'compilation';
  11. let engineeringListSchema = new Schema({
  12. // 工程专业id
  13. engineering: {
  14. type: Number
  15. },
  16. engineering_id: {
  17. type: Schema.Types.Mixed,
  18. default: []
  19. }
  20. }, {_id: false});
  21. let childrenSchema = new Schema({
  22. // 计价名称
  23. name: String,
  24. // 工程专业列表
  25. engineering_list: {
  26. type: [engineeringListSchema],
  27. default: []
  28. },
  29. // 是否启用
  30. enable: {
  31. type: Boolean,
  32. default: false
  33. },
  34. // 类型
  35. type: {
  36. type: Number
  37. }
  38. });
  39. let modelSchema = {
  40. // 是否发布
  41. is_release: {
  42. type: Boolean,
  43. default: false
  44. },
  45. // 自增id
  46. id: {
  47. type: Number
  48. },
  49. // 清单计价规则
  50. bill_valuation: {
  51. type: [childrenSchema],
  52. default: []
  53. },
  54. // 定额计价规则
  55. ration_valuation: {
  56. type: [childrenSchema],
  57. default: []
  58. },
  59. // 名称
  60. name: String,
  61. // 创建时间
  62. create_time: Number,
  63. // 创建者id
  64. creator: String,
  65. // 发布时间
  66. release_time: {
  67. type: Number,
  68. default: 0
  69. }
  70. };
  71. mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));