浏览代码

bug fixed

zhangweicheng 7 年之前
父节点
当前提交
138998bb36

+ 1 - 1
config/config.js

@@ -29,5 +29,5 @@ module.exports = {
             return  'mongodb://' + me[env].server + ':' + me[env].port + '/usersManagesOpr';//'mongodb://' + config.current.server + ':' + config.current.port + '/usersManagesOpr'
         }
     },
-    pageSize: 30
+    pageSize: 2
 };

+ 5 - 5
config/menu.js

@@ -19,14 +19,14 @@ let menuData = {
         iconClass: 'glyphicon glyphicon-user',
         children: {
             'index' : {
-                title: '最近注册',
+                title: '普通用户',
                 url: '/user',
                 name: 'index',
             },
             'last-login' : {
-                title: '最近登录',
-                url: '/user/last-login',
-                name: 'last-login',
+                title: '测试用户',
+                url: '/user/test-user',
+                name: 'test-user',
             }
         }
     },
@@ -37,7 +37,7 @@ let menuData = {
         iconClass: 'glyphicon glyphicon-bell',
     },
     'version': {
-        title: '编办管理',
+        title: '费用定额',
         url: '/compilation',
         name: 'compilation',
         iconClass: 'glyphicon glyphicon-tag'

+ 4 - 0
modules/all_models/user.js

@@ -43,6 +43,10 @@ let modelSchema = {
         type: Number,
         default: 0
     },
+    user_type:{
+        type:String,
+        default:'normal'//  normal : 普通用户,test:测试用户
+    }
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
 

+ 1 - 1
modules/common/helper/mongoose_helper.js

@@ -55,7 +55,7 @@ class MongooseHelper {
         let self = this;
         let limit = 0;
         let skip = 0;
-        let sort = {};
+        let sort = {_id:1};
         if (option !== null && Object.keys(option).length > 0) {
             limit = option.pageSize !== undefined ? option.pageSize : limit;
             skip = option.offset !== undefined ? option.offset : skip;

+ 5 - 0
modules/common/std/schemas/std_fee_rate_libs.js

@@ -48,6 +48,11 @@ let modelSchema = {
     region: String,
     // 标准名称
     libName: String,
+    //编办ID
+    compilationId: {
+        type: String,
+        index: true
+    },
     // 费率数据
     rates: [ratesSchema]
 };

+ 2 - 2
modules/common/std/std_fee_rate_libs_model.js

@@ -26,10 +26,10 @@ class STDFeeRateLibsModel extends BaseModel {
      *
      * @return {Promise}
      */
-    async getFeeRateList() {
+    async getFeeRateList(compilationId) {
         let result = [];
         let field = {ID: 1, libName: 1};
-        let feeRateList = await this.findDataByCondition({ID: {$ne: ''}}, field, false);
+        let feeRateList = await this.findDataByCondition({compilationId:compilationId,ID: {$ne: ''}}, field, false);
 
         if (feeRateList === null) {
             return result;

+ 1 - 1
modules/users/controllers/compilation_controller.js

@@ -208,7 +208,7 @@ class CompilationController extends BaseController {
 
             // 获取费率标准库
             let stdFeeRateLibsModel = new STDFeeRateLibsModel();
-            feeRateList = await stdFeeRateLibsModel.getFeeRateList();
+            feeRateList = await stdFeeRateLibsModel.getFeeRateList(selectedCompilation._id);
 
             // 获取人工系数标准库
             let stdLabourCoesModel = new STDLabourCoesModel();

+ 2 - 2
modules/users/controllers/user_controller.js

@@ -18,7 +18,7 @@ class UserController extends BaseController {
      * @param {object} response
      * @return {void}
      */
-    async lastRegister(request, response) {
+    async normalUsers(request, response) {//取普通用户
         let userModel = new UserModel();
         let total = 0;
         let pageData = {};
@@ -40,7 +40,7 @@ class UserController extends BaseController {
             let page = request.query.page === undefined ? 1 : request.query.page;
             pageData = {
                 current: page,
-                total: parseInt(total / Config.pageSize),
+                total: Math.ceil(total / Config.pageSize),
                 queryData: response.locals.urlQuery
             };
 

+ 2 - 2
modules/users/models/engineering_lib_model.js

@@ -174,8 +174,8 @@ class EngineeringLibModel extends BaseModel {
     _validLib(libData) {
         let result = [];
         // 判断标准库
-        if (libData === undefined || libData === '') {
-            throw '标准库不能为空';
+        if (libData === undefined || libData ===null ||libData === '') {
+            return result;//throw '标准库不能为空'; 按新需求,标准库等不做非空判断
         }
         libData = libData instanceof Array ? libData : [libData];
         for(let tmp in libData) {

+ 1 - 1
modules/users/routes/user_route.js

@@ -13,7 +13,7 @@ const userController = new UserController();
 
 module.exports =function (app) {
     // action定义区域
-    router.get('/', userController.auth, userController.init, userController.lastRegister);
+    router.get('/', userController.auth, userController.init, userController.normalUsers);
     router.get('/search', userController.auth, userController.init, userController.search);
 
     app.use("/user", router);

+ 5 - 5
web/users/js/compilation.js

@@ -117,7 +117,7 @@ $(document).ready(function() {
         switch (model) {
             case 'all':
                 $("#name-area").show();
-                $("#add-compilation-title").text('添加新编办');
+                $("#add-compilation-title").text('添加新费用定额');
                 break;
             case 'bill':
                 $("#bill-area").show();
@@ -281,7 +281,7 @@ function initCompilation() {
     let billsTemplateTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
 
     billsTemplateTree.loadDatas(JSON.parse(billsTemplateData));
-    if (mainTreeCol !== '') {
+    if (mainTreeCol !== '' && mainTreeColObj.cols.length > 0) {
         TREE_SHEET_HELPER.loadSheetHeader(mainTreeColObj, colSpread.getActiveSheet());
         TREE_SHEET_HELPER.showTreeData(mainTreeColObj, colSpread.getActiveSheet(), billsTemplateTree);
     }
@@ -455,8 +455,8 @@ function validLib() {
         if (engineering === '' || engineering <= 0) {
             throw '请选择工程专业';
         }
-
-        if ($("input:hidden[name='bill_lib']").length <= 0) {
+        //按新需求,清单库、定额库等不做非空验证
+      /*  if ($("input:hidden[name='bill_lib']").length <= 0) {
             throw '请添加标准清单';
         }
 
@@ -482,7 +482,7 @@ function validLib() {
 
         if ($("input:hidden[name='billsGuidance_lib']").length <= 0) {
             throw '请添加清单指引库';
-        }
+        }*/
 
         result = true;
     } catch (error) {

+ 16 - 7
web/users/js/template.js

@@ -184,18 +184,25 @@ let TEMPLATE_BILLS_SETTING = {
 
 $(document).ready(function () {
     let RefreshBaseActn = function (tree) {
-        let showButton = function (show, btn) {
+      /*  let showButton = function (show, btn) { 隐藏改成灰显
             if (show) {
                 btn.show();
             } else {
                 btn.hide();
             }
+        };*/
+        let setButtonValid = function (valid, btn) {
+            if (valid) {
+                btn.removeClass('disabled');
+            } else {
+                btn.addClass('disabled');
+            }
         };
-        showButton(tree.selected && tree.selected.canUpLevel(), $('#upLevel'));
-        showButton(tree.selected && tree.selected.canDownLevel(), $('#downLevel'));
-        showButton(tree.selected && tree.selected.canUpMove(), $('#upMove'));
-        showButton(tree.selected && tree.selected.canDownMove(), $('#downMove'));
-        showButton(tree.selected ? true : false, $('#delete'));
+        setButtonValid(tree.selected && tree.selected.canUpLevel(), $('#upLevel'));
+        setButtonValid(tree.selected && tree.selected.canDownLevel(), $('#downLevel'));
+        setButtonValid(tree.selected && tree.selected.canUpMove(), $('#upMove'));
+        setButtonValid(tree.selected && tree.selected.canDownMove(), $('#downMove'));
+        setButtonValid(tree.selected ? true : false, $('#delete'));
     };
     let RefreshBillsData = function (datas) {
         datas.forEach(function (data) {
@@ -251,7 +258,7 @@ $(document).ready(function () {
         }
     };
     let getRealValue = function (value,map) {//中文到实际值的转换
-        value = value.replace(/[\s\r\n]/g, "");//去掉空格,回车等无用字符
+        if(value) value = value.replace(/[\s\r\n]/g, "");//去掉空格,回车等无用字符
         if(map[value]!==undefined && map[value]!==null) value = map[value];
         return value;
     };
@@ -379,6 +386,8 @@ $(document).ready(function () {
     });
     tree.loadDatas(templateData);
     controller.showTreeData();
+    let sel = billsSpread.getActiveSheet().getSelections()[0];
+    controller.setTreeSelected(tree.items[sel.row == -1?0:sel.row]);//初始化选中项
     RefreshBaseActn(tree);
 
     $('#insert').click(function () {

+ 1 - 1
web/users/views/compilation/common.html

@@ -1,7 +1,7 @@
 <div class="panel-sidebar">
     <div class="panel-title">
         <div class="title-bar">
-            <h2><a class="pull-right add-compilation" title="添加新编办" href="javascript:void(0)" data-model="all"><span class="glyphicon glyphicon-plus"></span></a>编办管理</h2>
+            <h2><a class="pull-right add-compilation" title="添加新费用定额" href="javascript:void(0)" data-model="all"><span class="glyphicon glyphicon-plus"></span></a>费用定额</h2>
         </div>
     </div>
     <div class="scrollbar-auto">

+ 1 - 1
web/users/views/compilation/modal.html

@@ -4,7 +4,7 @@
         <div class="modal-content">
             <div class="modal-header">
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-                <h4 class="modal-title" id="add-compilation-title">添加新编办</h4>
+                <h4 class="modal-title" id="add-compilation-title">添加新费用定额</h4>
             </div>
             <div class="modal-body">
                 <div class="form-group" id="name-area">

+ 37 - 3
web/users/views/layout/page.html

@@ -1,9 +1,14 @@
 <ul aria-label="Page navigation" id="pages"></ul>
 <script type="text/javascript">
+
+    let totalPage = "<%= pages.total %>";
+    let current ="<%= pages.current %>";
+    let pageArray = getPageArray(parseInt(totalPage),2,parseInt(current));
     let options = {
         bootstrapMajorVersion: 3,
         currentPage: "<%= pages.current %>",
         totalPages: "<%= pages.total %>",
+        numberOfPages:"<%= pages.total %>",
         size: "normal",
         itemContainerClass: function(type, page, current) {
             let className = 'page-item';
@@ -36,7 +41,7 @@
                 case "next":
                     return "下一页";
                 case "last":
-                    return "最后一页";
+                    return "&raquo;";
                 case "page":
                     return page;
             }
@@ -48,14 +53,16 @@
                     result = (current !== 1);
                     break;
                 case "prev":
+                    result = false;
                     break;
                 case "next":
+                    result = false;
                     break;
                 case "last":
-                    result = false;
+                    result = (current != this.totalPages);
                     break;
                 case "page":
-                    result = true;
+                    result = pageArray.indexOf(page)!=-1;
                     break;
             }
             return result;
@@ -84,4 +91,31 @@
     if (options.totalPages > 0) {
         $("#pages").bootstrapPaginator(options);
     }
+
+    function getPageArray(totalPage,offset,current) {
+        let showPageArray = [current];
+        let pre_fix = current - offset;
+        let tai_fix = current + offset;
+        if(pre_fix<=0){
+            for(let p =1;p <= Math.abs(pre_fix)+1;p++){
+                showPageArray.push(current + offset +p)
+            }
+        }
+        if(tai_fix > totalPage){
+            for(let t=1;t < (tai_fix - totalPage)+1;t++){
+                showPageArray.push(current - offset - t)
+            }
+        }
+        for(let i=1;i<= offset;i++){
+            let pre = current - i;
+            let next = current + i;
+            if(pre > 0){
+                showPageArray.push(pre);
+            }
+            if(next <= totalPage){
+                showPageArray.push(next);
+            }
+        }
+        return showPageArray;
+    }
 </script>

+ 9 - 1
web/users/views/user/index.html

@@ -59,8 +59,12 @@
                     <th width="350">注册手机/邮箱</th>
                     <th>姓名</th>
                     <th>企业名称</th>
-                    <th>地区</th>
+                    <th>企业地区</th>
+                    <th>最近使用版本</th>
+                    <th width="180">最近登录</th>
                     <th width="180">注册时间</th>
+                    <th>详细</th>
+                    <th>升级</th>
                 </tr>
                 </thead>
                 <tbody>
@@ -72,7 +76,11 @@
                            data-content="企业类型:<%= model.companyType[user.company_type] %>,企业规模:<%= model.companyScale[user.company_scale] %>"><%= user.company %></a>
                     </td>
                     <td><%= model.province[user.province] %></td>
+                    <td>重庆01版</td>
+                    <td>登录时间</td>
                     <td><%= moment(user.create_time).format('YYYY-MM-DD HH:mm:ss') %></td>
+                    <td>详细</td>
+                    <td>升级</td>
                 </tr>
                 <% }) %>
                 </tbody>