|
@@ -0,0 +1,449 @@
|
|
|
+const is_numeric = (value) => {
|
|
|
+ if (typeof(value) === 'object') {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
|
|
|
+ }
|
|
|
+};
|
|
|
+function getPasteHint (str, row = '') {
|
|
|
+ let returnObj = str;
|
|
|
+ if (row) {
|
|
|
+ returnObj.msg = '指数清单第' + (row+1) + '行' + str.msg;
|
|
|
+ }
|
|
|
+ return returnObj;
|
|
|
+}
|
|
|
+function resetExTpTable() {
|
|
|
+ const rate = $('#changeRate').val();
|
|
|
+ const bqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), 2);
|
|
|
+ const jzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, bqhs), 2);
|
|
|
+ $('#tp_set').find('td').eq(3).text(ZhCalc.round(ex_tp, 2));
|
|
|
+ $('#tp_set').find('td').eq(4).text(ZhCalc.round(ZhCalc.add(ex_pre_tp, ex_tp), 2));
|
|
|
+ $('#rate_set').find('td').eq(3).text(bqhs !== 0 ? bqhs : '');
|
|
|
+ $('#rate_set').find('td').eq(4).text(jzbqhs !== 0 ? jzbqhs : '');
|
|
|
+ $('#ex_expr').html(ex_expr);
|
|
|
+}
|
|
|
+$(document).ready(() => {
|
|
|
+ autoFlashHeight();
|
|
|
+ const materialExponentSpread = SpreadJsObj.createNewSpread($('#material-exponent-spread')[0]);
|
|
|
+ const materialExponentSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '类型', colSpan: '1', rowSpan: '2', field: 'type', hAlign: 1, width: 60, formatter: '@', readOnly: true,cellType: 'customizeCombo', comboItems: materialType.ex_type, cellTypeKey: 1},
|
|
|
+ {title: '符号', colSpan: '1', rowSpan: '2', field: 'symbol', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '符号说明', colSpan: '1', rowSpan: '2', field: 'symbol_desc', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '加权系数', colSpan: '1', rowSpan: '2', field: 'weight_num', hAlign: 2, width: 120, formatter: '@', readOnly: 'readOnly.isConstant'},
|
|
|
+ {title: '基本价格指数', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 120, readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '现行价格指数', colSpan: '1', rowSpan: '2', field: 'm_price', hAlign: 2, width: 120, type: 'Number', readOnly: 'readOnly.remark'},
|
|
|
+ {title: '计算值', colSpan: '1', rowSpan: '2', field: 'calc_num', hAlign: 2, width: 80, formatter: '@', readOnly: true},
|
|
|
+ {title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.remark'},
|
|
|
+ {title: '是否汇总', colSpan: '1', rowSpan: '2', field: 'is_summary', hAlign: 1, width: 60, cellType: 'checkbox', readOnly: 'readOnly.isEdit'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 2,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: readOnly,
|
|
|
+ };
|
|
|
+ const materialExponentBase = {
|
|
|
+ isUsed: function (data) {
|
|
|
+ if (data.type === 2) {
|
|
|
+ return data.mid === materialID;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isEdit: function (data) {
|
|
|
+ return data.mid === materialID && data.type === 2;
|
|
|
+ },
|
|
|
+ isConstant: function (data) {
|
|
|
+ return (materialOrder === 1 && data.type === 1) || (data.mid === materialID && data.type === 2);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const materialExponentCol = {
|
|
|
+ getValue: {
|
|
|
+ calc_num : function (data) {
|
|
|
+ const calc_num = data.basic_price > 0 ? ZhCalc.mul(data.weight_num, ZhCalc.div(data.m_price, data.basic_price)) : 0;
|
|
|
+ return calc_num > 0 ? ZhCalc.round(calc_num, 3) : 0;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ readOnly: {
|
|
|
+ isEdit: function (data) {
|
|
|
+ return !(!readOnly && materialExponentBase.isEdit(data));
|
|
|
+ },
|
|
|
+ isUsed: function (data) {
|
|
|
+ return !(!readOnly && materialExponentBase.isUsed(data));
|
|
|
+ },
|
|
|
+ remark: function (data) {
|
|
|
+ return !(!readOnly && data.type === 2);
|
|
|
+ },
|
|
|
+ isConstant: function (data) {
|
|
|
+ return !(!readOnly && materialExponentBase.isConstant(data));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ };
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(materialExponentSpreadSetting, materialExponentCol);
|
|
|
+ SpreadJsObj.initSheet(materialExponentSpread.getActiveSheet(), materialExponentSpreadSetting);
|
|
|
+ SpreadJsObj.loadSheetData(materialExponentSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialExponentData);
|
|
|
+
|
|
|
+ const materialExponentSpreadObj = {
|
|
|
+ refreshActn: function (rowCount = 1) {
|
|
|
+ const setObjEnable = function (obj, enable) {
|
|
|
+ if (enable) {
|
|
|
+ obj.removeClass('disabled');
|
|
|
+ } else {
|
|
|
+ obj.addClass('disabled');
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const sheet = materialExponentSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ // 还需判断是否已被调差清单调用
|
|
|
+ setObjEnable($('#del'), !readOnly && select && materialExponentBase.isUsed(select) && rowCount === 1);
|
|
|
+ },
|
|
|
+ add: function () {
|
|
|
+ const sheet = materialExponentSpread.getActiveSheet();
|
|
|
+ postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
|
|
|
+ if (result) {
|
|
|
+ materialExponentData.push(result);
|
|
|
+ sheet.addRows(materialExponentData.length - 1, 1);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, materialExponentData.length - 1);
|
|
|
+ sheet.setSelection(materialExponentData.length - 1, 0, 1, 1);
|
|
|
+ materialExponentSpreadObj.refreshActn();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ del: function () {
|
|
|
+ const sheet = materialExponentSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
|
|
|
+ ex_tp = result.ex_tp;
|
|
|
+ ex_expr = result.ex_expr;
|
|
|
+ resetExTpTable();
|
|
|
+ const index = materialExponentData.indexOf(select);
|
|
|
+ materialExponentData.splice(index, 1);
|
|
|
+ sheet.deleteRows(index, 1);
|
|
|
+ const sel = sheet.getSelections();
|
|
|
+ sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
|
+ materialExponentSpreadObj.refreshActn();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ selectionChanged: function (e, info) {
|
|
|
+ const sel = info.sheet.getSelections()[0];
|
|
|
+ const col = info.sheet.zh_setting.cols[sel.col];
|
|
|
+ materialExponentSpreadObj.refreshActn(sel.rowCount);
|
|
|
+ const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ materialExponentSpreadObj.setReadOnly(true);
|
|
|
+ },
|
|
|
+ editEnded: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if (col.field === 'is_summary') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 未改变值则不提交
|
|
|
+ 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 (col.field === 'basic_price' || col.field === 'm_price') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const num = parseFloat(validText);
|
|
|
+ if (validText !== null && (num < 0 || num > 100 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
+ toastr.error('请输入0~100范围内并且小于3位小数的浮点数');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (col.field === 'weight_num') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const num = parseFloat(validText);
|
|
|
+ if (validText !== null && (num < 0 || num >= 1 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
+ toastr.error('请输入0~1范围内并且小于3位小数的浮点数');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const total_weight = ZhCalc.add(ZhCalc.sub(_.sumBy(materialExponentData, 'weight_num'), parseFloat(orgValue)), num);
|
|
|
+ if (total_weight > 1) {
|
|
|
+ toastr.error('加权系数总和不能大于1');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ select[col.field] = validText;
|
|
|
+ select.calc_num = materialExponentCol.getValue.calc_num(select);
|
|
|
+ // console.log(select);
|
|
|
+
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
+ ex_tp = result.ex_tp;
|
|
|
+ ex_expr = result.ex_expr;
|
|
|
+ resetExTpTable();
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ materialExponentData.splice(info.row, 1, select);
|
|
|
+ }, function () {
|
|
|
+ select[col.field] = orgValue;
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ buttonClicked: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if (materialExponentCol.readOnly.isEdit(select)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (col.field === 'is_summary') {
|
|
|
+ if (info.sheet.isEditing()) {
|
|
|
+ info.sheet.endEdit(true);
|
|
|
+ }
|
|
|
+ select.is_summary = info.sheet.getValue(info.row, info.col) ? 1 : 0;
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
+ ex_tp = result.ex_tp;
|
|
|
+ ex_expr = result.ex_expr;
|
|
|
+ resetExTpTable();
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ }, function () {
|
|
|
+ select.is_summary = info.sheet.getValue(info.row, info.col) ? 0 : 1;
|
|
|
+ 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~100范围内并且小于3位小数的浮点数'},
|
|
|
+ numberCan2: {type: 'error', msg: '请粘贴0~1范围内并且小于3位小数的浮点数'},
|
|
|
+ weightNumberCan: {type: 'error', msg: '粘贴的加权系数总和不能大于1'},
|
|
|
+ };
|
|
|
+ const range = info.cellRange;
|
|
|
+ const sortData = info.sheet.zh_data || [];
|
|
|
+ if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
|
|
|
+ toastMessageUniq(hint.cellError);
|
|
|
+ // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
+ SpreadJsObj.reLoadSheetHeader(materialExponentSpread.getActiveSheet());
|
|
|
+ SpreadJsObj.reLoadSheetData(materialExponentSpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (sortData.length > 0 && range.col + range.colCount > 10) {
|
|
|
+ toastMessageUniq(hint.cellError);
|
|
|
+ SpreadJsObj.reLoadSheetHeader(materialExponentSpread.getActiveSheet());
|
|
|
+ SpreadJsObj.reLoadSheetData(materialExponentSpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = [];
|
|
|
+ // const rowData = [];
|
|
|
+ for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
+ let bPaste = true;
|
|
|
+ const curRow = range.row + iRow;
|
|
|
+ // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
|
|
|
+ const materialExData = { id: sortData[curRow].id };
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ if (colSetting.field === 'basic_price' || colSetting.field === 'm_price') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const num = parseFloat(validText);
|
|
|
+ if (validText !== null && (num < 0 || num > 100 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (colSetting.field === 'weight_num') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const num = parseFloat(validText);
|
|
|
+ if (validText !== null && (num < 0 || num >= 1 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberCan2, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const total_weight = ZhCalc.add(ZhCalc.sub(_.sumBy(materialExponentData, 'weight_num'), parseFloat(orgValue)), num);
|
|
|
+ console.log(total_weight, _.sumBy(materialExponentData, 'weight_num'), orgValue, num);
|
|
|
+ if (total_weight > 1) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.weightNumberCan, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ materialExData[colSetting.field] = validText;
|
|
|
+ sortData[curRow][colSetting.field] = validText;
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ materialExData.calc_num = materialExponentCol.getValue.calc_num(sortData[curRow]);
|
|
|
+ data.push(materialExData);
|
|
|
+ // rowData.push(curRow);
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.length === 0) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // console.log(data);
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
|
|
|
+ materialExponentData = result.info;
|
|
|
+ SpreadJsObj.loadSheetData(materialExponentSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialExponentData);
|
|
|
+ ex_tp = result.ex_tp;
|
|
|
+ ex_expr = result.ex_expr;
|
|
|
+ resetExTpTable();
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ setReadOnly: function(readOnly) {
|
|
|
+ // SpreadJsObj.resetFieldReadOnly(materialSpread.getActiveSheet(), 'msg_spread', 'm_spread', 'm_tp', 'pre_tp', readOnly);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ materialExponentSpreadObj.refreshActn();
|
|
|
+ materialExponentSpread.bind(spreadNS.Events.SelectionChanged, materialExponentSpreadObj.selectionChanged);
|
|
|
+ materialExponentSpread.bind(spreadNS.Events.ClipboardPasted, materialExponentSpreadObj.clipboardPasted);
|
|
|
+ SpreadJsObj.addDeleteBind(materialExponentSpread, materialExponentSpreadObj.deletePress);
|
|
|
+
|
|
|
+ if (!readOnly) {
|
|
|
+ $('#add').click(materialExponentSpreadObj.add);
|
|
|
+ $('#del').click(materialExponentSpreadObj.del);
|
|
|
+ materialExponentSpread.bind(spreadNS.Events.EditEnded, materialExponentSpreadObj.editEnded);
|
|
|
+ materialExponentSpread.bind(spreadNS.Events.ButtonClicked, materialExponentSpreadObj.buttonClicked);
|
|
|
+ // 右键菜单
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#material-exponent-spread',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ const target = SpreadJsObj.safeRightClickSelection($trigger, e, materialExponentSpread);
|
|
|
+ return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
+ },
|
|
|
+ items: {
|
|
|
+ 'create': {
|
|
|
+ name: '新增',
|
|
|
+ icon: 'fa-sign-in',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ materialExponentSpreadObj.add(materialExponentSpread.getActiveSheet());
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 'delete': {
|
|
|
+ name: '删除',
|
|
|
+ icon: 'fa-remove',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ materialExponentSpreadObj.del(materialExponentSpread.getActiveSheet());
|
|
|
+ },
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const sheet = materialExponentSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ materialExponentSpreadObj.refreshActn(sel.rowCount);
|
|
|
+ if (!readOnly && select && materialExponentBase.isUsed(select) && sel.rowCount === 1) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 调差基数选中
|
|
|
+ $('.calc_select').on('click', function () {
|
|
|
+ for (const calc of ex_calc) {
|
|
|
+ calc.select = $('.calc_select[value="'+ calc.code +'"]').is(':checked');
|
|
|
+ }
|
|
|
+ postData(window.location.pathname + '/save', { type:'ex_calc', updateData: ex_calc }, function (result) {
|
|
|
+ ex_tp = result.ex_tp;
|
|
|
+ ex_expr = result.ex_expr;
|
|
|
+ resetExTpTable();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#changeRate').change(function () {
|
|
|
+ const rate = parseInt($(this).val());
|
|
|
+ postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
|
|
|
+ const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
|
|
|
+ const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), 2);
|
|
|
+ const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), 2);
|
|
|
+ const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), 2);
|
|
|
+ $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
|
|
|
+ $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
|
|
|
+ $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
|
|
|
+ $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $.divResizer({
|
|
|
+ select: '#right-spr',
|
|
|
+ callback: function () {
|
|
|
+ materialExponentSpread.refresh();
|
|
|
+ const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
|
|
|
+ // setLocalCache('material_month_' + materialID, width);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 展开收起月信息价并浏览器记住本期展开收起
|
|
|
+ $('a', '.right-nav').bind('click', function () {
|
|
|
+ //const main = $('#main-view'), tool = $('#tools-view');
|
|
|
+ const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
+ if (!tab.hasClass('active')) {
|
|
|
+ $('a', '.side-menu').removeClass('active');
|
|
|
+ $('.tab-content .tab-select-show').removeClass('active');
|
|
|
+ tab.addClass('active');
|
|
|
+ tabPanel.addClass('active');
|
|
|
+ showSideTools(tab.hasClass('active'));
|
|
|
+ if (tab.attr('content') === '#base-tab') {
|
|
|
+ const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
|
|
|
+ // setLocalCache('material_month_' + materialID, width);
|
|
|
+ // materialMonthSpread.refresh();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // removeLocalCache('material_month_' + materialID);
|
|
|
+ tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
+ showSideTools(tab.hasClass('active'));
|
|
|
+ }
|
|
|
+ // materialSpread.refresh();
|
|
|
+ materialExponentSpread.refresh();
|
|
|
+ });
|
|
|
+});
|