/**
 * 编办管理数据模型
 *
 * @author CaiAoLin
 * @date 2017/7/28
 * @version
 */
import mongoose from "mongoose";

let Schema = mongoose.Schema;
let collectionName = 'compilation';
let engineeringListSchema = new Schema({
    // 工程专业id
    engineering: {
        type: Number
    },
    engineering_id: {
        type: Schema.Types.Mixed,
        default: []
    }
}, {_id: false});
let childrenSchema = new Schema({
    // 计价名称
    name: String,
    // 工程专业列表
    engineering_list: {
        type: [engineeringListSchema],
        default: []
    },
    // 是否启用
    enable: {
        type: Boolean,
        default: false
    },
    // 类型
    type: {
        type: Number
    },
    // 列设置
    main_tree_col: {
        type: Schema.Types.Mixed,
        default: {
            "emptyRows":3,
            "headRows":0,
            "treeCol": 0,
            "headRowHeight":[],
            "cols":[]
        }
    }
});
let modelSchema = {
    // 是否发布
    is_release: {
        type: Boolean,
        default: false
    },
    // 清单计价规则
    bill_valuation: {
        type: [childrenSchema],
        default: []
    },
    // 定额计价规则
    ration_valuation: {
        type: [childrenSchema],
        default: []
    },
    // 名称
    name: String,
    // 创建时间
    create_time: Number,
    // 创建者id
    creator: String,
    // 发布时间
    release_time: {
        type: Number,
        default: 0
    }
};
let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
export {model as default, collectionName as collectionName};
