|
@@ -72,15 +72,15 @@ DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle,
|
|
};
|
|
};
|
|
|
|
|
|
function resetTpTable() {
|
|
function resetTpTable() {
|
|
- $('#tp_set').find('td').eq(1).text(ZhCalc.round(m_tp, 2));
|
|
|
|
- $('#tp_set').find('td').eq(2).text(ZhCalc.round(ZhCalc.add(pre_tp, m_tp), 2));
|
|
|
|
|
|
+ $('#tp_set').find('td').eq(1).text(ZhCalc.round(m_tp, materialDecimal.tp));
|
|
|
|
+ $('#tp_set').find('td').eq(2).text(ZhCalc.round(ZhCalc.add(pre_tp, m_tp), materialDecimal.tp));
|
|
if (materialTax) {
|
|
if (materialTax) {
|
|
- $('#tax_rate_set').find('td').eq(1).text(ZhCalc.round(m_tax_tp, 2));
|
|
|
|
- $('#tax_rate_set').find('td').eq(2).text(ZhCalc.round(ZhCalc.add(m_tax_pre_tp, m_tax_tp), 2));
|
|
|
|
|
|
+ $('#tax_rate_set').find('td').eq(1).text(ZhCalc.round(m_tax_tp, materialDecimal.tp));
|
|
|
|
+ $('#tax_rate_set').find('td').eq(2).text(ZhCalc.round(ZhCalc.add(m_tax_pre_tp, m_tax_tp), materialDecimal.tp));
|
|
} else {
|
|
} else {
|
|
const rate = $('#changeRate').val();
|
|
const rate = $('#changeRate').val();
|
|
- const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
|
|
|
|
- const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), 2);
|
|
|
|
|
|
+ const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
|
|
|
|
+ const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
|
|
$('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
|
|
$('#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(2).text(jzbqhs !== 0 ? jzbqhs : '');
|
|
}
|
|
}
|
|
@@ -129,7 +129,7 @@ $(document).ready(() => {
|
|
{title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 70, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
{title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 70, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
{title: '本期信息价|单价', colSpan: '3|1', rowSpan: '1|1', field: 'msg_tp', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.msg_tp'},
|
|
{title: '本期信息价|单价', colSpan: '3|1', rowSpan: '1|1', field: 'msg_tp', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.msg_tp'},
|
|
{title: '|时间', colSpan: '|1', rowSpan: '|1', field: 'msg_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.remark'},
|
|
{title: '|时间', colSpan: '|1', rowSpan: '|1', field: 'msg_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.remark'},
|
|
- {title: '|价差', colSpan: '|1', rowSpan: '|1', field: 'msg_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.msg_spread'},]
|
|
|
|
|
|
+ {title: '|单价差', colSpan: '|1', rowSpan: '|1', field: 'msg_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.msg_spread'},]
|
|
);
|
|
);
|
|
if (materialTax) {
|
|
if (materialTax) {
|
|
materialSpreadSettingCols = _.concat(materialSpreadSettingCols, [
|
|
materialSpreadSettingCols = _.concat(materialSpreadSettingCols, [
|
|
@@ -209,19 +209,19 @@ $(document).ready(() => {
|
|
const materialCol = {
|
|
const materialCol = {
|
|
getValue: {
|
|
getValue: {
|
|
msg_spread: function (data) {
|
|
msg_spread: function (data) {
|
|
- return ZhCalc.round(ZhCalc.sub(data.msg_tp, data.basic_price), 3);
|
|
|
|
|
|
+ return ZhCalc.round(ZhCalc.sub(data.msg_tp, data.basic_price), materialDecimal.up);
|
|
},
|
|
},
|
|
m_spread : function (data) {
|
|
m_spread : function (data) {
|
|
const msg_spread = materialCol.getValue.msg_spread(data);
|
|
const msg_spread = materialCol.getValue.msg_spread(data);
|
|
const cor = msg_spread >= 0 ? ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_up_risk, 100)) : ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_down_risk, 100));
|
|
const cor = msg_spread >= 0 ? ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_up_risk, 100)) : ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_down_risk, 100));
|
|
- return Math.abs(msg_spread) > Math.abs(cor) ? (msg_spread > 0 ? ZhCalc.round(ZhCalc.sub(msg_spread, cor), 3) : ZhCalc.round(ZhCalc.add(msg_spread, cor), 3)) : 0;
|
|
|
|
|
|
+ return Math.abs(msg_spread) > Math.abs(cor) ? (msg_spread > 0 ? ZhCalc.round(ZhCalc.sub(msg_spread, cor), materialDecimal.up) : ZhCalc.round(ZhCalc.add(msg_spread, cor), materialDecimal.up)) : 0;
|
|
},
|
|
},
|
|
m_tp: function (data) {
|
|
m_tp: function (data) {
|
|
- return ZhCalc.round(ZhCalc.mul(materialCol.getValue.m_spread(data), data.quantity), 2);
|
|
|
|
|
|
+ return ZhCalc.round(ZhCalc.mul(materialCol.getValue.m_spread(data), data.quantity), materialDecimal.tp);
|
|
},
|
|
},
|
|
m_tax_tp: function (data) {
|
|
m_tax_tp: function (data) {
|
|
- const m_tp = ZhCalc.round(ZhCalc.mul(materialCol.getValue.m_spread(data), data.quantity), 2);
|
|
|
|
- return data.m_tax ? ZhCalc.round(ZhCalc.mul(m_tp, (1+ZhCalc.div(data.m_tax, 100))), 2) : m_tp;
|
|
|
|
|
|
+ const m_tp = ZhCalc.round(ZhCalc.mul(materialCol.getValue.m_spread(data), data.quantity), materialDecimal.tp);
|
|
|
|
+ return data.m_tax ? ZhCalc.round(ZhCalc.mul(m_tp, (1+ZhCalc.div(data.m_tax, 100))), materialDecimal.tp) : m_tp;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
readOnly: {
|
|
readOnly: {
|
|
@@ -401,12 +401,10 @@ $(document).ready(() => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
let num = parseFloat(validText);
|
|
let num = parseFloat(validText);
|
|
- if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
|
- toastr.warning('已保留3位小数');
|
|
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
|
- // toastr.error('请输入大于0并且小于3位小数的浮点数');
|
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
- // return;
|
|
|
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ materialDecimal.up +"})?$");
|
|
|
|
+ if (validText !== null && (num < 0 || !reg.test(num))) {
|
|
|
|
+ toastr.warning('已保留'+ materialDecimal.up +'位小数');
|
|
|
|
+ validText = ZhCalc.round(num, materialDecimal.up);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (col.field === 'msg_tp') {
|
|
if (col.field === 'msg_tp') {
|
|
@@ -416,12 +414,10 @@ $(document).ready(() => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
const num = parseFloat(validText);
|
|
const num = parseFloat(validText);
|
|
- if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
|
- toastr.warning('已保留3位小数');
|
|
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
|
- // toastr.error('请输入大于0并且小于3位小数的浮点数');
|
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
- // return;
|
|
|
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ materialDecimal.up +"})?$");
|
|
|
|
+ if (validText !== null && (num < 0 || !reg.test(num))) {
|
|
|
|
+ toastr.warning('已保留'+ materialDecimal.up +'位小数');
|
|
|
|
+ validText = ZhCalc.round(num, materialDecimal.up);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (col.field === 'm_up_risk' || col.field === 'm_down_risk' || col.field === 'm_tax') {
|
|
if (col.field === 'm_up_risk' || col.field === 'm_down_risk' || col.field === 'm_tax') {
|
|
@@ -512,7 +508,7 @@ $(document).ready(() => {
|
|
codeError: {type: 'error', msg: '编号为纯数字时,不能为小数'},
|
|
codeError: {type: 'error', msg: '编号为纯数字时,不能为小数'},
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
riskCan: {type: 'error', msg: '只能粘贴0-100的正整数'},
|
|
riskCan: {type: 'error', msg: '只能粘贴0-100的正整数'},
|
|
- numberCan: {type: 'warning', msg: '已保留3位小数'},
|
|
|
|
|
|
+ numberCan: {type: 'warning', msg: '已保留'+ materialDecimal.up +'位小数'},
|
|
};
|
|
};
|
|
const range = info.cellRange;
|
|
const range = info.cellRange;
|
|
const sortData = info.sheet.zh_data || [];
|
|
const sortData = info.sheet.zh_data || [];
|
|
@@ -581,11 +577,10 @@ $(document).ready(() => {
|
|
}
|
|
}
|
|
const num = parseFloat(validText);
|
|
const num = parseFloat(validText);
|
|
if (colSetting.field === 'basic_price' || colSetting.field === 'msg_tp') {
|
|
if (colSetting.field === 'basic_price' || colSetting.field === 'msg_tp') {
|
|
- if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ materialDecimal.up +"})?$");
|
|
|
|
+ if (validText !== null && (num < 0 || !reg.test(num))) {
|
|
toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
|
- // bPaste = false;
|
|
|
|
- // continue;
|
|
|
|
|
|
+ validText = ZhCalc.round(num, materialDecimal.up);
|
|
}
|
|
}
|
|
} else if (colSetting.field === 'm_up_risk' || colSetting.field === 'm_down_risk' || colSetting.field === 'm_tax') {
|
|
} else if (colSetting.field === 'm_up_risk' || colSetting.field === 'm_down_risk' || colSetting.field === 'm_tax') {
|
|
if (validText !== null && (num < 0 || num > 100 || !/^\d+$/.test(num))) {
|
|
if (validText !== null && (num < 0 || num > 100 || !/^\d+$/.test(num))) {
|
|
@@ -766,7 +761,7 @@ $(document).ready(() => {
|
|
hadnum++;
|
|
hadnum++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- const average_tp = hadnum !== 0 ? ZhCalc.round(ZhCalc.div(msg_tp, hadnum), 3) : ZhCalc.round(ZhCalc.div(msg_tp, months.length), 3);
|
|
|
|
|
|
+ const average_tp = hadnum !== 0 ? ZhCalc.round(ZhCalc.div(msg_tp, hadnum), materialDecimal.up) : ZhCalc.round(ZhCalc.div(msg_tp, months.length), materialDecimal.up);
|
|
return average_tp;
|
|
return average_tp;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -812,12 +807,10 @@ $(document).ready(() => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
const num = parseFloat(validText);
|
|
const num = parseFloat(validText);
|
|
- if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
|
- // toastr.error('请输入大于0并且小于3位小数的浮点数');
|
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
- // return;
|
|
|
|
- toastr.warning('已保留3位小数');
|
|
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ materialDecimal.up +"})?$");
|
|
|
|
+ if (validText !== null && (num < 0 || !reg.test(num))) {
|
|
|
|
+ toastr.warning('已保留'+ materialDecimal.up +'位小数');
|
|
|
|
+ validText = ZhCalc.round(num, materialDecimal.up);
|
|
}
|
|
}
|
|
select[col.field] = validText;
|
|
select[col.field] = validText;
|
|
|
|
|
|
@@ -874,7 +867,7 @@ $(document).ready(() => {
|
|
const hint = {
|
|
const hint = {
|
|
cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
- numberCan: {type: 'warning', msg: '已保留3位小数'},
|
|
|
|
|
|
+ numberCan: {type: 'warning', msg: '已保留'+ materialDecimal.up +'位小数'},
|
|
};
|
|
};
|
|
const range = info.cellRange;
|
|
const range = info.cellRange;
|
|
const sortData = info.sheet.zh_data || [];
|
|
const sortData = info.sheet.zh_data || [];
|
|
@@ -922,11 +915,10 @@ $(document).ready(() => {
|
|
bPaste = false;
|
|
bPaste = false;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
|
|
|
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ materialDecimal.up +"})?$");
|
|
|
|
+ if (validText !== null && (num < 0 || !reg.test(num))) {
|
|
toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
|
- // bPaste = false;
|
|
|
|
- // continue;
|
|
|
|
|
|
+ validText = ZhCalc.round(num, materialDecimal.up);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
materialMonthData[colSetting.field] = validText;
|
|
materialMonthData[colSetting.field] = validText;
|
|
@@ -1021,10 +1013,10 @@ $(document).ready(() => {
|
|
$('#changeRate').change(function () {
|
|
$('#changeRate').change(function () {
|
|
const rate = parseInt($(this).val());
|
|
const rate = parseInt($(this).val());
|
|
postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
|
|
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);
|
|
|
|
|
|
+ const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
|
|
|
|
+ const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
|
|
|
|
+ const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
|
|
|
|
+ const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), materialDecimal.tp);
|
|
$('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
|
|
$('#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(2).text(jzbqhs !== 0 ? jzbqhs : '');
|
|
$('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
|
|
$('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
|