|
@@ -112,6 +112,41 @@ function setMonthHtml() {
|
|
|
$('#show_month').html(html);
|
|
|
$('#qi-month').html(qihtml);
|
|
|
}
|
|
|
+
|
|
|
+function monthSpreadHeaderReset() {
|
|
|
+ const newMonths = [];
|
|
|
+ for (const m of months) {
|
|
|
+ const year = m.split('-')[0];
|
|
|
+ const month = parseInt(m.split('-')[1]);
|
|
|
+ let one = _.find(newMonths, { 'year': year });
|
|
|
+ let oneIndex = _.findIndex(newMonths, { 'year': year });
|
|
|
+ if (one) {
|
|
|
+ one.month.push(month);
|
|
|
+ newMonths.splice(oneIndex, 1, one);
|
|
|
+ } else {
|
|
|
+ one = {
|
|
|
+ year: year,
|
|
|
+ month: [ month ],
|
|
|
+ };
|
|
|
+ newMonths.push(one);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const pushMonth = [];
|
|
|
+ for(const mo of newMonths) {
|
|
|
+ for (let i in mo.month) {
|
|
|
+ i = parseInt(i);
|
|
|
+ const newCols = {
|
|
|
+ title: (i === 0 ? mo.year: '') + '|' + mo.month[i] + '月',
|
|
|
+ colSpan: (i === 0 && mo.month.length === 1 ? '0' : '') + '|1',
|
|
|
+ rowSpan: i === 0 || i === mo.month.length-1 ? '1|1' : '|1',
|
|
|
+ field: mo.year + '-' + (mo.month[i] < 10 ? '0' + mo.month[i] : mo.month[i]),
|
|
|
+ hAlign: 2, width: 60, type: '@', readOnly: 'readOnly.isEdit'};
|
|
|
+ pushMonth.push(newCols);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pushMonth;
|
|
|
+}
|
|
|
+
|
|
|
$(document).ready(() => {
|
|
|
autoFlashHeight();
|
|
|
const materialSpread = SpreadJsObj.createNewSpread($('#material-spread')[0]);
|
|
@@ -128,7 +163,7 @@ $(document).ready(() => {
|
|
|
{title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 80, 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: '|1', rowSpan: '|1', field: 'msg_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.remark'},
|
|
|
- {title: '|价差', colSpan: '1', rowSpan: '1|1', field: 'msg_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.msg_spread'},
|
|
|
+ {title: '|价差', colSpan: '|1', rowSpan: '1|1', field: 'msg_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.msg_spread'},
|
|
|
{title: '本期材料调差|上涨幅度(%)', colSpan: '4|1', rowSpan: '1|1', field: 'm_up_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '|下跌幅度(%)', colSpan: '|1', rowSpan: '|1', field: 'm_down_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '|有效价差', colSpan: '|1', rowSpan: '|1', field: 'm_spread', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.m_spread'},
|
|
@@ -544,15 +579,15 @@ $(document).ready(() => {
|
|
|
// msg_range.cellType(new DatePickerCellType());
|
|
|
// msg_range.formatter("yyyy-MM-dd");
|
|
|
sheet.resumePaint();
|
|
|
-
|
|
|
+ const static_cols = [
|
|
|
+ {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 60, formatter: '@', readOnly: true},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: true},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
|
|
|
+ {title: '平均单价', colSpan: '1', rowSpan: '2', field: 'average_msg_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue:'getValue.average_msg_tp'},
|
|
|
+ ];
|
|
|
const materialMonthSpread = SpreadJsObj.createNewSpread($('#material-month-spread')[0]);
|
|
|
const materialMonthSpreadSetting = {
|
|
|
- cols: [
|
|
|
- {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 60, formatter: '@', readOnly: true},
|
|
|
- {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: true},
|
|
|
- {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
|
|
|
- {title: '平均单价', colSpan: '1', rowSpan: '2', field: 'average_msg_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue:'getValue.average_msg_tp'},
|
|
|
- ],
|
|
|
+ cols: static_cols,
|
|
|
emptyRows: 0,
|
|
|
headRows: 2,
|
|
|
headRowHeight: [25, 25],
|
|
@@ -562,12 +597,11 @@ $(document).ready(() => {
|
|
|
readOnly: readOnly,
|
|
|
};
|
|
|
if (months.length > 0) {
|
|
|
- for (const m of months) {
|
|
|
- const month = parseInt(m.split('-')[1]);
|
|
|
- const newCols = {title: month + '月|单价', colSpan: '1|1', rowSpan: '1|1', field: m, hAlign: 2, width: 60, type: '@', readOnly: 'readOnly.isEdit'};
|
|
|
- materialMonthSpreadSetting.cols.push(newCols);
|
|
|
- }
|
|
|
+ const monthCols = monthSpreadHeaderReset();
|
|
|
+ const monthSpreadHeaderCols = static_cols.concat(monthCols);
|
|
|
+ materialMonthSpreadSetting.cols = monthSpreadHeaderCols;
|
|
|
}
|
|
|
+ console.log(materialMonthSpreadSetting);
|
|
|
|
|
|
const materialMonthCol = {
|
|
|
getValue: {
|
|
@@ -941,14 +975,16 @@ $(document).ready(() => {
|
|
|
return false;
|
|
|
}
|
|
|
postData(window.location.pathname + '/month/save', { type: 'add', updateData: { yearmonth: yearmonth } }, function (data) {
|
|
|
- const month = parseInt(yearmonth.split('-')[1]);
|
|
|
- const newCols = {title: month + '月|单价', colSpan: '1|1', rowSpan: '1|1', field: yearmonth, hAlign: 2, width: 60, type: '@', readOnly: 'readOnly.isEdit'};
|
|
|
- materialMonthSpreadSetting.cols.push(newCols);
|
|
|
months.push(yearmonth);
|
|
|
+ months.sort();
|
|
|
+ const monthCols = monthSpreadHeaderReset();
|
|
|
+ const newMonthSpreadHeaderCols = static_cols.concat(monthCols);
|
|
|
+ materialMonthSpreadSetting.cols = newMonthSpreadHeaderCols;
|
|
|
monthsList = data.monthsList;
|
|
|
- SpreadJsObj.reinitSheetHeader(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
|
|
|
SpreadJsObj.initSpreadSettingEvents(materialMonthSpreadSetting, materialMonthCol);
|
|
|
- // SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
+ console.log(materialMonthSpreadSetting);
|
|
|
+ // SpreadJsObj.initSheet(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
|
|
|
+ SpreadJsObj.reinitSheetHeader(materialMonthSpread.getActiveSheet());
|
|
|
SpreadJsObj.loadSheetData(materialMonthSpread.getActiveSheet(), SpreadJsObj.DataType.Data, monthsList);
|
|
|
setMonthHtml();
|
|
|
|
|
@@ -972,16 +1008,20 @@ $(document).ready(() => {
|
|
|
}
|
|
|
postData(window.location.pathname + '/month/save', { type: 'del', updateData: { del_yearmonth: del_month_array } }, function (data) {
|
|
|
for (const dm of del_month_array) {
|
|
|
- _.remove(materialMonthSpreadSetting.cols, function (n) {
|
|
|
- return n.field === dm;
|
|
|
- });
|
|
|
+ // _.remove(materialMonthSpreadSetting.cols, function (n) {
|
|
|
+ // return n.field === dm;
|
|
|
+ // });
|
|
|
_.remove(months, function (n) {
|
|
|
return n === dm;
|
|
|
});
|
|
|
}
|
|
|
+ const monthCols = monthSpreadHeaderReset();
|
|
|
+ const newMonthSpreadHeaderCols = static_cols.concat(monthCols);
|
|
|
+ materialMonthSpreadSetting.cols = newMonthSpreadHeaderCols;
|
|
|
monthsList = data.monthsList;
|
|
|
- SpreadJsObj.reinitSheetHeader(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
|
|
|
SpreadJsObj.initSpreadSettingEvents(materialMonthSpreadSetting, materialMonthCol);
|
|
|
+ console.log(materialMonthSpreadSetting);
|
|
|
+ SpreadJsObj.reinitSheetHeader(materialMonthSpread.getActiveSheet());
|
|
|
SpreadJsObj.loadSheetData(materialMonthSpread.getActiveSheet(), SpreadJsObj.DataType.Data, monthsList);
|
|
|
setMonthHtml();
|
|
|
|