Bläddra i källkod

材料调差一些bug修复

laiguoran 5 år sedan
förälder
incheckning
dfb50473a5

+ 2 - 2
app/extend/helper.js

@@ -936,9 +936,9 @@ module.exports = {
             this.ctx.debugInfo = { key: {}, other: [] };
         }
         if (key) {
-             this.ctx.debugInfo.key[key] = data;
+            this.ctx.debugInfo.key[key] = data;
         } else {
             this.ctx.debugInfo.other.push(data);
         }
-    }
+    },
 };

+ 103 - 2
app/public/js/material.js

@@ -20,6 +20,63 @@ function loadUpdateMaterials(newMaterial, fields) {
     }
 }
 
+// function DatePickerCellType() {
+// }
+// DatePickerCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
+// DatePickerCellType.prototype.createEditorElement = function () {
+//     //Create input presenter.
+//     var input = document.createElement("input");
+//     return input;
+// };
+// DatePickerCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect) {
+//     //Initialize input editor.
+//     if (editorContext) {
+//         const $editor = $(editorContext);
+//         GC.Spread.Sheets.CellTypes.Base.prototype.activateEditor.apply(this, arguments);
+//         $editor.datepicker({
+//             language: 'zh',
+//         });
+//         $editor.css("position", "absolute");
+//         $editor.attr("gcUIElement", "gcEditingInput");
+//         $(".ui-datepicker").attr("gcUIElement", "gcEditingInput");
+//     }
+// }
+// // DatePickerCellType.prototype.deactivateEditor = function (editorContext) {
+// //     //Remove input editor when end editor status.
+// //     if (editorContext) {
+// //         var element = editorContext;
+// //         $(element).datepicker().data('datepicker').hide();
+// //         $(element).datepicker().data('datepicker').destroy();
+// //         // $(element).datepicker("hide");
+// //         // $(element).datepicker("destroy");
+// //     }
+// //     GC.Spread.Sheets.CellTypes.Base.prototype.deactivateEditor.apply(this, arguments)
+// // };
+// // DatePickerCellType.prototype.setEditorValue = function (editor, value) {
+// //     //Sync value from Cell value to editor value.
+// //     console.log($(editor), value);
+// //     // $(editor).datepicker("setDate", value);
+// //     $(editor).datepicker().data('datepicker').selectDate(value);
+// // };
+// // DatePickerCellType.prototype.getEditorValue = function (editor) {
+// //     //Sync value from editor value to cell value.
+// //     $(editor).datepicker({
+// //         onSelect: function onSelect(fd, date) {
+// //             console.log(fd);
+// //             $(editor).val(fd);
+// //         }
+// //     });
+// //     // return $(editor).datepicker("getDate");
+// //     return $(editor).val();
+// // };
+// DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect) {
+//     if (editorContext) {
+//         const $editor = $(editorContext);
+//         $editor.css("width", cellRect.width - 1);
+//         $editor.css("height", cellRect.height - 3);
+//     }
+// };
+
 function resetTpTable() {
     const rate = $('#changeRate').val();
     const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
@@ -34,12 +91,12 @@ $(document).ready(() => {
     const materialSpread = SpreadJsObj.createNewSpread($('#material-spread')[0]);
     const materialSpreadSetting = {
         cols: [
-            {title: '调差类型', colSpan: '1', rowSpan: '2', field: 't_type', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.t_type, cellTypeKey: 1},
+            {title: '调差类型', colSpan: '1', rowSpan: '2', field: 't_type', hAlign: 1, width: 80, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.t_type, cellTypeKey: 1},
             {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
-            {title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 0, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
+            {title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 1, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
             {title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number', readOnly: true},
             {title: '基准价', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit'},
             {title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
@@ -71,6 +128,7 @@ $(document).ready(() => {
         // return !readOnly && data.t_type === 2 && data.mid === materialID;
         return data.t_type === 2;
     };
+
     materialSpreadSetting.imageClick = function (data) {
         if (data.t_type === 2) {
             $('#bcyy').modal('show');
@@ -267,12 +325,55 @@ $(document).ready(() => {
                 });
             }
         },
+        // clipboardPasting(e, info) {
+        //     if (info.sheet.zh_setting) {
+        //         const sortData = info.sheet.zh_data;
+        //         const range = info.cellRange;
+        //         const validField = ['code', 'name', 'unit', 'spec', 'basic_price', 'basic_times', 'msg_tp', 'msg_times', 'm_up_risk', 'm_down_risk', 'remark'];
+        //         for (let iCol = range.col; iCol < range.col + range.colCount; iCol++) {
+        //             const col = info.sheet.zh_setting.cols[iCol];
+        //             // if (col.type === 'Number') {
+        //             //     const num = _.toNumber(newData[col.field]);
+        //             //     if (num) {
+        //             //         newData[col.field] = num;
+        //             //     } else {
+        //             //         try {
+        //             //             newData[col.field] = math.evaluate(transExpr(newData[col.field]));
+        //             //         } catch(err) {
+        //             //             toastr.error('输入的表达式非法');
+        //             //             stagePosSpreadObj.loadCurPosData();
+        //             //             return;
+        //             //
+        //             //         }
+        //             //     }
+        //             // }
+        //             if (validField.indexOf(col.field) === -1) {
+        //                 toastr.error('不可修改此数据');
+        //                 info.cancel = true;
+        //                 return;
+        //             }
+        //         }
+        //     }
+        // },
+        // clipboardPasted(e, info) {
+        //     // console.log(e, info);
+        // },
         setReadOnly: function(readOnly) {
             SpreadJsObj.resetFieldReadOnly(materialSpread.getActiveSheet(), 'msg_spread', 'm_spread', 'm_tp', 'pre_tp', readOnly);
         }
     };
     materialSpreadObj.refreshActn();
     materialSpread.bind(spreadNS.Events.SelectionChanged, materialSpreadObj.selectionChanged);
+    // materialSpread.bind(spreadNS.Events.ClipboardPasting, materialSpreadObj.clipboardPasting);
+    // materialSpread.bind(spreadNS.Events.ClipboardPasted, materialSpreadObj.clipboardPasted);
+    // const sheet = materialSpread.getActiveSheet();
+    // sheet.suspendPaint();
+    // var range = sheet.getRange(-1, 8, -1, 1);
+    // console.log(range);
+    // range.cellType(new DatePickerCellType());
+    // // range.formatter("yyyy-MM-dd");
+    // sheet.resumePaint();
+
     if (!readOnly) {
         $('#add').click(materialSpreadObj.add);
         $('#del').click(materialSpreadObj.del);

+ 1 - 1
app/service/material_audit.js

@@ -530,7 +530,7 @@ module.exports = app => {
                 newAuditors.push(na);
             }
             const result = await transaction.insert(this.tableName, newAuditors);
-            return result.effectRows = auditors.length;
+            return result.affectedRows === auditors.length;
         }
 
         /**

+ 1 - 1
app/service/material_list_notjoin.js

@@ -143,7 +143,7 @@ module.exports = app => {
                 notJoinlist.push(newLists);
             }
             // 复制上一期不参与调差的清单
-            return await transaction.insert(this.tableName, notJoinlist);
+            return notJoinlist.length > 0 ? await transaction.insert(this.tableName, notJoinlist) : true;
         }
     }
     return MaterialListNotJoin;

+ 3 - 1
app/view/material/info.ejs

@@ -49,7 +49,7 @@
                             <table class="table table-sm table-bordered">
                                 <tr><th></th><th>本期金额</th><th>截止本期金额</th></tr>
                                 <tr id="tp_set"><td>材料价差费用</td><td><%= material.m_tp %></td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.add(material.pre_tp, material.m_tp), 2) : null %></td></tr>
-                                <tr id="rate_set"><td>材料价差费用(含税)</td><td><%= material.m_tp !== null ? ctx.helper.mul(material.m_tp, 1+material.rate/100) : null %></td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(ctx.helper.add(material.pre_tp, material.m_tp), 1+material.rate/100), 2) : null %></td></tr>
+                                <tr id="rate_set"><td>材料价差费用(含税)</td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), 2) : null %></td><td><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(ctx.helper.add(material.pre_tp, material.m_tp), 1+material.rate/100), 2) : null %></td></tr>
                             </table>
                         </div>
                     </div>
@@ -62,6 +62,8 @@
     <img src="/public/images/ellipsis_horizontal.png" id="ellipsis-icon" />
     <img src="/public/images/icon-ok.png" id="icon-ok" />
 </div>
+<!--<script src="/public/js/datepicker/datepicker.min.js"></script>-->
+<!--<script src="/public/js/datepicker/datepicker.zh.js"></script>-->
 <% if ((material.status === auditConst.status.uncheck || material.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === material.user_id) {%>
 <script>
     const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');