فهرست منبع

feat: 材料调差-附件权限变更

lanjianrong 5 سال پیش
والد
کامیت
bac228a5d0
5فایلهای تغییر یافته به همراه47 افزوده شده و 5 حذف شده
  1. 34 2
      app/controller/stage_controller.js
  2. 8 1
      app/public/js/stage.js
  3. 2 2
      app/service/stage_att.js
  4. 1 0
      app/view/stage/index.ejs
  5. 2 0
      sql/update.sql

+ 34 - 2
app/controller/stage_controller.js

@@ -37,6 +37,7 @@ module.exports = app => {
             ctx.showProject = true;
             ctx.showTender = true;
             ctx.showTitle = true;
+            ctx.reUploadPermission = false;
         }
 
         /**
@@ -1197,6 +1198,32 @@ module.exports = app => {
         }
 
         /**
+         * 检测当前期当用用户是否在审核列表中,如果是的话运行再次上传附件
+         * @param {Object} ctx 上下文
+         */
+        _checkStageCanModifyRe(ctx) {
+            // 检查登录用户,是否可操作
+            if (ctx.stage.readOnly) {
+                if (ctx.stage.status === auditConst.status.checked) {
+                    // 当前期状态为完成,且提交人是审核列表中的则可再次上传
+                    console.log('当前期审核通过!');
+                    if (ctx.stage.auditors.findIndex(auditor => auditor.aid === ctx.session.sessionUser.accountId) !== -1) {
+                        console.log('当前用户拥有上传权限!');
+                        // 再次上传的图片要给个标识,方便给前端进行编辑操作
+                        ctx.reUploadPermission = true;
+                        return;
+                    }
+                    throw '该计量期当前您无权操作';
+
+                } else {
+                    throw '该计量期当前您无权操作';
+                }
+            }
+            if (ctx.stage.revising) {
+                throw '台账修订中,请勿修改提交期数据';
+            }
+        }
+        /**
          * 上传附件
          * @param {Object} ctx - egg全局变量
          * @return {void}
@@ -1209,7 +1236,7 @@ module.exports = app => {
             };
             let stream;
             try {
-                this._checkStageCanModify(ctx);
+                this._checkStageCanModifyRe(ctx);
 
                 const parts = ctx.multipart({ autoFields: true });
                 const files = [];
@@ -1245,6 +1272,10 @@ module.exports = app => {
                         filesize: Array.isArray(parts.field.size) ? parts.field.size[index] : parts.field.size,
                         filepath: path.join(dirName, fileName),
                     };
+                    if (ctx.reUploadPermission) {
+                        console.log('111111111111111');
+                        fileData.re_upload = 1;
+                    }
                     const result = await ctx.service.stageAtt.save(parts.field, fileData, ctx.session.sessionUser.accountId);
                     if (!result) {
                         throw '导入数据库保存失败';
@@ -1254,6 +1285,7 @@ module.exports = app => {
                     files.length !== 0 ? files.unshift(attData) : files.push(attData);
                     ++index;
                 }
+                console.log('files:', files);
                 responseData.data = files;
             } catch (err) {
                 this.log(err);
@@ -1344,7 +1376,7 @@ module.exports = app => {
                 data: '',
             };
             try {
-                this._checkStageCanModify(ctx);
+                this._checkStageCanModifyRe(ctx);
 
                 const data = JSON.parse(ctx.request.body.data);
                 const fileInfo = await ctx.service.stageAtt.getDataById(data.id);

+ 8 - 1
app/public/js/stage.js

@@ -3052,7 +3052,14 @@ $(document).ready(() => {
             $('#show-att tr').eq(4).children('td').text(att.remark);
             if (parseInt(userID) === att.uid) {
                 $('#btn-att').show();
-                $('#btn-att a').eq(3).show();
+                if (stage.status === auditConst.status.checked) {
+                    if (parseInt(att.re_upload) === 1) {
+                        $('#btn-att a').eq(3).show();
+                    } else {
+                        $('#btn-att a').eq(3).hide();
+                    }
+                }
+                // $('#btn-att a').eq(3).show();
                 $('#btn-att a').eq(2).hide();
                 $('#btn-att a').eq(4).hide();
                 $('#btn-att a').eq(5).hide();

+ 2 - 2
app/service/stage_att.js

@@ -62,7 +62,7 @@ module.exports = app => {
          * @return {void}
          */
         async getDataByTenderIdAndStageId(tid, sid) {
-            const sql = 'SELECT att.id, att.lid, att.uid, att.filename, att.fileext, att.filesize, att.remark, att.in_time,' +
+            const sql = 'SELECT att.id, att.lid, att.uid, att.filename, att.fileext, att.filesize, att.re_upload, att.remark, att.in_time,' +
                 ' pa.name as `username`, leg.name as `lname`, leg.code as `code`, leg.ledger_id as `ledger_id`, leg.b_code as `b_code`' +
                 ' FROM ?? AS att,?? AS pa,?? AS leg' +
                 ' WHERE leg.id = att.lid AND pa.id = att.uid AND att.tid = ? AND att.sid = ? ORDER BY att.id DESC';
@@ -77,7 +77,7 @@ module.exports = app => {
          * @return {void}
          */
         async getDataByFid(id) {
-            const sql = 'SELECT att.id, att.lid, att.uid, att.filename, att.fileext, att.filesize, att.remark, att.in_time,' +
+            const sql = 'SELECT att.id, att.lid, att.uid, att.filename, att.re_upload, att.fileext, att.filesize, att.remark, att.in_time,' +
                 ' pa.name as `username`, leg.name as `lname`, leg.code as `code`, leg.ledger_id as `ledger_id`,leg.b_code as `b_code`' +
                 ' FROM ?? AS att,?? AS pa,?? AS leg' +
                 ' WHERE leg.id = att.lid AND pa.id = att.uid AND att.id = ? ORDER BY att.in_time DESC';

+ 1 - 0
app/view/stage/index.ejs

@@ -585,6 +585,7 @@
     const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
     let attData = JSON.parse('<%- JSON.stringify(attData) %>');
     const ckColSetting = 'stage-col-visible-1.0.3-<%- tender.id %>';
+    const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
 </script>
 <% if (ctx.stage.status === auditConst.status.uncheck && ctx.session.sessionUser.accountId === ctx.stage.user_id) {%>
 <script>

+ 2 - 0
sql/update.sql

@@ -90,3 +90,5 @@ ADD COLUMN `real_qty`  decimal(24,8) NULL DEFAULT 0 COMMENT '实际使用数量'
 ALTER TABLE `calculation`.`zh_project`
 ADD COLUMN `page_path` INT NOT NULL DEFAULT 0 AFTER `page_show`;
 
+ALTER TABLE `calculation`.`zh_stage_attachment`
+ADD COLUMN `re_upload` INT NOT NULL DEFAULT 0 COMMENT '是否为审核通过后再次上传的文件,0为否' AFTER `in_time`;