|
@@ -0,0 +1,132 @@
|
|
|
+'use strict';
|
|
|
+
|
|
|
+/**
|
|
|
+ * 变更令详细页js
|
|
|
+ *
|
|
|
+ * @author EllisRan.
|
|
|
+ * @date 2018/11/22
|
|
|
+ * @version
|
|
|
+ */
|
|
|
+$(document).ready(() => {
|
|
|
+ const changeSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
|
|
|
+ {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price'},
|
|
|
+ {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.oamount'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.oa_tp'},
|
|
|
+ {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.ca_tp'},
|
|
|
+ {title: '审批后变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.sa_tp'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 2,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ };
|
|
|
+ for (const aid of aidList) {
|
|
|
+ const userinfo = _.find(auditList2, { 'uid': aid });
|
|
|
+ const newColcount = {
|
|
|
+ title: userinfo.name + ' 审批|数量',
|
|
|
+ colSpan: '2|1', rowSpan: '1|1',
|
|
|
+ field: 'audit_amount_' + aid,
|
|
|
+ hAlign: 2, width: 60, type: 'Number',
|
|
|
+ getValue: 'getValue.samount'
|
|
|
+ };
|
|
|
+ const newColTp = {
|
|
|
+ title: '|金额',
|
|
|
+ colSpan: '|1', rowSpan: '|1',
|
|
|
+ field: 'sa_tp',
|
|
|
+ hAlign: 2, width: 80, formatter: '@', type: 'Number',
|
|
|
+ getValue: 'getValue.sa_tp'};
|
|
|
+ changeSpreadSetting.cols.push(newColcount);
|
|
|
+ changeSpreadSetting.cols.push(newColTp);
|
|
|
+ }
|
|
|
+
|
|
|
+ const changeCol = {
|
|
|
+ getValue: {
|
|
|
+ unit_price: function(data) {
|
|
|
+ return ZhCalc.round(data.unit_price, unitPriceUnit);
|
|
|
+ },
|
|
|
+ oa_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(data.unit_price, data.oamount), totalPriceUnit);
|
|
|
+ },
|
|
|
+ ca_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(data.unit_price, data.camount), totalPriceUnit);
|
|
|
+ },
|
|
|
+ oamount: function (data) {
|
|
|
+ return ZhCalc.round(data.oamount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ camount: function (data) {
|
|
|
+ return ZhCalc.round(data.camount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ samount: function (data) {
|
|
|
+ return ZhCalc.round(data.samount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ sa_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(data.unit_price, data.samount), totalPriceUnit);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ const changeSpreadObj = {
|
|
|
+ makeSjsFooter: function () {
|
|
|
+ // 增加汇总行并设为锁定禁止编辑状态
|
|
|
+ changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
|
|
|
+ changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
|
|
|
+ changeSpreadObj.countSum();
|
|
|
+ },
|
|
|
+ countSum: function() {
|
|
|
+ const rowCount = changeSpreadSheet.getRowCount();
|
|
|
+ let oSum = 0,
|
|
|
+ cSum = 0,
|
|
|
+ sSum = 0;
|
|
|
+ for(let i = 0; i < rowCount - 1; i++){
|
|
|
+ oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
|
|
|
+ cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
|
|
|
+ sSum = ZhCalc.add(sSum, changeSpreadSheet.getValue(i, 11));
|
|
|
+ }
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, sSum !== 0 ? sSum : null);
|
|
|
+ // 用户的数据合计
|
|
|
+ for (const j in aidList) {
|
|
|
+ let audit_sum = 0;
|
|
|
+ for(let i = 0; i < rowCount - 1; i++){
|
|
|
+ audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 13 + j*2));
|
|
|
+ }
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 13 + j*2, audit_sum !== 0 ? audit_sum : null);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showHideAudit: function (show = false) {
|
|
|
+ const count = changeSpreadSetting.cols.length;
|
|
|
+ for (let i = 12; i < count; i++) {
|
|
|
+ changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ }
|
|
|
+ changeSpreadSheet.setColumnVisible(10, !show, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ changeSpreadSheet.setColumnVisible(11, !show, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
|
|
|
+ SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ changeSpreadObj.showHideAudit();
|
|
|
+
|
|
|
+ // 审批流程展示与隐藏
|
|
|
+ $('#show-table-detail').on('click', function (e) {
|
|
|
+ if($(e.target).is('label')){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ changeSpreadObj.showHideAudit($(this).is(':checked'));
|
|
|
+ });
|
|
|
+});
|