瀏覽代碼

查询用户使用情况

zhangweicheng 5 年之前
父節點
當前提交
45c441802b

+ 1 - 1
config/config.js

@@ -11,7 +11,7 @@ module.exports = {
             auth: {
                 "authdb": "admin"
             },
-            connectTimeoutMS: 20000,
+            connectTimeoutMS: 60000,
             useMongoClient: true
         }
     },

+ 10 - 0
modules/std_glj_lib/controllers/gljController.js

@@ -201,6 +201,16 @@ class GljController extends BaseController{
         }
     }
 
+    async getUsedInfo(req, res) {
+        try {
+            const {repositoryId, gljId} = JSON.parse(req.body.data);
+            const info = await gljDao.getUsedInfo(repositoryId, gljId);
+            res.json({error: 0, message: 'success', data: info});
+        } catch (err) {
+            res.json({error: 1, message: String(err), data: null});
+        }
+    }
+
     async importPrice(request, response) {
         let responseData = {
             err: 0,

+ 32 - 0
modules/std_glj_lib/models/gljModel.js

@@ -5,6 +5,9 @@ const mongoose = require('mongoose');
 const gljMapModel = mongoose.model('std_glj_lib_map');
 const gljModel = mongoose.model('std_glj_lib_gljList');
 const gljClassModel = mongoose.model('std_glj_lib_gljClass');
+const projectGLJModel = mongoose.model('glj_list');
+const projectModel = mongoose.model('projects');
+const userModel = mongoose.model('users');
 const gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate');
 const compilationModel = mongoose.model('compilation');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
@@ -14,6 +17,7 @@ import {OprDao} from  "./gljMapModel";
 import moment from "moment";
 import counter from "../../../public/counter/counter";
 import async from "async";
+let _ = require("lodash");
 
 class GljDao  extends OprDao{
     async getReference(repositoryId, gljId) {
@@ -42,6 +46,34 @@ class GljDao  extends OprDao{
         complementaryRations.forEach(ration => rst[complementaryLib].push({code: ration.code}));
         return rst;
     }
+
+    async getUsedInfo(repositoryId, gljId) {
+        let userMap = {};
+        let userIDList = [];
+        let projectList = await projectGLJModel.find({"glj_id":gljId},'-_id project_id').lean();
+        if(projectList.length > 0){
+            let projectUserList =  await projectModel.find({'ID':{$in:_.map(projectList,"project_id")}},'-_id ID userID').lean();
+            for(let p of projectUserList){
+                if(!userMap[p.userID]){
+                    userMap[p.userID] = true;
+                    userIDList.push(p.userID);
+                }
+            }
+            let userList = await userModel.find({'_id':{$in:userIDList}},'_id username mobile').lean();
+            for(let u of userList){
+                userMap[u._id.toString()] = u;
+            }
+            for(let p of projectUserList){
+                p.username = userMap[p.userID].username;
+                p.mobile = userMap[p.userID].mobile;
+            }
+           return projectUserList
+        }
+
+
+        return [];
+    }
+
     //test
     async deSomething (libID){
         let pClass = await gljClassModel.find({repositoryId: libID, Name: '2013全省材料预算价格'});

+ 2 - 0
modules/std_glj_lib/routes/routes.js

@@ -47,6 +47,8 @@ module.exports = function (app) {
     router.post('/importPrice', gljController.auth, gljController.init, gljController.importPrice);
     router.post('/importComponents', gljController.auth, gljController.init, gljController.importComponents);
 
+    // 查找用户使用
+    router.post("/getUsedInfo",gljController.auth, gljController.init, gljController.getUsedInfo);
 
     app.use("/stdGljRepository/api", router);
 

+ 3 - 0
web/maintain/std_glj_lib/css/main.css

@@ -302,4 +302,7 @@ body {
     float: right;
     width: 30px;
     text-decoration: none;
+}
+.usedInfo td{
+    padding: .3rem;
 }

+ 24 - 0
web/maintain/std_glj_lib/html/gongliao.html

@@ -205,6 +205,30 @@
             </div>
         </div>
     </div>
+
+    <div class="modal fade" id="usedInfo" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">工料机使用情况</h5>
+                    <button type="button"  class="close typeClose" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body reset">
+                    <div class="warp-p2 mt-3">
+                        <label id="usedTotal"></label>
+                        <table class="table table-hover table-bordered usedInfo">
+                            <thead><tr><th>项目ID</th><th>用户名称</th><th>电话号码</th></tr></thead>
+                            <tbody id="userInfoShowArea">
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
     <!-- JS. -->
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/jquery-contextmenu/jquery.contextMenu.min.js"></script>

+ 29 - 0
web/maintain/std_glj_lib/js/glj.js

@@ -1073,6 +1073,17 @@ let repositoryGljObj = {
                                     me.getReference(glj);
                                 }
                             },
+                            getUsedInfo: {
+                                name: '查找用户使用情况',
+                                disabled: function () {
+                                    return !(me.currentCache && me.currentCache[target.row]);
+                                },
+                                icon: 'fa-search',
+                                callback: function () {
+                                    const glj = me.currentCache[target.row];
+                                    me.getUsedInfo(glj);
+                                }
+                            }
                         }
                     };
                 }
@@ -1112,6 +1123,24 @@ let repositoryGljObj = {
             $.bootstrapLoading.end();
         });
     },
+    getUsedInfo:function (glj) {
+        $.bootstrapLoading.start();
+        $("#usedInfo").modal('show');
+        CommonAjax.post('/stdGljRepository/api/getUsedInfo', {repositoryId: glj.repositoryId, gljId: glj.ID}, function (info) {
+            $("#usedTotal").html(`共${info.length}项记录`);
+            let htmlString = "";
+            for(let u of info){
+                htmlString += `<tr><td>${u.ID}</td><td>${u.username}</td> <td>${u.mobile}</td></tr>`;
+            }
+            $("#userInfoShowArea").html(htmlString);
+
+            $.bootstrapLoading.end();
+        }, function () {
+            $.bootstrapLoading.end();
+        });
+    },
+
+
     validUpdateObj: function (pasteObj, rowIdx) {
         let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
             me = repositoryGljObj,