Browse Source

多人协同修改和计划进度数据精度问题

laiguoran 4 năm trước cách đây
mục cha
commit
932aef373e

+ 58 - 5
app/public/js/schedule_plan.js

@@ -57,9 +57,10 @@ $(function () {
     const monthsCols = [];
     if(scheduleMonth.length > 0) {
         for (const sm of scheduleMonth) {
+            const readOnly = sm.sj_gcl !== null || sm.sj_tp !== null;
             const yearmonth = sm.yearmonth.split('-')[0] + '年' + parseInt(sm.yearmonth.split('-')[1]) + '月';
-            const cols = {title: yearmonth + '|计划工程量', colSpan: '2|1', rowSpan: '1|1', field: sm.yearmonth+'_gcl', hAlign: 2, width: 90, type: 'Number', readOnly: 'readOnly.gcl'};
-            const cols2 = {title: '|计划金额(万元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_tp', hAlign: 2, width: 90, type: 'Number', readOnly: 'readOnly.tp'};
+            const cols = {title: yearmonth + '|计划工程量', colSpan: '2|1', rowSpan: '1|1', field: sm.yearmonth+'_gcl', hAlign: 2, width: 90, type: 'Number', readOnly: readOnly ? readOnly : 'readOnly.gcl'};
+            const cols2 = {title: '|计划金额(万元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_tp', hAlign: 2, width: 90, type: 'Number', readOnly: readOnly ? readOnly : 'readOnly.tp'};
             monthsCols.push(cols);
             monthsCols.push(cols2);
         }
@@ -155,7 +156,55 @@ $(function () {
                 }
             });
         },
+        editEnded: function (e, info) {
+            if (info.sheet.zh_setting) {
+                const select = SpreadJsObj.getSelectObject(info.sheet);
+                const col = info.sheet.zh_setting.cols[info.col];
+                const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
+                const orgValue = select[col.field];
+                if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+                if (isNaN(validText)) {
+                    toastr.error('不能输入其它非数字类型字符');
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+                select[col.field] = validText;
+                const yearmonth = col.field.split('_')[0];
+                const mode = col.field.split('_')[1];
+                let plan_gcl = 0;
+                let plan_tp = 0;
+                if (mode === 'tp') {
+                    plan_gcl = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, select.dgn_price), tenderInfo.decimal.up) : 0;
+                    plan_tp = validText;
+                    select[yearmonth + '_gcl'] = plan_gcl;
+                } else {
+                    plan_gcl = validText;
+                    plan_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 0;
+                    select[yearmonth + '_tp'] = plan_tp;
+                }
+                const updateData = {
+                    lid: select.ledger_id,
+                    yearmonth,
+                    plan_gcl,
+                    plan_tp,
+                };
+                console.log(updateData);
+                // postData(window.location.pathname + '/save', {type: 'mode', postData: updateData}, function (result) {
+                //     SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                // })
+            }
+        },
+        deletePress: function (sheet) {
+            return;
+        },
     };
+
+    ledgerSpread.bind(spreadNS.Events.EditEnded, ledgerSpreadObj.editEnded);
+    SpreadJsObj.addDeleteBind(ledgerSpread, ledgerSpreadObj.deletePress);
+
     // 进度计算方式选择
     $('.mode-select').on('click', function () {
         const _self = $(this);
@@ -316,10 +365,14 @@ function setLeafData(tree) {
         if (!child && !t.is_leaf) {
             t.is_leaf = true;
         }
-        for(const m of scheduleMonth) {
-            t[m.yearmonth] = m.sj_gcl !== null || m.sj_tp !== null;
-        }
         newtree.push(t);
     }
     return newtree;
 }
+const is_numeric = (value) => {
+    if (typeof(value) === 'object') {
+        return false;
+    } else {
+        return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
+    }
+};

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

@@ -784,7 +784,7 @@ $(document).ready(function () {
                     selects = [select];
                     if(select) {
                         setAllChildrenCanEdit(select, flag);
-                        setParentCanEdit(ledgerTree.nodes, select.ledger_pid, flag);
+                        // setParentCanEdit(ledgerTree.nodes, select.ledger_pid, flag);
                     }
                     const refreshNode = ledgerTree.loadPostData({update: selects});
                     ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
@@ -890,7 +890,7 @@ $(document).ready(function () {
             selects = [select];
             if(select) {
                 setAllChildrenCanEdit(select, true);
-                setParentCanEdit(ledgerTree.nodes, select.ledger_pid, true);
+                // setParentCanEdit(ledgerTree.nodes, select.ledger_pid, true);
             }
             const refreshNode = ledgerTree.loadPostData({update: selects});
             ledgerSpreadObj.refreshTree(ledgerSpread.getActiveSheet(), refreshNode);
@@ -1033,7 +1033,7 @@ function updateByCanEdit(datas, coolist, flag) {
         const ledgerInfo = _.find(datas, { 'ledger_id': coo.ledger_id });
         if(ledgerInfo) {
             setAllChildrenCanEdit(ledgerInfo, flag);
-            setParentCanEdit(datas, ledgerInfo.ledger_pid, flag);
+            // setParentCanEdit(datas, ledgerInfo.ledger_pid, flag);
         }
     }
 }

+ 1 - 0
app/service/ledger_cooperation.js

@@ -34,6 +34,7 @@ module.exports = app => {
                 const result = await this.db.insert(this.tableName, data);
                 data.id = result.insertId;
                 data.sign_path = null;
+                data.status = 1;
                 // }
             } else if (data.pwd !== '' && info) {
                 data.id = info.id;