Pārlūkot izejas kodu

工作台最近使用项目功能

ellisran 10 stundas atpakaļ
vecāks
revīzija
b4099f7367

+ 3 - 0
app/controller/dashboard_controller.js

@@ -144,6 +144,8 @@ module.exports = app => {
             const sysMsgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, '', 1, 0, 2);
             // 获取系统维护信息
             const maintainData = await ctx.service.maintain.getDataById(1);
+            // 最近使用项目列表
+            const recentProjects = await ctx.service.subProjPermission.getRecentProjects(ctx.session.sessionUser.accountId);
             const renderData = {
                 dashboardShenpis: ctx.helper._.orderBy(dashboardShenpis, ['start_audit', 'shenpi_time'], ['desc', 'asc']),
                 dashboardStatus,
@@ -172,6 +174,7 @@ module.exports = app => {
                 maintainData,
                 maintainConst,
                 typeColMap,
+                recentProjects,
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.dashboard.workspace),
             };
             await this.layout('dashboard/workspace.ejs', renderData, 'dashboard/modal.ejs');

+ 4 - 0
app/middleware/sub_project_check.js

@@ -92,6 +92,10 @@ module.exports = options => {
             } else {
                 this.redirect(`/sp/${this.subProject.id}/nop/${this.controllerName}`);
             }
+
+            // 更新用户最近使用项目时间
+            const auditInfo = yield this.service.subProjPermission.getDataByCondition({ spid: this.subProject.id, uid: accountInfo.id });
+            if (auditInfo) yield this.service.subProjPermission.defaultUpdate({ id: auditInfo.id, last_time: new Date() });
         } catch (err) {
             this.log(err);
             if (this.helper.isAjax(this.request)) {

+ 6 - 0
app/service/sub_proj_permission.js

@@ -566,6 +566,12 @@ module.exports = app => {
             if (updateArr.length > 0) transaction ? await transaction.updateRows(this.tableName, updateArr) : await this.db.updateRows(this.tableName, updateArr);
         }
 
+        async getRecentProjects(uid) {
+            const sql = 'SELECT sp.*, spp.last_time FROM ?? as spp LEFT JOIN ?? as sp ON spp.spid = sp.id WHERE spp.`uid` = ? AND spp.`last_time` is not null ORDER BY spp.`last_time` DESC LIMIT 10';
+            const sqlParams = [this.tableName, this.ctx.service.subProject.tableName, uid];
+            const result = await this.db.query(sql, sqlParams);
+            return result;
+        }
     }
 
     return subProjPermission;

+ 131 - 105
app/view/dashboard/workspace.ejs

@@ -31,9 +31,9 @@
             </div>
         <% } %>
         <div class="dashboard-height mx-3">
-            <div class="row agency-partheight">
+            <div class="row">
                 <div class="col-9 px-0">
-                    <div class="row ml-0">
+                    <div class="row ml-0 agency-partheight">
                         <div class="col-2 px-0">
                             <div class="card ml-3">
                                 <div class="card-header card-white d-flex justify-content-between">
@@ -46,9 +46,9 @@
                                             <h6 class="mt-2 text-muted text-center">参与标段</h6>
                                             <div class="row w-100">
                                                 <div class="col-7 pr-2 text-right">
-                                                    <span class="d-inline-block ws-icon ws-icon-primary">
-                                                    <i class="fa fa-list-ul"></i>
-                                                </span>
+                                            <span class="d-inline-block ws-icon ws-icon-primary">
+                                            <i class="fa fa-list-ul"></i>
+                                        </span>
                                                 </div>
                                                 <h4 class="col-5 pl-2 pr-0 my-0 data_tender_num"><%- dashboardStatus.all %></h4>
                                             </div>
@@ -58,9 +58,9 @@
                                             <h6 class="text-muted text-center">待办处理</h6>
                                             <div class="row w-100">
                                                 <div class="col-7 pr-2 text-right">
-                                                    <span class="d-inline-block ws-icon ws-icon-primary">
-                                                        <i class="fa fa-check-square-o"></i>
-                                                    </span>
+                                            <span class="d-inline-block ws-icon ws-icon-primary">
+                                                <i class="fa fa-check-square-o"></i>
+                                            </span>
                                                 </div>
                                                 <h4 class="col-5 pl-2 pr-0 my-0"><%- dashboardStatus.dashboard %></h4>
                                             </div>
@@ -70,9 +70,9 @@
                                             <h6 class="text-muted text-center">紧急审批</h6>
                                             <div class="row w-100">
                                                 <div class="col-7 pr-2 text-right">
-                                                    <span class="d-inline-block ws-icon ws-icon-danger">
-                                                        <i class="fa fa-exclamation-triangle"></i>
-                                                    </span>
+                                            <span class="d-inline-block ws-icon ws-icon-danger">
+                                                <i class="fa fa-exclamation-triangle"></i>
+                                            </span>
                                                 </div>
                                                 <h4 class="col-5 pl-2 pr-0 my-0 text-danger"><%- dashboardStatus.worry %></h4>
                                             </div>
@@ -82,9 +82,9 @@
                                             <h6 class="text-muted text-center">预警审批</h6>
                                             <div class="row w-100">
                                                 <div class="col-7 pr-2 text-right">
-                                                    <span class="d-inline-block ws-icon ws-icon-warning">
-                                                        <i class="fa fa-bell"></i>
-                                                    </span>
+                                            <span class="d-inline-block ws-icon ws-icon-warning">
+                                                <i class="fa fa-bell"></i>
+                                            </span>
                                                 </div>
                                                 <h4 class="col-5 pl-2 pr-0 my-0 text-warning"><%- dashboardStatus.early %></h4>
                                             </div>
@@ -423,114 +423,139 @@
                             </div>
                         </div>
                     </div>
-                </div>
-                <!--项目消息通知-->
-                <div class="col-3 pl-0">
-                    <div class="card ml-3">
-                        <div class="card-header card-white d-flex justify-content-between">
-                            <div class="card-big-htext"><span class="card-icon mr-2"></span>项目通知</div>
-<!--                            <div class="mt-1"><a class="text-secondary" href="/dashboard/msg">查看全部</a></div>-->
-                        </div>
-                        <div class="card-body p-0">
-                            <div class="contant-height-three">
-                                <ul class="list-group list-group-flush msg-height-list">
-                                    <% if (msgList.length === 0) { %>
-                                        <!--没有通知-->
-                                        <li class="list-group-item text-muted text-center p-5">
-                                            <img src="/public/images/nulllogo.png" />
-                                            <p class="pt-2 text-center mb-0">暂时没有通知</p>
-                                        </li>
-                                    <% } else { %>
-                                        <% for (const msg of msgList) { %>
-                                            <li class="list-group-item text-muted">
-                                                <a href="#view-msg" msg-id="<%= msg.id %>" data-toggle="modal" data-target="#view-msg"<% if (msg.istop !== '0') { %> class="text-danger">
-                                                    <i class="fa fa-exclamation-triangle" ></i> <% } else { %>><% } %><%- msg.title %></a><br><%- moment(msg.release_time*1000).format('YYYY/MM/DD HH:mm') %></li>
-                                        <% } %>
-                                    <% } %>
-                                </ul>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </div>
-            <div class="row agency-partheight">
-                <div class="col-6 px-0">
-                    <div class="card ml-3">
-                        <div class="card-header card-white d-flex justify-content-between">
-                            <div class="card-big-htext"><span class="card-icon mr-2"></span>参与的标段进度</div>
-                        </div>
-                        <div class="card-body p-0">
-                            <div class="contant-height-one">
-                                <div id="jlchart" style="height: 100%; width: 100%;overflow: hidden"></div>
+                    <div class="row ml-0 agency-partheight">
+                        <div class="col-8 px-0">
+                            <div class="card ml-3">
+                                <div class="card-header card-white d-flex justify-content-between">
+                                    <div class="card-big-htext"><span class="card-icon mr-2"></span>参与的标段进度</div>
+                                </div>
+                                <div class="card-body p-0">
+                                    <div class="contant-height-one">
+                                        <div id="jlchart" style="height: 100%; width: 100%;overflow: hidden"></div>
+                                    </div>
+                                </div>
                             </div>
                         </div>
-                    </div>
-                </div>
-                <div class="col-3 px-0">
-                    <div class="card ml-3">
-                        <div class="card-header card-white d-flex justify-content-between">
-                            <div class="card-big-htext"><span class="card-icon mr-2"></span>审批日历</div>
-                        </div>
-                        <div class="card-body p-0">
-                            <div class="contant-height-one">
-                                <div class="mx-4 mt-2 text-center">
-                                    <style>
-                                        #calendar .datepicker {
-                                            width: 100%;
-                                            min-width: 250px;
-                                            text-align: center;
-                                        }
+                        <div class="col-4 pl-0 pr-3">
+                            <div class="card ml-3">
+                                <div class="card-header card-white d-flex justify-content-between">
+                                    <div class="card-big-htext"><span class="card-icon mr-2"></span>审批日历</div>
+                                </div>
+                                <div class="card-body p-0">
+                                    <div class="contant-height-one">
+                                        <div class="mx-4 mt-2 text-center">
+                                            <style>
+                                                #calendar .datepicker {
+                                                    width: 100%;
+                                                    min-width: 250px;
+                                                    text-align: center;
+                                                }
 
-                                        #calendar .datepicker--cell {
-                                            height: 45px;
-                                        }
+                                                #calendar .datepicker--cell {
+                                                    height: 45px;
+                                                }
 
-                                        .shenpi-calendar {
-                                            background-color: #ffb8ff;
-                                        }
-                                        .shenpi-calendar:hover {
-                                            background-color: #fda5fd;
-                                        }
-                                    </style>
-                                    <div id="calendar"></div>
+                                                .shenpi-calendar {
+                                                    background-color: #ffb8ff;
+                                                }
+                                                .shenpi-calendar:hover {
+                                                    background-color: #fda5fd;
+                                                }
+                                            </style>
+                                            <div id="calendar"></div>
+                                        </div>
+                                    </div>
                                 </div>
                             </div>
                         </div>
                     </div>
                 </div>
                 <div class="col-3 pl-0">
-                    <div class="card ml-3">
-                        <div class="card-header card-white d-flex justify-content-between">
-                            <div class="card-big-htext"><span class="card-icon mr-2"></span>技术支持</div>
-                        </div>
-                        <div class="card-body p-0">
-                            <!--<h6 class="card-subtitle mb-2 text-muted"><%= salesmanData.username %></h6>-->
-                            <div class="contant-height-one">
-                                <div class="mx-4">
-                                    <ul class="list-group list-group-flush">
-                                        <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="腾讯QQ"><i class="fa fa-qq"></i> <%=salesmanData.qq%></li>
-                                        <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="手机号码"><i class="fa fa-tablet"></i> <%=salesmanData.telephone%></li>
-                                        <li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="固定电话"><i class="fa fa-phone"></i> <%=salesmanData.fixedphone%></li>
-                                        <% if (projectData.qrcode_json) { %>
-                                            <li class="list-group-item container-fluid">
-                                                <div class="row qrcode-height">
-                                                    <% for (const qr of JSON.parse(projectData.qrcode_json)) { %>
-                                                        <div class="col-sm text-center"><img src="/<%= qr.path %>" width="100%" style="max-width: 180px"><div class="text-center"><%= qr.name %></div></div>
-                                                    <% } %>
-                                                </div>
+                    <!--项目消息通知-->
+                    <div class="row ml-3 pr-3 pb-3 three-partheight">
+                        <div class="col-12 card px-0">
+                            <div class="card-header card-white d-flex justify-content-between">
+                                <div class="card-big-htext"><span class="card-icon mr-2"></span>最近使用</div>
+                            </div>
+                            <div class="card-body p-0">
+                                <div class="contant-height-three">
+                                    <ul class="list-group list-group-flush msg-height-list">
+                                        <% if (recentProjects.length === 0) { %>
+                                            <li class="list-group-item text-muted text-center p-5">
+                                                <img src="/public/images/nulllogo.png" />
+                                                <p class="pt-2 text-center mb-0">暂无使用</p>
                                             </li>
                                         <% } else { %>
-                                            <li class="list-group-item container-fluid">
-                                                <div class="row qrcode-height">
-                                                    <div class="col-sm text-center"><img src="/public/images/erweima.jpg" width="100%" style="max-width: 180px"><div class="text-center">虾米造价</div></div>
-                                                </div>
+                                            <% for (const p of recentProjects) { %>
+                                                <li class="list-group-item text-muted"><a href="/sp/<%- p.id %>/dashboard" target="_blank" class=""><%- p.name %></a><br><%- moment(p.last_time).format('YYYY/MM/DD HH:mm') %></li>
+                                            <% } %>
+                                        <% } %>
+                                    </ul>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row ml-3 pr-3 pb-3 three-partheight">
+                        <div class="col-12 card px-0">
+                            <div class="card-header card-white d-flex justify-content-between">
+                                <div class="card-big-htext"><span class="card-icon mr-2"></span>项目通知</div>
+                                <!--                            <div class="mt-1"><a class="text-secondary" href="/dashboard/msg">查看全部</a></div>-->
+                            </div>
+                            <div class="card-body p-0">
+                                <div class="contant-height-three">
+                                    <ul class="list-group list-group-flush msg-height-list">
+                                        <% if (msgList.length === 0) { %>
+                                            <!--没有通知-->
+                                            <li class="list-group-item text-muted text-center p-5">
+                                                <img src="/public/images/nulllogo.png" />
+                                                <p class="pt-2 text-center mb-0">暂时没有通知</p>
                                             </li>
+                                        <% } else { %>
+                                            <% for (const msg of msgList) { %>
+                                                <li class="list-group-item text-muted">
+                                                    <a href="#view-msg" msg-id="<%= msg.id %>" data-toggle="modal" data-target="#view-msg"<% if (msg.istop !== '0') { %> class="text-danger">
+                                                        <i class="fa fa-exclamation-triangle" ></i> <% } else { %>><% } %><%- msg.title %></a><br><%- moment(msg.release_time*1000).format('YYYY/MM/DD HH:mm') %></li>
+                                            <% } %>
                                         <% } %>
                                     </ul>
                                 </div>
                             </div>
                         </div>
                     </div>
+                    <div class="row ml-3 pr-3 pb-3 three-partheight">
+                            <div class="col-12 card px-0">
+                                <div class="card-header card-white d-flex justify-content-between">
+                                    <div class="card-big-htext"><span class="card-icon mr-2"></span>技术支持</div>
+                                </div>
+                                <div class="card-body p-0">
+                                    <!--<h6 class="card-subtitle mb-2 text-muted"><%= salesmanData.username %></h6>-->
+                                    <div class="contant-height-three">
+                                        <div class="mx-4">
+                                            <ul class="list-group list-group-flush">
+                                                <li class="list-group-item pt-0 pb-2" data-toggle="tooltip" data-placement="bottom" title="腾讯QQ"><i class="fa fa-qq"></i> <%=salesmanData.qq%></li>
+                                                <li class="list-group-item py-2" data-toggle="tooltip" data-placement="bottom" title="手机号码"><i class="fa fa-tablet"></i> <%=salesmanData.telephone%></li>
+                                                <li class="list-group-item py-2" data-toggle="tooltip" data-placement="bottom" title="固定电话"><i class="fa fa-phone"></i> <%=salesmanData.fixedphone%></li>
+                                                <% if (projectData.qrcode_json) { %>
+                                                    <li class="list-group-item container-fluid">
+                                                        <div class="row qrcode-height">
+                                                            <% for (const qr of JSON.parse(projectData.qrcode_json)) { %>
+                                                                <div class="col-sm text-center"><img src="/<%= qr.path %>" width="100%" style="max-width: 90px"><div class="text-center"><%= qr.name %></div></div>
+                                                            <% } %>
+                                                        </div>
+                                                    </li>
+                                                <% } else { %>
+                                                    <li class="list-group-item container-fluid">
+                                                        <div class="row qrcode-height">
+                                                            <div class="col-sm text-center"><img src="/public/images/erweima.jpg" width="100%" style="max-width: 90px"><div class="text-center">虾米造价</div></div>
+                                                        </div>
+                                                    </li>
+                                                <% } %>
+                                            </ul>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
                 </div>
             </div>
         </div>
@@ -569,11 +594,12 @@
             var maintainHeight = getObjHeight($(".maintain-height"));
             $('.dashboard-height').height($(window).height()- mobileHeight - maintainHeight - 34 - 16);
             $('.agency-partheight').height($('.dashboard-height').height()/2);
+            $('.three-partheight').height($('.dashboard-height').height()/3 - 18);
             // $('.agency-partheight').eq(1).height($('.sjs-height-0').height() - $('.agency-partheight').eq(0).height());
             $('.contant-height-one').height($('.agency-partheight').height() - 52 - 20);
             $('.contant-height-two').height($('.agency-partheight').height() - 52 - getObjHeight($(".echart-height")) - 20);
-            $('.contant-height-three').height($('.agency-partheight').height() - 52 - getObjHeight($(".addmsg-height")) - 20);
-            $('.qrcode-height').height($('.contant-height-one').height() - 43 - 44 - 44 - 25);
+            $('.contant-height-three').height($('.three-partheight').height() - 52 - 20);
+            $('.qrcode-height').height($('.contant-height-three').height() - 43 - 44 - 44 - 25);
             $('.qrcode-height .col-sm').css('padding-top', ($('.qrcode-height').height()/2 - ($('.qrcode-height img').height()+18)/2) + 'px');
             // resizeChart();
         }

+ 3 - 0
sql/update.sql

@@ -19,6 +19,9 @@ ADD COLUMN `file_company` varchar(100) NOT NULL DEFAULT '' COMMENT '归档单位
 ALTER TABLE `zh_filing_template`
 ADD COLUMN `file_company` varchar(100) NOT NULL DEFAULT '' COMMENT '归档单位' AFTER `tips`;
 
+ALTER TABLE `zh_sub_project_permission`
+ADD COLUMN `last_time` timestamp NULL DEFAULT NULL COMMENT '最近使用时间' AFTER `tp_cache_time`;
+
 ------------------------------------
 -- 表数据
 ------------------------------------