|
@@ -15,12 +15,17 @@ $(document).ready(() => {
|
|
|
// 初始化spread
|
|
|
const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
|
|
|
const billsSheet = billsSpread.getActiveSheet();
|
|
|
+
|
|
|
+ billsSpreadSetting.cols.push({title: '截止本期合同计量|数量', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
|
|
|
+ {title: '|完成率(%)', colSpan: '1', rowSpan: '|1', field: 'end_percent', hAlign: 2, width: 80, readOnly: true, type: 'Number'});
|
|
|
sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
|
|
|
if (thousandth) sjsSettingObj.setTpThousandthFormat(billsSpreadSetting);
|
|
|
sjsSettingObj.setNodeTypeCol(billsSpreadSetting.cols, [{field: 'node_type'}]);
|
|
|
SpreadJsObj.initSheet(billsSheet, billsSpreadSetting);
|
|
|
const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
|
|
|
const posSheet = posSpread.getActiveSheet();
|
|
|
+ posSpreadSetting.cols.push({title: '截止本期合同计量|数量', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
|
|
|
+ {title: '|完成率(%)', colSpan: '1', rowSpan: '|1', field: 'end_percent', hAlign: 2, width: 80, readOnly: true, type: 'Number'});
|
|
|
sjsSettingObj.setGridSelectStyle(posSpreadSetting);
|
|
|
if (thousandth) sjsSettingObj.setTpThousandthFormat(posSpreadSetting);
|
|
|
SpreadJsObj.initSheet(posSheet, posSpreadSetting);
|
|
@@ -62,10 +67,18 @@ $(document).ready(() => {
|
|
|
}
|
|
|
treeSetting.calcFun = function (node) {
|
|
|
node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
+ node.end_contract_qty = ZhCalc.add(node.contract_qty, node.pre_contract_qty);
|
|
|
+ node.end_percent = node.quantity ? ZhCalc.mul(ZhCalc.div(node.contract_qty, node.quantity, 4), 100, 2) : 0;
|
|
|
};
|
|
|
const billsTree = createNewPathTree('revise', treeSetting);
|
|
|
// 初始化 部位明细
|
|
|
- const pos = new PosData({ id: 'id', ledgerId: 'lid' });
|
|
|
+ const pos = new PosData({
|
|
|
+ id: 'id', ledgerId: 'lid',
|
|
|
+ calcFun: function(node) {
|
|
|
+ node.end_contract_qty = ZhCalc.add(node.contract_qty, node.pre_contract_qty);
|
|
|
+ node.end_percent = node.quantity ? ZhCalc.mul(ZhCalc.div(node.contract_qty, node.quantity, 4), 100, 2) : 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
const billsTreeSpreadObj = {
|
|
|
/**
|
|
@@ -157,8 +170,47 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.resetFieldReadOnly(posSheet);
|
|
|
},
|
|
|
};
|
|
|
+ const assignRelaData = function(main, rela, mainKey = 'id', clear = false) {
|
|
|
+ const index = {},
|
|
|
+ indexPre = 'id_';
|
|
|
+ const loadFields = function(datas, fields, prefix, relaId) {
|
|
|
+ for (const d of datas) {
|
|
|
+ const key = indexPre + d[relaId];
|
|
|
+ const m = index[key];
|
|
|
+ if (m) {
|
|
|
+ for (const f of fields) {
|
|
|
+ if (d[f] !== undefined) {
|
|
|
+ m[prefix + f] = d[f];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ for (const m of main) {
|
|
|
+ index[indexPre + m[mainKey]] = m;
|
|
|
+ for (const r of rela) {
|
|
|
+ if (r.defaultData) _.assignIn(m, r.defaultData);
|
|
|
+ }
|
|
|
+ if (clear) {
|
|
|
+ rela.forEach(r => {
|
|
|
+ r.fields.forEach(f => {
|
|
|
+ delete m[r.prefix + f];
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (const r of rela) {
|
|
|
+ loadFields(r.data, r.fields, r.prefix, r.relaId);
|
|
|
+ }
|
|
|
+ }
|
|
|
// 加载清单&计量单元数据
|
|
|
- postData('load', {filter:'reviseBills;revisePos;att'}, function (result) {
|
|
|
+ postData('load', {filter:'reviseBills;revisePos;att;stageBills;stagePos'}, function (result) {
|
|
|
+ assignRelaData(result.reviseBills, [
|
|
|
+ { data: result.stageBills, fields: ['contract_qty', 'pre_contract_qty'], prefix: '', relaId: 'lid' },
|
|
|
+ ]);
|
|
|
+ assignRelaData(result.revisePos, [
|
|
|
+ { data: result.stagePos, fields: ['contract_qty', 'pre_contract_qty'], prefix: '', relaId: 'lid' },
|
|
|
+ ]);
|
|
|
billsTree.loadDatas(result.reviseBills);
|
|
|
treeCalc.calculateAll(billsTree);
|
|
|
SpreadJsObj.loadSheetData(billsSheet, SpreadJsObj.DataType.Tree, billsTree);
|