浏览代码

1. 查询可用变更令Bug
2. 调用变更令,已用提示

MaiXinRong 6 年之前
父节点
当前提交
2d3024fb50
共有 3 个文件被更改,包括 33 次插入22 次删除
  1. 5 2
      app/public/js/spreadjs_rela/spreadjs_zh.js
  2. 25 6
      app/public/js/stage.js
  3. 3 14
      app/service/change.js

+ 5 - 2
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -26,8 +26,10 @@ proto.dottedLine = function (x1, y1, x2, y2, interval = 4) {
         progress += interval;
     }
 };
+
 // 简写Spread常量
 const spreadNS = GC.Spread.Sheets;
+
 // SpreadJs常用方法
 const SpreadJsObj = {
     initSpreadSettingEvents: function (setting, events) {
@@ -1002,7 +1004,6 @@ const SpreadJsObj = {
          * @returns {ImageCellType}
          */
         getImageCellType: function () {
-            const indent = 10;
             const ImageCellType = function (){};
             ImageCellType.prototype = new spreadNS.CellTypes.Text();
             const proto = ImageCellType.prototype;
@@ -1019,7 +1020,9 @@ const SpreadJsObj = {
 
             };
             proto.paint = function (canvas, value, x, y, w, h, style, options) {
+                const col = options.sheet.zh_setting.cols[options.col];
                 const img = this.getImage(options.sheet, options.row, options.col);
+                const indent = col.indent ? col.indent : 10;
                 if (img) {
                     if (style.backColor) {
                         canvas.save();
@@ -1027,7 +1030,7 @@ const SpreadJsObj = {
                         canvas.fillRect(x, y, indent + img.width, h);
                         canvas.restore();
                     }
-                    canvas.drawImage(img, x + 10, y + (h - img.height) / 2);
+                    canvas.drawImage(img, x + indent, y + (h - img.height) / 2);
                     if (style.hAlign !== spreadNS.HorizontalAlign.left) {
                         style.hAlign = spreadNS.HorizontalAlign.left;
                     }

+ 25 - 6
app/public/js/stage.js

@@ -141,17 +141,25 @@ $(document).ready(() => {
             // 初始化 清单编号窗口 参数
             this.spreadSetting = {
                 cols: [
-                    {title: '已用', field: 'used', width: 45, formatter: '@', cellType: 'checkbox', readOnly: true, hAlign: 1,},
-                    {title: '变更令号', field: 'code', width: 100, formatter: '@', readOnly: true},
-                    {title: '名称', field: 'name', width: 120, formatter: '@', readOnly: true},
-                    {title: '总数量', field: 'amount', width: 60, formatter: '@', readOnly: true},
-                    {title: '可变更数量', field: 'vamount', width: 60, readOnly: true},
-                    {title: '本期计量', field: 'uamount', width: 60, formatter: '@'},
+                    {title: '已用', field: '', width: 45, formatter: '@', cellType: 'image', readOnly: true, hAlign: 1, indent: 14},
+                    {title: '变更令号', field: 'code', width: 100, formatter: '@', readOnly: true, hAlign: 0, },
+                    {title: '名称', field: 'name', width: 120, formatter: '@', readOnly: true, hAlign: 0,},
+                    {title: '总数量', field: 'b_amount', width: 60, formatter: '@', readOnly: true, hAlign: 2, },
+                    {title: '可变更数量', field: 'vamount', width: 60, readOnly: true, hAlign: 2, },
+                    {title: '本期计量', field: 'uamount', width: 60, formatter: '@', hAlign: 2, },
                 ],
                 emptyRows: 0,
                 headRows: 1,
                 headRowHeight: [40],
             };
+            this.spreadSetting.cols[0].img = function (data) {
+                //return $('#icon-ok')[0];
+                if (data.uamount && !checkZero(data.uamount)) {
+                    return $('#icon-ok')[0];
+                } else {
+                    return null;
+                }
+            };
             this.curChangeId = '';
             this.spread = SpreadJsObj.createNewSpread($('#change-spread')[0]);
             this.firstView = true;
@@ -168,6 +176,17 @@ $(document).ready(() => {
                 const change = SpreadJsObj.getSelectObject(info.sheet);
                 self._loadChangeDetail(change);
             });
+            // 填写本期计量
+            this.spread.bind(spreadNS.Events.EditEnded, function (e, info) {
+                if (info.sheet.zh_setting) {
+                    const col = info.sheet.zh_setting.cols[info.col];
+                    const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
+                    const node = sortData[info.row];
+                    node[col.field] = col.type === 'Number' ? parseFloat(info.editingText) : info.editingText;
+                    // 刷新已用提示
+                    info.sheet.repaint(info.sheet.getCellRect(info.row, 0));
+                }
+            });
             // 过滤可变更数量为0
             $('#customCheckDisabled').click(function () {
                 self._filterEmptyChange(!this.checked);

+ 3 - 14
app/service/change.js

@@ -680,7 +680,7 @@ module.exports = app => {
          * @param pos - 查询的部位
          * @returns {Promise<*>} - 可用的变更令列表
          */
-        async getValidChanges(bills, pos) {
+        async getValidChanges(tid, bills, pos) {
             const filter = 'cb.`code` = ' + this.db.escape(bills.b_code) + (pos ? ' And cb.`detail` = ' + this.db.escape(pos.name) : '');
             const sql = 'SELECT c.cid, c.code, c.name, c.w_code, c.p_code, c.peg, c.org_name, c.org_code, c.new_name, c.new_code,' +
                         '    c.content, c.basis, c.memo, c.type, c.class, c.quality, c.company, c.charge, ' +
@@ -688,8 +688,8 @@ module.exports = app => {
                         '  FROM ?? As c ' +
                         '  Left Join ?? As cb ' +
                         '  On c.cid = cb.cid ' +
-                        '  WHERE c.status = ? And ' + filter;
-            const sqlParam = [this.tableName, this.ctx.service.changeAuditList.tableName, audit.flow.status.checked];
+                        '  WHERE c.tid = ? And c.status = ? And ' + filter;
+            const sqlParam = [this.tableName, this.ctx.service.changeAuditList.tableName, tid, audit.flow.status.checked];
             const changes = await this.db.query(sql, sqlParam);
             for (const c of changes) {
                 const aSql = 'SELECT ca.*, pa.name As u_name, pa.role As u_role ' +
@@ -700,17 +700,6 @@ module.exports = app => {
                 const aSqlParam = [this.ctx.service.changeAtt.tableName, this.ctx.service.projectAccount.tableName, c.cid];
                 c.attachments = await this.db.query(aSql, aSqlParam);
             }
-            // const sql = 'SELECT c.* FROM ?? As c' +
-            //     '  WHERE c.`cid` in (' +
-            //     '    SELECT cb.`cid` FROM ?? As cb' +
-            //     '      WHERE ' + filter +
-            //     '      GROUP BY cb.`cid`) ' +
-            //     '    And c.status = ?';
-            // const sqlParam = [this.tableName, this.ctx.service.changeAuditList.tableName, audit.flow.status.checked];
-            // const changes = await this.db.query(sql, sqlParam);
-            // for (const c of changes) {
-            //     c.bills = await this.ctx.service.changeAuditList.getDataByCondition({cid: c.cid, code: bills.b_code});
-            // }
             return changes;
         }