|
@@ -22,9 +22,6 @@ $(function () {
|
|
|
level: 'level',
|
|
|
rootId: -1,
|
|
|
fullPath: 'full_path',
|
|
|
- //treeCacheKey: 'ledger_bills_fold' + '_' + getTenderId(),
|
|
|
- // markFoldKey: 'bills-fold',
|
|
|
- // markFoldSubKey: window.location.pathname.split('/')[2],
|
|
|
};
|
|
|
const ledgerTree = createNewPathTree('filter', treeSetting);
|
|
|
|
|
@@ -37,16 +34,16 @@ $(function () {
|
|
|
{title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '自开工至本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '截止本期完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '截止本期完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_gather_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'end_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '本年计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '本期完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '本期完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '下月计划|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
];
|
|
@@ -71,59 +68,70 @@ $(function () {
|
|
|
SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
|
|
|
SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
|
|
|
|
|
|
- postData('/tender/' + getTenderId() + '/schedule/ledger/load', {}, function (data) {
|
|
|
- // let treeData = [];
|
|
|
- // for(const sl of selectedLedgerList) {
|
|
|
- // const one = _.find(data, { 'ledger_id' : sl });
|
|
|
- // treeData.push(one);
|
|
|
- // }
|
|
|
- // treeData = setLeafData(treeData);
|
|
|
- // console.log(treeData);
|
|
|
- // let treeData = data;
|
|
|
- const calcList = ['total_price'];
|
|
|
- const showList = ['ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
|
|
|
- 'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price'];
|
|
|
- for (const m of scheduleMonth) {
|
|
|
- if (m.stage_used === 1) {
|
|
|
- showList.push(m.yearmonth + '_plan_tp');
|
|
|
- showList.push(m.yearmonth + '_plan_gcl');
|
|
|
- showList.push(m.yearmonth + '_sj_tp');
|
|
|
- showList.push(m.yearmonth + '_sj_gcl');
|
|
|
- }
|
|
|
- // calcList.push(m + '_tp');
|
|
|
- // calcList.push(m + '_gcl');
|
|
|
- }
|
|
|
- const baseLedgerTree = createNewPathTree('base', {
|
|
|
- id: 'ledger_id',
|
|
|
- pid: 'ledger_pid',
|
|
|
- order: 'order',
|
|
|
- level: 'level',
|
|
|
- rootId: -1,
|
|
|
- fullPath: 'full_path',
|
|
|
- calcFields: calcList,
|
|
|
- calcFun: function (node) {
|
|
|
+ if (curScheduleStage && curScheduleStage.order) {
|
|
|
+ postData('/tender/' + getTenderId() + '/measure/stage/' + curScheduleStage.order + '/load', { filter: 'ledger' }, function (data) {
|
|
|
+ const calcList = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
|
|
|
+ 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
|
|
|
+ const showList = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
|
|
|
+ 'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
|
|
|
+ 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
|
|
|
+ const baseLedgerTreeSetting = {
|
|
|
+ id: 'ledger_id',
|
|
|
+ pid: 'ledger_pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ fullPath: 'full_path',
|
|
|
+ calcFields: calcList,
|
|
|
+ };
|
|
|
+ baseLedgerTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
|
|
|
+ baseLedgerTreeSetting.calcFun = function (node) {
|
|
|
+ if (!node.children || node.children.length === 0) {
|
|
|
+ node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
|
+ node.gather_qty = ZhCalc.add(node.contract_qty, node.qc_qty);
|
|
|
+ node.end_contract_qty = ZhCalc.add(node.pre_contract_qty, node.contract_qty);
|
|
|
+ node.end_qc_qty = ZhCalc.add(node.pre_qc_qty, node.qc_qty);
|
|
|
+ node.end_gather_qty = ZhCalc.add(node.pre_gather_qty, node.gather_qty);
|
|
|
+ }
|
|
|
+ node.pre_gather_tp = ZhCalc.add(node.pre_contract_tp, node.pre_qc_tp);
|
|
|
+ node.gather_tp = ZhCalc.add(node.contract_tp, node.qc_tp);
|
|
|
+ node.end_contract_tp = ZhCalc.add(node.pre_contract_tp, node.contract_tp);
|
|
|
+ node.end_qc_tp = ZhCalc.add(node.pre_qc_tp, node.qc_tp);
|
|
|
+ node.end_gather_tp = ZhCalc.add(node.pre_gather_tp, node.gather_tp);
|
|
|
+ node.end_final_tp = ZhCalc.add(node.end_qc_tp, node.total_price);
|
|
|
+ if (!node.children || node.children.length === 0) {
|
|
|
+ if (node.end_contract_qty) {
|
|
|
+ node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
|
|
|
+ } else {
|
|
|
+ node.end_correct_tp = node.end_gather_tp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
|
|
|
+ node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
|
|
|
+ node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
|
|
|
node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
- }
|
|
|
- });
|
|
|
- const newLedgerList = setMonthToLedger(data.bills, data.slm);
|
|
|
- baseLedgerTree.loadDatas(newLedgerList);
|
|
|
- treeCalc.calculateAll(baseLedgerTree);
|
|
|
- console.log(baseLedgerTree);
|
|
|
- for (const d of baseLedgerTree.nodes) {
|
|
|
- if (!d.b_code) {
|
|
|
- const one = _.find(selectedLedgerList, function (item) {
|
|
|
- return item === d.ledger_id;
|
|
|
- });
|
|
|
- if(one) {
|
|
|
- ledgerTree.addData(d, showList);
|
|
|
+ };
|
|
|
+ const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
|
|
|
+ // const newLedgerList = setMonthToLedger(data.bills, data.slm);
|
|
|
+ baseLedgerTree.loadDatas(data.ledgerData);
|
|
|
+ treeCalc.calculateAll(baseLedgerTree);
|
|
|
+ console.log(baseLedgerTree);
|
|
|
+ for (const d of baseLedgerTree.nodes) {
|
|
|
+ if (!d.b_code) {
|
|
|
+ const one = _.find(selectedLedgerList, function (item) {
|
|
|
+ return item === d.ledger_id;
|
|
|
+ });
|
|
|
+ if(one) {
|
|
|
+ ledgerTree.addData(d, showList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- console.log(ledgerTree);
|
|
|
- ledgerTree.sortTreeNode(true);
|
|
|
- // console.log(ledgerTree);
|
|
|
- SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree);
|
|
|
- }, null, true);
|
|
|
+ console.log(ledgerTree);
|
|
|
+ ledgerTree.sortTreeNode(true);
|
|
|
+ // console.log(ledgerTree);
|
|
|
+ SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree);
|
|
|
+ }, null, true);
|
|
|
+ }
|
|
|
|
|
|
const ledgerSpreadObj = {
|
|
|
refreshTree: function (sheet, data) {
|
|
@@ -175,183 +183,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;
|
|
|
- }
|
|
|
- const yearmonth = col.field.split('_')[0];
|
|
|
- // 判断输入位数,提示
|
|
|
- const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.up) +'})?$');
|
|
|
- if (validText !== null && (!reg.test(validText))) {
|
|
|
- toastr.error('输入工程量小数位数不能大于' + tenderInfo.decimal.up + '位');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- const sj_gcl = validText;
|
|
|
- const sj_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 0;
|
|
|
- select[col.field] = validText;
|
|
|
- const updateData = {
|
|
|
- lid: select.ledger_id,
|
|
|
- yearmonth,
|
|
|
- sj_gcl,
|
|
|
- sj_tp,
|
|
|
- };
|
|
|
- console.log(updateData);
|
|
|
- postData(window.location.pathname + '/save', {type: 'ledger_edit', postData: updateData}, function (result) {
|
|
|
- select[yearmonth + '_sj_tp'] = sj_tp;
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- },function () {
|
|
|
- select[col.field] = orgValue;
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- deletePress: function (sheet) {
|
|
|
- return;
|
|
|
- },
|
|
|
- clipboardPasted(e, info) {
|
|
|
- const hint = {
|
|
|
- cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
- numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
- numberCan: {type: 'error', msg: '请粘贴大于0并且小于3位小数的浮点数'},
|
|
|
- };
|
|
|
- const range = info.cellRange;
|
|
|
- const sortData = info.sheet.zh_data || [];
|
|
|
- if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
|
|
|
- toastMessageUniq(hint.cellError);
|
|
|
- SpreadJsObj.reLoadSheetHeader(materialMonthSpread.getActiveSheet());
|
|
|
- SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
- return;
|
|
|
- }
|
|
|
- if (sortData.length > 0 && range.col + range.colCount > 4 + months.length) {
|
|
|
- toastMessageUniq(hint.cellError);
|
|
|
- SpreadJsObj.reLoadSheetHeader(materialMonthSpread.getActiveSheet());
|
|
|
- SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
- return;
|
|
|
- }
|
|
|
- const data = [];
|
|
|
- for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
- let bPaste = true;
|
|
|
- const curRow = range.row + iRow;
|
|
|
- const materialMonthData = sortData[curRow];
|
|
|
- const hintRow = range.rowCount > 1 ? curRow : '';
|
|
|
- let sameCol = 0;
|
|
|
- for (let iCol = 0; iCol < range.colCount; iCol++) {
|
|
|
- const curCol = range.col + iCol;
|
|
|
- const colSetting = info.sheet.zh_setting.cols[curCol];
|
|
|
- if (!colSetting) continue;
|
|
|
-
|
|
|
- let validText = info.sheet.getText(curRow, curCol);
|
|
|
- validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
|
|
|
- const orgValue = sortData[curRow][colSetting.field];
|
|
|
- if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
- sameCol++;
|
|
|
- if (range.colCount === sameCol) {
|
|
|
- bPaste = false;
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
- const num = parseFloat(validText);
|
|
|
- if (isNaN(validText)) {
|
|
|
- toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
|
- bPaste = false;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
- toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
|
- bPaste = false;
|
|
|
- continue;
|
|
|
- }
|
|
|
- materialMonthData[colSetting.field] = validText;
|
|
|
- sortData[curRow][colSetting.field] = validText;
|
|
|
- }
|
|
|
- if (bPaste) {
|
|
|
- data.push(materialMonthData);
|
|
|
- } else {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
- }
|
|
|
- }
|
|
|
- if (data.length === 0) {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- return;
|
|
|
- }
|
|
|
- // // 更新至服务器
|
|
|
- // postData(window.location.pathname + '/month/save', { type:'paste', updateData: data }, function (result) {
|
|
|
- // SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
- // materialBillsData = result.materialBillsData;
|
|
|
- // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
- // m_tp = result.m_tp;
|
|
|
- // resetTpTable();
|
|
|
- // }, function () {
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- // return;
|
|
|
- // });
|
|
|
- },
|
|
|
};
|
|
|
|
|
|
- ledgerSpread.bind(spreadNS.Events.EditEnded, ledgerSpreadObj.editEnded);
|
|
|
- SpreadJsObj.addDeleteBind(ledgerSpread, ledgerSpreadObj.deletePress);
|
|
|
-
|
|
|
- // 月份添加
|
|
|
- $('#add-month').click(function () {
|
|
|
- const id = parseInt($('#month-select').val());
|
|
|
- if(id === 0) {
|
|
|
+ $('#add-stage').click(function () {
|
|
|
+ const yearmonth = $('#month_list').val();
|
|
|
+ const order = parseInt($('#stage_list').val());
|
|
|
+ if (yearmonth === '0') {
|
|
|
toastr.error('请选择计划进度月');
|
|
|
return;
|
|
|
}
|
|
|
+ if (order === 0) {
|
|
|
+ toastr.error('请选择计量期');
|
|
|
+ return;
|
|
|
+ }
|
|
|
const _self = $(this);
|
|
|
- postData(window.location.pathname + '/save', {type: 'add_stage', postData: { id: id }}, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', {type: 'add_stage', postData: { yearmonth, order }}, function (result) {
|
|
|
_self.addClass('disabled').attr('disabled', true);
|
|
|
- toastr.success('创建成功');
|
|
|
+ toastr.success('新增成功');
|
|
|
setTimeout(function () {
|
|
|
window.location.reload();
|
|
|
}, 500)
|
|
|
})
|
|
|
});
|
|
|
|
|
|
- $('#month-table input[type="checkbox"]').click(function () {
|
|
|
- const selectedMonth = [];
|
|
|
- $('#month-table input:checkbox:checked').each(function () {
|
|
|
- selectedMonth.push('「' + $(this).parents('td').siblings('td').text() + '」');
|
|
|
- });
|
|
|
- if(selectedMonth.length > 0) {
|
|
|
- $('#del-month-list').text(selectedMonth.join(''));
|
|
|
- $('#del-month-list').parent().show();
|
|
|
- $('#del-month').removeAttr('disabled');
|
|
|
- } else {
|
|
|
- $('#del-month-list').parent().hide();
|
|
|
- $('#del-month').attr('disabled', true);
|
|
|
+ $('#reload-stage').click(function () {
|
|
|
+ const order = parseInt($('#reload-stage-list').val());
|
|
|
+ const id = parseInt($(this).data('id'));
|
|
|
+ if (order === 0) {
|
|
|
+ toastr.error('请选择计量期');
|
|
|
+ return;
|
|
|
}
|
|
|
+ const _self = $(this);
|
|
|
+ postData('/tender/'+ getTenderId() + '/schedule/stage/save', {type: 'reload_stage', postData: { id, order }}, function (result) {
|
|
|
+ _self.addClass('disabled').attr('disabled', true);
|
|
|
+ toastr.success('重新生成成功');
|
|
|
+ setTimeout(function () {
|
|
|
+ window.location.href = '/tender/'+ getTenderId() + '/schedule/stage/order/' + order;
|
|
|
+ }, 500)
|
|
|
+ })
|
|
|
});
|
|
|
|
|
|
- $('#del-month').click(function () {
|
|
|
- const selectedMonth = [];
|
|
|
- $('#month-table input:checkbox:checked').each(function () {
|
|
|
- selectedMonth.push($(this).parents('td').siblings().text());
|
|
|
- });
|
|
|
- if (selectedMonth.length === 0) {
|
|
|
- toastr.error('请选择删除的计划周期');
|
|
|
- return;
|
|
|
- }
|
|
|
+ $('#del-stage').click(function () {
|
|
|
+ const id = parseInt($(this).data('id'));
|
|
|
const _self = $(this);
|
|
|
- postData(window.location.pathname + '/save', {type: 'del_stage', postData: selectedMonth}, function (result) {
|
|
|
+ postData('/tender/'+ getTenderId() + '/schedule/stage/save', {type: 'del_stage', postData: { id }}, function (result) {
|
|
|
_self.addClass('disabled').attr('disabled', true);
|
|
|
toastr.success('删除成功');
|
|
|
setTimeout(function () {
|
|
|
- window.location.reload();
|
|
|
+ window.location.href = '/tender/'+ getTenderId() + '/schedule/stage';
|
|
|
}, 500)
|
|
|
-
|
|
|
})
|
|
|
});
|
|
|
|