浏览代码

进度delete键功能补齐

laiguoran 4 年之前
父节点
当前提交
f01bc61214
共有 2 个文件被更改,包括 82 次插入2 次删除
  1. 44 1
      app/public/js/schedule_plan.js
  2. 38 1
      app/public/js/schedule_stage_gcl.js

+ 44 - 1
app/public/js/schedule_plan.js

@@ -265,13 +265,56 @@ $(function () {
             }
         },
         deletePress: function (sheet) {
-            return;
+            if (!sheet.zh_setting || sheet.zh_setting.readOnly) return;
+            if (sheet.zh_setting && sheet.zh_tree) {
+                const sel = sheet.getSelections()[0];
+                if (!sel) return;
+                if(sel.rowCount > 1 || sel.colCount > 1) {
+                    return;
+                }
+                const select = SpreadJsObj.getSelectObject(sheet);
+                const col = sheet.zh_setting.cols[sel.col];
+                const orgValue = select[col.field];
+                if (!orgValue) {
+                    return;
+                }
+                const yearmonth = col.field.split('_')[0];
+                const modes = col.field.split('_')[1];
+                if(col.readOnly === true || !select.is_leaf || mode[modes] !== schedule.mode) {
+                    return;
+                }
+                let plan_gcl = 0;
+                let plan_tp = 0;
+                select[col.field] = 0;
+                const updateData = {
+                    lid: select.ledger_id,
+                    yearmonth,
+                    plan_gcl,
+                    plan_tp,
+                };
+                postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
+                    if (modes === 'tp') {
+                        select[yearmonth + '_gcl'] = plan_gcl;
+                    } else {
+                        select[yearmonth + '_tp'] = plan_tp;
+                    }
+                    const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
+                    const refreshNode = ledgerTree.loadPostData({update: nodes});
+                    ledgerSpreadObj.refreshTree(sheet, refreshNode);
+                },function () {
+                    select[col.field] = orgValue;
+                    const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
+                    const refreshNode = ledgerTree.loadPostData({update: nodes});
+                    ledgerSpreadObj.refreshTree(sheet, refreshNode);
+                })
+            }
         },
         clipboardPasted(e, info) {
             const hint = {
                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
             };
+            console.log(info);
             const range = info.cellRange;
             if (range.rowCount > 1 || range.colCount > 1) {
                 toastMessageUniq(hint.cellError);

+ 38 - 1
app/public/js/schedule_stage_gcl.js

@@ -246,7 +246,44 @@ $(function () {
             }
         },
         deletePress: function (sheet) {
-            return;
+            if (!sheet.zh_setting || sheet.zh_setting.readOnly) return;
+            if (sheet.zh_setting && sheet.zh_tree) {
+                const sel = sheet.getSelections()[0];
+                if (!sel) return;
+                if(sel.rowCount > 1 || sel.colCount > 1) {
+                    return;
+                }
+                const select = SpreadJsObj.getSelectObject(sheet);
+                const col = sheet.zh_setting.cols[sel.col];
+                const orgValue = select[col.field];
+                if (!orgValue) {
+                    return;
+                }
+                const yearmonth = col.field.split('_')[0];
+                if(col.readOnly === true || !select.is_leaf) {
+                    return;
+                }
+                let sj_gcl = 0;
+                let sj_tp = 0;
+                select[col.field] = 0;
+                const updateData = {
+                    lid: select.ledger_id,
+                    yearmonth,
+                    sj_gcl,
+                    sj_tp,
+                };
+                postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
+                    select[yearmonth + '_sj_tp'] = sj_tp;
+                    const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
+                    const refreshNode = ledgerTree.loadPostData({update: nodes});
+                    ledgerSpreadObj.refreshTree(sheet, refreshNode);
+                },function () {
+                    select[col.field] = orgValue;
+                    const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
+                    const refreshNode = ledgerTree.loadPostData({update: nodes});
+                    ledgerSpreadObj.refreshTree(sheet, refreshNode);
+                })
+            }
         },
         clipboardPasted(e, info) {
             const hint = {