|
@@ -419,6 +419,123 @@ $(document).ready(() => {
|
|
|
czSpreadObj.makeSjsFooter();
|
|
|
});
|
|
|
|
|
|
+ // 清单汇总信息获取
|
|
|
+ let hzSpread = null;
|
|
|
+ const hzSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60},
|
|
|
+ {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: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.ca_tp'},
|
|
|
+ {title: '审批变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount', visible: auditStatus !== 6},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.sa_tp', visible: auditStatus !== 6},
|
|
|
+ {title: '审批变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'spamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.spamount', visible: auditStatus === 6},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'spa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.spa_tp', visible: auditStatus === 6},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 2,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ localCache: {
|
|
|
+ key: 'changes-hz',
|
|
|
+ colWidth: true,
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const hzCol = {
|
|
|
+ getValue: {
|
|
|
+ unit_price: function(data) {
|
|
|
+ return ZhCalc.round(data.unit_price, unitPriceUnit);
|
|
|
+ },
|
|
|
+ camount: function (data) {
|
|
|
+ return ZhCalc.round(data.camount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ ca_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
|
|
|
+ },
|
|
|
+ samount: function (data) {
|
|
|
+ return ZhCalc.round(data.samount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ sa_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.samount, findDecimal(data.unit))), totalPriceUnit);
|
|
|
+ },
|
|
|
+ spamount: function (data) {
|
|
|
+ return ZhCalc.round(data.spamount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ spa_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.spamount, findDecimal(data.unit))), totalPriceUnit);
|
|
|
+ },
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const hzSpreadObj = {
|
|
|
+ makeBackColor: function () {
|
|
|
+ const rowCount = hzSpread.getActiveSheet().getRowCount();
|
|
|
+ for (let i = 0; i < rowCount; i++) {
|
|
|
+ if (auditStatus === 6 && hzSpread.getActiveSheet().zh_data[i].camount != hzSpread.getActiveSheet().zh_data[i].spamount) {
|
|
|
+ hzSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#ffeeba');
|
|
|
+ } else if (auditStatus !== 6 && hzSpread.getActiveSheet().zh_data[i].camount != hzSpread.getActiveSheet().zh_data[i].samount) {
|
|
|
+ hzSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#ffeeba');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ makeSjsFooter: function () {
|
|
|
+ // 增加汇总行并设为锁定禁止编辑状态
|
|
|
+ hzSpread.getActiveSheet().addRows(hzSpread.getActiveSheet().getRowCount(), 1);
|
|
|
+ hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 0, '合计');
|
|
|
+ hzSpread.getActiveSheet().setStyle(hzSpread.getActiveSheet().getRowCount() - 1, -1, style1);
|
|
|
+ hzSpreadObj.countSum();
|
|
|
+ },
|
|
|
+ countSum: function () {
|
|
|
+ const rowCount = hzSpread.getActiveSheet().getRowCount();
|
|
|
+ let cSum = 0,
|
|
|
+ sSum = 0,
|
|
|
+ spSum = 0;
|
|
|
+ for (let i = 0; i < rowCount - 1; i++) {
|
|
|
+ cSum = ZhCalc.add(cSum, hzSpread.getActiveSheet().getValue(i, 5));
|
|
|
+ sSum = ZhCalc.add(sSum, hzSpread.getActiveSheet().getValue(i, 7));
|
|
|
+ spSum = ZhCalc.add(spSum, hzSpread.getActiveSheet().getValue(i, 9));
|
|
|
+ }
|
|
|
+ hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 5, cSum !== 0 ? cSum : null);
|
|
|
+ hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 7, sSum !== 0 ? sSum : null);
|
|
|
+ hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 9, spSum !== 0 ? spSum : null);
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ $('#qdgather').on('shown.bs.modal', function () {
|
|
|
+ if (!hzSpread) {
|
|
|
+ hzSpread = SpreadJsObj.createNewSpread($('#hz-spread')[0]);
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(hzSpreadSetting, hzCol);
|
|
|
+ SpreadJsObj.initSheet(hzSpread.getActiveSheet(), hzSpreadSetting);
|
|
|
+ }
|
|
|
+ const hzList = [];
|
|
|
+ const newChangeList = _.cloneDeep(changeList);
|
|
|
+ for (const cl of newChangeList) {
|
|
|
+ const hzIndex = _.findIndex(hzList, { code: cl.code, name: cl.name, unit: cl.unit, unit_price: cl.unit_price});
|
|
|
+ if (hzIndex !== -1) {
|
|
|
+ hzList[hzIndex].camount = ZhCalc.add(hzList[hzIndex].camount, cl.camount);
|
|
|
+ hzList[hzIndex].spamount = ZhCalc.add(hzList[hzIndex].spamount, cl.spamount);
|
|
|
+ const samount = cl.samount ? parseFloat(cl.samount) : 0;
|
|
|
+ hzList[hzIndex].samount = hzList[hzIndex].samount ? parseFloat(hzList[hzIndex].samount) : 0;
|
|
|
+ hzList[hzIndex].samount = ZhCalc.add(hzList[hzIndex].samount, samount);
|
|
|
+ } else {
|
|
|
+ hzList.push(cl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hzList.length > 0) {
|
|
|
+ // 按清单编号排序
|
|
|
+ hzList.sort(sortByCode);
|
|
|
+ }
|
|
|
+ console.log(hzList);
|
|
|
+ // // sjs设置
|
|
|
+ SpreadJsObj.loadSheetData(hzSpread.getActiveSheet(), SpreadJsObj.DataType.Data, hzList);
|
|
|
+ hzSpreadObj.makeBackColor();
|
|
|
+ hzSpreadObj.makeSjsFooter();
|
|
|
+ });
|
|
|
+
|
|
|
$.subMenu({
|
|
|
menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
|
|
|
toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
|