浏览代码

1. 界面调整
2. 变更清单排序相关

MaiXinRong 8 月之前
父节点
当前提交
5a1f041947

+ 1 - 0
app/controller/change_controller.js

@@ -1564,6 +1564,7 @@ module.exports = app => {
                 switch (data.type) {
                     case 'gather':
                         responseData.data = await ctx.service.changeAuditList.gatherBgBills(ctx.tender.id);
+                        responseData.data.sort((a, b) => { return ctx.helper.compareCode(a.code, b.code) });
                         break;
                     default:
                         throw '查询的数据不存在';

+ 126 - 2
app/controller/pay_controller.js

@@ -1,9 +1,133 @@
 'use strict';
 
 /**
- *
+ * 合同支付
  *
  * @author Mai
  * @date
  * @version
- */
+ */
+
+module.exports = app => {
+
+    class PayController extends app.BaseController {
+        /**
+         * 构造函数
+         *
+         * @param {Object} ctx - egg全局变量
+         * @return {void}
+         */
+        constructor(ctx) {
+            super(ctx);
+        }
+
+        async index(ctx) {
+            try {
+                const pays = await this.ctx.service.pay.getAllDataByCondition({ where: { tid: ctx.tender.id } });
+                const renderData = {
+                    jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.pay.list)
+                };
+                await this.layout('pay/index.ejs', renderData);
+            } catch (err) {
+                ctx.helper.log(err);
+            }
+        }
+
+        async uploadFile(ctx) {
+            let stream;
+            try {
+                const parts = ctx.multipart({ autoFields: true });
+                let index = 0;
+                const create_time = Date.parse(new Date()) / 1000;
+                let stream = await parts();
+                const bonus = await ctx.service.stageBonus.getStageDataById(parts.field.bonus_id);
+                //if (!bonus || bonus.sid !== ctx.stage.id) throw '该奖罚金,当前不允许上传附件';
+                while (stream !== undefined) {
+                    if (!stream.filename) {
+                        throw '未发现上传文件!';
+                    }
+
+                    const fileInfo = path.parse(stream.filename);
+                    const dirName = 'app/public/upload/extra/' + moment().format('YYYYMMDD');
+                    const fileName = create_time + '_' + index + fileInfo.ext;
+
+                    // 保存文件
+                    await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
+                    await sendToWormhole(stream);
+
+                    // 插入到stage_pay对应的附件列表中
+                    bonus.proof_file.push({
+                        filename: fileInfo.name,
+                        fileext: fileInfo.ext,
+                        filesize: Array.isArray(parts.field.size) ? parts.field.size[index] : parts.field.size,
+                        filepath: path.join(dirName, fileName),
+                        uid: ctx.session.sessionUser.accountId,
+                        in_time: moment(create_time * 1000).format('YYYY-MM-DD'),
+                        renew: bonus.sid === ctx.stage.id ? ctx.stage.status === auditConst.status.checked : true,
+                    });
+                    ++index;
+                    if (Array.isArray(parts.field.size) && index < parts.field.size.length) {
+                        stream = await parts();
+                    } else {
+                        stream = undefined;
+                    }
+                }
+                const result = await ctx.service.stageBonus.updateDatas({
+                    update: [
+                        { id: bonus.id, proof_file: bonus.proof_file },
+                    ]
+                });
+                for (const pf of bonus.proof_file) {
+                    pf.username = (await ctx.service.projectAccount.getAccountInfoById(pf.uid)).name;
+                    if (ctx.helper.canPreview(pf.fileext)){
+                        pf.viewpath = pf.filepath.substr(3, pf.filepath.length - 3);
+                    }
+                    delete pf.filepath;
+                }
+                ctx.body = {err: 0, msg: '', data: bonus.proof_file};
+            } catch (error) {
+                ctx.helper.log(error);
+                // 失败需要消耗掉stream 以防卡死
+                if (stream) {
+                    await sendToWormhole(stream);
+                }
+                ctx.body = this.ajaxErrorBody(error, '上传附件失败,请重试');
+            }
+        }
+
+        async deleteFile(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+
+                const bonus = await ctx.service.stageBonus.getStageDataById(data.b_id);
+                if (!bonus || !bonus.proof_file || !bonus.proof_file[data.index]) throw '删除的文件不存在';
+
+                const fileInfo = bonus.proof_file[data.index];
+                if (fileInfo.uid !== ctx.session.sessionUser.accountId) throw '您无权删除该文件';
+
+                const deleteFilePermission = PermissionCheck.delFile(this.ctx.session.sessionUser.permission);
+                if (ctx.stage.status === auditConst.status.checked && !fileInfo.renew && !deleteFilePermission) throw '不可删除该文件';
+
+                // 先删除文件
+                await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
+                // 再删除数据库
+                bonus.proof_file.splice(data.index, 1);
+                const result = await ctx.service.stageBonus.updateDatas({
+                    update: [
+                        { id: bonus.id, proof_file: bonus.proof_file },
+                    ]
+                });
+                for (const pf of bonus.proof_file) {
+                    delete pf.filepath;
+                    pf.username = (await ctx.service.projectAccount.getAccountInfoById(pf.uid)).name;
+                }
+                ctx.body = {err: 0, msg: '', data: bonus.proof_file};
+            } catch (err) {
+                this.log(err);
+                this.ctx.ajaxErrorBody(err, '删除文件失败');
+            }
+        }
+    }
+
+    return PayController;
+};

+ 4 - 0
app/controller/revise_controller.js

@@ -922,6 +922,10 @@ module.exports = app => {
                 if (!c) return;
                 c.bills.push(cb);
             });
+            const helper = ctx.helper;
+            change.forEach(x => {
+                x.bills.sort((a, b) => { return helper.compareCode(a.code, b.code)});
+            });
             return change;
         }
 

+ 6 - 0
app/controller/stage_controller.js

@@ -349,6 +349,10 @@ module.exports = app => {
                 if (!c) return;
                 c.bills.push(cb);
             });
+            const helper = ctx.helper;
+            change.forEach(x => {
+                x.bills.sort((a, b) => { return helper.compareCode(a.code, b.code)});
+            });
             return change;
         }
 
@@ -1188,8 +1192,10 @@ module.exports = app => {
          */
         async _getChangeDetailData(tid, sid, cid, isImport) {
             const data = {};
+            const helper = this.ctx.helper;
             data.attachments = await this.ctx.service.changeAtt.getChangeAttachment(cid);
             data.bills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid } });
+            data.bills.sort((a, b) => { return helper.compareCode(a.code, b.code)});
             if (isImport) {
                 data.endUsedBills = await this.ctx.service.stageImportChange.getChangeEndUsedData(tid, cid);
                 data.curUsedBills = await this.ctx.service.stageImportChange.getChangeUsedData(sid, cid);

+ 4 - 0
app/public/css/main.css

@@ -833,6 +833,10 @@ input.nospin[type="number"]{-moz-appearance:textfield;}
 .datepickers-container {
   z-index: 9999
 }
+.modal-height-600{
+    height:600px;
+    overflow: hidden
+}
 .modal-height-500{
   height:450px;
   overflow: hidden

+ 0 - 1
app/service/ledger.js

@@ -34,7 +34,6 @@ const SumLoad = require('../lib/sum_load');
 module.exports = app => {
 
     class Ledger extends app.BaseBillsService {
-
         /**
          * 构造函数
          *

+ 2 - 0
app/service/report_memory.js

@@ -1507,9 +1507,11 @@ module.exports = app => {
 
         async getChangeInfoBills(tid, sid) {
             if (!this.changeInfo) await this.getChangeInfo(tid, sid);
+            const helper = this.ctx.helper;
             this.changeInfoBills = [];
             for (const c of this.changeInfo) {
                 const cb = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: c.cid } });
+                cb.sort((a, b) => { return helper.compareCode(a.code, b.code)});
                 const cbu = await this.ctx.service.stageChange.getUsedData(tid, c.cid);
                 const curUsedBills = await this.ctx.service.stageChange.getStageUsedData(sid, c.cid);
                 for (const b of cb) {

+ 2 - 2
app/view/shares/select_rela_tender_modal.ejs

@@ -9,11 +9,11 @@
                 <div class="row">
                     <div class="col-7">
                         <h5>可选标段 </h5>
-                        <div class="modal-height-300" id="sr-source-spread"></div>
+                        <div class="modal-height-600" id="sr-source-spread"></div>
                     </div>
                     <div class="col-5">
                         <h5>已选标段 </h5>
-                        <div class="modal-height-300" id="sr-result-spread"></div>
+                        <div class="modal-height-600" id="sr-result-spread"></div>
                     </div>
                 </div>
             </div>