Преглед на файлове

feat: 增加子目增加费模板编辑器,定额可选择添加子目增加费模板

zhangweicheng преди 1 ден
родител
ревизия
053947aec7

+ 119 - 111
modules/all_models/engineering_lib.js

@@ -8,121 +8,129 @@
 import mongoose from "mongoose";
 
 let Schema = mongoose.Schema;
-let collectionName = 'engineering_lib';
-let taxGroupSchema = new Schema({
-    taxType: String,//计税方式
-    program_lib: { type: Schema.Types.Mixed, default: {} },// 计算程序标准库
-    template_lib: { type: Schema.Types.Mixed, default: {} },//清单模板库
-    col_lib: { type: Schema.Types.Mixed, default: {} },//列设置
-    fee_lib: { type: Schema.Types.Mixed, default: {} },//费率标准库
-    norm_lib: String//指标分部
-}, { _id: false });
-
+let collectionName = "engineering_lib";
+let taxGroupSchema = new Schema(
+  {
+    taxType: String, //计税方式
+    program_lib: { type: Schema.Types.Mixed, default: {} }, // 计算程序标准库
+    template_lib: { type: Schema.Types.Mixed, default: {} }, //清单模板库
+    col_lib: { type: Schema.Types.Mixed, default: {} }, //列设置
+    fee_lib: { type: Schema.Types.Mixed, default: {} }, //费率标准库
+    norm_lib: String, //指标分部
+  },
+  { _id: false }
+);
 
 let modelSchema = {
-    // 标准清单
-    bill_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    // 定额库
-    ration_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    // 工料机库
-    glj_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //清单指引库
-    billsGuidance_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    tax_group: {
-        type: [taxGroupSchema],
-        default: []
-    },
-    /* // 费率标准库 2018-08-28 改成放在tax_group 里了
+  // 标准清单
+  bill_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  // 定额库
+  ration_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  // 工料机库
+  glj_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //清单指引库
+  billsGuidance_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  tax_group: {
+    type: [taxGroupSchema],
+    default: [],
+  },
+  /* // 费率标准库 2018-08-28 改成放在tax_group 里了
      fee_lib: {
          type: Schema.Types.Mixed,
          default: []
      },*/
-    // 人工系数标准库
-    artificial_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //工程特征库
-    feature_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    info_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //累进区间库
-    progressive_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    engineer_info_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //工程特征指标库
-    engineer_feature_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //主要工料指标库
-    material_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //主要工程量指标库
-    main_quantity_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //主要经济指标库
-    economic_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //超高降效库
-    over_height_lib: {
-        type: Schema.Types.Mixed,
-        default: []
-    },
-    //设置人材机显示列
-    glj_col: {
-        showAdjustPrice: Boolean//是否显示调整价列
-    },
-    //清单或定额计价规则ID
-    valuationID: { type: String, index: true },
-    //工程专业名称
-    name: String,
-    //费用标准
-    feeName: String,
-    //前端是否显示
-    visible: { type: Boolean, default: false },
-    // 是否是项目汇总
-    isSummary: { type: Boolean, default: false },
-    //取费专业
-    engineering: Number,
-    //单位工程取费专业
-    projectEngineering: Number,
-    //是否计算安装增加费
-    isInstall: { type: Boolean, default: false },
-    //是否计算子目增加费
-    isItemIncrease: { type: Boolean, default: false },
-    //是否计算面积增加费
-    isAreaIncrease: { type: Boolean, default: false },
-    indexName: String,//指标专业名称
-    seq: Number//序列号
+  // 人工系数标准库
+  artificial_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //工程特征库
+  feature_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  info_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  item_increase_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //累进区间库
+  progressive_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  engineer_info_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //工程特征指标库
+  engineer_feature_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //主要工料指标库
+  material_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //主要工程量指标库
+  main_quantity_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //主要经济指标库
+  economic_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //超高降效库
+  over_height_lib: {
+    type: Schema.Types.Mixed,
+    default: [],
+  },
+  //设置人材机显示列
+  glj_col: {
+    showAdjustPrice: Boolean, //是否显示调整价列
+  },
+  //清单或定额计价规则ID
+  valuationID: { type: String, index: true },
+  //工程专业名称
+  name: String,
+  //费用标准
+  feeName: String,
+  //前端是否显示
+  visible: { type: Boolean, default: false },
+  // 是否是项目汇总
+  isSummary: { type: Boolean, default: false },
+  //取费专业
+  engineering: Number,
+  //单位工程取费专业
+  projectEngineering: Number,
+  //是否计算安装增加费
+  isInstall: { type: Boolean, default: false },
+  //是否计算子目增加费
+  isItemIncrease: { type: Boolean, default: false },
+  //是否计算面积增加费
+  isAreaIncrease: { type: Boolean, default: false },
+  indexName: String, //指标专业名称
+  seq: Number, //序列号
 };
-mongoose.model(collectionName, new Schema(modelSchema, { versionKey: false, collection: collectionName }));
-
+mongoose.model(
+  collectionName,
+  new Schema(modelSchema, { versionKey: false, collection: collectionName })
+);

+ 32 - 0
modules/all_models/item_increate_lib.js

@@ -0,0 +1,32 @@
+"use strict";
+
+/**
+ *
+ *
+ * @author zhang
+ * @date 2019/3/5
+ * @version
+ */
+//子目增加费模板库
+const mongoose = require("mongoose");
+const Schema = mongoose.Schema;
+const oprSchema = require("../all_schemas/opr_schema");
+const itemIncreaseLib = new Schema(
+  {
+    ID: { type: String, index: true },
+    name: String,
+    creator: String,
+    createDate: Number,
+    recentOpr: [oprSchema],
+    template: {
+      type: Schema.Types.Mixed,
+      default: [],
+    },
+  },
+  { versionKey: false }
+);
+mongoose.model(
+  "std_item_increase_lib",
+  itemIncreaseLib,
+  "std_item_increase_lib"
+);

+ 107 - 0
modules/item_increase_lib/controllers/item_increase_controller.js

@@ -0,0 +1,107 @@
+/**
+ * Created by zhang on 2018/9/3.
+ */
+import BaseController from "../../common/base/base_controller";
+import itemIncreaseFacade from "../facade/item_increase_facade.js";
+let config = require("../../../config/config.js");
+let logger = require("../../../logs/log_helper").logger;
+
+class ItemIncreaseController extends BaseController {
+  async main(request, response) {
+    let itemIncreaseLibs = await itemIncreaseFacade.findByCondition(
+      {},
+      { feature: 0 },
+      false
+    );
+    let randerData = {
+      title: "子目增加费库",
+      userAccount: request.session.managerData.username,
+      userID: request.session.managerData.userID,
+      itemIncreaseLibs,
+      layout: "maintain/common/html/layout",
+    };
+    response.render("maintain/item_increase_lib/html/main", randerData);
+  }
+  async addLib(request, response) {
+    try {
+      await itemIncreaseFacade.addLib(request.body);
+    } catch (error) {
+      console.log(error);
+    }
+    response.redirect(request.headers.referer);
+  }
+  async findLib(request, response) {
+    let result = {
+      error: 0,
+    };
+    try {
+      let data = request.body.data;
+      data = JSON.parse(data);
+      let conditions = { ID: data.ID };
+      let resultData = await itemIncreaseFacade.findByCondition(conditions);
+      result.data = resultData;
+    } catch (err) {
+      console.log(err);
+      result.error = 1;
+      result.message = err.message;
+    }
+    response.json(result);
+  }
+  async saveLib(request, response) {
+    let result = {
+      error: 0,
+    };
+    try {
+      let data = request.body.data;
+      data = JSON.parse(data);
+      let resultData = await itemIncreaseFacade.saveLib(data);
+      result.data = resultData;
+    } catch (err) {
+      console.log(err);
+      result.error = 1;
+      result.message = err.message;
+    }
+    response.json(result);
+  }
+  async deleteLibByID(request, response) {
+    logger.info(`delete itemIncreaseLib ${request.ip}`);
+    let result = {
+      error: 0,
+    };
+    try {
+      let data = request.body.data;
+      data = JSON.parse(data);
+      let resultData = await itemIncreaseFacade.deleteLibByID(data.ID);
+      result.data = resultData;
+    } catch (err) {
+      console.log(err);
+      result.error = 1;
+      result.message = err.message;
+    }
+    response.json(result);
+  }
+  async edit(request, response) {
+    //先取出替换库信息:
+    let libID = request.params.libID;
+    let itemIncreaseLib = await itemIncreaseFacade.findByCondition({
+      ID: libID,
+    });
+    if (itemIncreaseLib) {
+      let randerData = {
+        title: "基本信息库",
+        mainURL: "/itemSetting/main",
+        libName: itemIncreaseLib.name,
+        userAccount: request.session.managerData.username,
+        userID: request.session.managerData.userID,
+        template: JSON.stringify(itemIncreaseLib.template),
+        libID: libID,
+        LicenseKey: config.getLicenseKey(process.env.NODE_ENV),
+        layout: "maintain/common/html/edit_layout",
+      };
+      response.render("maintain/item_increase_lib/html/edit", randerData);
+    } else {
+      response.redirect(request.headers.referer);
+    }
+  }
+}
+export default ItemIncreaseController;

+ 39 - 0
modules/item_increase_lib/facade/item_increase_facade.js

@@ -0,0 +1,39 @@
+/**
+ * Created by zhang on 2018/9/3.
+ */
+import mongoose from "mongoose";
+const uuidV1 = require("uuid/v1");
+let moment = require("moment");
+let itemIncreaseModel = mongoose.model("std_item_increase_lib");
+
+let itemIncreaseLib = {
+  findByCondition: async function (conditions, options, single = true) {
+    if (single == true) {
+      return await itemIncreaseModel.findOne(conditions, options);
+    } else {
+      return await itemIncreaseModel.find(conditions, options);
+    }
+  },
+  addLib: async function (data) {
+    let now = new Date().getTime();
+    let dateStr = moment(now).format("YYYY-MM-DD HH:mm:ss");
+    let newLib = {
+      creator: data.userAccount,
+      createDate: now,
+      recentOpr: [{ operator: data.userAccount, operateDate: dateStr }],
+      name: data.name,
+    };
+    newLib.ID = uuidV1();
+    return await itemIncreaseModel.create(newLib);
+  },
+  saveLib: async function (param) {
+    return await itemIncreaseModel.findOneAndUpdate(param.query, param.data, {
+      new: true,
+    });
+  },
+  deleteLibByID: async function (ID) {
+    return await itemIncreaseModel.deleteOne({ ID: ID });
+  },
+};
+
+export default itemIncreaseLib;

+ 48 - 0
modules/item_increase_lib/routes/item_increase_router.js

@@ -0,0 +1,48 @@
+/**
+ * Created by zhang on 2018/9/3.
+ */
+
+let express = require("express");
+let itemRouter = express.Router();
+import ItemIncreaseController from "../controllers/item_increase_controller";
+let itemIncreaseController = new ItemIncreaseController();
+
+module.exports = function (app) {
+  itemRouter.get(
+    "/main",
+    itemIncreaseController.auth,
+    itemIncreaseController.init,
+    itemIncreaseController.main
+  );
+  itemRouter.post(
+    "/addLib",
+    itemIncreaseController.auth,
+    itemIncreaseController.init,
+    itemIncreaseController.addLib
+  );
+  itemRouter.post(
+    "/findLib",
+    itemIncreaseController.auth,
+    itemIncreaseController.init,
+    itemIncreaseController.findLib
+  );
+  itemRouter.post(
+    "/saveLib",
+    itemIncreaseController.auth,
+    itemIncreaseController.init,
+    itemIncreaseController.saveLib
+  );
+  itemRouter.post(
+    "/deleteLibByID",
+    itemIncreaseController.auth,
+    itemIncreaseController.init,
+    itemIncreaseController.deleteLibByID
+  );
+  itemRouter.get(
+    "/edit/:libID",
+    itemIncreaseController.auth,
+    itemIncreaseController.init,
+    itemIncreaseController.edit
+  );
+  app.use("/itemSetting", itemRouter);
+};

+ 10 - 0
modules/users/controllers/compilation_controller.js

@@ -32,6 +32,7 @@ import mainColFacade from "../../main_col_lib/facade/main_col_facade";
 import billTemplateFacade from "../../bills_template_lib/facade/bills_template_facade";
 import projectFeatureFacade from "../../project_feature_lib/facade/project_feature_facade";
 import basicInfoFacade from "../../basic_info_lib/facade/basic_info_facade";
+import itemIncreaseFacade from "../../item_increase_lib/facade/item_increase_facade.js";
 import engineerInfoFacade from "../../engineer_info_lib/facade/engineer_info_facade";
 import engineerFeatureFacade from "../../engineer_feature_lib/facade/engineer_feature_facade";
 import materialFacade from "../../material_lib/facade/material_facade";
@@ -227,6 +228,7 @@ class CompilationController extends BaseController {
       billsTemplateData = [],
       featureList = [],
       infoList = [],
+      itemIncreaseList = [],
       engineerInfoList = [],
       progressiveList = [],
       engineerFeatureList = [],
@@ -323,6 +325,13 @@ class CompilationController extends BaseController {
       //获取基本信息库
       infoList = await basicInfoFacade.findByCondition({}, null, false);
 
+      //获取子目增加费库
+      itemIncreaseList = await itemIncreaseFacade.findByCondition(
+        {},
+        "-template",
+        false
+      );
+
       engineerInfoList = await engineerInfoFacade.findByCondition(
         {},
         null,
@@ -383,6 +392,7 @@ class CompilationController extends BaseController {
       billsGuidanceList: JSON.stringify(billsGuidanceList),
       featureList: JSON.stringify(featureList),
       infoList: JSON.stringify(infoList),
+      itemIncreaseList: JSON.stringify(itemIncreaseList),
       engineerInfoList: JSON.stringify(engineerInfoList),
       progressiveList: JSON.stringify(progressiveList),
       engineerFeatureList: JSON.stringify(engineerFeatureList),

+ 312 - 282
modules/users/models/engineering_lib_model.js

@@ -9,177 +9,193 @@ import mongoose from "mongoose";
 import BaseModel from "../../common/base/base_model";
 import CompilationModel from "./compilation_model";
 let stdRationLibModel = mongoose.model("std_ration_lib_map");
-import { default as EngineeringConst, List as EngineeringList } from "../../common/const/engineering";
-const billsGuidanceLibModel = mongoose.model('std_billsGuidance_lib');
-const billsLibListsModel = mongoose.model('std_bills_lib_lists');
+import {
+  default as EngineeringConst,
+  List as EngineeringList,
+} from "../../common/const/engineering";
+const billsGuidanceLibModel = mongoose.model("std_billsGuidance_lib");
+const billsLibListsModel = mongoose.model("std_bills_lib_lists");
 
 class EngineeringLibModel extends BaseModel {
-    /**
-     * 构造函数
-     *
-     * @return {void}
-     */
-    constructor() {
-        let parent = super();
-        parent.model = mongoose.model("engineering_lib");
-        parent.init();
+  /**
+   * 构造函数
+   *
+   * @return {void}
+   */
+  constructor() {
+    let parent = super();
+    parent.model = mongoose.model("engineering_lib");
+    parent.init();
+  }
+
+  /**
+   * 获取标准库数据
+   *
+   * @param {Object} data
+   * @param {Number} engineering
+   * @return {Promise}
+   */
+  async getLib(data, engineering) {
+    let result = {};
+    if (data.length <= 0) {
+      return result;
     }
-
-    /**
-     * 获取标准库数据
-     *
-     * @param {Object} data
-     * @param {Number} engineering
-     * @return {Promise}
-     */
-    async getLib(data, engineering) {
-        let result = {};
-        if (data.length <= 0) {
-            return result;
-        }
-        let id = '';
-        for (let tmp of data) {
-            if (tmp.engineering === engineering) {
-                id = tmp.engineering_id;
-                break;
-            }
-        }
-        if (id === '') {
-            return result;
-        }
-        let condition = { _id: id };
-        return this.findDataByCondition(condition);
+    let id = "";
+    for (let tmp of data) {
+      if (tmp.engineering === engineering) {
+        id = tmp.engineering_id;
+        break;
+      }
     }
-
-    async getLibsByValuationID(valuationID) {
-        return this.findDataByCondition({ valuationID: valuationID }, null, false);
+    if (id === "") {
+      return result;
     }
-
-    async deleteByValuationID(valuationID) {
-        return await this.db.delete({ valuationID: valuationID });
+    let condition = { _id: id };
+    return this.findDataByCondition(condition);
+  }
+
+  async getLibsByValuationID(valuationID) {
+    return this.findDataByCondition({ valuationID: valuationID }, null, false);
+  }
+
+  async deleteByValuationID(valuationID) {
+    return await this.db.delete({ valuationID: valuationID });
+  }
+
+  //添加空的默认的所有标准库
+  /**
+   * @param valuationID
+   * @returns {Promise.<*>}
+   */
+  async addStdLib(valuationID) {
+    let stdLibs = [];
+    for (let eng of EngineeringList) {
+      let tem = {
+        glj_col: { showAdjustPrice: false },
+        valuationID: valuationID,
+        name: eng.name,
+        engineering: eng.value,
+      };
+      stdLibs.push(tem);
     }
-
-
-    //添加空的默认的所有标准库
-    /**
-     * @param valuationID
-     * @returns {Promise.<*>}
-     */
-    async addStdLib(valuationID) {
-        let stdLibs = [];
-        for (let eng of EngineeringList) {
-            let tem = {
-                glj_col: { showAdjustPrice: false },
-                valuationID: valuationID,
-                name: eng.name,
-                engineering: eng.value
-            };
-            stdLibs.push(tem);
-        }
-        let result = await this.db.create(stdLibs);
-        return result;
+    let result = await this.db.create(stdLibs);
+    return result;
+  }
+
+  async addEngineer(data) {
+    data.glj_col = { showAdjustPrice: false };
+    if (data.compilationId && data.compilationId != "") {
+      data.ration_lib = [];
+      let rationList = await stdRationLibModel.find(
+        { compilationId: data.compilationId },
+        ["ID", "dispName"]
+      );
+      for (let i = 0; i < rationList.length; i++) {
+        let tem = {
+          id: rationList[i].ID,
+          name: rationList[i].dispName,
+          isDefault: false,
+        };
+        if (i == 0) tem.isDefault = true;
+        data.ration_lib.push(tem);
+      }
     }
-
-    async addEngineer(data) {
-        data.glj_col = { showAdjustPrice: false };
-        if (data.compilationId && data.compilationId != "") {
-            data.ration_lib = [];
-            let rationList = await stdRationLibModel.find({ compilationId: data.compilationId }, ['ID', 'dispName']);
-            for (let i = 0; i < rationList.length; i++) {
-                let tem = {
-                    id: rationList[i].ID,
-                    name: rationList[i].dispName,
-                    isDefault: false
-                };
-                if (i == 0) tem.isDefault = true;
-                data.ration_lib.push(tem);
-            }
-        }
-        let result = await this.db.create(data);
-        return result;
+    let result = await this.db.create(data);
+    return result;
+  }
+
+  // 拷贝工程专业
+  async copyEngineer(sourceID) {
+    const engineering = await this.db.findOne({ _id: sourceID });
+    const newEngineering = engineering._doc;
+    delete newEngineering._id;
+    newEngineering.visible = false;
+    await this.db.create(newEngineering);
+  }
+
+  /**
+   * 新增标准库
+   *
+   * @param {String} valuationId
+   * @param {Object} data
+   * @return {Promise}
+   */
+  async addLib(engineerId, data) {
+    if (data.glj_col) {
+      data.glj_col = JSON.parse(data.glj_col);
     }
-
-    // 拷贝工程专业
-    async copyEngineer(sourceID) {
-        const engineering = await this.db.findOne({ _id: sourceID });
-        const newEngineering = engineering._doc;
-        delete newEngineering._id;
-        newEngineering.visible = false;
-        await this.db.create(newEngineering);
+    data.isInstall == "true"
+      ? (data.isInstall = true)
+      : (data.isInstall = false);
+    data.isItemIncrease == "true"
+      ? (data.isItemIncrease = true)
+      : (data.isItemIncrease = false);
+    data.isAreaIncrease == "true"
+      ? (data.isAreaIncrease = true)
+      : (data.isAreaIncrease = false);
+    let result = false;
+    data = this.filterLibData(data);
+    try {
+      // 处理清单指引
+      if (data.billsGuidance_lib && data.billsGuidance_lib.length) {
+        const billsGuidanceLibIDs = data.billsGuidance_lib.map(
+          (item) => item.id
+        );
+        const billsGuidanceLibs = await billsGuidanceLibModel
+          .find({ ID: { $in: billsGuidanceLibIDs } }, "-_id ID type")
+          .lean();
+        const libTypeMap = {};
+        billsGuidanceLibs.forEach((lib) => (libTypeMap[lib.ID] = lib.type));
+        data.billsGuidance_lib.forEach((lib) => {
+          lib.type = libTypeMap[lib.id] || 1;
+        });
+      }
+      // 标准清单新增清单类型
+      if (data.bill_lib && data.bill_lib.length) {
+        const billLibIDs = data.bill_lib.map((item) => +item.id);
+        const billLibs = await billsLibListsModel
+          .find({ billsLibId: { $in: billLibIDs } }, "-_id billsLibId libType")
+          .lean();
+        const libTypeMap = {};
+        billLibs.forEach((lib) => (libTypeMap[lib.billsLibId] = lib.libType));
+        data.bill_lib.forEach((lib) => {
+          lib.libType = libTypeMap[lib.id] || "1";
+        });
+      }
+      let engineeringLib = await this.findDataByCondition({ _id: engineerId });
+      if (engineeringLib) {
+        // 存在则直接更新
+        delete data.id;
+        delete data.section;
+        let condition = { _id: engineerId };
+        result = await this.db.update(condition, data);
+        result = result.ok === 1;
+      } else {
+        throw new Error("找不到对应的工程专业");
+      }
+    } catch (error) {
+      console.log(error);
+      result = false;
     }
 
-    /**
-     * 新增标准库
-     *
-     * @param {String} valuationId
-     * @param {Object} data
-     * @return {Promise}
-     */
-    async addLib(engineerId, data) {
-        if (data.glj_col) {
-            data.glj_col = JSON.parse(data.glj_col);
-        }
-        data.isInstall == 'true' ? data.isInstall = true : data.isInstall = false;
-        data.isItemIncrease == 'true' ? data.isItemIncrease = true : data.isItemIncrease = false;
-        data.isAreaIncrease == 'true' ? data.isAreaIncrease = true : data.isAreaIncrease = false;
-        let result = false;
-        data = this.filterLibData(data);
-        try {
-            // 处理清单指引
-            if (data.billsGuidance_lib && data.billsGuidance_lib.length) {
-                const billsGuidanceLibIDs = data.billsGuidance_lib.map(item => item.id);
-                const billsGuidanceLibs = await billsGuidanceLibModel.find({ ID: { $in: billsGuidanceLibIDs } }, '-_id ID type').lean();
-                const libTypeMap = {};
-                billsGuidanceLibs.forEach(lib => libTypeMap[lib.ID] = lib.type);
-                data.billsGuidance_lib.forEach(lib => {
-                    lib.type = libTypeMap[lib.id] || 1;
-                });
-            }
-            // 标准清单新增清单类型
-            if (data.bill_lib && data.bill_lib.length) {
-                const billLibIDs = data.bill_lib.map(item => +item.id);
-                const billLibs = await billsLibListsModel.find({ billsLibId: { $in: billLibIDs } }, '-_id billsLibId libType').lean();
-                const libTypeMap = {};
-                billLibs.forEach(lib => libTypeMap[lib.billsLibId] = lib.libType);
-                data.bill_lib.forEach(lib => {
-                    lib.libType = libTypeMap[lib.id] || '1';
-                });
-            }
-            let engineeringLib = await this.findDataByCondition({ _id: engineerId });
-            if (engineeringLib) {
-                // 存在则直接更新
-                delete data.id;
-                delete data.section;
-                let condition = { _id: engineerId };
-                result = await this.db.update(condition, data);
-                result = result.ok === 1;
-            } else {
-                throw new Error("找不到对应的工程专业");
-            }
-
-        } catch (error) {
-            console.log(error);
-            result = false;
-        }
-
-        return result;
+    return result;
+  }
+
+  /**
+   * 过滤计价数据
+   *
+   * @param {Object} data
+   * @return {Object}
+   */
+  filterLibData(data) {
+    if (Object.keys(data).length <= 0 || data.section === undefined) {
+      console.log("1");
+      throw "数据有误";
     }
-
-    /**
-     * 过滤计价数据
-     *
-     * @param {Object} data
-     * @return {Object}
-     */
-    filterLibData(data) {
-        if (Object.keys(data).length <= 0 || data.section === undefined) {
-            console.log('1');
-            throw '数据有误';
-        }
-        data.engineering = parseInt(data.engineering);
-        //需求修改,工程专业可以随便输入了
-        //检测专业工程是否合法
-        /*     let match = false;
+    data.engineering = parseInt(data.engineering);
+    //需求修改,工程专业可以随便输入了
+    //检测专业工程是否合法
+    /*     let match = false;
              for(let index in EngineeringConst) {
                  if (EngineeringConst[index] === data.engineering) {
                      match = true;
@@ -190,157 +206,171 @@ class EngineeringLibModel extends BaseModel {
                  throw '工程专业错误';
              }*/
 
-        // 判断标准清单
-        data.bill_lib = this._validLib(data.bill_lib);
+    // 判断标准清单
+    data.bill_lib = this._validLib(data.bill_lib);
 
-        // 判断定额库
-        data.ration_lib = this._validLib(data.ration_lib);
+    // 判断定额库
+    data.ration_lib = this._validLib(data.ration_lib);
 
-        //设置默认定额库
-        this.setDefaultRation(data);
+    //设置默认定额库
+    this.setDefaultRation(data);
 
-        // 判断工料机库
-        data.glj_lib = this._validLib(data.glj_lib);
+    // 判断工料机库
+    data.glj_lib = this._validLib(data.glj_lib);
 
-        // 判断清单指引库
-        data.billsGuidance_lib = this._validLib(data.billsGuidance_lib);
+    // 判断清单指引库
+    data.billsGuidance_lib = this._validLib(data.billsGuidance_lib);
 
-        /*// 判断费率标准
+    /*// 判断费率标准
         data.fee_lib = this._validLib(data.fee_lib);*/
 
-        // 判断人工系数
-        data.artificial_lib = this._validLib(data.artificial_lib);
+    // 判断人工系数
+    data.artificial_lib = this._validLib(data.artificial_lib);
 
-        //判断工程特征库
-        data.feature_lib = this._validLib(data.feature_lib);
+    //判断工程特征库
+    data.feature_lib = this._validLib(data.feature_lib);
 
-        //判断基本信息
-        data.info_lib = this._validLib(data.info_lib);
+    //判断基本信息
+    data.info_lib = this._validLib(data.info_lib);
 
-        //判断工程信息
-        data.engineer_info_lib = this._validLib(data.engineer_info_lib);
+    //判断基本信息
+    data.item_increase_lib = this._validLib(data.item_increase_lib);
 
-        //判断累进区间库
-        data.progressive_lib = this._validLib(data.progressive_lib);
+    //判断工程信息
+    data.engineer_info_lib = this._validLib(data.engineer_info_lib);
 
-        //判断工程特征指标信息
-        data.engineer_feature_lib = this._validLib(data.engineer_feature_lib);
+    //判断累进区间库
+    data.progressive_lib = this._validLib(data.progressive_lib);
 
-        //判断主要工料指标信息
-        data.material_lib = this._validLib(data.material_lib);
+    //判断工程特征指标信息
+    data.engineer_feature_lib = this._validLib(data.engineer_feature_lib);
 
-        //判断主要工料指标信息
-        data.main_quantity_lib = this._validLib(data.main_quantity_lib);
+    //判断主要工料指标信息
+    data.material_lib = this._validLib(data.material_lib);
 
-        //判断主要经济指标信息
-        data.economic_lib = this._validLib(data.economic_lib);
+    //判断主要工料指标信息
+    data.main_quantity_lib = this._validLib(data.main_quantity_lib);
 
-        data.over_height_lib = this._validLib(data.over_height_lib);
+    //判断主要经济指标信息
+    data.economic_lib = this._validLib(data.economic_lib);
 
-        //计税方式组合
-        data.tax_group = this._validLib(data.tax_group);
+    data.over_height_lib = this._validLib(data.over_height_lib);
 
-        return data;
-    }
+    //计税方式组合
+    data.tax_group = this._validLib(data.tax_group);
+    return data;
+  }
 
-    /**
-     * 校验库数据
-     *
-     * @param {Object} libData
-     * @return {Object}
-     */
-    _validLib(libData) {
-        let result = [];
-        // 判断标准库
-        if (libData === undefined || libData === null || libData === '') {
-            return result;//throw '标准库不能为空'; 按新需求,标准库等不做非空判断
-        }
-        libData = libData instanceof Array ? libData : [libData];
-        for (let tmp in libData) {
-            result[tmp] = JSON.parse(libData[tmp]);
-        }
-        return result;
+  /**
+   * 校验库数据
+   *
+   * @param {Object} libData
+   * @return {Object}
+   */
+  _validLib(libData) {
+    let result = [];
+    // 判断标准库
+    if (libData === undefined || libData === null || libData === "") {
+      return result; //throw '标准库不能为空'; 按新需求,标准库等不做非空判断
     }
-
-    //设置默认定额库
-    setDefaultRation(data) {
-        if (data.ration_lib && data.ration_lib.length > 0) {
-            if (data.ration_isDefault && data.ration_isDefault != "") {
-                for (let r of data.ration_lib) {
-                    r.id.toString() == data.ration_isDefault ? r.isDefault = true : r.isDefault = false;
-                }
-            } else {
-                data.ration_lib[0].isDefault = true;
-            }
-        }
+    libData = libData instanceof Array ? libData : [libData];
+    for (let tmp in libData) {
+      result[tmp] = JSON.parse(libData[tmp]);
     }
-
-
-    /**
-     * 获取对应标准库数量
-     *
-     * @param {Object} valuationData
-     * @return {Object}
-     */
-    async getLibCount(valuationData) {
-        let result = {};
-        if (valuationData.engineering_list === undefined || valuationData.engineering_list.length <= 0) {
-            return result;
-        }
-
-        // 整理需要查找的数据
-        let findIdList = [];
-        for (let engineering of valuationData.engineering_list) {
-            findIdList.push(engineering.engineering_id);
-        }
-
-        let condition = { _id: { $in: findIdList } };
-        let libData = await this.findDataByCondition(condition, null, false);
-        if (libData === null) {
-            return result;
-        }
-
-        // 整理数据
-        let countData = {};
-        for (let tmp of libData) {
-            countData[tmp._id] = {
-                bill_count: tmp.bill_lib.length,
-                ration_count: tmp.ration_lib.length,
-                glj_count: tmp.glj_lib.length,
-                fee_count: tmp.fee_lib.length,
-                artificial_count: tmp.artificial_lib.length,
-                program_count: tmp.program_lib.length,
-            };
+    return result;
+  }
+
+  //设置默认定额库
+  setDefaultRation(data) {
+    if (data.ration_lib && data.ration_lib.length > 0) {
+      if (data.ration_isDefault && data.ration_isDefault != "") {
+        for (let r of data.ration_lib) {
+          r.id.toString() == data.ration_isDefault
+            ? (r.isDefault = true)
+            : (r.isDefault = false);
         }
+      } else {
+        data.ration_lib[0].isDefault = true;
+      }
+    }
+  }
+
+  /**
+   * 获取对应标准库数量
+   *
+   * @param {Object} valuationData
+   * @return {Object}
+   */
+  async getLibCount(valuationData) {
+    let result = {};
+    if (
+      valuationData.engineering_list === undefined ||
+      valuationData.engineering_list.length <= 0
+    ) {
+      return result;
+    }
 
+    // 整理需要查找的数据
+    let findIdList = [];
+    for (let engineering of valuationData.engineering_list) {
+      findIdList.push(engineering.engineering_id);
+    }
 
-        for (let engineering of valuationData.engineering_list) {
-            if (countData[engineering.engineering_id] !== undefined) {
-                result[engineering.engineering] = countData[engineering.engineering_id];
-            }
-        }
+    let condition = { _id: { $in: findIdList } };
+    let libData = await this.findDataByCondition(condition, null, false);
+    if (libData === null) {
+      return result;
+    }
 
-        return result;
+    // 整理数据
+    let countData = {};
+    for (let tmp of libData) {
+      countData[tmp._id] = {
+        bill_count: tmp.bill_lib.length,
+        ration_count: tmp.ration_lib.length,
+        glj_count: tmp.glj_lib.length,
+        fee_count: tmp.fee_lib.length,
+        artificial_count: tmp.artificial_lib.length,
+        program_count: tmp.program_lib.length,
+      };
     }
 
-    async copyRationLibsToOthers(valuationID, engineeringID) {
-        const compilationModel = new CompilationModel();
-        const compilation = await compilationModel.model.findOne({ $or: [{ 'bill_valuation.id': valuationID }, { 'ration_valuation.id': valuationID }] });
-        if (!compilation) {
-            return;
-        }
-        const valuationIDList = [];
-        const allValuation = compilation.ration_valuation.concat(compilation.bill_valuation);
-        for (const valuation of allValuation) {
-            valuationIDList.push(valuation.id);
-        }
-        const engineering = await this.findDataByCondition({ _id: engineeringID });
-        if (!engineering) {
-            return;
-        }
-        await this.model.updateMany({ valuationID: { $in: valuationIDList } }, { $set: { ration_lib: engineering.ration_lib } });
+    for (let engineering of valuationData.engineering_list) {
+      if (countData[engineering.engineering_id] !== undefined) {
+        result[engineering.engineering] = countData[engineering.engineering_id];
+      }
     }
 
+    return result;
+  }
+
+  async copyRationLibsToOthers(valuationID, engineeringID) {
+    const compilationModel = new CompilationModel();
+    const compilation = await compilationModel.model.findOne({
+      $or: [
+        { "bill_valuation.id": valuationID },
+        { "ration_valuation.id": valuationID },
+      ],
+    });
+    if (!compilation) {
+      return;
+    }
+    const valuationIDList = [];
+    const allValuation = compilation.ration_valuation.concat(
+      compilation.bill_valuation
+    );
+    for (const valuation of allValuation) {
+      valuationIDList.push(valuation.id);
+    }
+    const engineering = await this.findDataByCondition({ _id: engineeringID });
+    if (!engineering) {
+      return;
+    }
+    await this.model.updateMany(
+      { valuationID: { $in: valuationIDList } },
+      { $set: { ration_lib: engineering.ration_lib } }
+    );
+  }
 }
 
 export default EngineeringLibModel;

+ 38 - 0
web/maintain/item_increase_lib/html/edit.html

@@ -0,0 +1,38 @@
+<nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0 second_header">
+    <ul class="nav nav-tabs" role="tablist">
+        <li class="nav-item">
+            <a class="nav-link active px-3" href="javascript: void(0);">子目增加费</a>
+        </li>
+    </ul>
+</nav>
+
+<div class="main">
+    <div class="content" >
+        <div class="container-fluid" >
+        <div class=" col-lg-12 p-0">
+            <nav class="navbar sticky-top navbar-toggleable-md navbar-light bg-faded tools-bar">
+                <div class="collapse navbar-collapse" id="navbarNav">
+                    <div class="tools-btn btn-group align-top">
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="createNormal"><i class="fa fa-list-alt" aria-hidden="true"></i> 生成默认</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
+                    </div>
+                </div>
+            </nav>
+            <textarea class="form-control lock-text-control" id="template" rows="38"></textarea>
+        </div>
+        </div>
+        <input type="hidden" id="libID" value="<%= libID %>">
+        <input type="hidden" id="originalInfo" value="<%= template %>">
+    </div>
+</div>
+
+
+
+<script type="text/javascript">
+
+</script>
+<script type="text/javascript" src="/public/web/PerfectLoad.js"></script>
+<script type="text/javascript" src="/lib/json/json2.js"></script>
+<script src="/public/web/lock_util.js"></script>
+<script type="text/javascript" src="/web/maintain/item_increase_lib/js/item_increase_edit.js"></script>

+ 123 - 0
web/maintain/item_increase_lib/html/main.html

@@ -0,0 +1,123 @@
+<div class="main">
+    <div class="content">
+        <div class="container-fluid">
+            <div class="row">
+                <div class="col-md-8">
+                    <div class="warp-p2 mt-3">
+                        <table class="table table-hover table-bordered">
+                            <thead>
+                                <tr>
+                                    <th>库名称</th>
+                                    <th width="160">添加时间</th>
+                                    <th width="70">操作</th>
+                                </tr>
+                            </thead>
+                            <tbody id="showArea">
+                                <% for(let lib of itemIncreaseLibs){ %>
+                                <tr class="libTr">
+                                    <td id="<%= lib.ID%>"><a
+                                            href="/itemSetting/edit/<%= lib.ID%>?locked=true"><%= lib.name%></a></td>
+                                    <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
+                                    <td>
+                                        <a class="lock-btn-control disabled" href="javascript:void(0);"
+                                            style="color: #0275d8" onclick='getItemIncreaseLib("<%= lib.ID%>")'
+                                            title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                        <a class="text-danger lock-btn-control disabled" href="javascript:void(0);"
+                                            style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")'
+                                            title="删除"><i class="fa fa-remove"></i></a>
+                                        <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i
+                                                class="fa fa-unlock-alt"></i></a>
+                                    </td>
+                                </tr>
+                                <% } %>
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<!--弹出添加-->
+<div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">添加子目增加费库</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">×</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <form id="addLibForm" method="post" action="/itemSetting/addLib"
+                    enctype="application/x-www-form-urlencoded21">
+                    <div class="form-group">
+                        <label>库名称</label>
+                        <input id="name" name="name" class="form-control" placeholder="请输入子目增加费库名称" type="text">
+                        <small class="form-text text-danger" id="nameError" style="display: none">请输入子目增加费库名称。</small>
+                    </div>
+                    <input type="hidden" name="userAccount" value="<%= userAccount%>">
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button id="addLibs" class="btn btn-primary">新建</button>
+                <button type="button" id="cancelBtn" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<!--弹出编辑-->
+<div class="modal fade" id="edit" data-backdrop="static" style="display: none;" aria-hidden="true">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">子目增加费库</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">×</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <form>
+                    <div class="form-group">
+                        <label>子目增加费库名称</label>
+                        <input id="renameText" class="form-control" placeholder="输入名称" type="text" value="">
+                        <small class="form-text text-danger" id="renameError" style="display: none">请输入名称。</small>
+                        <input id="libID" type="hidden">
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <a id="rename" href="javascript: void(0);" class="btn btn-primary">确定</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<!--弹出删除-->
+<div class="modal fade" id="del" data-backdrop="static" style="display: none;" aria-hidden="true">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">删除确认</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">×</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <h5 class="text-danger">删除后无法恢复,确认是否删除?</h5>
+                <input type="hidden" id="libID_del">
+                <input type="hidden" id="delCount">
+            </div>
+            <div class="modal-footer">
+                <a id="delete" href="javascript:void(0);" class="btn btn-danger">确认</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script src="/public/web/lock_util.js"></script>
+<script type="text/javascript" src="/web/maintain/item_increase_lib/js/item_increase.js"></script>

+ 90 - 0
web/maintain/item_increase_lib/js/item_increase.js

@@ -0,0 +1,90 @@
+/**
+ * Created by zhang on 2018/9/3.
+ */
+$(document).ready(function () {
+  // 保存按钮
+  $("#addLibs").click(async function () {
+    let name = $("#name").val();
+    if (name == "") {
+      $("#nameError").show();
+      return;
+    } else {
+      $("#addLibs").attr("disabled", true); //防止重复提交
+      $("#addLibForm").submit();
+    }
+  });
+
+  $("#rename").click(async function () {
+    let libID = $("#libID").val();
+    let name = $("#renameText").val();
+    if (libID != "") {
+      if (name == "") {
+        $("#renameError").show();
+        return;
+      } else {
+        try {
+          let newInfo = await ajaxPost("/itemSetting/saveLib", {
+            query: { ID: libID },
+            data: { name: name },
+          });
+          $("#" + libID)
+            .children("a")
+            .text(newInfo.name);
+          $("#edit").modal("hide");
+        } catch (err) {
+          console.log(err);
+        }
+      }
+    }
+  });
+
+  $("#delete").click(async function () {
+    let libID = $("#libID_del").val();
+    let delCount = parseInt($("#delCount").val());
+    delCount = delCount + 1;
+    $("#delCount").val(delCount);
+    if (delCount == 3) {
+      if (libID != "") {
+        try {
+          let result = await ajaxPost("/itemSetting/deleteLibByID", {
+            ID: libID,
+          });
+          if (result.ok) {
+            $("#" + libID)
+              .parent(".libTr")
+              .remove();
+          }
+          $("#del").modal("hide");
+        } catch (err) {
+          console.log(err);
+        }
+      }
+    }
+  });
+
+  // 锁定、解锁
+  $(".lock").click(function () {
+    lockUtil.handleLockClick($(this));
+  });
+});
+
+async function getItemIncreaseLib(ID) {
+  try {
+    let lib = await ajaxPost("/itemSetting/findLib", { ID: ID });
+    if (lib) {
+      $("#renameText").val(lib.name);
+      $("#libID").val(ID);
+      $("#edit").modal({ show: true });
+    } else {
+      alert("没有找到基本信息库");
+    }
+  } catch (err) {
+    console.log(err);
+  }
+}
+
+function showDeleteModal(ID) {
+  $("#libID_del").val(ID);
+  $("#delCount").val(0);
+  $("#del").modal({ show: true });
+}

+ 106 - 0
web/maintain/item_increase_lib/js/item_increase_edit.js

@@ -0,0 +1,106 @@
+/**
+ * Created by zhang on 2018/9/3.
+ */
+
+$(document).ready(function () {
+  const locked = lockUtil.getLocked();
+  lockUtil.lockTools($(document.body), locked);
+  try {
+    let tem = sortJson(JSON.parse($("#originalInfo").val()), compareInfo);
+    $("#template").val(JSON.stringify(tem, null, 4));
+  } catch (err) {
+    console.log(err);
+  }
+
+  $("#format").click(function () {
+    try {
+      let jsonText = $("#template").val();
+      $("#template").val(JSON.stringify(JSON.parse(jsonText), null, 4));
+    } catch (err) {
+      console.log(err);
+      alert("输入的JSON格式有误,请重新输入!");
+    }
+  });
+  $("#save").click(async function () {
+    try {
+      $.bootstrapLoading.start();
+      let libID = $("#libID").val();
+      let jsonText = $("#template").val();
+      if (jsonText.indexOf("'") != -1) {
+        alert(
+          "输入的格式不能包含 ' 位于:" +
+            jsonText.substr(jsonText.indexOf("'") - 15, 18)
+        );
+        return;
+      }
+      await ajaxPost("/itemSetting/saveLib", {
+        query: { ID: libID },
+        data: { template: JSON.parse(jsonText) },
+      });
+      $.bootstrapLoading.end();
+    } catch (err) {
+      $.bootstrapLoading.end();
+      console.log(err);
+      alert("保存失败,请查看输入数据");
+    }
+  });
+  $("#createNormal").click(async function () {
+    let basicTemplate = [
+      {
+        ID: "1",
+        name: "在生产车间边生产边施工",
+        base: "人工费",
+        coe: 10,
+        isCalc: false,
+        reductionRate: 100,
+        measureRate: 70,
+        position: "010001",
+      },
+      {
+        ID: "2",
+        name: "在有害身体健康的场所内施工",
+        base: "人工费",
+        coe: 10,
+        isCalc: false,
+        reductionRate: 100,
+        measureRate: 70,
+        position: "010001",
+      },
+      {
+        ID: "3",
+        name: "在洞内、地下室内、库内或暗室内进行施工",
+        base: "人工费",
+        coe: 40,
+        isCalc: false,
+        reductionRate: 100,
+        measureRate: 70,
+        position: "010001",
+      },
+      {
+        ID: "4",
+        name: "在洞内、地下室内、库内或暗室内进行施工(模板拆除)",
+        base: "人工费",
+        coe: 10,
+        isCalc: false,
+        reductionRate: 100,
+        measureRate: 70,
+        position: "010001",
+      },
+    ];
+    try {
+      let jsonText = JSON.stringify(basicTemplate);
+      $("#template").val(JSON.stringify(JSON.parse(jsonText), null, 4));
+    } catch (err) {
+      console.log(err);
+    }
+  });
+});
+function compareInfo(a, b) {
+  let mapping = {
+    ID: 1,
+    name: 2,
+  };
+  let aV = mapping[a] ? mapping[a] : 0,
+    bV = mapping[b] ? mapping[b] : 0;
+  return aV - bV;
+}

+ 25 - 1
web/users/js/compilation.js

@@ -531,6 +531,10 @@ $(document).ready(function () {
         $("#info-area").show();
         $("#add-compilation-title").text("添加基本信息");
         break;
+      case "item_increase":
+        $("#item-increase-area").show();
+        $("#add-compilation-title").text("添加子目增加费");
+        break;
       case "progressive":
         $("#progressive-area").show();
         $("#add-compilation-title").text("添加累进区间");
@@ -579,7 +583,7 @@ $(document).ready(function () {
         $(this).parent().remove();
     })*/
   $(
-    ".bill-list, .ration-list, .glj-list, .fee-list, .artificial-list, .program-list, .billsGuidance-list,.feature-list,.info-list,.progressive-list,.engineer_info-list,.engineer_feature-list,.material-list,.main_quantity-list,.economic-list,.over_height-list"
+    ".bill-list, .ration-list, .glj-list, .fee-list, .artificial-list, .program-list, .billsGuidance-list,.feature-list,.info-list,.progressive-list,.engineer_info-list,.engineer_feature-list,.material-list,.main_quantity-list,.economic-list,.over_height-list,.item_increase-list"
   ).on("click", ".remove-lib", function () {
     $(this).parent().remove();
   });
@@ -930,6 +934,8 @@ function initCompilation() {
     mainTreeColList == undefined ? [] : JSON.parse(mainTreeColList);
   let featureData = featureList == undefined ? [] : JSON.parse(featureList);
   let infoData = infoList == undefined ? [] : JSON.parse(infoList);
+  let itemIncreaseData =
+    itemIncreaseList == undefined ? [] : JSON.parse(itemIncreaseList);
   let progressiveData =
     progressiveList == undefined ? [] : JSON.parse(progressiveList);
   let engineerInfoData =
@@ -1050,6 +1056,14 @@ function initCompilation() {
   }
   $("select[name='info_lib']").children("option").first().after(html);
 
+  //基本信息库
+  html = "";
+  for (let tmp of itemIncreaseData) {
+    let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
+    html += tmpHtml;
+  }
+  $("select[name='item_increase_lib']").children("option").first().after(html);
+
   //累进区间库
   html = "";
   for (let tmp of progressiveData) {
@@ -1138,6 +1152,9 @@ function getAndValidData(model) {
     .children("option:selected")
     .val();
   let infoLib = $("select[name='info_lib']").children("option:selected").val();
+  let itemIncreaseLib = $("select[name='item_increase_lib']")
+    .children("option:selected")
+    .val();
   let progressiveLib = $("select[name='progressive_lib']")
     .children("option:selected")
     .val();
@@ -1222,6 +1239,9 @@ function getAndValidData(model) {
   let infoString = $("select[name='info_lib']")
     .children("option:selected")
     .text();
+  let itemIncreaseString = $("select[name='item_increase_lib']")
+    .children("option:selected")
+    .text();
   let progressiveString = $("select[name='progressive_lib']")
     .children("option:selected")
     .text();
@@ -1282,6 +1302,10 @@ function getAndValidData(model) {
       id: infoLib,
       name: infoString,
     },
+    item_increase: {
+      id: itemIncreaseLib,
+      name: itemIncreaseString,
+    },
     progressive: {
       id: progressiveLib,
       name: progressiveString,

+ 18 - 0
web/users/views/compilation/engineering.html

@@ -243,6 +243,23 @@
                                 </div>
                                 <a href="#" class="btn btn-link btn-sm add-compilation" data-model="over_height">添加</a>
                             </div>
+                            <div class="form-group col-md-3">
+                                <label>子目增加费</label>
+                                <div class="item_increase-list">
+                                    <% if (Object.keys(libData).length > 0 && libData.item_increase_lib && libData.item_increase_lib.length > 0) { %>
+                                    <% libData.item_increase_lib.forEach(function (info, index){ %>
+                                    <p class="form-control-static">
+                                        <a class="pull-right text-danger remove-lib" data-model="item_increase" title="移除" data-id="<%= info.id %>">
+                                            <span class="glyphicon glyphicon-remove"></span>
+                                        </a>
+                                        <input type="hidden" name="item_increase_lib" data-id="<%= info.id %>" value="<%= JSON.stringify({id: info.id, name: info.name}) %>">
+                                        <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= info.name %>
+                                    </p>
+                                    <% }) %>
+                                    <% } %>
+                                </div>
+                                <a href="#" class="btn btn-link btn-sm add-compilation" data-model="item_increase">添加</a>
+                            </div>
                     </div>
 
                     <div class="col-md-12">
@@ -380,6 +397,7 @@
     let mainTreeColList = '<%- mainTreeColList %>';
     let featureList = '<%- featureList %>';
     let infoList = '<%- infoList %>';
+    let itemIncreaseList = '<%- itemIncreaseList %>';
     let progressiveList = '<%- progressiveList %>';
     let engineerInfoList ='<%- engineerInfoList %>';
     let engineerFeatureList ='<%- engineerFeatureList %>';

+ 10 - 0
web/users/views/compilation/modal.html

@@ -61,6 +61,16 @@
                         </div>
                     </div>
                 </div>
+                <div class="form-group" id="item-increase-area">
+                    <label>子目增加费</label>
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <select class="form-control" name="item_increase_lib">
+                                <option value="">请选择子目增加费库</option>
+                            </select>
+                        </div>
+                    </div>
+                </div>
                 <div class="form-group" id="progressive-area">
                     <label>累进区间</label>
                     <div class="row">