|
@@ -94,6 +94,24 @@ const is_numeric = (value) => {
|
|
return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
|
|
return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+function setMonthHtml() {
|
|
|
|
+ let html = '';
|
|
|
|
+ let qihtml = '';
|
|
|
|
+ for (const m of months) {
|
|
|
|
+ html += '<div class="custom-control custom-checkbox mb-2">\n' +
|
|
|
|
+ ' <input type="checkbox" name="del_month" value="' + m + '" class="custom-control-input" id="month_' + m + '">\n' +
|
|
|
|
+ ' <label class="custom-control-label" for="month_' + m + '">' + m + '月</label>\n' +
|
|
|
|
+ ' </div>';
|
|
|
|
+ qihtml += parseInt(m.split('-')[1]) + '月,';
|
|
|
|
+ }
|
|
|
|
+ if (months.length > 0) {
|
|
|
|
+ qihtml = '<span class="mx-2 text-muted">/</span>本期月信息价:' + qihtml;
|
|
|
|
+ qihtml = qihtml.substring(0, qihtml.length-1);
|
|
|
|
+ }
|
|
|
|
+ $('#show_month').html(html);
|
|
|
|
+ $('#qi-month').html(qihtml);
|
|
|
|
+}
|
|
$(document).ready(() => {
|
|
$(document).ready(() => {
|
|
autoFlashHeight();
|
|
autoFlashHeight();
|
|
const materialSpread = SpreadJsObj.createNewSpread($('#material-spread')[0]);
|
|
const materialSpread = SpreadJsObj.createNewSpread($('#material-spread')[0]);
|
|
@@ -108,7 +126,7 @@ $(document).ready(() => {
|
|
{title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
{title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
{title: '基准价', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
{title: '基准价', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 60, type: 'Number', 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: '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.remark'},
|
|
|
|
|
|
+ {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|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: '4|1', rowSpan: '1|1', field: 'm_up_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
@@ -202,6 +220,9 @@ $(document).ready(() => {
|
|
remark: function () {
|
|
remark: function () {
|
|
return readOnly;
|
|
return readOnly;
|
|
},
|
|
},
|
|
|
|
+ msg_tp: function () {
|
|
|
|
+ return !(!readOnly && months.length === 0);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
};
|
|
};
|
|
SpreadJsObj.initSpreadSettingEvents(materialSpreadSetting, materialCol);
|
|
SpreadJsObj.initSpreadSettingEvents(materialSpreadSetting, materialCol);
|
|
@@ -209,7 +230,7 @@ $(document).ready(() => {
|
|
SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
|
|
|
const materialSpreadObj = {
|
|
const materialSpreadObj = {
|
|
- refreshActn: function () {
|
|
|
|
|
|
+ refreshActn: function (rowCount = 1) {
|
|
const setObjEnable = function (obj, enable) {
|
|
const setObjEnable = function (obj, enable) {
|
|
if (enable) {
|
|
if (enable) {
|
|
obj.removeClass('disabled');
|
|
obj.removeClass('disabled');
|
|
@@ -220,7 +241,7 @@ $(document).ready(() => {
|
|
const sheet = materialSpread.getActiveSheet();
|
|
const sheet = materialSpread.getActiveSheet();
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
// 还需判断是否已被调差清单调用
|
|
// 还需判断是否已被调差清单调用
|
|
- setObjEnable($('#del'), !readOnly && select && materialBase.isUsed(select));
|
|
|
|
|
|
+ setObjEnable($('#del'), !readOnly && select && materialBase.isUsed(select) && rowCount === 1);
|
|
},
|
|
},
|
|
add: function () {
|
|
add: function () {
|
|
const sheet = materialSpread.getActiveSheet();
|
|
const sheet = materialSpread.getActiveSheet();
|
|
@@ -231,6 +252,16 @@ $(document).ready(() => {
|
|
SpreadJsObj.reLoadRowData(sheet, materialBillsData.length - 1);
|
|
SpreadJsObj.reLoadRowData(sheet, materialBillsData.length - 1);
|
|
sheet.setSelection(materialBillsData.length - 1, 0, 1, 1);
|
|
sheet.setSelection(materialBillsData.length - 1, 0, 1, 1);
|
|
materialSpreadObj.refreshActn();
|
|
materialSpreadObj.refreshActn();
|
|
|
|
+ // 月信息价需要同时添加空白的list
|
|
|
|
+ if (months.length > 0) {
|
|
|
|
+ const one_month ={ mb_id: result.id, code: '', name: null, unit: null, };
|
|
|
|
+ for (const m of months) {
|
|
|
|
+ one_month[m] = null;
|
|
|
|
+ }
|
|
|
|
+ monthsList.push(one_month);
|
|
|
|
+ materialMonthSpread.getActiveSheet().addRows(monthsList.length - 1, 1);
|
|
|
|
+ SpreadJsObj.reLoadRowData(materialMonthSpread.getActiveSheet(), monthsList.length - 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -243,16 +274,22 @@ $(document).ready(() => {
|
|
const index = materialBillsData.indexOf(select);
|
|
const index = materialBillsData.indexOf(select);
|
|
materialBillsData.splice(index, 1);
|
|
materialBillsData.splice(index, 1);
|
|
sheet.deleteRows(index, 1);
|
|
sheet.deleteRows(index, 1);
|
|
- SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
|
|
|
+ // SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
const sel = sheet.getSelections();
|
|
const sel = sheet.getSelections();
|
|
sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
materialSpreadObj.refreshActn();
|
|
materialSpreadObj.refreshActn();
|
|
|
|
+ // 月信息价需要同时删除
|
|
|
|
+ if (months.length > 0) {
|
|
|
|
+ monthsList.splice(index, 1);
|
|
|
|
+ materialMonthSpread.getActiveSheet().deleteRows(index, 1);
|
|
|
|
+ // SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
|
+ }
|
|
});
|
|
});
|
|
},
|
|
},
|
|
selectionChanged: function (e, info) {
|
|
selectionChanged: function (e, info) {
|
|
- materialSpreadObj.refreshActn();
|
|
|
|
const sel = info.sheet.getSelections()[0];
|
|
const sel = info.sheet.getSelections()[0];
|
|
const col = info.sheet.zh_setting.cols[sel.col];
|
|
const col = info.sheet.zh_setting.cols[sel.col];
|
|
|
|
+ materialSpreadObj.refreshActn(sel.rowCount);
|
|
const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
materialSpreadObj.setReadOnly(true);
|
|
materialSpreadObj.setReadOnly(true);
|
|
},
|
|
},
|
|
@@ -341,6 +378,11 @@ $(document).ready(() => {
|
|
m_tp = result.m_tp;
|
|
m_tp = result.m_tp;
|
|
resetTpTable();
|
|
resetTpTable();
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
+ // 判断如果是更改了编号,名称,单位,月信息价需要跟着改变值
|
|
|
|
+ if (months.length > 0 && (col.field === 'code' || col.field === 'name' || col.field === 'unit')) {
|
|
|
|
+ monthsList[info.row][col.field] = validText;
|
|
|
|
+ SpreadJsObj.reLoadRowData(materialMonthSpread.getActiveSheet(), info.row);
|
|
|
|
+ }
|
|
}, function () {
|
|
}, function () {
|
|
select[col.field] = orgValue;
|
|
select[col.field] = orgValue;
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
@@ -465,11 +507,19 @@ $(document).ready(() => {
|
|
// 更新至服务器
|
|
// 更新至服务器
|
|
postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
|
|
postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
|
|
materialBillsData = result.info;
|
|
materialBillsData = result.info;
|
|
- SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
|
|
|
+ SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
// for (const row in rowData) {
|
|
// for (const row in rowData) {
|
|
// materialBillsData.splice(index, 1, result.info[row]);
|
|
// materialBillsData.splice(index, 1, result.info[row]);
|
|
// SpreadJsObj.reLoadRowData(info.sheet, row);
|
|
// SpreadJsObj.reLoadRowData(info.sheet, row);
|
|
// }
|
|
// }
|
|
|
|
+ if (months.length > 0) {
|
|
|
|
+ for (const [i,m] of monthsList.entries()) {
|
|
|
|
+ m.code = materialBillsData[i].code;
|
|
|
|
+ m.name = materialBillsData[i].name;
|
|
|
|
+ m.unit = materialBillsData[i].unit;
|
|
|
|
+ }
|
|
|
|
+ SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
|
+ }
|
|
m_tp = result.m_tp;
|
|
m_tp = result.m_tp;
|
|
resetTpTable();
|
|
resetTpTable();
|
|
}, function () {
|
|
}, function () {
|
|
@@ -495,10 +545,182 @@ $(document).ready(() => {
|
|
// msg_range.formatter("yyyy-MM-dd");
|
|
// msg_range.formatter("yyyy-MM-dd");
|
|
sheet.resumePaint();
|
|
sheet.resumePaint();
|
|
|
|
|
|
|
|
+ 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'},
|
|
|
|
+ ],
|
|
|
|
+ emptyRows: 0,
|
|
|
|
+ headRows: 2,
|
|
|
|
+ headRowHeight: [25, 25],
|
|
|
|
+ defaultRowHeight: 21,
|
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
|
+ font: '12px 微软雅黑',
|
|
|
|
+ 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 materialMonthCol = {
|
|
|
|
+ getValue: {
|
|
|
|
+ average_msg_tp: function (data) {
|
|
|
|
+ let msg_tp = 0;
|
|
|
|
+ for (const m of months) {
|
|
|
|
+ msg_tp += data[m];
|
|
|
|
+ }
|
|
|
|
+ const average_tp = ZhCalc.round(ZhCalc.div(msg_tp, months.length), 3);
|
|
|
|
+ return average_tp;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ readOnly: {
|
|
|
|
+ isEdit: function (data) {
|
|
|
|
+ return readOnly;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(materialMonthSpreadSetting, materialMonthCol);
|
|
|
|
+ SpreadJsObj.initSheet(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
|
|
|
|
+ SpreadJsObj.loadSheetData(materialMonthSpread.getActiveSheet(), SpreadJsObj.DataType.Data, monthsList);
|
|
|
|
+
|
|
|
|
+ const materialMonthSpreadObj = {
|
|
|
|
+ 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 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;
|
|
|
|
+ }
|
|
|
|
+ select[col.field] = validText;
|
|
|
|
+
|
|
|
|
+ // 更新至服务器
|
|
|
|
+ postData(window.location.pathname + '/month/save', { type:'update', updateData: { mb_id: select.mb_id, yearmonth: col.field, value: validText } }, function (result) {
|
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
+ materialBillsData = result.materialBillsData;
|
|
|
|
+ SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
|
+ m_tp = result.m_tp;
|
|
|
|
+ resetTpTable();
|
|
|
|
+ }, 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;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ materialMonthSpread.bind(spreadNS.Events.ClipboardPasted, materialMonthSpreadObj.clipboardPasted);
|
|
|
|
+ SpreadJsObj.addDeleteBind(materialMonthSpread, materialMonthSpreadObj.deletePress);
|
|
|
|
+
|
|
if (!readOnly) {
|
|
if (!readOnly) {
|
|
$('#add').click(materialSpreadObj.add);
|
|
$('#add').click(materialSpreadObj.add);
|
|
$('#del').click(materialSpreadObj.del);
|
|
$('#del').click(materialSpreadObj.del);
|
|
materialSpread.bind(spreadNS.Events.EditEnded, materialSpreadObj.editEnded);
|
|
materialSpread.bind(spreadNS.Events.EditEnded, materialSpreadObj.editEnded);
|
|
|
|
+ materialMonthSpread.bind(spreadNS.Events.EditEnded, materialMonthSpreadObj.editEnded);
|
|
// 右键菜单
|
|
// 右键菜单
|
|
$.contextMenu({
|
|
$.contextMenu({
|
|
selector: '#material-spread',
|
|
selector: '#material-spread',
|
|
@@ -523,8 +745,9 @@ $(document).ready(() => {
|
|
disabled: function (key, opt) {
|
|
disabled: function (key, opt) {
|
|
const sheet = materialSpread.getActiveSheet();
|
|
const sheet = materialSpread.getActiveSheet();
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
- materialSpreadObj.refreshActn();
|
|
|
|
- if (!readOnly && select && materialBase.isUsed(select)) {
|
|
|
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
|
+ materialSpreadObj.refreshActn(sel.rowCount);
|
|
|
|
+ if (!readOnly && select && materialBase.isUsed(select) && sel.rowCount === 1) {
|
|
return false;
|
|
return false;
|
|
} else {
|
|
} else {
|
|
return true;
|
|
return true;
|
|
@@ -697,7 +920,76 @@ $(document).ready(() => {
|
|
SpreadJsObj.reLoadRowData(sheet, index);
|
|
SpreadJsObj.reLoadRowData(sheet, index);
|
|
$('#bcyy').modal('hide');
|
|
$('#bcyy').modal('hide');
|
|
});
|
|
});
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 创建月信息价
|
|
|
|
+ $('#make-month').click(function() {
|
|
|
|
+ const yearmonth = $('#months').val();
|
|
|
|
+ const result = yearmonth.match(/^(\d{1,4})(-|\/)(\d{1,2})$/);
|
|
|
|
+ if (result === null) {
|
|
|
|
+ toastr.error('请选择正确的信息价月份');
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ //判断是否已存在当前月份
|
|
|
|
+ if (months.indexOf(yearmonth) !== -1) {
|
|
|
|
+ toastr.error('调差期已创建过本月的信息价');
|
|
|
|
+ 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);
|
|
|
|
+ monthsList = data.monthsList;
|
|
|
|
+ SpreadJsObj.reinitSheetHeader(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
|
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(materialMonthSpreadSetting, materialMonthCol);
|
|
|
|
+ // SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
|
+ SpreadJsObj.loadSheetData(materialMonthSpread.getActiveSheet(), SpreadJsObj.DataType.Data, monthsList);
|
|
|
|
+ setMonthHtml();
|
|
|
|
+
|
|
|
|
+ // 工料表单价显示也要更新
|
|
|
|
+ materialBillsData = data.materialBillsData;
|
|
|
|
+ SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
|
+ m_tp = data.m_tp;
|
|
|
|
+ resetTpTable();
|
|
|
|
+ $('#add-month').modal('hide');
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ // 删除月信息价
|
|
|
|
+ $('#del-month').click(function () {
|
|
|
|
+ const del_month_array = [];
|
|
|
|
+ $("input[name='del_month']:checked").each(function () {
|
|
|
|
+ del_month_array.push($(this).val());
|
|
|
|
+ });
|
|
|
|
+ if (del_month_array.length === 0) {
|
|
|
|
+ toastr.error('请选择要移除的月信息价');
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ 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(months, function (n) {
|
|
|
|
+ return n === dm;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ monthsList = data.monthsList;
|
|
|
|
+ console.log(monthsList);
|
|
|
|
+ SpreadJsObj.reinitSheetHeader(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
|
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(materialMonthSpreadSetting, materialMonthCol);
|
|
|
|
+ SpreadJsObj.loadSheetData(materialMonthSpread.getActiveSheet(), SpreadJsObj.DataType.Data, monthsList);
|
|
|
|
+ setMonthHtml();
|
|
|
|
+
|
|
|
|
+ // 工料表单价显示也要更新
|
|
|
|
+ materialBillsData = data.materialBillsData;
|
|
|
|
+ console.log(materialBillsData);
|
|
|
|
+ SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
|
+ m_tp = data.m_tp;
|
|
|
|
+ resetTpTable();
|
|
|
|
+ $('#remove-month').modal('hide');
|
|
|
|
+ });
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
// SpreadJsObj.forbiddenSpreadContextMenu('#material-spread', materialSpread);
|
|
// SpreadJsObj.forbiddenSpreadContextMenu('#material-spread', materialSpread);
|
|
}
|
|
}
|