Forráskód Böngészése

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

chenshilong 6 éve
szülő
commit
a70cf71f75

+ 6 - 0
modules/all_models/compilation.js

@@ -59,6 +59,12 @@ let modelSchema = {
     release_time: {
         type: Number,
         default: 0
+    },
+
+    // cld 办事处id
+    categoryID: {
+        type: Number,
+        default: 12 // 总部id
     }
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 69 - 0
modules/complementary_ration_lib/models/searchModel.js

@@ -69,15 +69,84 @@ class SearchDao{
                     '$or': [{'isDeleted': {"$exists":false}}, {'isDeleted': null}, {'isDeleted': false}, {deleteInfo: null}]
                 }]
             };
+            let stdGljIds = [],
+                comGljIds = [];
             let stdRations = await stdRationModel.find(filter);
             for(let i = 0, len = stdRations.length; i < len; i++){
                 stdRations[i]._doc.type = 'std';
+                for(let glj of stdRations[i].rationGljList){
+                    stdGljIds.push(glj.gljId);
+                }
             }
             filter.userId = userId;
             let compleRations = await compleRationModel.find(filter);
             for(let i = 0, len = compleRations.length; i <len; i++){
                 compleRations[i]._doc.type = 'complementary';
+                for(let glj of stdRations[i].rationGljList){
+                    if(glj.type === 'std'){
+                        stdGljIds.push(glj.gljId);
+                    }
+                    else {
+                        comGljIds.push(glj.gljId);
+                    }
+                }
+            }
+            //设置悬浮信息
+            stdGljIds = Array.from(new Set(stdGljIds));
+            comGljIds = Array.from(new Set(comGljIds));
+            let gljIDMapping = {};
+            if(stdGljIds.length > 0){
+                let stdGljs = await stdGljModel.find({ID: {$in: stdGljIds}}, '-_id ID code name specs unit');
+                for(let stdGlj of stdGljs){
+                    gljIDMapping[stdGlj.ID] = stdGlj;
+                }
+            }
+            if(comGljIds.length > 0){
+                let comGljs = await complementaryGljModel.find({ID: {$in: stdGljIds}});
+                for(let comGlj of comGljs){
+                    gljIDMapping[comGlj.ID] = comGlj;
+                }
+            }
+            for(let ration of stdRations){
+                let hintsArr = [];
+                for(let rationGlj of ration.rationGljList){
+                    let glj = gljIDMapping[rationGlj.gljId];
+                    if(glj){
+                        hintsArr.push(` ${glj.code} ${glj.name}${glj.specs ? ' ' + glj.specs : ''} ${glj.unit} ${rationGlj.consumeAmt}`);
+                    }
+                }
+                hintsArr.push(`基价 元 ${ration.basePrice}`);
+                if(ration.jobContent && ration.jobContent.toString().trim() !== ''){
+                    hintsArr.push(`工作内容:`);
+                    hintsArr = hintsArr.concat(ration.jobContent.split('\n'));
+                }
+                if(ration.annotation && ration.annotation.toString().trim() !== ''){
+                    hintsArr.push(`附注:`);
+                    hintsArr = hintsArr.concat(ration.annotation.split('\n'));
+                }
+                ration._doc.hint = hintsArr.join('<br>');
+            }
+            for(let ration of compleRations){
+                let hintsArr = [];
+                for(let rationGlj of ration.rationGljList){
+                    let glj = gljIDMapping[rationGlj.gljId];
+                    if(glj){
+                        hintsArr.push(` ${glj.code} ${glj.name}${glj.specs ? ' ' + glj.specs : ''} ${glj.unit} ${rationGlj.consumeAmt}`);
+                    }
+                }
+                hintsArr.push(`基价 元 ${ration.basePrice}`);
+                if(ration.jobContent && ration.jobContent.toString().trim() !== ''){
+                    hintsArr.push(`工作内容:`);
+                    hintsArr = hintsArr.concat(ration.jobContent.split('\n'));
+                }
+                if(ration.annotation && ration.annotation.toString().trim() !== ''){
+                    hintsArr.push(`附注:`);
+                    hintsArr = hintsArr.concat(ration.annotation.split('\n'));
+                }
+                ration._doc.hint = hintsArr.join('<br>');
             }
+
+
             callback(0, stdRations.concat(compleRations));
         }
         catch(err){

+ 8 - 8
modules/reports/rpt_component/jpc_flow_tab.js

@@ -724,9 +724,9 @@ JpcFlowTabSrv.prototype.createNew = function(){
                 // 2.2 Column tab
                 tabRstLst.push(me.outputColumn(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, pi));
                 // 2.3 Sum Seg
-                tabRstLst.push(me.outputSegSum(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls));
+                tabRstLst.push(me.outputSegSum(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls, $CURRENT_RPT));
                 // 2.4 Sum Page
-                tabRstLst.push(me.outputPageSum(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls));
+                tabRstLst.push(me.outputPageSum(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls, $CURRENT_RPT));
                 // 2.5 Group
                 // 2.6 Discrete
                 if (pi === 0) {
@@ -794,12 +794,12 @@ JpcFlowTabSrv.prototype.createNew = function(){
                 //normal content
                 let flexiblePrecisionRefObj = null, flexibleRefField = null, precision_ref_data = null;
                 for (let rowIdx = 0; rowIdx < contentValuesIdx.length; rowIdx++) {
-                    for (let i = 0; i < tab_fields.length; i++) {
-                        let tab_field = tab_fields[i];
+                    for (let fieldIdx = 0; fieldIdx < tab_fields.length; fieldIdx++) {
+                        let tab_field = tab_fields[fieldIdx];
                         let data_field = null,
                             map_data_field = JE.F(tab_field[JV.PROP_FIELD_ID], $CURRENT_RPT);
-                        if (me.disp_fields_idx[i] !== JV.BLANK_FIELD_INDEX) {
-                            data_field = data_details[me.disp_fields_idx[i]];
+                        if (me.disp_fields_idx[fieldIdx] !== JV.BLANK_FIELD_INDEX && (typeof me.disp_fields_idx[fieldIdx] !== 'object')) {
+                            data_field = data_details[me.disp_fields_idx[fieldIdx]];
                         } else {
                             if (map_data_field) {
                                 data_field = map_data_field[JV.PROP_AD_HOC_DATA];
@@ -845,7 +845,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
                         for (let idx_ex = 0; idx_ex < tab_fields_ex.length; idx_ex++) {
                             let tab_fieldex = tab_fields_ex[idx_ex];
                             let data_fieldex = null, map_data_fieldex = JE.F(tab_fieldex[JV.PROP_FIELD_ID], $CURRENT_RPT);
-                            if (me.disp_fields_ex_idx[idx_ex] !== JV.BLANK_FIELD_INDEX) {
+                            if (me.disp_fields_ex_idx[idx_ex] !== JV.BLANK_FIELD_INDEX && (typeof me.disp_fields_idx[idx_ex] !== 'object')) {
                                 data_fieldex = data_details_ex[me.disp_fields_ex_idx[idx_ex]];
                             } else {
                                 if (map_data_fieldex) {
@@ -937,7 +937,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
         }
         return rst;
     };
-    JpcFlowTabResult.outputSegSum = function (rptTpl, dataObj, page, segIdx, bands, unitFactor, controls) {
+    JpcFlowTabResult.outputSegSum = function (rptTpl, dataObj, page, segIdx, bands, unitFactor, controls, $CURRENT_RPT) {
         let me = this, rst = [];
         let FLOW_NODE_STR = me.isEx?JV.NODE_FLOW_INFO_EX:JV.NODE_FLOW_INFO;
         let tab = rptTpl[FLOW_NODE_STR][JV.NODE_FLOW_SEG_SUM];

+ 73 - 0
modules/users/controllers/cld_controller.js

@@ -0,0 +1,73 @@
+'use strict';
+
+/**
+ * CLD接口相关控制器
+ *
+ * @author EllisRan.
+ * @date 2018/9/25
+ * @version
+ */
+
+import CLDModel from "../models/cld_model";
+import UserModel from "../models/user_model"
+import CompilationModel from "../models/compilation_model";
+
+class CLDController {
+
+    /**
+     * 获取cld办事处人员信息
+     *
+     * @param request
+     * @param reponse
+     * @return {Promise.<void>}
+     */
+    async getCategoryStaff(request, response) {
+        let category = request.query.category;
+        try {
+            let cldModel = new CLDModel();
+            let result = await cldModel.getCategoryStaff(category);
+            response.json({error: 0, msg: 'success', data: JSON.parse(result)});
+        } catch (err) {
+            response.json({error: 1, msg: err});
+        }
+    }
+
+    /**
+     * cld 获取建筑用户和编办接口
+     *
+     * @param request
+     * @param response
+     * @return {Promise.<void>}
+     */
+    async getUsersAndCompilationList(request, response) {
+        let mobile = request.query.mobile;
+        try {
+            //获取用户信息
+            let userModel = new UserModel();
+            let userData = await userModel.findDataByMobile(mobile);
+            if (userData === null || userData === '') {
+                throw '不存在该建筑用户';
+            }
+
+            //获取编办列表
+            let compilationModel = new CompilationModel();
+            let compilationList = await compilationModel.getList();
+            if (userData.upgrade_list !== undefined) {
+                let userUpgradeList = userData.upgrade_list;
+                for (let index in userUpgradeList) {
+                    let oneCompilationIndex = compilationList.findIndex(function (item) {
+                        return item.id === userUpgradeList[index].compilationID;
+                    });
+                    if (oneCompilationIndex !== -1) {
+                        compilationList[oneCompilationIndex].isUpgrade = userUpgradeList[index].isUpgrade;
+                    }
+                }
+            }
+            response.json({error: 0, msg: 'success', data: { userInfo: userData, compilationList: compilationList }});
+        } catch (err) {
+            response.json({error: 1, msg: err});
+        }
+    }
+}
+
+export default CLDController;

+ 48 - 0
modules/users/models/cld_model.js

@@ -0,0 +1,48 @@
+'use strict';
+
+/**
+ * cld接口模型
+ *
+ * @author EllisRan.
+ * @date 2018/9/25
+ * @version
+ */
+
+import Request from "request";
+import BaseModel from "../../common/base/base_model";
+
+class CLDModel extends BaseModel {
+
+    CLDUrl = 'http://cld.smartcost.com.cn';
+
+    /**
+     * 获取办事处人员信息
+     *
+     * @param cid
+     * @return {Promise}
+     */
+    async getCategoryStaff(cid) {
+        let postData = {
+            url: this.CLDUrl + '/api/building/category/staff/' + cid,
+            encoding: 'utf8'
+        };
+        return new Promise(function (resolve, reject) {
+            try {
+                // 请求接口
+                Request.post(postData, function (err, postResponse, body) {
+                    if (err) {
+                        throw '请求错误';
+                    }
+                    if (postResponse.statusCode !== 200) {
+                        throw 'CLD通讯失败!';
+                    }
+                    resolve(body);
+                });
+            } catch (error) {
+                reject([]);
+            }
+        });
+    }
+}
+
+export default CLDModel;

+ 1 - 1
modules/users/models/compilation_model.js

@@ -28,7 +28,7 @@ class CompilationModel extends BaseModel {
      */
     async getList() {
         // 筛选字段
-        let field = {_id: 1, name: 1, is_release: 1, description: 1};
+        let field = {_id: 1, name: 1, is_release: 1, description: 1, categoryID: 1};
         let compilationData = await this.findDataByCondition({name: {$ne: ''}, is_release: true}, field, false);
 
         return compilationData === null ? [] : compilationData;

+ 24 - 0
modules/users/routes/cld_route.js

@@ -0,0 +1,24 @@
+'use strict';
+
+/**
+ * CLD接口路由
+ *
+ * @author EllisRan.
+ * @date 2018/9/25
+ * @version
+ */
+
+import express from "express";
+import CLDController from "../controllers/cld_controller";
+
+
+module.exports = function (app) {
+    let router = express.Router();
+    let cldController = new CLDController();
+    // 登录页面action
+    router.get('/getCategoryStaff', cldController.getCategoryStaff);
+
+    router.get('/getUsersAndCompilation', cldController.getUsersAndCompilationList);
+
+    app.use('/cld',router)
+};

+ 4 - 2
public/web/sheet/sheet_data_helper.js

@@ -192,14 +192,16 @@ var SheetDataHelper = {
                     }
                     $(this._toolTipElement).html(text);
                     //定额库定额特殊处理
-                    if($(hitinfo.sheet.getParent().qo).attr('id') === 'stdSectionRations'){
+                    if($(hitinfo.sheet.getParent().qo).attr('id') === 'stdSectionRations' ||
+                        $(hitinfo.sheet.getParent().qo).hasClass('main-data-side-search')){
                         let divWidth = $(this._fixedTipElement).width(),
                             divHeight = $(this._fixedTipElement).height();
                         if(divWidth > 600){
                             divWidth = 590;
                            $(this._toolTipElement).width(divWidth);
                         }
-                        $(this._toolTipElement).css("top", setting.pos.y  + hitinfo.y - divHeight).css("left", setting.pos.x - divWidth);
+                        let top = setting.pos.y  + hitinfo.y - divHeight < 0 ? 0 : setting.pos.y  + hitinfo.y - divHeight;
+                        $(this._toolTipElement).css("top", top).css("left", setting.pos.x - divWidth);
                     }
                     else{
                         $(this._toolTipElement).css("top", setting.pos.y + hitinfo.y +15).css("left", setting.pos.x + hitinfo.x + 15);

+ 2 - 2
server.js

@@ -55,8 +55,8 @@ app.use(session({
 // 登录状态全局判断
 app.use(function (req, res, next) {
     let url = req.originalUrl;
-    if (/^\/login/.test(url) || /\.map|\.ico$/.test(url) || /^\/sms/.test(url)) {
-        // 如果是登录页面或短信接口则忽略判断数据
+    if (/^\/login/.test(url) || /\.map|\.ico$/.test(url) || /^\/sms/.test(url) || /^\/cld/.test(url)) {
+        // 如果是登录页面或短信接口或cld接口则忽略判断数据
         next();
     } else {
         try {

+ 2 - 1
test/unit/reports/test_rpt_test_template.js

@@ -32,7 +32,8 @@ let demoPrjId = - 1;
 // let demoRptId = 361; //封1
 // let demoRptId = 279; //表04
 // let demoRptId = 261; //封3
-let demoRptId = 418; //09
+// let demoRptId = 418; //09
+let demoRptId = 386; //04
 // let demoRptId = 389; //10
 // let demoRptId = 280; //11-1 暂列金
 // let demoRptId = 2260; //测试基本信息

+ 32 - 26
web/building_saas/complementary_ration_lib/js/ration.js

@@ -70,33 +70,37 @@ let rationOprObj = {
     onSelectionChanged: function (sender, info) {
         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
-            let me = rationOprObj,
-                sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
-                sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
-                sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting,
-                sheetInst = rationInstObj.sheet, settingInst = rationInstObj.setting;
-            sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
-            sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
-            sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
-            sheetCommonObj.cleanSheet(sheetInst, settingInst, -1);
-            let cacheSection = me.getCache();
-            if (cacheSection && row < cacheSection.length) {
-                rationGLJOprObj.getGljItems(cacheSection[row], function () {
-                    me.workBook.focus(true);
-                });
-                rationCoeOprObj.getCoeItems(cacheSection[row], function () {
-                    me.workBook.focus(true);
-                });
-                rationAssistOprObj.getAssItems(cacheSection[row]);
-                rationInstObj.getInstItems(cacheSection[row], function () {
-                    me.workBook.focus(true);
-                });
-            }
-            else {
-                rationGLJOprObj.currentRationItem = null;
-            }
-            me.workBook.focus(true);
+            let me = rationOprObj;
+            me.rationSelInit(row);
+        }
+    },
+    rationSelInit: function (row) {
+        let me = rationOprObj,
+            sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
+            sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
+            sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting,
+            sheetInst = rationInstObj.sheet, settingInst = rationInstObj.setting;
+        sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
+        sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
+        sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
+        sheetCommonObj.cleanSheet(sheetInst, settingInst, -1);
+        let cacheSection = me.getCache();
+        if (cacheSection && row < cacheSection.length) {
+            rationGLJOprObj.getGljItems(cacheSection[row], function () {
+                me.workBook.focus(true);
+            });
+            rationCoeOprObj.getCoeItems(cacheSection[row], function () {
+                me.workBook.focus(true);
+            });
+            rationAssistOprObj.getAssItems(cacheSection[row]);
+            rationInstObj.getInstItems(cacheSection[row], function () {
+                me.workBook.focus(true);
+            });
+        }
+        else {
+            rationGLJOprObj.currentRationItem = null;
         }
+        me.workBook.focus(true);
     },
     isDef: function (v) {
         return v !== undefined && v !== null;
@@ -546,6 +550,8 @@ let rationOprObj = {
                     else if (a.code < b.code) rst = -1;
                     return rst;
                 });
+                let curRow = me.workBook.getActiveSheet().getActiveRowIndex();
+                me.rationSelInit(curRow);
                 //jobContent
                 if(jobContentOprObj ){
                     jobContentOprObj.currentRationItems = cacheSection;

+ 1 - 1
web/building_saas/glj/html/project_glj.html

@@ -157,7 +157,7 @@
                 </div>
             </div>
             <div class="modal-footer">
-                <button type="button" class="btn btn-primary" data-dismiss="modal" id="renameUnitFileConfirm" disabled>确定</button>
+                <button type="button" class="btn btn-primary" id="renameUnitFileConfirm">确定</button>
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
             </div>
         </div>

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

@@ -446,7 +446,24 @@
                                           </div>
                                           <!--搜索结果窗体-->
                                           <div class="side-search-box col-12 p-0" id="rationSearchResult" style="display: none;">
+                                              <div class="d-flex justify-content-between">
+                                                  <span id="rationSearchCount"></span>
+                                                  <a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0)"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                                              </div>
+                                              <div class="w-100 main-data-side-search"></div>
                                           </div>
+                                          <!--
+                                          html.push('<div class="d-flex justify-content-between">');
+        html.push('<span>搜索结果:');
+        html.push(result.length.toString());
+        html.push('</span>');
+        html.push('<a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0)"><i class="fa fa-remove" aria-hidden="true"></i></a>');
+        html.push('</div>');
+
+        html.push('<div class="w-100 main-data-side-search">');
+        html.push('</div>');
+        return html.join('');
+                                          -->
                                       </div>
                                   </div>
                                   <div class="top-content" style="overflow: hidden">

+ 5 - 4
web/building_saas/main/js/views/project_glj_view.js

@@ -1262,10 +1262,10 @@ $(function () {
         projectGLJ.checkUnitFileName(this.value,function (data) {
             if(data){
                 $("#renameError_unitFile").text('已存在同名单价文件').show();
-                $('#renameUnitFileConfirm').attr("disabled","disabled");
+                //$('#renameUnitFileConfirm').attr("disabled","disabled");
             }else {
                 $("#renameError_unitFile").hide();
-                $('#renameUnitFileConfirm').removeAttr("disabled");
+               // $('#renameUnitFileConfirm').removeAttr("disabled");
             }
         });
 
@@ -1277,10 +1277,11 @@ $(function () {
         projectGLJ.checkUnitFileName(newName,function (data) {
             if(data){
                 $("#renameError_unitFile").text('已存在同名单价文件').show();
-                $('#renameUnitFileConfirm').attr("disabled","disabled");
+                //$('#renameUnitFileConfirm').attr("disabled","disabled");
             }else {
                 $("#renameError_unitFile").hide();
-                $('#renameUnitFileConfirm').removeAttr("disabled");
+                $('#rename-unitFile').modal('hide');
+               // $('#renameUnitFileConfirm').removeAttr("disabled");
                 let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: 1,newName:newName};
                 projectObj.project.projectGLJ.changeFile(data,function () {
                     projectGljObject.changeFileCallback();

+ 1 - 1
web/building_saas/main/js/views/project_view.js

@@ -2555,7 +2555,7 @@ $('#importConfirm').click(function () {
         //选择的表及导入位置
         let importSheetsInfo = importBills.getImportSheetsInfo();
         if(importSheetsInfo.length === 0){
-            throw '请选要导入的表';
+            throw '请选要导入的表';
         }
         let importSheets = importBills.getImportSheets(importJson.sheets, importSheetsInfo, fileType);
         console.log(`importSheets`);

+ 80 - 15
web/building_saas/main/js/views/std_ration_lib.js

@@ -125,14 +125,16 @@ var rationLibObj = {
         });
         args.sheet.repaint();
     },
-    setTagForHint: function (datas) {
-        let sheet = this.sectionRationsSpread.getActiveSheet();
+    setTagForHint: function (sheet, datas) {
         sheet.suspendPaint();
         sheet.suspendEvent();
         for(let i = 0, len = sheet.getRowCount(); i < len; i++){
             sheet.setTag(i, 0, '');
         }
         for(let i = 0, len = datas.length; i < len; i++){
+            if(datas[i].code === 'AA0032'){
+                console.log(datas[i]);
+            }
             sheet.setTag(i, 0, datas[i].hint ? datas[i].hint : '');
         }
         sheet.resumePaint();
@@ -147,7 +149,7 @@ var rationLibObj = {
             });
             SheetDataHelper.loadSheetHeader(setting, rationLibObj.sectionRationsSpread.getActiveSheet());
             SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
-            rationLibObj.setTagForHint(datas);
+            rationLibObj.setTagForHint(rationSheet, datas);
         };
         if (sectionID) {
             CommonAjax.post('/complementaryRation/api/getRationGljItemsBySection', {user_Id: userID, sectionId: sectionID}, function (datas) {
@@ -440,8 +442,28 @@ $('#rationSearchKeyword').bind('keypress', function (event) {
         $('#rationSearch').click();
     }
 });
+$('#rationSearchKeyword').keyup(function () {
+    let keyword = $('#rationSearchKeyword').val();
+    if(keyword === ''){
+        if($('#rationSearchResult').is(':visible')){
+            $('#rationSearchResult').hide();
+            $(".main-data-side-search", $('#rationSearchResult')).height(0);
+            autoFlashHeight();
+            rationLibObj.refreshSpread();
+        }
+    }
+});
 $('#rationSearch').click(function () {
     var keyword = $('#rationSearchKeyword').val(), rationLibID = $('#stdRationLibSelect').val();
+    if(keyword === ''){
+        if($('#rationSearchResult').is(':visible')){
+            $('#rationSearchResult').hide();
+            $(".main-data-side-search", $('#rationSearchResult')).height(0);
+            autoFlashHeight();
+            rationLibObj.refreshSpread();
+        }
+        return;
+    }
     var getResultHtml = function (result) {
         var html = [], i, serialNo;
         html.push('<div class="d-flex justify-content-between">');
@@ -455,14 +477,56 @@ $('#rationSearch').click(function () {
         html.push('</div>');
         return html.join('');
     };
+    let bindContextmenuOpr = function (sheet) {
+        $.contextMenu({
+            selector: '#rationSearchResult',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                let offset = $('.main-data-side-search').offset(),
+                    x = e.pageX - offset.left,
+                    y = e.pageY - offset.top;
+                let target = sheet.hitTest(x, y);
+                if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
+                    sheet.setActiveCell(target.row, target.col);
+                    return {
+                        callback: function(){},
+                        items: {
+                            "locate": {
+                                name: "定位至章节",
+                                disabled: function () {
+                                    return target.row >= rationLibObj.resultCache.length;
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    let data = rationLibObj.resultCache[target.row];
+                                    $('#rationSearchResult').hide();
+                                    $(".main-data-side-search", $('#rationSearchResult')).height(0);
+                                    autoFlashHeight();
+                                    rationLibObj.refreshSpread();
+                                    rationLibObj.locateAtRation(data.rationRepId, data.code);
+                                }}
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
+            }
+        });
+    };
     var showResult = function (result) {
-        let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
-        rationLibObj.resultSpread = resultSpread;
-        rationLibObj.setTagForHint(result);
-        SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
-        SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet(), result);
-
-        resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
+        rationLibObj.resultCache = result;
+        if(!rationLibObj.resultSpread){
+            let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
+            rationLibObj.resultSpread = resultSpread;
+            bindContextmenuOpr(resultSpread.getActiveSheet());
+            SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
+            resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
+        }else {
+            rationLibObj.resultSpread.refresh();
+        }
+        SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, rationLibObj.resultSpread.getActiveSheet(), result);
+        rationLibObj.setTagForHint(rationLibObj.resultSpread.getActiveSheet(), result);
     };
     CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibID, 'keyword': keyword}, function (result) {
         //sort
@@ -472,14 +536,15 @@ $('#rationSearch').click(function () {
             else if(a.code < b.code) rst = -1;
             return rst;
         });
-        var resultObj = $('#rationSearchResult'), resultSpread = null;
-        resultObj.empty();
-        resultObj.append(getResultHtml(result));
-        $('a', resultObj).click(function () {
+        var resultObj = $('#rationSearchResult');
+        /*resultObj.empty();
+        resultObj.append(getResultHtml(result));*/
+        $('#rationSearchCount').text(`搜索结果:${result.length.toString()}`);
+        $('a', result).unbind('click');
+        $('a', resultObj).bind('click', function () {
             resultObj.hide();
             $(".main-data-side-search", resultObj).height(0);
             autoFlashHeight();
-            //$(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-d").height() - 202);
             rationLibObj.refreshSpread();
         });
         resultObj.show();

+ 5 - 90
web/users/html/user-buy.html

@@ -88,9 +88,9 @@
                                         <li class="list-group-item d-flex justify-content-between">
                                             <%= compilation.name %>
                                             <% if (compilation.isUpgrade === undefined || compilation.isUpgrade !== true) { %>
-                                            <a class="btn btn-primary btn-sm" href="activ" data-toggle="modal" data-target="#activ">立即激活</a>
+                                            <a href="javascript:void(0);" class="btn btn-primary btn-sm getcategory" data-upgrade="<%= compilation.isUpgrade %>" data-category="<%= compilation.categoryID %>">立即激活</a>
                                             <% } else { %>
-                                            <a class="btn btn-outline-secondary btn-sm" href="activ2" data-toggle="modal" data-target="#activ2"><i class="fa fa-check"></i> 已激活</a>
+                                            <a href="javascript:void(0);" class="btn btn-outline-secondary btn-sm getcategory" data-title="<%= compilation.name %>" data-upgrade="<%= compilation.isUpgrade %>" data-category="<%= compilation.categoryID %>"><i class="fa fa-check"></i> 已激活</a>
                                             <% } %>
                                         </li>
                                         <% }) %>
@@ -108,18 +108,18 @@
             </div>
         </div>
     </div>
-    <!--激活产品-->
+    <!--激活产品 & 售后服务-->
     <div class="modal fade" id="activ" data-backdrop="static" style="display: none;" aria-hidden="true">
         <div class="modal-dialog modal-lg" role="document">
             <div class="modal-content">
                 <div class="modal-header">
-                  <h5 class="modal-title">联系销售代表激活</h5>
+                  <h5 class="modal-title" id="upgrade-title">联系销售代表激活</h5>
                   <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                     <span aria-hidden="true">×</span>
                   </button>
                 </div>
                 <div class="modal-body">
-                  <div class="row px-3">
+                  <div class="row px-3" id="staffList">
                     <div class="col-4 mb-4">
                       <div class="card">
                         <div class="card-body">
@@ -206,91 +206,6 @@
             </div>
         </div>
     </div>
-    <!--售后服务-->
-    <div class="modal fade" id="activ2" data-backdrop="static" style="display: none;" aria-hidden="true">
-        <div class="modal-dialog modal-lg" role="document">
-            <div class="modal-content">
-                <div class="modal-header">
-                  <h5 class="modal-title">重庆(2015)售后服务</h5>
-                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-                    <span aria-hidden="true">×</span>
-                  </button>
-                </div>
-                <div class="modal-body">
-                  <div class="row px-3">
-                    <div class="col-4 mb-4">
-                      <div class="card">
-                        <div class="card-body">
-                          <h4 class="card-title">王星植</h4>
-                          <h6 class="card-subtitle mb-2 text-muted">重庆办</h6>
-                        </div>
-                        <ul class="list-group list-group-flush">
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="腾讯QQ"><i class="fa fa-qq"></i> 914630468</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="手机号码"><i class="fa fa-tablet"></i> 15812644017</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="固定电话"><i class="fa fa-phone"></i> 0756-3850891</li>
-                        </ul>
-                      </div>
-                    </div>
-                    <div class="col-4 mb-4">
-                      <div class="card">
-                        <div class="card-body">
-                          <h4 class="card-title">张文远</h4>
-                          <h6 class="card-subtitle mb-2 text-muted">重庆办</h6>
-                        </div>
-                        <ul class="list-group list-group-flush">
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="腾讯QQ"><i class="fa fa-qq"></i> 914630468</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="手机号码"><i class="fa fa-tablet"></i> 15812644017</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="固定电话"><i class="fa fa-phone"></i> 0756-3850891</li>
-                        </ul>
-                      </div>
-                    </div>
-                    <div class="col-4 mb-4">
-                      <div class="card">
-                        <div class="card-body">
-                          <h4 class="card-title">李清学</h4>
-                          <h6 class="card-subtitle mb-2 text-muted">重庆办</h6>
-                        </div>
-                        <ul class="list-group list-group-flush">
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="腾讯QQ"><i class="fa fa-qq"></i> 914630468</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="手机号码"><i class="fa fa-tablet"></i> 15812644017</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="固定电话"><i class="fa fa-phone"></i> 0756-3850891</li>
-                        </ul>
-                      </div>
-                    </div>
-                    <div class="col-4 mb-4">
-                      <div class="card">
-                        <div class="card-body">
-                          <h4 class="card-title">周洪波</h4>
-                          <h6 class="card-subtitle mb-2 text-muted">重庆办</h6>
-                        </div>
-                        <ul class="list-group list-group-flush">
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="腾讯QQ"><i class="fa fa-qq"></i> 914630468</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="手机号码"><i class="fa fa-tablet"></i> 15812644017</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="固定电话"><i class="fa fa-phone"></i> 0756-3850891</li>
-                        </ul>
-                      </div>
-                    </div>
-                    <div class="col-4 mb-4">
-                      <div class="card">
-                        <div class="card-body">
-                          <h4 class="card-title">邹芝达</h4>
-                          <h6 class="card-subtitle mb-2 text-muted">重庆办</h6>
-                        </div>
-                        <ul class="list-group list-group-flush">
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="腾讯QQ"><i class="fa fa-qq"></i> 914630468</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="手机号码"><i class="fa fa-tablet"></i> 15812644017</li>
-                          <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="固定电话"><i class="fa fa-phone"></i> 0756-3850891</li>
-                        </ul>
-                      </div>
-                    </div>
-                  </div>
-                </div>
-                <div class="modal-footer">
-                  <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
-                </div>
-            </div>
-        </div>
-    </div>
     <!-- JS. -->
   <script src="/web/building_saas/js/global.js"></script>
   <script src="/web/users/js/user.js"></script>

+ 43 - 0
web/users/js/user.js

@@ -16,6 +16,49 @@ $(document).ready(function() {
     $("input").blur(function () {
         cleanError();
     });
+
+    //获取cld接口手机号码和数据
+    $('.getcategory').on('click', function () {
+        let category = $(this).attr('data-category');
+        let isupgrade = $(this).attr('data-upgrade');
+        if (isupgrade === 'true') {
+            $('#upgrade-title').text($(this).attr('data-title') + ' 售后服务');
+        } else {
+            $('#upgrade-title').text('联系销售代表激活');
+        }
+        $.ajax({
+            type: 'get',
+            url: '/cld/getCategoryStaff?category=' + category,
+            dataType: 'json',
+            timeout: 5000,
+            success: function (response) {
+                if (response.error !== 0) {
+                    alert('获取CLD人员信息失败!');
+                } else {
+                    let staffList = response.data;
+                    let staffhtml = '';
+                    $.each(staffList, function (key, staff) {
+                        staffhtml += '<div class="col-4 mb-4"> ' +
+                            '<div class="card"> ' +
+                            '<div class="card-body"> ' +
+                            '<h4 class="card-title">' + staff.username + '</h4> ' +
+                            '<h6 class="card-subtitle mb-2 text-muted">' + staff.category + '</h6> ' +
+                            '</div> ' +
+                            '<ul class="list-group list-group-flush"> ' +
+                            '<li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="腾讯QQ"><i class="fa fa-qq"></i> ' + staff.qq + '</li> ' +
+                            '<li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="手机号码"><i class="fa fa-tablet"></i> ' + staff.telephone + '</li> ' +
+                            '<li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="固定电话"><i class="fa fa-phone"></i> ' + staff.phone + '</li> ' +
+                            '</ul> </div> </div>';
+                    });
+                    $('#staffList').html(staffhtml);
+                    $('#activ').modal('show');
+                }
+            },
+            error: function () {
+                console.log('请求超时');
+            }
+        })
+    })
 });
 
 /**