Selaa lähdekoodia

不显示作废修订

MaiXinRong 2 vuotta sitten
vanhempi
commit
ce27af781b

+ 15 - 2
app/controller/revise_controller.js

@@ -91,8 +91,11 @@ module.exports = app => {
         async index(ctx) {
             try {
                 // 分页相关
-                const count = await ctx.service.ledgerRevise.count({ tid: ctx.tender.id });
-                const ledgerRevise = await ctx.service.ledgerRevise.getReviseList(ctx.tender.id);
+                const user = await this.ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
+                const condition = { tid: ctx.tender.id };
+                if (!user.show_revise_invalid) condition.valid = 1;
+                const count = await ctx.service.ledgerRevise.count(condition);
+                const ledgerRevise = await ctx.service.ledgerRevise.getReviseList(ctx.tender.id, user.show_revise_invalid);
                 if (ledgerRevise.length > 0) {
                     const revise = ledgerRevise[0];
                     if (ctx.page === 1) {
@@ -131,6 +134,7 @@ module.exports = app => {
                     auditConst2: JSON.stringify(audit.revise),
                     stdBills,
                     stdChapters,
+                    show_invalid: user.show_revise_invalid,
                 };
                 await this.layout('revise/index.ejs', renderData, 'revise/modal.ejs');
             } catch (err) {
@@ -139,6 +143,15 @@ module.exports = app => {
             }
         }
 
+        async showInvalid(ctx) {
+            try {
+                await ctx.service.projectAccount.defaultUpdate({ id: ctx.session.sessionUser.accountId, show_revise_invalid: ctx.query.show });
+            } catch (err) {
+                this.log(err);
+            }
+            ctx.redirect(ctx.request.header.referer);
+        }
+
         /**
          * 修订审批流程(Get)
          * @param ctx

+ 1 - 0
app/router.js

@@ -239,6 +239,7 @@ module.exports = app => {
     app.post('/tender/:id/revise/add', sessionAuth, tenderCheck, uncheckTenderCheck, 'reviseController.add');
     app.post('/tender/:id/revise/cancel', sessionAuth, tenderCheck, uncheckTenderCheck, 'reviseController.cancel');
     app.post('/tender/:id/revise/save', sessionAuth, tenderCheck, uncheckTenderCheck, 'reviseController.save');
+    app.post('/setting/revise/show-invalid', sessionAuth, 'reviseController.showInvalid');
 
     // 台账修订页面
     app.get('/tender/:id/revise/:rid/info', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, reviseAuditCheck, 'reviseController.info');

+ 2 - 2
app/service/ledger_revise.js

@@ -37,12 +37,12 @@ module.exports = app => {
          * @param {Number}tid - 标段id
          * @returns {Promise<*>} - ledger_change下所有数据,并关联 project_account(读取提交人名称、单位、公司)
          */
-        async getReviseList (tid) {
+        async getReviseList (tid, show_revise_invalid) {
             const sql = 'SELECT lc.id, lc.tid, lc.corder, lc.in_time, lc.uid, lc.begin_time, lc.end_time, lc.times, lc.status, lc.valid, lc.content, lc.pre_his_id, lc.his_id,' +
                 '    pa.name As user_name, pa.role As user_role, pa.company As user_company' +
                 '  FROM ' + this.tableName + ' As lc' +
                 '  INNER JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa ON lc.uid = pa.id' +
-                '  WHERE lc.tid = ?' +
+                '  WHERE lc.tid = ?' + (show_revise_invalid ? '' : ' AND lc.valid = 1') +
                 '  ORDER BY lc.in_time DESC' +
                 '  LIMIT ?, ?';
             const Len = this.app.config.pageSize;

+ 11 - 0
app/view/revise/index.ejs

@@ -12,6 +12,17 @@
                         </div>
                     </div>
                 </div>
+                <div class="d-inline-block ml-2">
+                    <div class="input-group input-group-sm">
+                        <form action="/setting/revise/show-invalid?show=<%- (show_invalid ? 0 : 1) %>" method="post" onchange="submit();">
+                        <div class="form-group form-check">
+                            <input type="checkbox" class="form-check-input group-checkbox" id="show-revise-invalid" <%- (show_invalid ? '' : 'checked')%>>
+                            <label class="form-check-label" for="show-revise-invalid">不显示作废修订</label>
+                        </div>
+                            <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>">
+                        </form>
+                    </div>
+                </div>
             </div>
             <div class="ml-auto">
                 <% if (addVisible) { %>

+ 2 - 0
sql/update.sql

@@ -5,6 +5,8 @@ where userId='Administrator';
 ALTER TABLE `zh_project_account`
 ADD COLUMN `self_category_level`  varchar(255) NOT NULL DEFAULT '' AFTER `invalid_time`;
 
+ALTER TABLE `zh_project_account`
+ADD COLUMN `show_revise_invalid`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否显示,台账修订作废' AFTER `self_category_level`;
 
 
 -- 很重要!!!!