فهرست منبع

1.待办页需要你关注所有sql补齐
2.调差无法检索重复编号问题

laiguoran 5 سال پیش
والد
کامیت
adc62df950

+ 8 - 8
app/controller/dashboard_controller.js

@@ -31,15 +31,15 @@ module.exports = app => {
             const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
             const lastNotice = pa.last_notice ? pa.last_notice : (pa.last_notice === 0 ? new Date() : new Date(pa.last_login * 1000));
             const noticeLedger = await ctx.service.ledgerAudit.getNoticeTender(ctx.session.sessionProject.id, pa.id, lastNotice);
-            // const noticeStage = await ctx.service.stageAudit.getNoticeStage(ctx.session.sessionProject.id, pa.id, lastNotice);
-            // const noticeChange = await ctx.service.changeAudit.getNoticeChange(ctx.session.sessionProject.id, pa.id, lastNotice);
-            // const noticeRevise = await ctx.service.reviseAudit.getNoticeRevise(ctx.session.sessionProject.id, pa.id, lastNotice);
-            // const noticeMaterial = await ctx.service.materialAudit.getNoticeMaterial(ctx.session.sessionProject.id, pa.id, lastNotice);
+            const noticeStage = await ctx.service.stageAudit.getNoticeStage(ctx.session.sessionProject.id, pa.id, lastNotice);
+            const noticeChange = await ctx.service.changeAudit.getNoticeChange(ctx.session.sessionProject.id, pa.id, lastNotice);
+            const noticeRevise = await ctx.service.reviseAudit.getNoticeRevise(ctx.session.sessionProject.id, pa.id, lastNotice);
+            const noticeMaterial = await ctx.service.materialAudit.getNoticeMaterial(ctx.session.sessionProject.id, pa.id, lastNotice);
             // const noticeLedger = [];
-            const noticeStage = [];
-            const noticeChange = [];
-            const noticeRevise = [];
-            const noticeMaterial = [];
+            // const noticeStage = [];
+            // const noticeChange = [];
+            // const noticeRevise = [];
+            // const noticeMaterial = [];
             const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
             // 获取销售人员数据
             const salesmanData = await ctx.service.manager.getDataById(projectData.manager_id);

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

@@ -399,7 +399,7 @@ $(document).ready(() => {
                         bPaste = false;
                         continue;
                     }
-                    if (colSetting.field === 'code' && _.find(sortData, { code: validText })) {
+                    if (colSetting.field === 'code' && _.find(sortData, { code: validText.toString() })) {
                         toastMessageUniq(getPasteHint(hint.codeUsed, hintRow));
                         bPaste = false;
                         continue;

+ 7 - 6
app/service/change_audit.js

@@ -296,16 +296,17 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getNoticeChange(pid, uid, time) {
-            const sql = 'SELECT t.`id`, t.`name`, t.`type`, t.`user_id`, ' +
+            const sql = 'SELECT * FROM (SELECT t.`id`, t.`name`, t.`type`, t.`user_id`, ' +
                         '    ca.`cid`, c.`code` As `c_code`, c.name As `c_name`, ' +
                         '    ca.`uid`, ca.`sin_time` As `cu_time`, ca.`status` As `cu_status`, ca.`name` As `cu_name`, ca.`jobs` As `cu_jobs`, ca.company As `cu_company`' +
-                        '  FROM ?? As t' +
+                        '  FROM (SELECT * FROM ?? WHERE `user_id` = ? OR `id` in (SELECT `tid` FROM ?? WHERE `uid` = ? GROUP BY `tid`)) As t' +
                         '  LEFT JOIN ?? As c ON c.`tid` = t.`id`' +
                         '  LEFT JOIN ?? As ca ON ca.`cid` = c.`cid`' +
-                        '  WHERE t.`project_id` = ? and ca.`uid` <> ? and `ca`.`sin_time` > ?' +
-                        '  GROUP BY t.`id`' +
-                        '  ORDER BY ca.`sin_time`';
-            const sqlParam = [this.ctx.service.tender.tableName, this.ctx.service.change.tableName, this.tableName, pid, uid, time];
+                        '  WHERE t.`project_id` = ? and `ca`.`sin_time` > ?' +
+                        '  ORDER By ca.`sin_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`id`' +
+                        '  ORDER BY new_t.`cu_time`';
+            const sqlParam = [this.ctx.service.tender.tableName, uid, this.tableName, uid, this.ctx.service.change.tableName, this.tableName, pid, time];
+            console.log(sql, sqlParam);
             return await this.db.query(sql, sqlParam);
         }
     }

+ 7 - 7
app/service/material_audit.js

@@ -501,19 +501,19 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getNoticeMaterial(pid, uid, time) {
-            const sql = 'SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
+            const sql = 'SELECT * FROM (SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
                 '    m.`order` As `m_order`, m.`status` As `m_status`, ' +
                 '    ma.`aid`, ma.`times`, ma.`order`, ma.`end_time`, ma.`tid`, ma.`mid`, ma.`status`, ' +
                 '    pa.`name` As `su_name`, pa.role As `su_role`, pa.company As `su_company`' +
-                '  FROM ?? As t' +
+                '  FROM (SELECT * FROM ?? WHERE `user_id` = ? OR `id` in (SELECT `tid` FROM ?? WHERE `aid` = ? GROUP BY `tid`)) As t' +
                 '  LEFT JOIN ?? As m On t.`id` = m.`tid`' +
                 '  LEFT JOIN ?? As ma ON m.`id` = ma.`mid`' +
                 '  LEFT JOIN ?? As pa ON ma.`aid` = pa.`id`' +
-                '  WHERE ma.`aid` <> ? and ma.`end_time` > ? and t.`project_id` = ?' +
-                '  GROUP By t.`id`' +
-                '  ORDER By ma.`end_time`';
-            const sqlParam = [this.ctx.service.tender.tableName, this.ctx.service.material.tableName, this.tableName,
-                this.ctx.service.projectAccount.tableName, uid, time, pid];
+                '  WHERE ma.`end_time` > ? and t.`project_id` = ?' +
+                '  ORDER By ma.`end_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`tid`' +
+                '  ORDER BY new_t.`end_time`';
+            const sqlParam = [this.ctx.service.tender.tableName, uid, this.tableName, uid, this.ctx.service.material.tableName, this.tableName,
+                this.ctx.service.projectAccount.tableName, time, pid];
             return await this.db.query(sql, sqlParam);
         }
 

+ 10 - 10
app/service/revise_audit.js

@@ -373,7 +373,7 @@ module.exports = app => {
                 '    p.name As audit_name, p.role As audit_role, p.company As audit_company' +
                 '  FROM ' + this.tableName + ' AS ra' +
                 '  Left Join ' + this.ctx.service.ledgerRevise.tableName + ' As r On ra.rid = r.id' +
-                '  Left Join '+ this.ctx.service.tender.tableName +' AS t On r.tid = t.id' +
+                '  Left Join ' + this.ctx.service.tender.tableName + ' AS t On r.tid = t.id' +
                 '  Left Join ' + this.ctx.service.projectAccount.tableName + ' As p On ra.audit_id = p.id' +
                 '  WHERE r.`valid` != 0 and ((ra.`audit_id` = ? and ra.`status` = ?) OR' +
                 '    (r.`uid` = ? and r.`status` = ? and ra.`status` = ? and ra.`times` = (r.`times`-1)))';
@@ -389,18 +389,18 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getNoticeRevise(projectId, auditorId, noticeTime) {
-            const sql = 'SELECT ra.`audit_id`, ra.`times`, ra.`audit_order`, ra.`end_time`, ra.`status`,' +
-                '    r.id, r.corder, r.uid, r.status, r.content, ' +
+            const sql = 'SELECT * FROM (SELECT ra.`audit_id`, ra.`times`, ra.`audit_order`, ra.`end_time`, ra.`status`,' +
+                '    r.id, r.corder, r.uid, r.status As `r_status`, r.content, ' +
                 '    t.`id` As t_id, t.`name` As t_name, t.`project_id` As t_pid, t.`type` As t_type, t.`user_id` As t_uid, ' +
                 '    pa.name As `ru_name`, pa.role As `ru_role`, pa.company As `ru_company`' +
-                '  FROM ' + this.tableName + ' As ra' +
-                '  LEFT JOIN ' + this.ctx.service.ledgerRevise.tableName + ' As r ON ra.rid = r.id' +
-                '  LEFT JOIN ' + this.ctx.service.tender.tableName + ' As t ON r.`tid` = t.`id`' +
+                '  FROM (SELECT * FROM ?? WHERE `user_id` = ? OR `id` in (SELECT `tender_id` FROM ?? WHERE `audit_id` = ? GROUP BY `tender_id`)) As t' +
+                '  LEFT JOIN ' + this.ctx.service.ledgerRevise.tableName + ' As r ON r.`tid` = t.`id`' +
+                '  LEFT JOIN ' + this.tableName + ' As ra  ON ra.rid = r.id' +
                 '  LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa ON ra.`audit_id` = pa.`id`' +
-                '  WHERE ra.audit_id <> ? and ra.end_time > ? and t.project_id = ?' +
-                '  GROUP By t.`id`' +
-                '  ORDER By ra.`end_time`';
-            const sqlParam = [auditorId, noticeTime, projectId];
+                '  WHERE ra.end_time > ? and t.project_id = ?' +
+                '  ORDER By ra.`end_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`id`' +
+                '  ORDER By new_t.`end_time`';
+            const sqlParam = [this.ctx.service.tender.tableName, auditorId, this.tableName, auditorId, noticeTime, projectId];
             return await this.db.query(sql, sqlParam);
         }
 

+ 7 - 7
app/service/stage_audit.js

@@ -753,19 +753,19 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getNoticeStage(pid, uid, time) {
-            const sql = 'SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
+            const sql = 'SELECT * FROM (SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
                         '    s.`order` As `s_order`, s.`status` As `s_status`, ' +
                         '    sa.`aid`, sa.`times`, sa.`order`, sa.`end_time`, sa.`tid`, sa.`sid`, sa.`status`, ' +
                         '    pa.`name` As `su_name`, pa.role As `su_role`, pa.company As `su_company`' +
-                        '  FROM ?? As t' +
+                        '  FROM (SELECT * FROM ?? WHERE `user_id` = ? OR `id` in (SELECT `tid` FROM ?? WHERE `aid` = ? GROUP BY `tid`)) As t' +
                         '  LEFT JOIN ?? As s On t.`id` = s.`tid`' +
                         '  LEFT JOIN ?? As sa ON s.`id` = sa.`sid`' +
                         '  LEFT JOIN ?? As pa ON sa.`aid` = pa.`id`' +
-                        '  WHERE sa.`aid` <> ? and sa.`end_time` > ? and t.`project_id` = ?' +
-                        '  GROUP By t.`id`' +
-                        '  ORDER By sa.`end_time`';
-            const sqlParam = [this.ctx.service.tender.tableName, this.ctx.service.stage.tableName, this.tableName,
-                this.ctx.service.projectAccount.tableName, uid, time, pid];
+                        '  WHERE sa.`end_time` > ? and t.`project_id` = ?' +
+                        '  ORDER By sa.`end_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`tid`' +
+                        '  ORDER By new_t.`end_time`';
+            const sqlParam = [this.ctx.service.tender.tableName, uid, this.tableName, uid, this.ctx.service.stage.tableName, this.tableName,
+                this.ctx.service.projectAccount.tableName, time, pid];
             return await this.db.query(sql, sqlParam);
         }