std_fee_rate_libs.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * 费率标准库数据模型
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/8/30
  6. * @version
  7. */
  8. import mongoose from "mongoose";
  9. let Schema = mongoose.Schema;
  10. let collectionName = "std_fee_rate_libs";
  11. const oprSchema = require("../all_schemas/opr_schema");
  12. let optionSchema = new Schema(
  13. {
  14. name: String,
  15. value: String,
  16. selected: Boolean,
  17. },
  18. { _id: false }
  19. );
  20. let subRecord = new Schema(
  21. {
  22. ID: Number,
  23. name: String,
  24. amount: Number, //倍数
  25. value: Number,
  26. },
  27. { _id: false }
  28. );
  29. let recordSchema = new Schema(
  30. {
  31. ID: Number,
  32. name: String,
  33. editable: Boolean,
  34. step: Number, //每增加的步数
  35. amount: Number, //倍数
  36. value: Number,
  37. subList: [subRecord],
  38. optionList: [optionSchema],
  39. },
  40. { _id: false }
  41. );
  42. let valueMapSchema = new Schema(
  43. {
  44. ID: String,
  45. value: Number,
  46. },
  47. { _id: false }
  48. );
  49. let subFeeRatesSchema = new Schema(
  50. {
  51. recodes: [recordSchema],
  52. valueMaps: [valueMapSchema],
  53. },
  54. { _id: false }
  55. );
  56. let ratesSchema = new Schema(
  57. {
  58. ID: Number,
  59. ParentID: Number,
  60. name: String,
  61. rate: Number,
  62. memo: String,
  63. sum: Boolean,
  64. subFeeRate: subFeeRatesSchema,
  65. },
  66. { _id: false }
  67. );
  68. let modelSchema = {
  69. // 自增id
  70. ID: String,
  71. // 工程所在地
  72. region: String,
  73. // 标准名称
  74. libName: String,
  75. //编码
  76. code: String,
  77. //编办ID
  78. compilationId: {
  79. type: String,
  80. index: true,
  81. },
  82. compilationName: String,
  83. // 费率数据
  84. rates: { type: [ratesSchema], default: [] },
  85. creator: String,
  86. createDate: Number,
  87. recentOpr: [oprSchema],
  88. };
  89. mongoose.model(
  90. collectionName,
  91. new Schema(modelSchema, { versionKey: false, collection: collectionName })
  92. );