Просмотр исходного кода

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

MaiXinRong 5 лет назад
Родитель
Сommit
d13903fb03

+ 3 - 3
app/const/setting.js

@@ -18,9 +18,9 @@ cTypeStr[cType.dropDown] = '下拉菜单';
 
 // 显示设置-路由列表
 const listPath = [
-    { is_default: 1, label_name: '标段列表', path: '/list' }, // 标段列表
-    { is_default: 0, label_name: '金额概况', path: '/list/info' }, // 金额概况
-    { is_default: 0, label_name: '计量进度', path: '/list/progress' }, // 计量进度
+    { label_name: '计量进度', path: '/list/progress', is_default: false }, // 计量进度
+    { label_name: '标段列表', path: '/list', is_default: false }, // 标段列表
+    { label_name: '金额概况', path: '/list/info', is_default: false }, // 金额概况
 ];
 
 

+ 1 - 1
app/controller/setting_controller.js

@@ -604,7 +604,7 @@ module.exports = app => {
                 if (!projectData) {
                     throw '没有对应的项目数据';
                 }
-                const showList = await ctx.service.settingShow.getList(projectId);
+                const showList = await ctx.service.settingShow.getList(projectData.page_path);
                 const renderData = { projectData, showList };
                 await this.layout('setting/show.ejs', renderData);
             } catch (error) {

+ 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);

+ 1 - 0
app/middleware/session_auth.js

@@ -45,6 +45,7 @@ module.exports = options => {
             // 对sub_menu项目默认打开页进行配置
             const path = yield this.service.settingShow.getDefaultPath(this.session.sessionProject.id);
             path && (this.curListUrl = path);
+
         } catch (error) {
             console.log(error);
             if (this.helper.isAjax(this.request)) {

+ 3 - 3
app/public/js/setting.js

@@ -176,9 +176,9 @@ $(document).ready(() => {
         const data = {id: attid};
         postData('/setting/show/update', data, function (result) {
            let html = ''
-            result.forEach(item => {
+            result.forEach((item, idx) => {
                 html += `<li class="list-group-item">${item.label_name}`
-                html+= item.is_default ? `<span class="pull-right">默认</span></li>`:`<a href="javascript:void(0)" id="set-default" class="btn btn-primary btn-sm pull-right" data-attid="${item.id}">设为默认</a></li>`
+                html+= item.is_default ? `<span class="pull-right">默认</span></li>`:`<a href="javascript:void(0)" id="set-default" class="btn btn-primary btn-sm pull-right" data-attid="${idx}">设为默认</a></li>`
             })
             // <li class="list-group-item">
             // 标段列表<a href="#" class="btn btn-primary btn-sm pull-right">设为默认</a>
@@ -189,7 +189,7 @@ $(document).ready(() => {
             // </li>
             $('.list-group').empty()
             $('.list-group').append(html)
-            const item = result.find(i => i.id === attid)
+            const item = result.find((i, idx) => idx=== attid)
             $('#nav_tender').attr('href', item.path)
         });
     });

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

@@ -3054,7 +3054,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();

+ 17 - 32
app/service/setting_show.js

@@ -23,39 +23,35 @@ module.exports = app => {
          */
         constructor(ctx) {
             super(ctx);
-            this.tableName = 'setting_show';
+            this.tableName = 'project';
         }
 
         /**
          * 获取表的全部记录
-         * @param {Number} pid 项目id
+         * @param {Number | Null} i listPath对应下标
          * @return {Array} 查询结果集
          */
-        async getList(pid) {
-            const record = await this.getAllDataByCondition({ pid });
-            return record.map(item => {
-                // 拼接路由path
-                const { sid } = item;
-                item.path = listPath[sid].path;
+        async getList(i = 0) {
+            return listPath.map((item, idx) => {
+                if (i === idx) {
+                    return { ...item, is_default: true }
+                }
                 return item;
             });
         }
 
         /**
          * 设置默认显示字段
-         * @param {Number} id 标签id
+         * @param {Number} id 标签索引
          * @param {Number} pid 项目id
          * @return {Promise<void>} 查询结果集
          */
         async setDefaultLabel(id, pid) {
-            const record = await this.getDataByCondition({ pid, is_default: 1 });
-            if (!record) throw '该标签不存在';
-            await this.update({ is_default: 0 }, { id: record.id });
-            await this.update({ is_default: 1 }, { id });
-            const records = await this.getAllDataByCondition({ pid });
-            return records.map(item => {
-                const { sid } = item;
-                item.path = listPath[sid].path;
+            await this.update({ page_path: id }, { id: pid });
+            return listPath.map((item, idx) => {
+                if (id === idx) {
+                    return { ...item, is_default: true}
+                }
                 return item;
             });
         }
@@ -66,21 +62,10 @@ module.exports = app => {
          * @return {String} path 路由名
          */
         async getDefaultPath(pid) {
-            let record = await this.getAllDataByCondition({ pid });
-            if (record && !record.length) {
-                console.log('显示列表为空,正在进行初始化数据.......');
-                // 记录为空,说明表没有进行初始化
-                listPath.forEach(async (list, idx) => {
-                    await this.db.insert(this.tableName, { pid, is_default: list.is_default, sid: idx, label_name: list.label_name });
-                });
-                // 获取当前项目下默认的记录
-                record = await this.getAllDataByCondition({ pid, is_default: 1 });
-            }
-            // const record = await this.getDataByCondition({ is_default: 1, pid });
-            if (record && record.length) {
-                const { sid } = record[0];
-                return listPath[sid].path;
-            }
+            const record = await this.getDataByCondition({ id: pid });
+            const { page_path = 0 } = record;
+            const list = listPath.find((item, idx) => idx === page_path);
+            return list.path;
         }
     }
     return settingShow;

+ 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';

+ 4 - 4
app/service/stage_jgcl.js

@@ -214,9 +214,9 @@ module.exports = app => {
                 throw '标段数据有误';
             }
             const preDatas = await this.getAllDataByCondition({
-                columns: ['uuid', 'name', 'unit', 'unit_price', 'source', 'bills_code', 'check_code', 'memo', 'add_uid', 'add_sid'],
-                where: { sid: preStage.id }
-            });;
+                columns: ['uuid', 'name', 'unit', 'unit_price', 'source', 'bills_code', 'check_code', 'memo', 'add_uid', 'add_sid', 'order'],
+                where: { sid: preStage.id },
+            });
             if (preDatas.length > 0) {
                 for (const pd of preDatas) {
                     pd.pre_used = pd.pre_used || !this.ctx.helper.checkZero(pd.arrive_qty) || !this.ctx.helper.checkZero(pd.deduct_qty);
@@ -231,4 +231,4 @@ module.exports = app => {
     }
 
     return StageJgcl;
-};
+};

+ 1 - 1
app/view/layout/menu.ejs

@@ -12,7 +12,7 @@
             <% for (const index in ctx.menuList) { %>
             <% if (ctx.menuList[index].display === undefined || !ctx.menuList[index].display) { continue } %>
             <li <% if(ctx.controllerName === index || (ctx.controllerName === 'list' && index === 'tender')) { %>class="active"<% } %>>
-                <a href="<%- (index === 'tender' && !ctx.app.config.is_debug ? ctx.curListUrl : ctx.menuList[index].url) %>" id="<%- 'nav_' + index%>" data-toggle="tooltip" data-placement="right" title="" data-original-title="<%- ctx.menuList[index].name %>">
+                <a href="<%- (index === 'tender' ? ctx.curListUrl : ctx.menuList[index].url) %>" id="<%- 'nav_' + index%>" data-toggle="tooltip" data-placement="right" title="" data-original-title="<%- ctx.menuList[index].name %>">
                     <i class="fa <%- ctx.menuList[index].icon %>"></i>
                     <% if (ctx.menuList[index].caption) { %>
                     <span><%- ctx.menuList[index].caption %></span>

+ 2 - 2
app/view/setting/show.ejs

@@ -14,11 +14,11 @@
                             <label>项目列表默认显示</label>
                             <div class="card w-50">
                                 <ul class="list-group list-group-flush">
-                                    <% showList.forEach(function(item) { %>
+                                    <% showList.forEach(function(item, idx) { %>
                                         <li class="list-group-item">
                                             <%= item.label_name %>
                                             <% if(!item.is_default) { %>
-                                                <a href="javascript:void(0)" id="set-default" class="btn btn-primary btn-sm pull-right" data-attid="<%- item.id %>">设为默认</a>
+                                                <a href="javascript:void(0)" id="set-default" class="btn btn-primary btn-sm pull-right" data-attid="<%- idx %>">设为默认</a>
                                             <% } else {%>
                                                 <span class="pull-right">默认</span>
                                             <% } %>

+ 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>

+ 5 - 10
sql/update.sql

@@ -84,16 +84,11 @@ ADD COLUMN `pre_sf_tp`  decimal(24,8) NULL DEFAULT NULL COMMENT '截止上期实
 ALTER TABLE `zh_stage_detail`
 ADD COLUMN `calc_img_remark` TEXT NULL DEFAULT NULL COMMENT '草图备注' AFTER `custom_define`;
 
-CREATE TABLE `zh_setting_show` (
-  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
-  `pid` int(11) NOT NULL COMMENT '项目id',
-  `is_default` int(11) NOT NULL DEFAULT '0' COMMENT '是否默认显示',
-  `sid` int(11) NOT NULL COMMENT '对应consts下listPath的下标',
-  `label_name` varchar(45) COLLATE utf8_unicode_ci NOT NULL COMMENT '标签名',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-
 ALTER TABLE `zh_pos`
 ADD COLUMN `real_qty`  decimal(24,8) NULL DEFAULT 0 COMMENT '实际使用数量' AFTER `qtcl_expr`;
 
+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`;