compilation.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. id:String,
  23. // 计价名称
  24. name: String,
  25. // 工程专业列表
  26. engineering_list: {
  27. type: [engineeringListSchema],
  28. default: []
  29. },
  30. // 是否启用
  31. enable: {
  32. type: Boolean,
  33. default: false
  34. },
  35. // 类型
  36. type: {
  37. type: Number
  38. }
  39. },{_id: false});
  40. let modelSchema = {
  41. // 是否发布
  42. is_release: {
  43. type: Boolean,
  44. default: false
  45. },
  46. // 自增id
  47. id: {
  48. type: Number
  49. },
  50. // 清单计价规则
  51. bill_valuation: {
  52. type: [childrenSchema],
  53. default: []
  54. },
  55. // 定额计价规则
  56. ration_valuation: {
  57. type: [childrenSchema],
  58. default: []
  59. },
  60. // 名称
  61. name: String,
  62. // 创建时间
  63. create_time: Number,
  64. // 创建者id
  65. creator: String,
  66. //描述
  67. description: String,
  68. // 发布时间
  69. release_time: {
  70. type: Number,
  71. default: 0
  72. }
  73. };
  74. mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));