/** * Created by chen on 2017/6/29. */ let subSchema = require("../../main/models/bills_sub_schemas"); let deleteSchema = require('../../../public/models/delete_schema'); var mongoose = require('mongoose'), Schema = mongoose.Schema; //下面是临时代码,以后删除 var rationAssItemSchema = mongoose.Schema({ name: String, assistID: Number, assistCode: String, stdValue: Number, actualValue:Number, stepValue: String, decimal: Number, carryBit: String, minValue: String, maxValue: String }, { _id: false }); /*var gljSchema =new Schema({ repositoryId: Number, ID:Number, //以下是基于已有access库 code: String, name: String, specs: String, unit: String, basePrice: Number, gljType: Number, //这个是UI显示上的详细分类,对应gljTypeSchema shortName: String, //人工,材料,机械 gljClass:Number },{versionKey:false}); mongoose.model("std_ration_lib_glj_list",gljSchema,"std_ration_lib_glj_list");*/ let rationSchema = new Schema({ // 公用属性部分 ID: String, projectID: Number, billsItemID: String, serialNo: Number, code: String, name: String, unit: String, quantity: String, contain:String,//含量 quantityEXP:String,//工程量表达式 programID: Number, marketUnitFee: String, marketTotalFee: String, fees: [subSchema.feesSchema], deleteInfo: deleteSchema, type: Number, // 1 定额、2 量价、3 工料机定额 subType: Number, // 子类型:1人工、201材料、301机械、4主材、5设备 // 定额特有属性: libID: Number, maskName: String, caption: String, isFromDetail:{type: Number,default:0}, // 1 true 2 false adjustState: String, rationProjName: String, comments: String, // 说明 flags: [subSchema.flagsSchema], // 标记字段 rationAssList: [rationAssItemSchema], content: String, // 工作内容 ruleText: String, // 计算规则 //工料机特有属性 projectGLJID:Number, //项目工料机ID GLJID:Number,//工料机库ID original_code:String, //原始编码 specs:String,//规格型号 shortName:String,//缩写 customQuantity:String,//自定义消耗 from:{type: String,default:'std'}//std, cpt 来自标准工料机库、补充工料机库 },{versionKey:false}); mongoose.model("ration", rationSchema, "ration"); var coeSchema = mongoose.Schema({ coeType: String, // 系数类型,指作用范围: // 单个(如:111量0.001)、人工类、材料类、机械类、全部(如:定额×0.925)。 gljID: Number, // 要调整的工料机ID(当coeType=0时有效) operator: String, // 运算符(*、+、-、=) amount: String, // 调整的量 _id: false }); var coeListSchema = mongoose.Schema({ libID: Number, // 所属定额定ID ID: Number, // 系数ID(流水号ID) name: String, // 名称 content: String, // 说明 coes: [coeSchema] }, {versionKey: false}); mongoose.model("std_ration_lib_coe_list",coeListSchema, "std_ration_lib_coe_list"); var rationGljItemSchema = mongoose.Schema({ gljId: Number, consumeAmt: Number, proportion: Number //配合比,暂时无需使用,默认0 }, { _id: false }); var rationAssItemSchema = mongoose.Schema({ name: String, assistID: Number, assistCode: String, stdValue: String, stepValue: String, decimal: Number, carryBit: String, minValue: String, maxValue: String }, { _id: false }); var rationItemSchema = mongoose.Schema({ ID:Number, code: String, name: String, unit: String, basePrice: Number, sectionId: Number, rationRepId: Number, caption: String, feeType: Number, rationGljList: [rationGljItemSchema], rationCoeList: Array, rationAssList: [rationAssItemSchema] }); mongoose.model("std_ration_lib_ration_items",rationItemSchema, "std_ration_lib_ration_items"); let billsSchema = new Schema({ ID: Number, ParentID: Number, NextSiblingID: Number, projectID: Number, serialNo: Number, chapterID: Number, code: String, fullCode: String, type:Number, isAdd:{type: Number,default:0},//1 true 0 false是否新增 name: String, unit: String, quantity: String, // Decimal feeRateID:String, feeRate:String, isFromDetail:{type: Number,default:0},//1 true 2 false programID: Number, comments: String, // 调价 xs_Labour: String, // Decimal xs_Material: String, // Decimal xs_Machine: String, // Decimal xs_FeeRate: String, // Decimal xs_LabourPrice: String, // Decimal xs_MaterialPrice: String, // Decimal xs_MachinePrice: String, // Decimal isTender_Labour: Boolean, isTender_Material: Boolean, isTender_Machine: Boolean, tenderTargetPrice: String, // Decimal tenderTargetUnitPrice: String, // Decimal tenderTargetUnitPrice: String, // Decimal // 费用字段 fees: [subSchema.feesSchema], // 标记字段 flags: [subSchema.flagsSchema], deleteInfo: deleteSchema }); mongoose.model("bills", billsSchema);