Explorar el Código

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/ConstructionCost

laiguoran hace 4 años
padre
commit
38e5d7019c
Se han modificado 28 ficheros con 548 adiciones y 105 borrados
  1. 5 0
      config/gulpConfig.js
  2. 2 1
      modules/all_models/compleRation_ration.js
  3. 2 1
      modules/all_models/ration_glj.js
  4. 54 21
      modules/complementary_glj_lib/controllers/gljController.js
  5. 63 1
      modules/complementary_glj_lib/models/gljModel.js
  6. 2 1
      modules/complementary_glj_lib/routes/routes.js
  7. 7 2
      modules/complementary_ration_lib/models/compleRationModel.js
  8. 8 1
      modules/main/facade/ration_facade.js
  9. 38 9
      modules/ration_glj/controllers/ration_glj_controller.js
  10. 5 1
      modules/ration_glj/facade/ration_glj_facade.js
  11. 33 37
      public/web/sheet/sheet_common.js
  12. 6 1
      public/web/tree_sheet/tree_sheet_helper.js
  13. 11 4
      web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html
  14. 7 4
      web/building_saas/complementary_glj_lib/js/glj.js
  15. 1 1
      web/building_saas/complementary_glj_lib/js/gljClassTree.js
  16. 6 4
      web/building_saas/complementary_glj_lib/js/gljComponent.js
  17. 124 0
      web/building_saas/complementary_glj_lib/js/init.js
  18. 2 1
      web/building_saas/complementary_ration_lib/js/gljSelect.js
  19. 12 1
      web/building_saas/complementary_ration_lib/js/ration_glj.js
  20. 24 0
      web/building_saas/main/html/main.html
  21. 9 0
      web/building_saas/main/js/models/ration_glj.js
  22. 7 5
      web/building_saas/main/js/views/glj_view.js
  23. 9 0
      web/building_saas/main/js/views/main_tree_col.js
  24. 89 0
      web/building_saas/main/js/views/select_FB_view.js
  25. 14 3
      web/building_saas/main/js/views/std_billsGuidance_lib.js
  26. 3 3
      web/building_saas/report/js/rpt_main.js
  27. 4 2
      web/common/components/share/index.js
  28. 1 1
      web/common/html/header.html

+ 5 - 0
config/gulpConfig.js

@@ -186,6 +186,7 @@ module.exports = {
         'web/building_saas/main/js/views/fee_rate_view.js',
         'web/building_saas/main/js/views/quantity_edit_view.js',
         'web/building_saas/main/js/views/sub_fee_rate_views.js',
+        'web/building_saas/main/js/views/select_FB_view.js',
         'web/building_saas/main/js/views/calc_base_view.js',
         'web/building_saas/main/js/views/project_property_labour_coe_view.js',
         'web/building_saas/main/js/views/locate_view.js',
@@ -198,6 +199,9 @@ module.exports = {
         'lib/ztree/css/zTreeStyle.css',
     ],
     compleGlj_jspaths: [
+        'lib/pinyinjs/pinyin_dict_firstletter.js',
+        'lib/pinyinjs/pinyinUtil.js',
+        'web/common/components/share/index.js',
         'public/web/common_ajax.js',
         'public/web/treeDataHelper.js',
         'public/web/QueryParam.js',
@@ -207,6 +211,7 @@ module.exports = {
         'public/web/tree_sheet/tree_sheet_helper.js',
         'public/web/tools_const.js',
         'public/web/ration_glj_units.js',
+        'web/building_saas/complementary_glj_lib/js/init.js',
         'web/building_saas/complementary_glj_lib/js/glj.js',
         'web/building_saas/complementary_glj_lib/js/gljClassTree.js',
         'web/building_saas/complementary_glj_lib/js/gljComponent.js',

+ 2 - 1
modules/all_models/compleRation_ration.js

@@ -10,7 +10,8 @@ const deleteSchema = require('../all_schemas/delete_schema');
 const compleRationGljItemSchema = new Schema({
     gljId: Number,
     consumeAmt: String,
-    type: String    //std or complementary
+    type: String,    //std or complementary
+    fromUser: String,
 
 }, { _id: false });
 

+ 2 - 1
modules/all_models/ration_glj.js

@@ -36,7 +36,8 @@ var ration_glj = new Schema({
     rationItemQuantity:String,
     tenderQuantity:String,//调整后消耗量
     createType: {type: String,default:'normal'},//normal、add、replace  正常、添加工料机、替换工料机
-    from:{type: String,default:'std'}//std, cpt  来自标准工料机库、补充工料机库
+    from:{type: String,default:'std'},//std, cpt  来自标准工料机库、补充工料机库
+    fromUser: String, // 来自某个用户的人材机(分享补充人材机)
 },{versionKey:false});
 
 mongoose.model('ration_glj', ration_glj);

+ 54 - 21
modules/complementary_glj_lib/controllers/gljController.js

@@ -6,39 +6,58 @@ const stdgljutil = require("../../../public/cache/std_glj_type_util");
 const GljDao = require("../models/gljModel");
 const EngineeringLibModel = require("../../users/models/engineering_lib_model");
 let config = require("../../../config/config.js");
-
+const pmFacade = require('../../pm/facade/pm_facade');
+const { ShareLibType } = require('../../../public/common_constants');
 let gljDao = new GljDao();
 let callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };
 
+async function getGljLibId(sessionCompilation) {
+    let gljLibId = null,
+        rationValuation = sessionCompilation.ration_valuation,
+        billValuation = sessionCompilation.bill_valuation,
+        engineeringLibModel = new EngineeringLibModel(),
+        valuationIDs = [] ;
+    for(let r of rationValuation){//{ "glj_lib.0": {$exists:1} }
+        if(r.id){
+            valuationIDs.push(r.id);
+        }
+    }
+    for(let b of billValuation){
+        if(b.id){
+            valuationIDs.push(b.id);
+        }
+    }
+    if(valuationIDs.length > 0){
+        let engineeringInfo = await engineeringLibModel.findDataByCondition({'valuationID': {"$in": valuationIDs},"glj_lib.0": {$exists:1}});//数组大于0
+        gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+    }
+    return gljLibId;
+}
+
 class GljController extends BaseController{
     async redirectGlj(req, res){
-        let gljLibId = null, engineeringId, sessionCompilation = req.session.sessionCompilation,
-            rationValuation = sessionCompilation.ration_valuation,
-            billValuation = sessionCompilation.bill_valuation,
-            engineeringLibModel = new EngineeringLibModel(),
-            valuationIDs = [] ;
-        for(let r of rationValuation){//{ "glj_lib.0": {$exists:1} }
-            if(r.id){
-                valuationIDs.push(r.id);
+        const { userID } = req.params;
+        const sessionUserID = req.session.sessionUser.id;
+        const compilationID = req.session.sessionCompilation._id;
+        if (userID !== sessionUserID) {
+            const receiveList = await pmFacade.getReceiveLibList(sessionUserID, compilationID, ShareLibType.GLJ_LIB);
+            const isValid = !!receiveList.find(user => String(user._id) === userID);
+            if (!isValid) {
+                return res.redirect(`/complementaryGlj/${sessionUserID}`);
             }
         }
-        for(let b of billValuation){
-            if(b.id){
-                valuationIDs.push(b.id);
-            }
-        }
-        if(valuationIDs.length > 0){
-            let engineeringInfo = await engineeringLibModel.findDataByCondition({'valuationID': {"$in": valuationIDs},"glj_lib.0": {$exists:1}});//数组大于0
-            gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
-        }
-        let overWriteUrl = req.session.sessionCompilation && req.session.sessionCompilation.overWriteUrl &&
-                            req.session.sessionCompilation._id !== '5b4d581023a924000b760f2d' ? req.session.sessionCompilation.overWriteUrl : null;
+        const sessionCompilation = req.session.sessionCompilation;
+        const gljLibId = await getGljLibId(sessionCompilation);
+        let overWriteUrl = sessionCompilation && req.session.sessionCompilation.overWriteUrl &&
+            compilationID !== '5b4d581023a924000b760f2d' ? req.session.sessionCompilation.overWriteUrl : null;
         const priceProperties = sessionCompilation.priceProperties || [];
         const consumeAmtProperties = sessionCompilation.consumeAmtProperties || [];
+        const isReadOnly = userID !== sessionUserID;
         res.render('building_saas/complementary_glj_lib/html/tools-gongliaoji.html',{
-            userID: req.session.sessionUser.id,
+            isReadOnly,
+            userID: sessionUserID,
             gljLibId: gljLibId,
             compilationId: sessionCompilation._id,
             compilationName: sessionCompilation.name,
@@ -49,6 +68,20 @@ class GljController extends BaseController{
             overWriteUrl: overWriteUrl,
         });
     }
+
+    async prepareInitData(req, res) {
+        try {
+            const { userID, projection } = JSON.parse(req.body.data);
+            const sessionUserID = req.session.sessionUser.id;
+            const gljLibID = await getGljLibId(req.session.sessionCompilation);
+            const compilationID = req.session.sessionCompilation._id;
+            const initData = await gljDao.prepareInitData(gljLibID, userID, sessionUserID, compilationID, projection);
+            res.json({error: 0, message: 'success', data: initData});
+        } catch (err) {
+            console.log(err);
+            res.json({error: 1, message: 'fail', data: null});
+        }
+    }
     getGljDistType (req, res) {
         let gljDistTypeCache = stdgljutil.getStdGljTypeCacheObj().toArray();
         if(gljDistTypeCache.length >0 ){

+ 63 - 1
modules/complementary_glj_lib/models/gljModel.js

@@ -1,3 +1,33 @@
+/*
+ * @Descripttion: 
+ * @Author: vian
+ * @Date: 2020-12-16 17:48:47
+ */
+/*
+ * @Descripttion: 
+ * @Author: vian
+ * @Date: 2020-12-16 17:48:47
+ */
+/*
+ * @Descripttion: 
+ * @Author: vian
+ * @Date: 2020-12-16 17:48:47
+ */
+/*
+ * @Descripttion: 
+ * @Author: vian
+ * @Date: 2020-12-16 17:48:47
+ */
+/*
+ * @Descripttion: 
+ * @Author: vian
+ * @Date: 2020-12-16 17:48:47
+ */
+/*
+ * @Descripttion: 
+ * @Author: vian
+ * @Date: 2020-12-16 17:48:47
+ */
 /**
  * Created by Zhong on 2017/8/22.
  */
@@ -14,8 +44,27 @@ const libType = {
     stdGLJ: 1,
     complementaryGLJs: 2
 };
+const stdgljutil = require("../../../public/cache/std_glj_type_util");
+const { ShareLibType } = require('../../../public/common_constants');
 
 class GljDao {
+    
+    async prepareInitData(gljLibID, userID, sessionUserID, compilationID, projection) {
+        const pmFacade = require('../../pm/facade/pm_facade');
+        const receiveLibs = await pmFacade.getReceiveLibList(sessionUserID, compilationID, ShareLibType.GLJ_LIB);
+        const shareLibs = sessionUserID === userID ? await pmFacade.getLibShareList(sessionUserID, compilationID, ShareLibType.GLJ_LIB) : [];
+        const gljItems = await this.getGLJItemsSync(gljLibID, userID, compilationID, projection);
+        const mixTree = await this.getMixedTree(gljLibID, userID, compilationID);
+        const gljDistTypeCache = stdgljutil.getStdGljTypeCacheObj().toArray();
+        return {
+            receiveLibs,
+            shareLibs,
+            gljItems,
+            mixTree,
+            distTypeData: gljDistTypeCache,
+        };
+    }
+
     getGljTypes (gljLibId, callback){
         gljClassModel.find({"repositoryId": gljLibId},function(err,data){
             if(data.length) {
@@ -159,7 +208,6 @@ class GljDao {
                 catch (err) {
                     cb(err);
                 }
-
             },
             function (cb) {
                 if (!userId || !compilationId) {
@@ -189,6 +237,20 @@ class GljDao {
 
     }
 
+    async getGLJItemsSync(stdGljLibId, userId, compilationId, projection) {
+        const rst = { stdGljs: [], complementaryGljs: [] };
+        const task = [
+            stdGljModel.find({ repositoryId: stdGljLibId }, projection).lean(),
+            complementaryGljModel.find({ userId: userId, compilationId: compilationId }, '-_id').lean()
+        ];
+        const [ stdRst, cptRst ] = await Promise.all(task);
+        this.sortToNumber(stdRst);
+        rst.stdGljs = stdRst;
+        this.sortToNumber(cptRst);
+        rst.complementaryGljs = cptRst;
+        return rst;
+    }
+
     async getStdItems (stdGljLibId, projection, callback) {
         try {
             let stdItems = await stdGljModel.find({repositoryId: stdGljLibId}, projection).lean();

+ 2 - 1
modules/complementary_glj_lib/routes/routes.js

@@ -11,13 +11,14 @@ let gljController = new GljController();
 let compleRationController = new CompleRationController();
 
 module.exports = function (app) {
-    app.get('/complementaryGlj', gljController.init, gljController.redirectGlj);
+    app.get('/complementaryGlj/:userID', gljController.init, gljController.redirectGlj);
 
    /* router.post("/updateRationBasePrc",gljController.init, gljController.updateRationBasePrc);//更新定额单价
     router.post("/getRationGljIds", gljController.init, gljController.getRationGljIds);
     router.post("/createNewGljTypeNode", gljController.init, gljController.createNewGljTypeNode);
     router.post("/updateGljNodes", gljController.init, gljController.updateGljNodes);
     router.post("/deleteGljNodes", gljController.init, gljController.deleteGljNodes);*/
+    router.post("/initData", gljController.init, gljController.prepareInitData);
     router.post("/getGljDistType", gljController.init, gljController.getGljDistType);
     router.post("/getGljTree", gljController.init, gljController.getGljTree);
     router.post("/getGljItems", gljController.init, gljController.getGljItems);

+ 7 - 2
modules/complementary_ration_lib/models/compleRationModel.js

@@ -101,7 +101,8 @@ class CompleRatoinDao {
                     }
                 }
                 else if(ids[i].type === 'complementary'){
-                    let compleGlj = await complementaryGljModel.find({userId: userID, ID: ids[i].id, deleteInfo: null});
+                    const owner = ids[i].fromUser || userID;
+                    let compleGlj = await complementaryGljModel.find({userId: owner, ID: ids[i].id, deleteInfo: null});
                     if(compleGlj.length > 0){
                         compleGlj[0]._doc.type = 'complementary';
                         rst.push(compleGlj[0]);
@@ -150,6 +151,7 @@ class CompleRatoinDao {
                 comGljIds = [],
                 stdGljs = [],
                 comGljs = [];
+            const users = [userId];
             let gljAmtMapping = {};
             for(let rationGlj of ration.rationGljList){
                 gljAmtMapping[rationGlj.gljId] = rationGlj.consumeAmt;
@@ -157,6 +159,9 @@ class CompleRatoinDao {
                     stdGljIds.push(rationGlj.gljId);
                 }
                 else {
+                    if (rationGlj.fromUser && !users.includes(rationGlj.fromUser)) {
+                        users.push(rationGlj.fromUser);
+                    }
                     comGljIds.push(rationGlj.gljId);
                 }
             }
@@ -164,7 +169,7 @@ class CompleRatoinDao {
                 stdGljs = await stdGljModel.find({ID: {$in: stdGljIds}}).lean();
             }
             if(comGljIds.length > 0) {
-                comGljs = await complementaryGljModel.find({userId: userId, ID: {$in: comGljIds}}).lean();
+                comGljs = await complementaryGljModel.find({userId: { $in: users }, ID: {$in: comGljIds}}).lean();
             }
             let gljDatas = gljUtil.sortRationGLJ(stdGljs.concat(comGljs),true);
             if(ration.jobContent && ration.jobContent.toString().trim() !== ''){

+ 8 - 1
modules/main/facade/ration_facade.js

@@ -443,12 +443,16 @@ async function addRationGLJ(std,newRation,compilation) {
     }
     let ext = getExtendData(property,compilation);
     let first = +new Date();
+    const users = [std.userId];
     if(std.hasOwnProperty('rationGljList') && std.rationGljList.length > 0){
         let stdGLJID =[];//标准工料机ID数组
         let cptGLJID=[];//补充工料机ID数组
             //let stdGLJID = _.map(std.rationGljList,'gljId');
         for(let tem_g  of std.rationGljList){
              if(tem_g.type == 'complementary'){
+               if (tem_g.fromUser && !users.includes(tem_g.fromUser)) {
+                 users.push(tem_g.fromUser);
+               }
                 cptGLJID.push(tem_g.gljId);
              }else {
                 stdGLJID.push(tem_g.gljId);
@@ -456,7 +460,7 @@ async function addRationGLJ(std,newRation,compilation) {
         }
        let stdGLJList = stdGLJID.length > 0 ? await std_glj_lib_gljList_model.find({'ID':{'$in':stdGLJID}}):[];//速度优化-------先一次性取出所有的工料机列表
        let stdGLJMap = _.indexBy(stdGLJList, 'ID');
-       let cptGLJList =  cptGLJID.length > 0 ? await complementary_glj_model.find({'userId':std.userId,'ID':{'$in':cptGLJID}}):[];
+       let cptGLJList =  cptGLJID.length > 0 ? await complementary_glj_model.find({'userId':{$in: users},'ID':{'$in':cptGLJID}}):[];
        let cptGLJMap = _.indexBy(cptGLJList, 'ID');
         let stdGLJMapTime = +new Date();
         console.log("找到工料机映射表时间-------------------------------"+(stdGLJMapTime - first));
@@ -472,6 +476,9 @@ async function addRationGLJ(std,newRation,compilation) {
           newGLJ.glj_repository_id = std.rationRepId;
           let std_glj = null;
           if(sub.type == 'complementary'){//有可能来自标准工料机库或补充工料机库
+            if (sub.fromUser) {
+              newGLJ.fromUser = sub.fromUser;
+            }
               std_glj = cptGLJMap[sub.gljId];
               newGLJ.from = 'cpt';
           }else {

+ 38 - 9
modules/ration_glj/controllers/ration_glj_controller.js

@@ -5,7 +5,8 @@ let mongoose = require("mongoose")
 let ration_glj_facade = require('../facade/ration_glj_facade')
 const EngineeringLibModel = require("../../users/models/engineering_lib_model");
 let logger = require("../../../logs/log_helper").logger;
-const { COMPILATION, COMPLEMENTARY_LIB } = require('../../../public/common_constants');
+const { COMPILATION, COMPLEMENTARY_LIB, ShareLibType } = require('../../../public/common_constants');
+const pmFacade = require('../../pm/facade/pm_facade');
 
 module.exports={
     createRationGLJ:createRationGLJ,
@@ -67,12 +68,18 @@ async function getGLJDataPaging(req, res) {
         const compilationId = req.session.sessionCompilation._id;
         const userID = req.session.sessionUser.id;
         let libData = null;
-        if (condition.gljLibID !== COMPLEMENTARY_LIB) {
+        const cptLibReg = new RegExp(COMPLEMENTARY_LIB);
+        if (!cptLibReg.test(condition.gljLibID)) {
             condition.gljLibID = +condition.gljLibID;
         }
         if (condition.initLibs) {
             libData = await ration_glj_facade.getLibOptionsForCompilation(compilationId);
-            libData.push({ name: '补充工料机', gljLibId: COMPLEMENTARY_LIB });
+            libData.push({ name: '我的补充人材机库', gljLibId: COMPLEMENTARY_LIB });
+            // 设置被分享的人材机库
+            const receiveData = await pmFacade.getReceiveLibList(userID, compilationId, ShareLibType.GLJ_LIB);
+            receiveData.forEach(user => {
+                libData.push({ name: `${user.real_name}的补充人材机库`, gljLibId: `${COMPLEMENTARY_LIB}*${user._id}` });
+            });
             if (condition.gljLibID) { // 替换人材机初始化会触发此条件(初始化库且定位了库)
                 const orgDefalutLib = libData.find(lib => lib.isDefault);
                 const newDefaultLib = libData.find(lib => lib.gljLibId === condition.gljLibID);
@@ -85,9 +92,16 @@ async function getGLJDataPaging(req, res) {
         if (!condition.gljLibID && libData) {
             condition.gljLibID = (libData.find(lib => lib.isDefault) || {}).gljLibId;
         }
-        const info = condition.gljLibID === COMPLEMENTARY_LIB
+        let info;
+        if (cptLibReg.test(condition.gljLibID)) {
+            const owner = condition.gljLibID.split('*')[1] || userID;
+            info = { gljLibId: null, userID: owner, compilationId  };
+        } else {
+            info = { gljLibId: condition.gljLibID, userID: null, compilationId: null };
+        }
+        /* const info = condition.gljLibID === COMPLEMENTARY_LIB
             ? { gljLibId: null, userID, compilationId  }
-            : { gljLibId: condition.gljLibID, userID: null, compilationId: null };
+            : { gljLibId: condition.gljLibID, userID: null, compilationId: null }; */
         result.data = await ration_glj_facade.getGLJDataPaging(info, condition);
         if (req.session.sessionCompilation.priceProperties) {
             result.data.priceProperties = req.session.sessionCompilation.priceProperties
@@ -133,15 +147,23 @@ async function getGLJData(req, res) {
     try {
         let libData = null;
         let { engineerID, gljLibId, isInitial } = req.params;
-        if (gljLibId !== COMPLEMENTARY_LIB) {
+        const userID = req.session.sessionUser.id;
+        const compilationId = req.session.sessionCompilation._id;
+        const cptLibReg = new RegExp(COMPLEMENTARY_LIB);
+        if (!cptLibReg.test(gljLibId)) {
             gljLibId = +gljLibId;
         }
         isInitial = JSON.parse(isInitial);
         if (!gljLibId || isInitial) { // 替换人材机的话,可能存在gljLibID,但是是初始化的操作
             libData = engineerID === COMPILATION 
-            ? await ration_glj_facade.getLibOptionsForCompilation(req.session.sessionCompilation._id)
+            ? await ration_glj_facade.getLibOptionsForCompilation(compilationId)
             : await ration_glj_facade.getLibOptions(engineerID);
             libData.push({ name: '补充工料机', gljLibId: COMPLEMENTARY_LIB });
+            // 设置被分享的人材机库
+            const receiveData = await pmFacade.getReceiveLibList(userID, compilationId, ShareLibType.GLJ_LIB);
+            receiveData.forEach(user => {
+                libData.push({ name: `${user.real_name}的补充人材机库`, gljLibId: `${COMPLEMENTARY_LIB}*${user._id}` });
+            });
             if (gljLibId) { // 替换人材机初始化会触发此条件
                 const orgDefalutLib = libData.find(lib => lib.isDefault);
                 const newDefaultLib = libData.find(lib => lib.gljLibId === gljLibId);
@@ -155,9 +177,16 @@ async function getGLJData(req, res) {
         if (!gljLibId && libData) {
             gljLibId = (libData.find(lib => lib.isDefault) || {}).gljLibId;
         }
-        const info = gljLibId === COMPLEMENTARY_LIB 
+        let info;
+        if (cptLibReg.test(gljLibId)) {
+            const owner = gljLibId.split('*')[1] || userID;
+            info = { gljLibId: null, userID: owner, compilationId  };
+        } else {
+            info = { gljLibId, userID: null, compilationId: null };
+        }
+/*         const info = gljLibId === COMPLEMENTARY_LIB 
             ? { gljLibId: null, userID: req.session.sessionUser.id, compilationId: req.session.sessionCompilation._id }
-            : { gljLibId, userID: null, compilationId: null };
+            : { gljLibId, userID: null, compilationId: null }; */
         info.skipGLJ = skipGLJ;
         ration_glj_facade.getGLJData(info,function (err,datas) {
             if(err){

+ 5 - 1
modules/ration_glj/facade/ration_glj_facade.js

@@ -188,6 +188,9 @@ function createNewRecord(ration_glj) {
     newRecoed.repositoryId = ration_glj.repositoryId;
     newRecoed.projectGLJID = ration_glj.projectGLJID;
     newRecoed.adjCoe = ration_glj.adjCoe;
+    if (ration_glj.fromUser) {
+        newRecoed.fromUser = ration_glj.fromUser;
+    }
     return newRecoed
 }
 
@@ -698,7 +701,8 @@ function getGLJSearchInfo(ration_glj) {
         supply_quantity:0,
         supply:0,
         materialIndexCoe:ration_glj.materialIndexCoe,
-        from: ration_glj.from ? ration_glj.from : 'std'//std:标准工料机库, cpt:补充工料机库
+        from: ration_glj.from ? ration_glj.from : 'std',//std:标准工料机库, cpt:补充工料机库
+        fromUser: ration_glj.fromUser,
     };
     let glj_type_object = glj_type_util.getStdGljTypeCacheObj();
     let type = glj_type_object.getItemById(data.type);

+ 33 - 37
public/web/sheet/sheet_common.js

@@ -685,42 +685,6 @@ var sheetCommonObj = {
         }
         //sheet.setCellType(row, col,this.getSelectButton(header.headerWidth),GC.Spread.Sheets.SheetArea.viewport);
     },
-
-    paintCusButtonImage:function(ctx, value, x, y, w, h, style, options){
-        if (options.sheet.getActiveRowIndex() == options.row && options.sheet.getActiveColumnIndex() == options.col) {
-            var image = document.getElementById('f_btn'), imageMagin = 3;
-            var imageHeight = 15;
-            var imageWidth = 25;
-            var imageX = x + w - imageWidth - imageMagin, imageY = y + h / 2 - imageHeight / 2;
-            ctx.save();
-           /* 2020-12-16 这里原先是还原背景色的,发现不需要了,先观察 
-            if (style.backColor) {
-                ctx.fillStyle = style.backColor;
-                ctx.fillRect(x, y, w, h);
-            } 
-            */
-            ctx.drawImage(image, imageX, imageY, imageWidth, imageHeight);
-            ctx.beginPath();
-            ctx.arc(imageX + imageWidth / 2, imageY + imageHeight / 2, 1, 0, 360, false);
-            ctx.arc(imageX + imageWidth / 2 - 4, imageY + imageHeight / 2, 1, 0, 360, false);
-            ctx.arc(imageX + imageWidth / 2 + 4, imageY + imageHeight / 2, 1, 0, 360, false);
-            ctx.fillStyle = "black";//填充颜色,默认是黑色
-            ctx.fill();//画实心圆
-            ctx.closePath();
-            ctx.restore();
-            w = w - imageWidth - imageMagin;
-            //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
-            if (style.hAlign == 0) {
-                if (value) {
-                    let textWidth = ctx.measureText(value).width;
-                    let spaceWidth = w;
-                    if (spaceWidth < textWidth) {
-                        style.hAlign = 2;
-                    }
-                }
-            }
-        }
-    },
     getCusButtonCellType: function (callback, readOnly = false, ostyle) {
         var ns = GC.Spread.Sheets;
 
@@ -730,7 +694,39 @@ var sheetCommonObj = {
         CusButtonCellType.prototype = new ns.CellTypes.Text();
         CusButtonCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
             if (!readOnly) {
-                sheetCommonObj.paintCusButtonImage(ctx, value, x, y, w, h, style, options);
+                if (options.sheet.getActiveRowIndex() == options.row && options.sheet.getActiveColumnIndex() == options.col) {
+                    var image = document.getElementById('f_btn'), imageMagin = 3;
+                    var imageHeight = 15;
+                    var imageWidth = 25;
+                    var imageX = x + w - imageWidth - imageMagin, imageY = y + h / 2 - imageHeight / 2;
+                    ctx.save();
+                   /* 2020-12-16 这里原先是还原背景色的,发现不需要了,先观察 
+                    if (style.backColor) {
+                        ctx.fillStyle = style.backColor;
+                        ctx.fillRect(x, y, w, h);
+                    } 
+                    */
+                    ctx.drawImage(image, imageX, imageY, imageWidth, imageHeight);
+                    ctx.beginPath();
+                    ctx.arc(imageX + imageWidth / 2, imageY + imageHeight / 2, 1, 0, 360, false);
+                    ctx.arc(imageX + imageWidth / 2 - 4, imageY + imageHeight / 2, 1, 0, 360, false);
+                    ctx.arc(imageX + imageWidth / 2 + 4, imageY + imageHeight / 2, 1, 0, 360, false);
+                    ctx.fillStyle = "black";//填充颜色,默认是黑色
+                    ctx.fill();//画实心圆
+                    ctx.closePath();
+                    ctx.restore();
+                    w = w - imageWidth - imageMagin;
+                    //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
+                    if (style.hAlign == 0) {
+                        if (value) {
+                            let textWidth = ctx.measureText(value).width;
+                            let spaceWidth = w;
+                            if (spaceWidth < textWidth) {
+                                style.hAlign = 2;
+                            }
+                        }
+                    }
+                }
             }
             if (ostyle) gljUtil.setProperty(style, ostyle);
             GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);

+ 6 - 1
public/web/tree_sheet/tree_sheet_helper.js

@@ -191,6 +191,9 @@ var TREE_SHEET_HELPER = {
                 if(colSetting.data.autoHeight == true){
                     colSetting.setAutoHeight(cell,node);
                 }
+                //主界面分部名称点击弹窗    
+                if(sheet.name()=="mainSheet" && colSetting.data.field=="name") MainTreeCol.setNameCusButton(cell,node);   
+
                 if(colSetting.editChecking&&colSetting.editChecking(node,colSetting.data.field)){
                     cell.locked(true);
                 }else if (colSetting.readOnly) {
@@ -313,6 +316,8 @@ var TREE_SHEET_HELPER = {
         let halfExpandLength = 3;
     
         let isRationNode = sheet.name()=="mainSheet" && initNode.sourceType == ModuleNames.ration&&initNode.data.type == rationType.ration;
+
+
         let questionImg = document.getElementById('question_pic'),
             questionImgWidth = 16,
             questionImgHeight = 16;
@@ -330,6 +335,7 @@ var TREE_SHEET_HELPER = {
             } else {
                 ctx.clearRect(x, y, w, h);
             }
+
             // ������(x1, y1)���(��, ��), (x2, y2)�յ�(��, ��), ��ɫ
             let drawLine = function (canvas, x1, y1, x2, y2, color) {
                 ctx.save();
@@ -438,7 +444,6 @@ var TREE_SHEET_HELPER = {
                 let centerY = Math.floor((y + (y + h)) / 2);
                 ctx.drawImage(questionImg, centerX + 3, centerY - 7, questionImgWidth,questionImgHeight);
             }
-
         };
         TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
             return {

+ 11 - 4
web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html

@@ -27,6 +27,11 @@
     <script type="text/javascript">
         let priceProperties = JSON.parse('<%- priceProperties %>');
         let consumeAmtProperties = JSON.parse('<%- consumeAmtProperties %>');
+        let userId = "<%= userID%>";
+        const userID = "<%= userID%>";
+        let compilationId = "<%= compilationId%>";
+        let stdGljLibId = "<%= gljLibId%>";//用户当前编办下的标准工料机库ID,目前认为一个编办只有一个标准工料机库
+        const isReadOnly = JSON.parse('<%= isReadOnly %>');
     </script>
 </head>
 <body>
@@ -150,6 +155,7 @@
             </div>
         </div>
     </div>
+    <%include ../../../common/components/share/index.html %>
     <!-- JS. -->
     <script src="/lib/jquery-contextmenu/jquery.contextMenu.min.js"></script>
     <script src="/lib/jquery-contextmenu/jquery.ui.position.js"></script>
@@ -160,6 +166,9 @@
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.exedit.js"></script>
     <!--inject:js-->
     <script src="/web/building_saas/js/global.js"></script>
+    <script src="/lib/pinyinjs/pinyin_dict_firstletter.js"></script>
+    <script src="/lib/pinyinjs/pinyinUtil.js"></script>
+    <script src="/web/common/components/share/index.js"></script>
     <!-- zTree -->
     <script type="text/javascript" src="/public/web/common_ajax.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
@@ -170,6 +179,7 @@
     <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_controller.js"></script>
     <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
     <script type="text/javascript" src="/public/web/ration_glj_units.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/init.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/glj.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/gljClassTree.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/gljComponent.js"></script>
@@ -182,9 +192,6 @@
     <!--endinject-->
     <script type="text/javascript" src="<%= overWriteUrl %>"></script>
     <SCRIPT type="text/javascript">
-        let userId = "<%= userID%>";
-        let compilationId = "<%= compilationId%>";
-        let stdGljLibId = "<%= gljLibId%>";//用户当前编办下的标准工料机库ID,目前认为一个编办只有一个标准工料机库
         let gljSetting = {
             view: {
                 //addHoverDom: gljTypeTreeOprObj.addHoverDom,
@@ -262,7 +269,7 @@
             $('#componentTreeDiv').height($(window).height() - 300);
             $("#componentSheet").height($("#componentTreeDiv").height() - 15);
             $("#componentSheet").width($('#modalCon').width() * 0.63); */
-            pageOprObj.initPage($("#GLJListSheet")[0], $('#gljComponentSheet')[0], $("#componentSheet")[0]);
+            //pageOprObj.initPage($("#GLJListSheet")[0], $('#gljComponentSheet')[0], $("#componentSheet")[0]);
         });
         //组成物弹出窗大小设置
         /* $(window).resize(function () {

+ 7 - 4
web/building_saas/complementary_glj_lib/js/glj.js

@@ -308,7 +308,7 @@ let repositoryGljObj = {
     },
     getGljDistType: function (callback) {
         let me = this;
-        CommonAjax.post('complementartGlj/api/getGljDistType', {}, function (rstData) {
+        CommonAjax.post('/complementartGlj/api/getGljDistType', {}, function (rstData) {
             if (callback) {
                 me.distTypeTree = me.getComboData(rstData);
                 console.log(me.distTypeTree);
@@ -318,7 +318,7 @@ let repositoryGljObj = {
     },
     getGljTree: function (gljLibId, callback) {
         let me = this;
-        CommonAjax.post('complementartGlj/api/getGljTree', { gljLibId: gljLibId }, function (rstData) {
+        CommonAjax.post('/complementartGlj/api/getGljTree', { gljLibId: gljLibId }, function (rstData) {
             zTreeHelper.createTree(rstData, gljSetting, "repositoryTree", me);
             zTreeHelper.createTree(rstData, componentSetting, "componentTree", componentOprObj);
             if (rstData && rstData.length > 0) {
@@ -464,6 +464,9 @@ let repositoryGljObj = {
     buildSheet: function (container) {
         let me = repositoryGljObj;
         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
+        if (isReadOnly) {
+            sheetCommonObj.disableSpread(me.workBook);
+        }
         sheetCommonObj.spreadDefaultStyle(me.workBook);
         me.repositoryGljDelOpr();
         me.onContextmenuOpr();
@@ -1055,7 +1058,7 @@ let repositoryGljObj = {
                             "delete": {
                                 name: "删除",
                                 disabled: function () {
-                                    return !(me.currentCache && me.currentCache[target.row]);
+                                    return isReadOnly || !(me.currentCache && me.currentCache[target.row]);
                                 },
                                 icon: "fa-remove",
                                 callback: function (key, opt) {
@@ -1471,7 +1474,7 @@ let repositoryGljObj = {
         if (addArr.length > 0) {
             me.saveInString(addArr);
         }
-        let url = 'complementartGlj/api/mixUpdateGljItems';
+        let url = '/complementartGlj/api/mixUpdateGljItems';
         let post = { updateItems: updateArr, addItems: addArr, removeIds: removeIds };
         let scCaller = function (rstData) {
             me.updateCache(addArr, updateArr, removeIds, rstData);

+ 1 - 1
web/building_saas/complementary_glj_lib/js/gljClassTree.js

@@ -149,7 +149,7 @@ let gljClassTreeObj = {
     },
 
     gljClassTreeAjax: function (postData, scFunc, errFunc) {
-        CommonAjax.post('api/updateNodes', {updateData: postData, lastOpr: userAccount}, scFunc, errFunc);
+        CommonAjax.post('/complementartGlj/api/updateNodes', {updateData: postData, lastOpr: userAccount}, scFunc, errFunc);
     },
     //模仿默认点击
     initSelection: function (node) {

+ 6 - 4
web/building_saas/complementary_glj_lib/js/gljComponent.js

@@ -100,7 +100,9 @@ let gljComponentOprObj = {
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
         sheetOpr.cleanData(me.workBook.getSheet(0), me.setting, -1);
-
+        if (isReadOnly) {
+            sheetCommonObj.disableSpread(me.workBook);
+        }
         me.onContextmenuOpr();//右键菜单
         me.gljComponentDelOpr();
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
@@ -228,7 +230,7 @@ let gljComponentOprObj = {
                         callback: function () { },
                         items: {
                             "insert": {
-                                name: "插入", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {
+                                name: "插入", disabled: isReadOnly || insertDis, icon: "fa-sign-in", callback: function (key, opt) {
                                     let oprFunc = function () {
                                         //默认radio所有工料机
                                         co.initRadio();
@@ -246,7 +248,7 @@ let gljComponentOprObj = {
                                 }
                             },
                             "delete": {
-                                name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
+                                name: "删除", disabled: isReadOnly || delDis, icon: "fa-remove", callback: function (key, opt) {
                                     //删除
                                     let deleteObj = that.currentComponent[target.row];
                                     let gljComponent = that.currentGlj.component;
@@ -518,7 +520,7 @@ let gljComponentOprObj = {
         that.saveInString(updateArr);
         $.ajax({
             type: 'post',
-            url: 'complementartGlj/api/updateComponent',
+            url: '/complementartGlj/api/updateComponent',
             data: { "userId": pageOprObj.userId, "updateArr": JSON.stringify(updateArr) },
             dataType: 'json',
             success: function (result) {

+ 124 - 0
web/building_saas/complementary_glj_lib/js/init.js

@@ -0,0 +1,124 @@
+const GLJ_INIT = (() => {
+  const params = location.href.split('/');
+  const curUserID = params[params.length - 1];
+  console.log('curUserID', curUserID);
+
+  // 头部按钮相关
+  function initHeaderTools(receiveList, shareList) {
+    // 设置下拉项
+    const selectHtml = `
+    <select class="form-control  form-control-sm" id="glj-libs">
+    </select>`;
+    // 设置分享按钮
+    const shareHtml = `
+    <span id="share-tip" class="ml-2" data-toggle="tooltip" data-placement="bottom" data-original-title="">
+        <a id="init-share" href="javascript:;" class="btn btn-xs btn-primary ${isReadOnly ? 'disabled' : ''}"><i class="fa fa-share-alt"></i> 分享</a>
+    </span>`;
+    const html = `
+        <div style="display: flex; align-items: center">
+            ${selectHtml}
+            ${shareHtml}
+        </div>
+    `
+    $('#fullpath').html(html);
+    initShareTip(shareList);
+    $('[data-toggle="tooltip"]').tooltip();
+    initLibOptions(receiveList);
+    // 分享给
+    SHARE_TO.handleEventListener();
+    $('#init-share').click(() => {
+      SHARE_TO.initModal(SHARE_TO.Mode.GLJ_LIB);
+      $('#share-tip').tooltip('hide');
+    });
+
+    // 库下拉
+    function initShareTip(shareList) {
+      if (shareList.length) {
+        const owners = shareList.map(owner => owner.real_name);
+        const tips = `已分享给 ${owners.join(' ')}`;
+        $('#share-tip').attr('data-original-title', tips);
+      }
+    }
+
+    // 库下拉
+    function initLibOptions(receiveList) {
+      const libList = [
+        `<option value="${userID}">我的补充人材机库</option>`
+      ];
+      const options = receiveList.map(owner => `<option value=${owner._id} ${curUserID === owner._id ? 'selected' : ''}>${owner.real_name}的补充人材机库</option>`);
+      libList.push(...options);
+      $('#glj-libs').html(libList.join(''))
+    }
+
+    $('#glj-libs').change(function () {
+      const userID = $(this).val();
+      window.location.href = `/complementaryGlj/${userID}`;
+    });
+  }
+
+  $(document).ready(() => {
+    $.bootstrapLoading.start();
+    const projection = {
+      _id: 0,
+      ID: 1,
+      code: 1,
+      unit: 1,
+      name: 1,
+      priceProperty: 1,
+      basePrice: 1
+    };
+    CommonAjax.post('/complementartGlj/api/initData', { projection, userID: curUserID }, res => {
+        if (res.error) {
+            alert('数据初始化失败,请重试。');
+            setTimeout(() => {
+                window.location.href = '/'
+            }, 1200);
+        } else {
+          const { receiveLibs, shareLibs, gljItems, mixTree, distTypeData } = res;
+          initHeaderTools(receiveLibs, shareLibs);
+          pageOprObj.stdGljLibId = stdGljLibId;
+          repositoryGljObj.currentRepositoryId = stdGljLibId;
+          pageOprObj.userId = userId;
+          pageOprObj.compilationId = compilationId;
+          //生成人材机表格列头
+          repositoryGljObj.setting.header = repositoryGljObj.initHeaders(priceProperties);
+          //生成列映射
+          sheetCommonObj.initColMapping(repositoryGljObj, repositoryGljObj.setting.header);
+          //生成单价列下标数组
+          repositoryGljObj.initPriceCols(priceProperties, repositoryGljObj.colMapping);
+          repositoryGljObj.buildSheet($("#GLJListSheet")[0]);
+          gljComponentOprObj.buildSheet($('#gljComponentSheet')[0]);
+          componentOprObj.buildSheet($("#componentSheet")[0]);
+          // distTypeTree
+          repositoryGljObj.distTypeTree = repositoryGljObj.getComboData(distTypeData);
+          // tree
+          gljClassTreeObj.treeData = mixTree;
+          if (mixTree.comple && mixTree.comple.length > 0) {
+            gljClassTreeObj.gljCurTypeId = mixTree.comple[0].ID;
+          }
+          gljClassTreeObj.buildSheet();
+          gljClassTreeObj.initTree(mixTree.comple);
+          gljClassTreeObj.cache = gljClassTreeObj.tree.items;
+          repositoryGljObj.updateParentNodeIds(gljClassTreeObj.cache, repositoryGljObj);
+          gljClassTreeObj.initController(gljClassTreeObj.tree, gljClassTreeObj.sheet, gljClassTreeObj.setting.sheet);
+          gljClassTreeObj.controller.showTreeData();
+          gljClassTreeObj.sheet.setFormatter(-1, 0, '@');
+          // gljItems
+          repositoryGljObj.stdGljList = gljItems.stdGljs;
+          // 兼容多单价情况
+          for (const sGlj of repositoryGljObj.stdGljList) {
+              if (sGlj.priceProperty && typeof sGlj.priceProperty.price1 !== 'undefined') {
+                  sGlj.basePrice = sGlj.priceProperty.price1;
+              }
+          }
+          repositoryGljObj.sortGlj(repositoryGljObj.stdGljList);
+          repositoryGljObj.setProp('isStd', true, repositoryGljObj.stdGljList);
+          repositoryGljObj.complementaryGljList = gljItems.complementaryGljs;
+          repositoryGljObj.sortGlj(repositoryGljObj.complementaryGljList);
+          gljClassTreeObj.initSelection(gljClassTreeObj.tree.selected);
+        }
+        $.bootstrapLoading.end();
+    });
+  });
+
+})();

+ 2 - 1
web/building_saas/complementary_ration_lib/js/gljSelect.js

@@ -247,7 +247,8 @@ let gljSelOprObj = {
         let me = gljSelOprObj;
         //选择改变,数据重新筛选显示
         me.showGljList = [];
-        if (gljLib === commonConstants.COMPLEMENTARY_LIB) {
+        const cptLibReg = new RegExp(commonConstants.COMPLEMENTARY_LIB);
+        if (cptLibReg.test(gljLib)) {
             me.setShowGljList(me.complementaryGljList);
         } else {
             me.setShowGljList(me.stdGljList);

+ 12 - 1
web/building_saas/complementary_ration_lib/js/ration_glj.js

@@ -580,7 +580,12 @@ var rationGLJOprObj = {
         if (me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]) {
             var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
             for (var i = 0; i < cacheArr.length; i++) {
-                rst.push({ gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, type: cacheArr[i].type });
+                const newItem = { gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, type: cacheArr[i].type };
+                if (cacheArr[i].userId && cacheArr[i].userId !== userID) {
+                    // 是分享人材机
+                    newItem.fromUser = cacheArr[i].userId;
+                }
+                rst.push(newItem);
             }
         }
         return rst;
@@ -597,6 +602,9 @@ var rationGLJOprObj = {
         rst.unit = repGlj.unit;
         rst.basePrice = repGlj.basePrice;
         rst.gljType = repGlj.gljType;
+        if (rItem.fromUser) {
+            rst.userId = rItem.fromUser;
+        }
         return rst;
     },
     getGljItems: function (rationItem, callback) {
@@ -610,6 +618,9 @@ var rationGLJOprObj = {
                 let idObj = Object.create(null);
                 idObj.type = rationGljList[i].type;
                 idObj.id = rationGljList[i].gljId;
+                if (rationGljList[i].fromUser) {
+                    idObj.fromUser = rationGljList[i].fromUser;
+                }
                 gljIds.push(idObj);
             }
             CommonAjax.post('/complementaryRation/api/getGljItemsByIds', { ids: gljIds }, function (rstData) {

+ 24 - 0
web/building_saas/main/html/main.html

@@ -2694,6 +2694,29 @@
     </div>
   </div>
 
+  
+<!--弹出 选择分部窗口-->
+<div class="modal fade" id="selectFBDiv" data-backdrop="static">
+  <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">&times;</span>
+              </button>
+          </div>
+          <div class="modal-body" style="height: 450px;padding: 0px">
+              <div class="ovf-hidden full-h" id="selectFBSheet" style="height: 100%;"></div>
+          </div>
+          <div class="modal-footer">
+              <button type="button" class="btn btn-primary" data-dismiss="modal" id="selectFBConfirm">确定</button>
+              <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+          </div>
+      </div>
+  </div>
+</div>
+
+
 
   <%include ../../../common/components/share/index.html %>
 
@@ -2861,6 +2884,7 @@
   <script type="text/javascript" src="/web/building_saas/main/js/views/fee_rate_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/quantity_edit_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/sub_fee_rate_views.js"></script>
+  <script type="text/javascript" src="/web/building_saas/main/js/views/select_FB_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/calc_base_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_labour_coe_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/locate_view.js"></script>

+ 9 - 0
web/building_saas/main/js/models/ration_glj.js

@@ -753,6 +753,9 @@ let ration_glj = {
                 const glj = allGLJ.find(item => gljOprObj.getIndex(item, gljLibKeyArray) === selKey);
                 if (glj) {
                     const rationGLJ = me.getAddDataByStd(glj, ration.ID, ration.billsItemID, ration.projectID);
+                    if (glj.userId) {
+                        rationGLJ.fromUser = glj.userId;
+                    }
                     gljList.push(rationGLJ);
                 }
             });
@@ -840,6 +843,9 @@ let ration_glj = {
             oldData. materialIndexCoe =  glj.materialIndexCoe;
             if (glj.hasOwnProperty("compilationId")) {
                 oldData.from = "cpt";
+                if (glj.userId) {
+                    oldData.fromUser = glj.userId;
+                }
                 if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的
                     oldData.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
                 }
@@ -909,6 +915,9 @@ let ration_glj = {
             };
             if (glj.hasOwnProperty("compilationId")) {
                 doc.from = "cpt";
+                if (glj.userId) {
+                    doc.fromUser = glj.userId;
+                }
                 if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的
                     doc.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
                 }

+ 7 - 5
web/building_saas/main/js/views/glj_view.js

@@ -78,7 +78,7 @@ var gljOprObj = {
                         me.gljCurTypeId = treeNode.ID;
                         /* me.filterLibGLJSheetData();
                          me.showLibGLJSheetData();*/
-                        me.loadPageData(gljOprObj.gljLibSheet, true, 0);
+                        me.loadPageData(gljOprObj.gljLibSheet, true, 0, $('#glj-lib-select').val());
                         //gljOprObj.initSelection({row: me.gljLibSheet.getActiveRowIndex()});
                     }
                 } else {
@@ -338,8 +338,8 @@ var gljOprObj = {
             me.loadPageData(args.sheet, false, curRecord.length);
         }
     },
-    loadPageData: function (sheet, reset, index) {
-        let condition = this.getPagingCondition(false, reset, false, index, false, null);
+    loadPageData: function (sheet, reset, index, gljLibID = null) {
+        let condition = this.getPagingCondition(false, reset, false, index, false, gljLibID);
         let getPagingFun =  typeof unitPriceObj != 'undefined' ? unitPriceObj.getGLJDataPaging:projectObj.project.ration_glj.getGLJDataPaging;
         getPagingFun(condition, function (data) {
             sheetCommonObj.appendData(sheet, condition.index, 0, gljOprObj.gljLibSheetSetting, data);
@@ -1179,6 +1179,7 @@ var gljOprObj = {
             // 搜索文本
             search: ''
         };
+        const cptLibReg = new RegExp(commonConstants.COMPLEMENTARY_LIB);
         // 触发入口(添加、替换、批量替换)
         const actionType = $('#actionType').val();
         const replaceActions = ['replace', 'm_replace'];
@@ -1201,12 +1202,13 @@ var gljOprObj = {
         } else {
             if (condition.replace) {
                 const selected = gljOprObj.sheetData[gljContextMenu.selectedRow];
-                condition.gljLibID =  selected.from === 'cpt' || !selected.repositoryId ? commonConstants.COMPLEMENTARY_LIB : selected.repositoryId;
+                const cptLibID = selected.fromUser && selected.fromUser !== userID ? `${commonConstants.COMPLEMENTARY_LIB}*${selected.fromUser}` : commonConstants.COMPLEMENTARY_LIB;
+                condition.gljLibID =  selected.from === 'cpt' || !selected.repositoryId ? cptLibID : selected.repositoryId;
             } else {
                 condition.gljLibID = initLibs ? null : $('#glj-lib-select').val();
             }
         }
-        if (condition.gljLibID === commonConstants.COMPLEMENTARY_LIB) {
+        if (cptLibReg.test(condition.gljLibID)) {
             condition.type = this.pagingType.complementaryGLJs;
         }
         if (init) {

+ 9 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -625,6 +625,15 @@ let MainTreeCol = {
             const color = 'red';
             return calcTools.unitFeeGTMaxPrice(node, 'common.unitFee') || calcTools.unitFeeLTMinPrice(node, 'common.unitFee') ? color : null;
         }
+    },
+    setNameCusButton:function(cell,node){
+        let isFBNode = node.sourceType == ModuleNames.bills&&node.data.type == billType.FB;
+        if(isFBNode){
+           let CELL =sheetCommonObj.getCusButtonCellType(()=>{
+            $('#selectFBDiv').modal('show');
+            })
+            cell.cellType(CELL); 
+        }
     }
 };
 

+ 89 - 0
web/building_saas/main/js/views/select_FB_view.js

@@ -0,0 +1,89 @@
+let selectFBObject = { 
+    spread:null,
+    datas:[],
+    setting:{
+        header: [
+            {headerName: "编号", headerWidth: 180, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 210, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String", hAlign: "center"},
+        ],
+        view:{ lockColumns: ["name","code","unit"]}
+    },
+    initSpread:function(){
+        if(!this.spread){
+            this.spread = SheetDataHelper.createNewSpread($("#selectFBSheet")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.spread);
+            let sheet = this.spread.getSheet(0);
+            sheetCommonObj.initSheet(sheet,this.setting,0);
+              /*   sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onSelectionChange);
+                sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onEngineerInfoValueChange);
+                sheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onEngineerInfoRangeChange);
+                sheet.name('engineerInfo'); */
+               
+          
+
+            if(projectReadOnly){
+                sheetCommonObj.disableSpread(this.spread);
+            }
+        }else{
+            this.spread.repaint();
+        }
+        
+    },
+    getSelectedData:function(){
+        let sel = this.spread.getSheet(0).getSelections()[0];
+        if(sel && gljUtil.isDef(sel.row)){
+            return this.datas[sel.row]
+        }
+        return null;
+    },
+    showData:function(){
+        let me = selectFBObject;
+        billsGuidance.initBillsLibs(()=>{
+            if(me.datas.length==0){
+                for(let r of billsGuidance.bills.tree.roots){
+                    selectFBObject.setDatas(r);
+                }
+            }
+            sheetCommonObj.showTreeData(me.spread.getSheet(0), me.setting, me.datas);
+        });
+    },
+    setDatas:function(node){
+        if(node.children.length > 0){//过滤叶子节点
+            let nodeData = node.data;
+            let d = {
+                ID:nodeData.ID,
+                ParentID:nodeData.ParentID,
+                code:nodeData.code,
+                name:nodeData.name,
+                unit:nodeData.unit
+            }
+            this.datas.push(d);
+            for(let c of node.children){
+                this.setDatas(c)
+            }
+        }
+    }
+}
+$(function () {
+
+    $('#selectFBDiv').on('shown.bs.modal', function (e) {
+        selectFBObject.initSpread();
+        selectFBObject.showData();
+    })
+    $("#selectFBConfirm").click(async ()=>{
+        let data = selectFBObject.getSelectedData();
+        if(!data) return;
+        let selected = projectObj.project.mainTree.selected;
+        let datas = [{
+            type:'bills',
+            data:{
+                ID:selected.data.ID,
+                name:data.name,
+                code:data.code,
+                unit:data.unit
+            }
+          }]
+          await projectObj.project.syncUpdateNodesAndRefresh(datas);
+    })
+})

+ 14 - 3
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -383,7 +383,7 @@ const billsGuidance = (function () {
     }
     //初始选择清单指引库
     //@param {Number}libID @return {void}
-    function libInitSel(libID){
+    function libInitSel(libID,rcallback){
         //获取清单
         $.bootstrapLoading.start();
         CommonAjax.post('/billsGuidance/api/getLibWithBills', {libID: libID, isGuidanceLib: false}, function(rstData){
@@ -393,6 +393,7 @@ const billsGuidance = (function () {
                 if(doAfterLoadGuidance){
                     doAfterLoadGuidance();
                 }
+                if(rcallback)rcallback();
                 $.bootstrapLoading.end();
             };
             //获取清单库中的工作内容和项目特征
@@ -403,7 +404,7 @@ const billsGuidance = (function () {
     }
     //初始化清单指引库
     //@param {Array}libDats @return {void}
-    function initLibs(libDatas){
+    function initLibs(libDatas,callback){
         libSel.empty();
         if(!libDatas){
             return;
@@ -417,7 +418,7 @@ const billsGuidance = (function () {
             libSel.append(opt);
         }
         //初始默认选择
-        libInitSel(libSel.select().val());
+        libInitSel(libSel.select().val(),callback);
     }
     //初始化视图
     //@param {void} @return {void}
@@ -452,6 +453,15 @@ const billsGuidance = (function () {
             TREE_SHEET_HELPER.refreshNodesVisible(bills.tree.roots, billsSheet, true);
         });
     }
+
+    function initBillsLibs(callback){
+        if(libSel.children().length === 0 && !$(this).hasClass('disabled')){
+            initLibs(projectObj.project.projectInfo.engineeringInfo.bill_lib,callback);
+        }else{
+            callback();
+        }
+    }
+    
     //各按钮监听事件
     //@return {void}
     function bindBtn(){
@@ -577,6 +587,7 @@ const billsGuidance = (function () {
         bindBtn,
         refreshWorkBook,
         locateAtBills,
+        initBillsLibs,
         bills
     };
 })();

+ 3 - 3
web/building_saas/report/js/rpt_main.js

@@ -29,7 +29,7 @@ let rptTplObj = {
             }
             //收集本单位工程所属的建设项目下所有单位工程id用
             me.project_tree = tree_Data_Helper.buildTreeNodeDirectly(JSON.parse(sessionStorage.getItem('projects_tree_data')), false);
-            console.log(me.getAllPrjIds());
+            // console.log(me.getAllPrjIds());
             // projectObj.project.projectInfo.ID
             // dynamicLoadJs('/lib/jspdf/SmartSimsun-normal.js');
             // dynamicLoadJs('/lib/jspdf/SmartSimsun-bold.js', me.pdfFontSimsunCallBack);
@@ -452,6 +452,7 @@ let rptControlObj = {
             let orgRptName = projectObj.project.projectInfo.name;
             let refRptTplIds = [];
             let flags = [];
+            let params = {};
             for (let node of zTreeOprObj.checkedRptTplNodes) {
                 refRptTplIds.push(node.refId);
                 let flag = null;
@@ -461,7 +462,6 @@ let rptControlObj = {
                 }
                 flags.push(flag);
             }
-            let params = {};
             params.prj_id = projectObj.project.projectInfo.ID;
             params.rpt_ids = refRptTplIds;
             params.flags = flags;
@@ -497,6 +497,7 @@ let rptControlObj = {
         let me = rptControlObj;
         if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
             let rpt_ids = [], flags = [], rpt_names = [];
+            let params = {};
             for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
                 rpt_ids.push(tplNode.refId);
                 rpt_names.push(tplNode.name)
@@ -507,7 +508,6 @@ let rptControlObj = {
                 }
                 flags.push(flag);
             }
-            let params = {};
             params.prj_id = projectObj.project.projectInfo.ID;
             params.rpt_ids = rpt_ids;
             params.flags = flags;

+ 4 - 2
web/common/components/share/index.js

@@ -12,11 +12,13 @@ const SHARE_TO = (() => {
 
     const Mode = {
         PROJECT: 1,
-        RATION_LIB: 2
+        RATION_LIB: 2,
+        GLJ_LIB: 3,
     };
 
     const ModeToLibType = {
-        [Mode.RATION_LIB]: ShareLibType.RATION_LIB
+        [Mode.RATION_LIB]: ShareLibType.RATION_LIB,
+        [Mode.GLJ_LIB]: ShareLibType.GLJ_LIB,
     };
 
     // 当前模式

+ 1 - 1
web/common/html/header.html

@@ -67,7 +67,7 @@
                 <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-wrench" data-placement="bottom"></i> 工具</a>
                 <div class="dropdown-menu dropdown-menu-right">
                     <a id="compleRationLib" class="dropdown-item compleRationLib" href=<%- "/complementaryRation/ration/" + userID %> target="_blank">定额库编辑器</a>
-                    <a id="compleGljLib" class="dropdown-item compleGljLib" href=<%- "/complementaryGlj" %> target="_blank">人材机库编辑器</a>
+                    <a id="compleGljLib" class="dropdown-item compleGljLib" href=<%- "/complementaryGlj/" + userID %> target="_blank">人材机库编辑器</a>
                 </div>
             </li>
             <% } %>