Browse Source

1. 期,标题显示调整
2. 合同支付,各列输入,右键菜单可用,调整
3. 合同支付,记录所有参与人编辑的名称

MaiXinRong 5 years ago
parent
commit
a2992c26f0
4 changed files with 52 additions and 28 deletions
  1. 34 12
      app/public/js/stage_pay.js
  2. 1 1
      app/service/pay.js
  3. 16 14
      app/service/stage_pay.js
  4. 1 1
      app/view/stage/stage_sub_menu.ejs

+ 34 - 12
app/public/js/stage_pay.js

@@ -93,22 +93,36 @@ $(document).ready(() => {
                 return data.ptype !== 1;
             },
             isOld: function (data) {
-                return (data.csorder < getStageId()) && (getStageId() > 1);
+                if (data.csorder === 0) {
+                    return stage.order > 1 || stage.times > 1 || stage.curOrder > 0;
+                } else {
+                    return stage.order > data.csorder || stage.times > data.cstimes || stage.curOrder > data.csaorder;
+                }
+            },
+            isYB: function (data) {
+                return (stage.curOrder > 0);
+            },
+            isStarted: function (data) {
+                return (data.tp === data.end_tp) && (!data.pre_tp || data.pre_tp === 0);
             },
             name: function (data) {
-                return payCol.readOnly.isSpecial(data) || payCol.readOnly.isOld(data);
+                return payCol.readOnly.isSpecial(data); // 所有人,轮到自己时,均可修改
             },
             minus: function (data) {
-                return readOnly || (payCol.readOnly.isSpecial(data) || payCol.readOnly.isOld(data));
+                if (payCol.readOnly.isOld(data)) { // 上报或审批后,仅原报,在未开始计量前,可修改
+                    return payCol.readOnly.isSpecial(data) || payCol.readOnly.isStarted(data) || !payCol.readOnly.isYB(data);
+                } else { // 新增时,新增人可修改
+                    return payCol.readOnly.isSpecial(data);
+                }
             },
             tp: function (data) {
-                return data.ptype === 2 || data.ptype === 4 || (payCol.readOnly.isOld(data) && data.expr);
+                return data.ptype === 2 || data.ptype === 4; // 仅本期完成计量、本期应付,不可修改
             },
             sprice: function (data) {
-                return payCol.readOnly.isSpecial(data) || payCol.readOnly.isOld(data);
+                return payCol.readOnly.minus(data); // 同扣款项
             },
             rprice: function (data) {
-                return payCol.readOnly.isSpecial(data) || payCol.readOnly.isOld(data);
+                return payCol.readOnly.minus(data); // 同扣款项
             },
         }
     };
@@ -257,13 +271,16 @@ $(document).ready(() => {
                 }
                 // 获取更新信息
                 const data = {
-                    type: col.field === 'tp' ? 'stage' : 'info',
+                    type: (col.field === 'tp' || col.field === 'name') ? 'stage' : 'info',
                     updateData: {}
                 };
                 // 获取更新数据
                 if (col.field === 'tp') {
                     data.updateData.pid = select.pid;
                     paySpreadObj._checkExpr(validText, data.updateData, 'tp', 'expr');
+                } else if (col.field === 'name') {
+                    data.updateData.pid = select.pid;
+                    data.updateData.name = validText;
                 } else {
                     data.updateData.id = select.pid;
                     if (validText) {
@@ -585,7 +602,8 @@ $(document).ready(() => {
                     return select.ptype === 1 && select.pause;
                 },
                 disabled: function (key, opt) {
-                    return readOnly;
+                    const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+                    return readOnly || payCol.readOnly.minus(select);
                 }
             },
             'stop': {
@@ -611,7 +629,8 @@ $(document).ready(() => {
                     return select.ptype === 1 && !select.pause;
                 },
                 disabled: function (key, opt) {
-                    return readOnly;
+                    const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+                    return readOnly || payCol.readOnly.minus(select);
                 }
             },
             'setDeadline': {
@@ -632,7 +651,8 @@ $(document).ready(() => {
                     }
                 },
                 disabled: function (key, opt) {
-                    return readOnly;
+                    const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+                    return readOnly || payCol.readOnly.minus(select);
                 }
             },
             'dropYF': {
@@ -659,7 +679,8 @@ $(document).ready(() => {
                     });
                 },
                 disabled: function (key, opt) {
-                    return readOnly;
+                    const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+                    return readOnly || payCol.readOnly.minus(select);
                 }
             },
             'belongYF': {
@@ -686,7 +707,8 @@ $(document).ready(() => {
                     });
                 },
                 disabled: function (key, opt) {
-                    return readOnly;
+                    const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+                    return readOnly || payCol.readOnly.minus(select);
                 }
             }
         }

+ 1 - 1
app/service/pay.js

@@ -70,7 +70,7 @@ module.exports = app => {
                 csid: this.ctx.stage.id,
                 cstimes: this.ctx.stage.times,
                 csorder: this.ctx.stage.order,
-                csaorder: this.ctx.stage.curAuditor ? this.ctx.stage.curAuditor : 0,
+                csaorder: this.ctx.stage.curOrder,
                 uid: this.ctx.session.sessionUser.accountId,
                 minus: false,
                 ptype: payConst.payType.normal,

+ 16 - 14
app/service/stage_pay.js

@@ -35,7 +35,7 @@ module.exports = app => {
          */
         async getAuditorStagePay(pid, sid, times, order) {
             const pidSql = pid instanceof Array ? ' And SP.`pid` in (' + pid.join(',') + ')' : 'And SP.`pid` = ' + pid;
-            const sql = 'SELECT SP.*, P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
+            const sql = 'SELECT SP.*, P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
                 '  FROM ?? As SP, ?? As P ' +
                 '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND P.`valid`' + pidSql +
                 '  ORDER BY P.`order`';
@@ -57,7 +57,7 @@ module.exports = app => {
          */
         async getAuditorStageData(sid, times, order) {
             const sql = 'SELECT SP.*,' +
-                '    P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
+                '    P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
                 '  FROM ?? As SP, ?? As P ' +
                 '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND P.`valid`' +
                 '  ORDER BY P.`order`';
@@ -88,7 +88,7 @@ module.exports = app => {
             for (const p of pays) {
                 stagePays.push({
                     tid: p.tid, sid: stage.id, pid: p.id,
-                    stimes: stage.times, sorder: 0, expr: p.expr,
+                    stimes: stage.times, sorder: 0, expr: p.expr, name: p.name,
                 });
             }
             // 获取截止上期数据
@@ -100,6 +100,7 @@ module.exports = app => {
                 const prePays = await this.getStageLastestPays(preStage.id);
                 for (const pp of prePays) {
                     const sp = this._.find(stagePays, {pid: pp.pid});
+                    sp.name = pp.name;
                     sp.expr = pp.expr;
                     sp.pre_tp= pp.end_tp;
                     sp.pause = pp.pause;
@@ -135,7 +136,7 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getStageLastestPays(sid) {
-            const sql = 'SELECT SP.*, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
+            const sql = 'SELECT SP.*, P.`order`, P.uid, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
                 '  FROM ' + this.tableName + ' As SP' +
                 '  INNER JOIN ' + this.ctx.service.pay.tableName + ' As P ON SP.pid = P.id' +
                 '  INNER JOIN ( ' +
@@ -184,6 +185,7 @@ module.exports = app => {
                 for (const data of datas) {
                     const stagePay = await this.getStagePay(this.ctx.stage, data.pid);
                     const updateData = { id: stagePay.id };
+                    if (data.name !== undefined) { updateData.name = data.name }
                     if (data.expr !== undefined) { updateData.expr = data.expr }
                     if (data.tp !== undefined) { updateData.tp = data.tp }
                     if (data.pause !== undefined) { updateData.pause = data.pause }
@@ -192,14 +194,14 @@ module.exports = app => {
                         throw '保存数据失败';
                     }
                     // 缓存至pay
-                    if (data.expr !== undefined) {
-                        const pr = await transaction.update(this.ctx.service.pay.tableName, {
-                            id: data.pid, expr: data.expr
-                        });
-                        if (pr.affectedRows !== 1) {
-                            throw '保存数据失败';
-                        }
-                    }
+                    // if (data.expr !== undefined) {
+                    //     const pr = await transaction.update(this.ctx.service.pay.tableName, {
+                    //         id: data.pid, expr: data.expr
+                    //     });
+                    //     if (pr.affectedRows !== 1) {
+                    //         throw '保存数据失败';
+                    //     }
+                    // }
                 }
                 await transaction.commit();
             } catch(err) {
@@ -243,8 +245,8 @@ module.exports = app => {
             if (!stage || !transaction || !times || order === undefined) {
                 throw '数据错误';
             }
-            const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `tp`, `expr`, `pause`, `attachment`, `pre_tp`) ' +
-                        '  SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.`tp`, SP.`expr`, SP.`pause`, SP.`attachment`, SP.`pre_tp` ' +
+            const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `name`, `tp`, `expr`, `pause`, `attachment`, `pre_tp`) ' +
+                        '  SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.name, SP.`tp`, SP.`expr`, SP.`pause`, SP.`attachment`, SP.`pre_tp` ' +
                         '  FROM ?? As SP, ?? As P ' +
                         '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? And SP.`pid` = P.`id` And P.`valid`';
             const sqlParam = [this.tableName, times, order, this.tableName, this.ctx.service.pay.tableName,

+ 1 - 1
app/view/stage/stage_sub_menu.ejs

@@ -1,7 +1,7 @@
 <div class="panel-sidebar">
     <div class="panel-title">
         <div class="title-bar">
-            <h2 class="text-truncate" style="width:199px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" data-toggle="tooltip" data-placement="right" title=""  data-original-title="第<%- ctx.stage.order%>期 - <%- tender.name %>">第<%- ctx.stage.order%>期 - <%- tender.name %></h2>
+            <h2 class="text-truncate" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" data-toggle="tooltip" data-placement="right" title=""  data-original-title="第<%- ctx.stage.order%>期 - <%- tender.name %>">第<%- ctx.stage.order%>期 - <%- tender.name %></h2>
         </div>
     </div>
     <div class="scrollbar-auto">