Browse Source

修复设置页账户搜索bug

laiguoran 4 years ago
parent
commit
a46ab0b573

+ 4 - 0
app/controller/setting_controller.js

@@ -118,6 +118,9 @@ module.exports = app => {
                 // const accountData = await ctx.service.projectAccount.getListByProjectId(columns, projectId);
                 const accountData = await ctx.service.projectAccount.getListWithBuilder();
 
+                // 获取账号个数
+                const user_total = await ctx.service.projectAccount.count({ project_id: projectId });
+
                 // 分页相关
                 const pageInfo = {
                     page,
@@ -132,6 +135,7 @@ module.exports = app => {
                     permission,
                     pageInfo,
                     keyword,
+                    user_total,
                     // rule: JSON.stringify(frontRule),
                 };
                 await this.layout('setting/user.ejs', renderData, 'setting/user_modal.ejs');

+ 4 - 4
app/service/project_account.js

@@ -727,19 +727,19 @@ module.exports = app => {
             if (data.keyword !== undefined && data.keyword !== '') {
                 this.sqlBuilder.setNewOrWhere([{
                     field: 'account',
-                    value: this.db.escape(data.keyword + '%'),
+                    value: this.db.escape('%' + data.keyword + '%'),
                     operate: 'like',
                 }, {
                     field: 'name',
-                    value: this.db.escape(data.keyword + '%'),
+                    value: this.db.escape('%' + data.keyword + '%'),
                     operate: 'like',
                 }, {
                     field: 'company',
-                    value: this.db.escape(data.keyword + '%'),
+                    value: this.db.escape('%' + data.keyword + '%'),
                     operate: 'like',
                 }, {
                     field: 'mobile',
-                    value: this.db.escape(data.keyword + '%'),
+                    value: this.db.escape('%' + data.keyword + '%'),
                     operate: 'like',
                 }]);
             }

+ 1 - 1
app/view/setting/user.ejs

@@ -3,7 +3,7 @@
     <div class="panel-title">
         <div class="title-main">
             <h2>账号管理
-                <% if (projectData.max_user !== accountData.length) { %>
+                <% if (projectData.max_user !== user_total) { %>
                 <a href="#ver" data-toggle="modal" data-target="#add-user" class="btn btn-primary btn-sm pull-right">添加账号</a>
                 <% } else { %>
                 <a href="#add-unpass" data-toggle="modal" data-target="#add-unpass" class="btn btn-primary btn-sm pull-right">添加账号(受限)</a>