|
@@ -124,8 +124,6 @@ function roundPrice(obj) {
|
|
|
function calculateC2() {
|
|
|
const constract = _.toNumber($('#contract-price').val());
|
|
|
const zanLie = _.toNumber($('#zan-lie-price').val());
|
|
|
- //const iDecimal = getDealTpDecimal();
|
|
|
- //$('#c-zl').val(ZhCalc.round(constract - zanLie, iDecimal));
|
|
|
$('#c-zl').val(ZhCalc.minus(constract, zanLie));
|
|
|
}
|
|
|
// 根据小数位数,计算全部的合同参数
|
|
@@ -172,6 +170,244 @@ function checkNumberValid(obj) {
|
|
|
}
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
+ // 清单精度
|
|
|
+ const precisionObj = (function () {
|
|
|
+ const spread = SpreadJsObj.createNewSpread($('#precision-spread')[0]);
|
|
|
+ spread.options.showVerticalScrollbar = false;
|
|
|
+ spread.options.showHorizontalScrollbar = false;
|
|
|
+ const sheet = spread.getActiveSheet();
|
|
|
+ SpreadJsObj.protectedSheet(sheet);
|
|
|
+ sheet.options.rowHeaderVisible = false;
|
|
|
+ sheet.options.colHeaderVisible = false;
|
|
|
+ SpreadJsObj.massOperationSheet(sheet, function () {
|
|
|
+ sheet.defaults.rowHeight = 28;
|
|
|
+ sheet.setColumnCount(3);
|
|
|
+ sheet.setRowCount(14);
|
|
|
+ sheet.setColumnWidth(0, 1);
|
|
|
+ sheet.setColumnWidth(1, 100);
|
|
|
+ sheet.setColumnWidth(2, 60);
|
|
|
+ sheet.setRowHeight(0, 1);
|
|
|
+ sheet.getRange(1, 1, 14, 1).vAlign(1).backColor('#e4e7ea').locked(true);
|
|
|
+ sheet.getRange(1, 2, 14, 1).vAlign(1).hAlign(2).locked(true);
|
|
|
+ sheet.setText(1, 1, 't');
|
|
|
+ sheet.setText(2, 1, 'km');
|
|
|
+ sheet.setText(3, 1, 'm');
|
|
|
+ sheet.setText(4, 1, 'm2');
|
|
|
+ sheet.setText(5, 1, 'm3');
|
|
|
+ sheet.setText(6, 1, 'kg');
|
|
|
+ sheet.setText(7, 1, '个');
|
|
|
+ sheet.setText(8, 1, '台');
|
|
|
+ sheet.setText(9, 1, '套');
|
|
|
+ sheet.setText(10, 1, '棵');
|
|
|
+ sheet.setText(11, 1, '组');
|
|
|
+ sheet.setText(12, 1, '系统');
|
|
|
+ sheet.setText(13, 1, '其他未列单位');
|
|
|
+ const lineBorder = new spreadNS.LineBorder('#6a696e', spreadNS.LineStyle.thin);
|
|
|
+ sheet.getRange(0, 0, 14, 3).setBorder(lineBorder, {all: true});
|
|
|
+ sheet.getRange(0, 0, 14, 3).formatter('@');
|
|
|
+ sheet.setSelection(1, 2, 1, 1);
|
|
|
+ });
|
|
|
+
|
|
|
+ spread.bind(spreadNS.Events.EditEnded, function (e, info) {
|
|
|
+ const value = _.toNumber(info.editingText);
|
|
|
+ if (_.isInteger(value)) {
|
|
|
+ toast('请输入0-6的整数', 'warning');
|
|
|
+ sheet.setText(info.row, info.col, '0');
|
|
|
+ } else if (value > 6) {
|
|
|
+ toast('请输入0-6的整数', 'warning');
|
|
|
+ sheet.setText(info.row, info.col, '6');
|
|
|
+ } else if (value < 0) {
|
|
|
+ toast('请输入0-6的整数', 'warning');
|
|
|
+ sheet.setText(info.row, info.col, '0');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ SpreadJsObj.addDeleteBind(spread, function (sheet) {
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ let calc = false;
|
|
|
+ if (sel) {
|
|
|
+ for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
|
|
|
+ if (iRow === 3) continue;
|
|
|
+ for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
|
|
|
+ if (iCol !== 2) continue;
|
|
|
+ sheet.setText(iRow, iCol, '0');
|
|
|
+ if (iRow === 1 || iRow === 2) calc = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (calc) calcHtjMinusZlj();
|
|
|
+ });
|
|
|
+ spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
|
|
|
+ let bHint = false;
|
|
|
+ for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
|
|
|
+ const curRow = info.cellRange.row + iRow;
|
|
|
+ for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
|
|
|
+ const curCol = info.cellRange.col + iCol;
|
|
|
+ const value = _.toNumber(info.sheet.getText(curRow, curCol));
|
|
|
+ if (_.isNaN(value) || !_.isInteger(value)) {
|
|
|
+ bHint = true;
|
|
|
+ info.sheet.setText(curRow, curCol, '0');
|
|
|
+ } else if (value > 6) {
|
|
|
+ bHint = true;
|
|
|
+ info.sheet.setText(curRow, curCol, '6');
|
|
|
+ } else if (value < 0) {
|
|
|
+ bHint = true;
|
|
|
+ info.sheet.setText(curRow, curCol, '0');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bHint) {
|
|
|
+ toast('请输入0-6的整数', 'warning');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ function loadPrecisonProperty() {
|
|
|
+ $('#hint-3').hide();
|
|
|
+ sheet.setValue(1, 2, property.precision.t.value);
|
|
|
+ sheet.setValue(2, 2, property.precision.km.value);
|
|
|
+ sheet.setValue(3, 2, property.precision.m.value);
|
|
|
+ sheet.setValue(4, 2, property.precision.m2.value);
|
|
|
+ sheet.setValue(5, 2, property.precision.m3.value);
|
|
|
+ sheet.setValue(6, 2, property.precision.kg.value);
|
|
|
+ sheet.setValue(7, 2, property.precision.ge.value);
|
|
|
+ sheet.setValue(8, 2, property.precision.tai.value);
|
|
|
+ sheet.setValue(9, 2, property.precision.tao.value);
|
|
|
+ sheet.setValue(10, 2, property.precision.ke.value);
|
|
|
+ sheet.setValue(11, 2, property.precision.zu.value);
|
|
|
+ sheet.setValue(12, 2, property.precision.xitong.value);
|
|
|
+ sheet.setValue(13, 2, property.precision.other.value);
|
|
|
+ }
|
|
|
+ function setReadOnly(readOnly) {
|
|
|
+ sheet.getRange(1, 2, 14, 1).locked(readOnly);
|
|
|
+ }
|
|
|
+ function getNewPrecisionData() {
|
|
|
+ const precision = JSON.parse(JSON.stringify(property.precision));
|
|
|
+ precision.t.value = _.toNumber(sheet.getText(1, 2));
|
|
|
+ precision.km.value = _.toNumber(sheet.getText(2, 2));
|
|
|
+ precision.m.value = _.toNumber(sheet.getText(3, 2));
|
|
|
+ precision.m2.value = _.toNumber(sheet.getText(4, 2));
|
|
|
+ precision.m3.value = _.toNumber(sheet.getText(5, 2));
|
|
|
+ precision.kg.value = _.toNumber(sheet.getText(6, 2));
|
|
|
+ precision.ge.value = _.toNumber(sheet.getText(7, 2));
|
|
|
+ precision.tai.value = _.toNumber(sheet.getText(8, 2));
|
|
|
+ precision.tao.value = _.toNumber(sheet.getText(9, 2));
|
|
|
+ precision.ke.value = _.toNumber(sheet.getText(10, 2));
|
|
|
+ precision.zu.value = _.toNumber(sheet.getText(11, 2));
|
|
|
+ precision.xitong.value = _.toNumber(sheet.getText(12, 2));
|
|
|
+ precision.other.value = _.toNumber(sheet.getText(13, 2));
|
|
|
+ }
|
|
|
+
|
|
|
+ return {loadPrecisonProperty, setReadOnly, getNewPrecisionData, };
|
|
|
+ })();
|
|
|
+ // 合同参数
|
|
|
+ const dealObj = (function () {
|
|
|
+ const spread = SpreadJsObj.createNewSpread($('#param-spread')[0]);
|
|
|
+ spread.options.showVerticalScrollbar = false;
|
|
|
+ spread.options.showHorizontalScrollbar = false;
|
|
|
+ const sheet = spread.getActiveSheet();
|
|
|
+ SpreadJsObj.protectedSheet(sheet);
|
|
|
+ SpreadJsObj.massOperationSheet(sheet, function () {
|
|
|
+ sheet.options.rowHeaderVisible = false;
|
|
|
+ sheet.options.colHeaderVisible = false;
|
|
|
+ sheet.defaults.rowHeight = 35;
|
|
|
+ sheet.setColumnCount(3);
|
|
|
+ sheet.setRowCount(6);
|
|
|
+ sheet.setColumnWidth(0, 1);
|
|
|
+ sheet.setColumnWidth(1, 200);
|
|
|
+ sheet.setColumnWidth(2, 200);
|
|
|
+ sheet.setRowHeight(0, 1);
|
|
|
+ sheet.getRange(1, 1, 5, 1).vAlign(1).backColor('#e4e7ea').locked(true);
|
|
|
+ sheet.getRange(1, 2, 5, 1).vAlign(1).hAlign(2).locked(true);
|
|
|
+ sheet.setText(1, 1, '签约合同价');
|
|
|
+ sheet.setText(2, 1, '暂列金额');
|
|
|
+ sheet.setText(3, 1, '签约合同价(不含暂列金)');
|
|
|
+ sheet.setText(4, 1, '签约开工预付款');
|
|
|
+ sheet.setText(5, 1, '签约材料预付款');
|
|
|
+ const lineBorder = new spreadNS.LineBorder('#6a696e', spreadNS.LineStyle.thin);
|
|
|
+ sheet.getRange(0, 0, 6, 3).setBorder(lineBorder, {all: true});
|
|
|
+ sheet.getRange(0, 0, 6, 3).formatter('@');
|
|
|
+ sheet.setSelection(1, 2, 1, 1);
|
|
|
+ });
|
|
|
+
|
|
|
+ function calcHtjMinusZlj() {
|
|
|
+ const htj = _.toNumber(sheet.getText(1, 2));
|
|
|
+ const zlj = _.toNumber(sheet.getText(2, 2));
|
|
|
+ sheet.setValue(3, 2, accSub(zlj, htj));
|
|
|
+ }
|
|
|
+
|
|
|
+ spread.bind(spreadNS.Events.EditEnded, function (e, info) {
|
|
|
+ const value = _.toNumber(info.editingText);
|
|
|
+ if (_.isNaN(value)) {
|
|
|
+ toast('请输入不超过万亿的数字', 'warning');
|
|
|
+ info.sheet.setText(info.row, info.col, '0');
|
|
|
+ } else if (value > Math.pow(10, 13)) {
|
|
|
+ toast('请输入不超过万亿的数字', 'warning');
|
|
|
+ info.sheet.setText(info.row, info.col, '0');
|
|
|
+ }
|
|
|
+ if (info.row === 1 || info.row === 2) {
|
|
|
+ calcHtjMinusZlj();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ SpreadJsObj.addDeleteBind(spread, function (sheet) {
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ let calc = false;
|
|
|
+ if (sel) {
|
|
|
+ for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
|
|
|
+ if (iRow === 3) continue;
|
|
|
+ for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
|
|
|
+ if (iCol !== 2) continue;
|
|
|
+ sheet.setText(iRow, iCol, '0');
|
|
|
+ if (iRow === 1 || iRow === 2) calc = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (calc) calcHtjMinusZlj();
|
|
|
+ });
|
|
|
+ spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
|
|
|
+ let bHint = false;
|
|
|
+ for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
|
|
|
+ const curRow = info.cellRange.row + iRow;
|
|
|
+ for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
|
|
|
+ const curCol = info.cellRange.col + iCol;
|
|
|
+ const value = _.toNumber(info.sheet.getText(curRow, curCol));
|
|
|
+ if (_.isNaN(value) || value > Math.pow(10, 13)) {
|
|
|
+ bHint = true;
|
|
|
+ info.sheet.setText(curRow, curCol, '0');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bHint) {
|
|
|
+ toast('请输入不超过万亿的数字', 'warning');
|
|
|
+ }
|
|
|
+ calcHtjMinusZlj();
|
|
|
+ });
|
|
|
+
|
|
|
+ function loadDealProperty() {
|
|
|
+ $('#hint-4').hide();
|
|
|
+ sheet.setValue(1, 2, property.deal_param.contractPrice);
|
|
|
+ sheet.setValue(2, 2, property.deal_param.zanLiePrice);
|
|
|
+ sheet.setValue(3, 2, accSub(property.deal_param.zanLiePrice, property.deal_param.contractPrice));
|
|
|
+ sheet.setValue(4, 2, property.deal_param.startAdvance);
|
|
|
+ sheet.setValue(5, 2, property.deal_param.materialAdvance);
|
|
|
+
|
|
|
+ }
|
|
|
+ function setReadOnly (readOnly) {
|
|
|
+ sheet.getCell(1, 2).locked(readOnly);
|
|
|
+ sheet.getCell(2, 2).locked(readOnly);
|
|
|
+ sheet.getCell(4, 2).locked(readOnly);
|
|
|
+ sheet.getCell(5, 2).locked(readOnly);
|
|
|
+ }
|
|
|
+ function getNewDealData () {
|
|
|
+ const result = {};
|
|
|
+ result.contractPrice = _.toNumber(sheet.getText(1, 2));
|
|
|
+ result.zanLiePrice = _.toNumber(sheet.getText(2, 2));
|
|
|
+ result.startAdvance = _.toNumber(sheet.getText(4, 2));
|
|
|
+ result.materialAdvance = _.toNumber(sheet.getText(5, 2));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return { loadDealProperty, setReadOnly, getNewDealData, };
|
|
|
+ })();
|
|
|
// 章节设置
|
|
|
const chapterObj = (function () {
|
|
|
const spreadSetting = {
|
|
@@ -253,8 +489,8 @@ $(document).ready(function() {
|
|
|
// 加载属性
|
|
|
loadCommonProperty();
|
|
|
loadCalculateProperty();
|
|
|
- loadPrecisionProperty();
|
|
|
- loadDealProperty();
|
|
|
+ precisionObj.loadPrecisonProperty();
|
|
|
+ dealObj.loadDealProperty();
|
|
|
loadDisplayProperty();
|
|
|
chapterObj.loadChapterProperty();
|
|
|
// 设置只读
|
|
@@ -375,36 +611,23 @@ $(document).ready(function() {
|
|
|
*/
|
|
|
// 编辑
|
|
|
$('#edit-3').click(() => {
|
|
|
- setReadOnly('#v-pills-3', false);
|
|
|
+ precisionObj.setReadOnly(false);
|
|
|
$('#post-3').parent().show();
|
|
|
$('#edit-3').parent().hide();
|
|
|
});
|
|
|
// 取消
|
|
|
$('#cancel-3').click(() => {
|
|
|
- setReadOnly('#v-pills-3', true);
|
|
|
- loadPrecisionProperty();
|
|
|
+ precisionObj.setReadOnly(true);
|
|
|
+ precisionObj.loadPrecisonProperty();
|
|
|
$('#post-3').parent().hide();
|
|
|
$('#edit-3').parent().show();
|
|
|
});
|
|
|
// 提交
|
|
|
$('#post-3').click(() => {
|
|
|
- const prop = { precision: JSON.parse(JSON.stringify(property.precision)) };
|
|
|
- prop.precision.t.value = _.toNumber($('#unit-t').val());
|
|
|
- prop.precision.km.value = _.toNumber($('#unit-km').val());
|
|
|
- prop.precision.m.value = _.toNumber($('#unit-m').val());
|
|
|
- prop.precision.m2.value = _.toNumber($('#unit-m2').val());
|
|
|
- prop.precision.m3.value = _.toNumber($('#unit-m3').val());
|
|
|
- prop.precision.kg.value = _.toNumber($('#unit-kg').val());
|
|
|
- prop.precision.ge.value = _.toNumber($('#unit-ge').val());
|
|
|
- prop.precision.tai.value = _.toNumber($('#unit-tai').val());
|
|
|
- prop.precision.tao.value = _.toNumber($('#unit-tao').val());
|
|
|
- prop.precision.ke.value = _.toNumber($('#unit-ke').val());
|
|
|
- prop.precision.zu.value = _.toNumber($('#unit-zu').val());
|
|
|
- prop.precision.xitong.value = _.toNumber($('#unit-xitong').val());
|
|
|
- prop.precision.other.value = _.toNumber($('#unit-other').val());
|
|
|
+ const prop = { precision: precisionObj.getNewPrecisionData() };
|
|
|
const tenderId = window.location.pathname.split('/')[2];
|
|
|
postData('/tender/' + tenderId + '/save', prop, function (data) {
|
|
|
- setReadOnly('#v-pills-3', true);
|
|
|
+ precisionObj.setReadOnly(true);
|
|
|
property.precision = data.precision;
|
|
|
$('#post-3').parent().hide();
|
|
|
$('#edit-3').parent().show();
|
|
@@ -416,30 +639,23 @@ $(document).ready(function() {
|
|
|
*/
|
|
|
// 编辑
|
|
|
$('#edit-4').click(() => {
|
|
|
- setReadOnly('#v-pills-4', false);
|
|
|
+ dealObj.setReadOnly(false);
|
|
|
$('#post-4').parent().show();
|
|
|
$('#edit-4').parent().hide();
|
|
|
});
|
|
|
// 取消
|
|
|
$('#cancel-4').click(() => {
|
|
|
- setReadOnly('#v-pills-4', true);
|
|
|
- loadDealProperty();
|
|
|
+ dealObj.setReadOnly(true);
|
|
|
+ dealObj.loadDealProperty();
|
|
|
$('#post-4').parent().hide();
|
|
|
$('#edit-4').parent().show();
|
|
|
});
|
|
|
// 提交
|
|
|
$('#post-4').click(() => {
|
|
|
- const prop = {
|
|
|
- deal_param: {
|
|
|
- contractPrice: _.toNumber($('#contract-price').val()),
|
|
|
- zanLiePrice: _.toNumber($('#zan-lie-price').val()),
|
|
|
- startAdvance: _.toNumber($('#start-advance').val()),
|
|
|
- materialAdvance: _.toNumber($('#material-advance').val()),
|
|
|
- }
|
|
|
- };
|
|
|
+ const prop = { deal_param: dealObj.getNewDealData() };
|
|
|
const tenderId = window.location.pathname.split('/')[2];
|
|
|
postData('/tender/' + tenderId + '/save', prop, function (data) {
|
|
|
- setReadOnly('#v-pills-4', true);
|
|
|
+ dealObj.setReadOnly(true);
|
|
|
property.deal_param = data.deal_param;
|
|
|
$('#post-4').parent().hide();
|
|
|
$('#edit-4').parent().show();
|