Przeglądaj źródła

巡检功能更新

ellisran 4 dni temu
rodzic
commit
2d2a07796f

+ 2 - 0
app/middleware/quality_inspection_check.js

@@ -43,6 +43,8 @@ module.exports = options => {
             const permission = this.session.sessionUser.permission;
             if (accountId === inspection.uid) { // 原报
                 inspection.filePermission = true;
+            } else if (this.permission.safe_inspection.view_all) {
+                inspection.filePermission = true;
             } else if (auditorIds.indexOf(accountId) !== -1) { // 审批人
                 if (inspection.status === status.uncheck) {
                     throw '您无权查看该数据';

+ 1 - 1
app/public/js/quality_inspection_information.js

@@ -118,7 +118,7 @@ $(document).ready(function () {
         oldSearchVal = e.target.value
         timer && clearTimeout(timer)
         timer = setTimeout(() => {
-            const newVal = $('#gr-search').val()
+            const newVal = $('.gr-search').val()
             let html = ''
             if (newVal && newVal === oldSearchVal) {
                 accountList.filter(item => item && inspection.uid !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {

+ 1 - 1
app/public/js/safe_inspection_information.js

@@ -118,7 +118,7 @@ $(document).ready(function () {
         oldSearchVal = e.target.value
         timer && clearTimeout(timer)
         timer = setTimeout(() => {
-            const newVal = $('#gr-search').val()
+            const newVal = $('.gr-search').val()
             let html = ''
             if (newVal && newVal === oldSearchVal) {
                 accountList.filter(item => item && inspection.uid !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {

+ 14 - 15
app/service/quality_inspection.js

@@ -158,7 +158,7 @@ module.exports = app => {
         async getListByStatus(tid, status, hadlimit = 0, sortBy = '', orderBy = '') {
             let sql = '';
             let sqlParam = '';
-            if ((this.ctx.tender.isTourist || this.ctx.session.sessionUser.is_admin) && status === 0) {
+            if ((this.ctx.tender.isTourist || this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all) && status === 0) {
                 sql = 'SELECT a.* FROM ?? As a WHERE a.tid = ?';
                 sqlParam = [this.tableName, tid];
             } else {
@@ -185,10 +185,10 @@ module.exports = app => {
                     case auditConst.filter.status.uncheck: // 待上报(所有的)PS:取未上报,退回,修订的变更令
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE ' +
-                            'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ?)';
+                            'a.tid = ? AND (a.status = ? OR a.status = ?)' +
+                            (this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all ? '' : ' AND a.uid = ' + this.ctx.session.sessionUser.accountId);
                         sqlParam = [
                             this.tableName,
-                            this.ctx.session.sessionUser.accountId,
                             tid,
                             auditConst.status.uncheck,
                             auditConst.status.checkNo,
@@ -198,16 +198,16 @@ module.exports = app => {
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE ' +
                             '(a.status = ? OR a.status = ?) AND a.tid = ?' +
-                            (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
-                        sqlParam = [this.tableName, status, auditConst.status.checkNoPre, tid, this.ctx.service.qualityInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
+                            (this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
+                        sqlParam = [this.tableName, status, auditConst.status.checkNoPre, tid, this.ctx.service.safeInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
                         break;
                     case auditConst.filter.status.rectification: // 整改中(所有的)
                     case auditConst.filter.status.checkStop: // 终止(所有的)
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE ' +
                             'a.status = ? AND a.tid = ?' +
-                            (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
-                        sqlParam = [this.tableName, status, tid, this.ctx.service.qualityInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
+                            (this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
+                        sqlParam = [this.tableName, status, tid, this.ctx.service.safeInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
                         break;
                     case auditConst.filter.status.checked: // 已完成(所有的)
                         sql = 'SELECT a.* FROM ?? as a WHERE a.status = ? AND a.tid = ?';
@@ -243,7 +243,7 @@ module.exports = app => {
          * @return {void}
          */
         async getCountByStatus(tid, status = 0) {
-            if ((this.ctx.tender.isTourist || this.ctx.session.sessionUser.is_admin) && status === 0) {
+            if ((this.ctx.tender.isTourist || this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all) && status === 0) {
                 const sql5 = 'SELECT count(*) AS count FROM ?? AS a WHERE a.tid = ?';
                 const sqlParam5 = [this.tableName, tid];
                 const result5 = await this.db.query(sql5, sqlParam5);
@@ -272,11 +272,10 @@ module.exports = app => {
                     return result6[0].count;
                 case auditConst.filter.status.uncheck: // 待上报(所有的)PS:取未上报,退回的变更立项
                     const sql2 =
-                        'SELECT count(*) AS count FROM ?? AS a WHERE ' +
-                        'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ?)';
+                        'SELECT count(*) AS count FROM ?? AS a WHERE a.tid = ? AND (a.status = ? OR a.status = ?)' +
+                        (this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all ? '' : ' AND a.uid = ' + this.ctx.session.sessionUser.accountId);
                     const sqlParam2 = [
                         this.tableName,
-                        this.ctx.session.sessionUser.accountId,
                         tid,
                         auditConst.status.uncheck,
                         auditConst.status.checkNo,
@@ -287,8 +286,8 @@ module.exports = app => {
                     const sql7 =
                         'SELECT count(*) AS count FROM ?? as a WHERE ' +
                         '(a.status = ? OR a.status = ?) AND a.tid = ?' +
-                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
-                    const sqlParam7 = [this.tableName, status, auditConst.status.checkNoPre, tid, this.ctx.service.qualityInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
+                        (this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
+                    const sqlParam7 = [this.tableName, status, auditConst.status.checkNoPre, tid, this.ctx.service.safeInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
                     const result7 = await this.db.query(sql7, sqlParam7);
                     return result7[0].count;
                 case auditConst.filter.status.rectification: // 整改中(所有的)
@@ -296,8 +295,8 @@ module.exports = app => {
                     const sql3 =
                         'SELECT count(*) AS count FROM ?? as a WHERE ' +
                         'a.status = ? AND a.tid = ?' +
-                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
-                    const sqlParam3 = [this.tableName, status, tid, this.ctx.service.qualityInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
+                        (this.ctx.session.sessionUser.is_admin || this.ctx.permission.safe_inspection.view_all ? '' : ' AND a.id IN (SELECT b.qiid FROM ?? AS b WHERE b.aid = ? GROUP BY b.qiid)');
+                    const sqlParam3 = [this.tableName, status, tid, this.ctx.service.safeInspectionAudit.tableName, this.ctx.session.sessionUser.accountId];
                     const result3 = await this.db.query(sql3, sqlParam3);
                     return result3[0].count;
                 case auditConst.filter.status.checked: // 已完成(所有的)

+ 1 - 0
app/service/tender_permission.js

@@ -31,6 +31,7 @@ module.exports = app => {
                 inspection: {
                     view: { title: '查看', value: 1, isDefault: 1 },
                     add: { title: '新增巡检', value: 2 },
+                    view_all: { title: '查看所有巡检', value: 3 },
                 },
                 safe_inspection: {
                     view: { title: '查看', value: 1, isDefault: 1 },