|
|
@@ -73,17 +73,32 @@ DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle,
|
|
|
|
|
|
function resetTpTable() {
|
|
|
$('#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));
|
|
|
+ $('#tp_set').find('td').eq(2).text(ZhCalc.add(pre_tp, ZhCalc.round(m_tp, materialDecimal.tp)));
|
|
|
if (materialTax) {
|
|
|
$('#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));
|
|
|
+ $('#tax_rate_set').find('td').eq(2).text(ZhCalc.add(m_tax_pre_tp, ZhCalc.round(m_tax_tp, materialDecimal.tp)));
|
|
|
} else {
|
|
|
const rate = $('#rateInput').val();
|
|
|
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);
|
|
|
+ const jzbqhs = ZhCalc.add(pre_tp_hs, bqhs);
|
|
|
$('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
|
|
|
$('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
|
|
|
}
|
|
|
+
|
|
|
+ if (isStageSelf) {
|
|
|
+ let html = '';
|
|
|
+ for (const ms of materialStageData) {
|
|
|
+ const taxHtml = materialTax ? ' <td class="text-center">' + ms.m_tax_tp + '</td>\n' : '';
|
|
|
+ html += '<tr><td>第' + ms.order + '期</td><td class="text-center">' + ms.m_tp + '</td>\n' +
|
|
|
+ taxHtml +
|
|
|
+ ' </tr>';
|
|
|
+ }
|
|
|
+ const allTaxHtml = materialTax ? ' <td class="text-center">' + m_tax_tp + '</td>\n' : '';
|
|
|
+ html += '<tr><td>合计</td><td class="text-center">' + m_tp + '</td>\n' +
|
|
|
+ allTaxHtml +
|
|
|
+ ' </tr>';
|
|
|
+ $('#materialStageTable').html(html);
|
|
|
+ }
|
|
|
}
|
|
|
function getPasteHint (str, row = '') {
|
|
|
let returnObj = str;
|
|
|
@@ -121,11 +136,12 @@ $(document).ready(() => {
|
|
|
{title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 1, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
|
|
|
];
|
|
|
if (materialTax) {
|
|
|
- materialSpreadSettingCols.push({title: '税率(%)', colSpan: '1', rowSpan: '2', field: 'm_tax', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'});
|
|
|
+ materialSpreadSettingCols.push({title: '税率(%)', colSpan: '1', rowSpan: '2', field: 'm_tax', hAlign: 2, width: 50, type: 'Number', readOnly: editTaxPermission ? 'readOnly.remark' : 'readOnly.isEdit'});
|
|
|
}
|
|
|
materialSpreadSettingCols = _.concat(materialSpreadSettingCols, [
|
|
|
- {title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 90, type: 'Number', readOnly: true},
|
|
|
- {title: '基准价', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '上涨 幅度(%)', colSpan: '1', rowSpan: '2', field: 'm_up_risk', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
+ {title: '下跌 幅度(%)', colSpan: '1', rowSpan: '2', field: 'm_down_risk', hAlign: 2, width: 50, 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: 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: '|1', rowSpan: '|1', field: 'msg_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.remark'},
|
|
|
@@ -133,24 +149,22 @@ $(document).ready(() => {
|
|
|
);
|
|
|
if (materialTax) {
|
|
|
materialSpreadSettingCols = _.concat(materialSpreadSettingCols, [
|
|
|
- {title: '本期材料调差|上涨 幅度(%)', colSpan: '5|1', rowSpan: '1|1', field: 'm_up_risk', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
- {title: '|下跌 幅度(%)', colSpan: '|1', rowSpan: '|1', field: 'm_down_risk', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
- {title: '|有效价差', colSpan: '|1', rowSpan: '|1', field: 'm_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.m_spread'},
|
|
|
+ {title: '本期材料调差|有效价差', colSpan: '4|1', rowSpan: '1|1', field: 'm_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.m_spread'},
|
|
|
+ {title: '|本期应耗数量', colSpan: '|1', rowSpan: '|1', field: 'quantity', hAlign: 2, width: 90, type: 'Number', readOnly: true},
|
|
|
{title: '|调差金额', colSpan: '|1', rowSpan: '|1', field: 'm_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true, getValue: 'getValue.m_tp'},
|
|
|
{title: '|调差金额(材料税)', colSpan: '|1', rowSpan: '|1', field: 'm_tax_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true, getValue: 'getValue.m_tax_tp'},
|
|
|
{title: '截止上期|调差金额', colSpan: '2|1', rowSpan: '1|1', field: 'pre_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
{title: '|调差金额(材料税)', colSpan: '|1', rowSpan: '|1', field: 'tax_pre_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
- {title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 50, formatter: '@', readOnly: 'readOnly.remark'},
|
|
|
+ {title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 50, formatter: '@', cellType: 'ellipsisAutoTip', readOnly: 'readOnly.remark'},
|
|
|
{title: '是否汇总', colSpan: '1', rowSpan: '2', field: 'is_summary', hAlign: 1, width: 60, cellType: 'checkbox', readOnly: 'readOnly.isEdit'}
|
|
|
])
|
|
|
} else {
|
|
|
materialSpreadSettingCols = _.concat(materialSpreadSettingCols, [
|
|
|
- {title: '本期材料调差|上涨 幅度(%)', colSpan: '4|1', rowSpan: '1|1', field: 'm_up_risk', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'},
|
|
|
- {title: '|下跌 幅度(%)', colSpan: '|1', rowSpan: '|1', field: 'm_down_risk', hAlign: 2, width: 50, 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'},
|
|
|
+ {title: '本期材料调差|有效价差', colSpan: '3|1', rowSpan: '1|1', field: 'm_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.m_spread'},
|
|
|
+ {title: '|本期应耗数量', colSpan: '|1', rowSpan: '|1', field: 'quantity', hAlign: 2, width: 90, type: 'Number', readOnly: true},
|
|
|
{title: '|调差金额', colSpan: '|1', rowSpan: '|1', field: 'm_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true, getValue: 'getValue.m_tp'},
|
|
|
{title: '截止上期|调差金额', colSpan: '1|1', rowSpan: '1|1', field: 'pre_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
- {title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 50, formatter: '@', readOnly: 'readOnly.remark'},
|
|
|
+ {title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 50, formatter: '@', cellType: 'ellipsisAutoTip', readOnly: 'readOnly.remark'},
|
|
|
{title: '是否汇总', colSpan: '1', rowSpan: '2', field: 'is_summary', hAlign: 1, width: 60, cellType: 'checkbox', readOnly: 'readOnly.isEdit'}
|
|
|
])
|
|
|
}
|
|
|
@@ -161,6 +175,7 @@ $(document).ready(() => {
|
|
|
spCol.normalImg = '#ellipsis-icon';
|
|
|
spCol.indent = 5;
|
|
|
spCol.showImage = function (data) {
|
|
|
+ // console.log(data, data.t_type);
|
|
|
// return !readOnly && data.t_type === 2 && data.mid === materialID;
|
|
|
return data.t_type === 2;
|
|
|
};
|
|
|
@@ -239,18 +254,78 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
};
|
|
|
- SpreadJsObj.initSpreadSettingEvents(materialSpreadSetting, materialCol);
|
|
|
- SpreadJsObj.initSheet(materialSpread.getActiveSheet(), materialSpreadSetting);
|
|
|
- SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
+
|
|
|
+ const needUpdateArray = ['quantity', 'msg_tp', 'msg_times', 'msg_spread', 'm_spread', 'm_tp', 'm_tax_tp', 'is_summary', 'remark'];
|
|
|
|
|
|
const materialSpreadObj = {
|
|
|
- materialSheetReset: function () {
|
|
|
- let newMaterialBillsData = materialBillsData;
|
|
|
+ getMaterialBillsData: function () {
|
|
|
+ if (isStageSelf) {
|
|
|
+ // 当前选中nav id
|
|
|
+ const ms_id = $('#myTab').find('.active').data('msid');
|
|
|
+ const msbList = _.filter(materialStageBillsData, { ms_id });
|
|
|
+ for (const mb of materialBillsData) {
|
|
|
+ mb.ms_id = ms_id;
|
|
|
+ const msbInfo = _.find(msbList, { mb_id: mb.mb_id ? mb.mb_id : mb.id });
|
|
|
+ if (msbInfo) {
|
|
|
+ for (const nu of needUpdateArray) {
|
|
|
+ mb[nu] = msbInfo[nu];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return materialBillsData;
|
|
|
+ },
|
|
|
+ updateOneMaterialBill: function (data) {
|
|
|
+ const ms_id = $('#myTab').find('.active').data('msid');
|
|
|
+ const msbInfo = _.find(materialStageBillsData, { ms_id, mb_id: data.id });
|
|
|
+ console.log(msbInfo);
|
|
|
+ data.ms_id = ms_id;
|
|
|
+ for (const nu of needUpdateArray) {
|
|
|
+ data[nu] = msbInfo[nu];
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ updateMaterialData: function (datas) {
|
|
|
+ if (datas.stageData && datas.stageData.length > 0) {
|
|
|
+ if (datas.stageData.length === materialStageData.length) {
|
|
|
+ // 全体替换
|
|
|
+ materialStageData = datas.stageData;
|
|
|
+ } else {
|
|
|
+ // 替换对应的stage数据
|
|
|
+ for (const s of datas.stageData) {
|
|
|
+ const index = _.findIndex(materialStageData, { id: s.id });
|
|
|
+ materialStageData.splice(index, 1, s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (datas.pushStageBillsData && datas.pushStageBillsData.length > 0) {
|
|
|
+ materialStageBillsData = _.concat(materialStageBillsData, datas.pushStageBillsData);
|
|
|
+ }
|
|
|
+ if (datas.stageBillsData && datas.stageBillsData.length > 0) {
|
|
|
+ if (datas.stageBillsData.length === materialStageBillsData.length) {
|
|
|
+ // 全体替换
|
|
|
+ materialStageBillsData = datas.stageBillsData;
|
|
|
+ } else {
|
|
|
+ // 替换对应的stage数据
|
|
|
+ for (const s of datas.stageBillsData) {
|
|
|
+ const index = _.findIndex(materialStageBillsData, { id: s.id });
|
|
|
+ materialStageBillsData.splice(index, 1, s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ materialSheetReset: function (redo = false) {
|
|
|
+ let newMaterialBillsData = _.cloneDeep(materialBillsData);
|
|
|
if($('#bills0_list').is(':checked')) {
|
|
|
newMaterialBillsData = _.filter(materialBillsData, function (item) {
|
|
|
return item.quantity !== null && item.quantity !== 0;
|
|
|
});
|
|
|
+ if (redo) {
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(materialSpreadSetting, materialCol);
|
|
|
+ SpreadJsObj.initSheet(materialSpread.getActiveSheet(), materialSpreadSetting);
|
|
|
+ }
|
|
|
}
|
|
|
+ console.log(newMaterialBillsData);
|
|
|
SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, newMaterialBillsData);
|
|
|
materialSpreadObj.refreshActn();
|
|
|
},
|
|
|
@@ -273,7 +348,11 @@ $(document).ready(() => {
|
|
|
const sheet = materialSpread.getActiveSheet();
|
|
|
postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
|
|
|
if (result) {
|
|
|
- materialBillsData.push(result);
|
|
|
+ materialBillsData.push(result.info);
|
|
|
+ if (isStageSelf) {
|
|
|
+ materialSpreadObj.updateMaterialData(result);
|
|
|
+ materialSpreadObj.getMaterialBillsData();
|
|
|
+ }
|
|
|
// sheet.addRows(materialBillsData.length - 1, 1);
|
|
|
// SpreadJsObj.reLoadRowData(sheet, materialBillsData.length - 1);
|
|
|
let newMaterialBillsData = materialBillsData;
|
|
|
@@ -288,7 +367,7 @@ $(document).ready(() => {
|
|
|
materialSpreadObj.refreshActn();
|
|
|
// 月信息价需要同时添加空白的list
|
|
|
if (months.length > 0) {
|
|
|
- const one_month ={ mb_id: result.id, code: '', name: null, origin: null, unit: null, order: result.order };
|
|
|
+ const one_month ={ mb_id: result.info.id, code: '', name: null, origin: null, unit: null, order: result.info.order };
|
|
|
for (const m of months) {
|
|
|
one_month[m] = null;
|
|
|
}
|
|
|
@@ -312,7 +391,7 @@ $(document).ready(() => {
|
|
|
if (materialTax) {
|
|
|
m_tax_tp = result.m_tax_tp;
|
|
|
}
|
|
|
- resetTpTable();
|
|
|
+
|
|
|
const index = materialBillsData.indexOf(select);
|
|
|
let newMaterialBillsData = materialBillsData;
|
|
|
let newIndex = index;
|
|
|
@@ -324,6 +403,11 @@ $(document).ready(() => {
|
|
|
}
|
|
|
materialBillsData.splice(index, 1);
|
|
|
sheet.deleteRows(newIndex, 1);
|
|
|
+ if (isStageSelf) {
|
|
|
+ materialSpreadObj.updateMaterialData(result);
|
|
|
+ materialSpreadObj.getMaterialBillsData();
|
|
|
+ }
|
|
|
+ resetTpTable();
|
|
|
// SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
const sel = sheet.getSelections();
|
|
|
sheet.setSelection(newIndex > 0 ? newIndex - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
|
@@ -340,73 +424,112 @@ $(document).ready(() => {
|
|
|
if($('#bills0_list').is(':checked')) {
|
|
|
return;
|
|
|
}
|
|
|
+ const data = {
|
|
|
+ type: 'changeOrder',
|
|
|
+ postData: [],
|
|
|
+ };
|
|
|
const sheet = materialSpread.getActiveSheet();
|
|
|
- const cur = SpreadJsObj.getSelectObject(sheet);
|
|
|
- const up = materialBillsData[materialBillsData.indexOf(cur) - 1];
|
|
|
- const mbIndex = materialBillsData.indexOf(cur);
|
|
|
- postData(window.location.pathname + '/save', {type: 'changeOrder', id1: cur.id, id2: up.id}, function () {
|
|
|
- const order = cur.order;
|
|
|
- cur.order = up.order;
|
|
|
- up.order = order;
|
|
|
- materialBillsData.sort(function (a, b) {
|
|
|
- return a.order - b.order
|
|
|
- });
|
|
|
- SpreadJsObj.reLoadSheetData(sheet);
|
|
|
- const sel = sheet.getSelections();
|
|
|
- const index = materialBillsData.indexOf(cur);
|
|
|
- sheet.setSelection(index, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const row = selection[0].row, count = selection[0].rowCount;
|
|
|
+ const first = sheet.zh_data[row];
|
|
|
+ if (!first) {
|
|
|
materialSpreadObj.refreshActn();
|
|
|
- if (months.length > 0) {
|
|
|
- const monthCur = monthsList[mbIndex];
|
|
|
- const monthUp = monthsList[mbIndex - 1];
|
|
|
- const monthOrder = monthCur.order;
|
|
|
- monthCur.order = monthUp.order;
|
|
|
- monthUp.order = monthOrder;
|
|
|
- monthsList.sort(function (a, b) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const pre = sheet.zh_data[row - 1], preUpdate = {id: pre.id};
|
|
|
+ for (let iRow = 0; iRow < count; iRow++) {
|
|
|
+ const posData = sheet.zh_data[iRow + row];
|
|
|
+ if (posData) {
|
|
|
+ data.postData.push({id: posData.id, order: sheet.zh_data[iRow + row - 1].order});
|
|
|
+ preUpdate.order = posData.order;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(monthsList);
|
|
|
+ data.postData.push(preUpdate);
|
|
|
+ console.log(data);
|
|
|
+ if (data.postData.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', data, function () {
|
|
|
+ _.forEach(data.postData, function (item) {
|
|
|
+ const cl = _.find(materialBillsData, { id: item.id });
|
|
|
+ cl.order = item.order;
|
|
|
+ });
|
|
|
+ materialBillsData.sort(function (a, b) {
|
|
|
return a.order - b.order
|
|
|
});
|
|
|
- const materialMonthSheet = materialMonthSpread.getActiveSheet();
|
|
|
- SpreadJsObj.reLoadSheetData(materialMonthSheet);
|
|
|
- }
|
|
|
- });
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ const sel = selection[0];
|
|
|
+ if (sel) {
|
|
|
+ sheet.setSelection(sheet.zh_data.indexOf(first), sel.col, sel.rowCount, sel.colCount);
|
|
|
+ }
|
|
|
+ if (months.length > 0) {
|
|
|
+ _.forEach(data.postData, function (item) {
|
|
|
+ const cl = _.find(monthsList, { mb_id: item.id });
|
|
|
+ cl.order = item.order;
|
|
|
+ });
|
|
|
+ monthsList.sort(function (a, b) {
|
|
|
+ return a.order - b.order
|
|
|
+ });
|
|
|
+ const materialMonthSheet = materialMonthSpread.getActiveSheet();
|
|
|
+ SpreadJsObj.reLoadSheetData(materialMonthSheet);
|
|
|
+ }
|
|
|
+ materialSpreadObj.refreshActn();
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
downMove: function () {
|
|
|
if($('#bills0_list').is(':checked')) {
|
|
|
return;
|
|
|
}
|
|
|
- const sheet = materialSpread.getActiveSheet();
|
|
|
- const cur = SpreadJsObj.getSelectObject(sheet);
|
|
|
- const down = materialBillsData[materialBillsData.indexOf(cur) + 1];
|
|
|
- const mbIndex = materialBillsData.indexOf(cur);
|
|
|
- postData(window.location.pathname + '/save', {
|
|
|
+ const data = {
|
|
|
type: 'changeOrder',
|
|
|
- id1: cur.id,
|
|
|
- id2: down.id
|
|
|
- }, function () {
|
|
|
- const order = cur.order;
|
|
|
- cur.order = down.order;
|
|
|
- down.order = order;
|
|
|
- materialBillsData.sort(function (a, b) {
|
|
|
- return a.order - b.order
|
|
|
- });
|
|
|
- SpreadJsObj.reLoadSheetData(sheet);
|
|
|
- const sel = sheet.getSelections();
|
|
|
- const index = materialBillsData.indexOf(cur);
|
|
|
- sheet.setSelection(index, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
|
+ postData: [],
|
|
|
+ };
|
|
|
+ const sheet = materialSpread.getActiveSheet();
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const row = selection[0].row, count = selection[0].rowCount;
|
|
|
+ const first = sheet.zh_data[row];
|
|
|
+ if (!first) {
|
|
|
materialSpreadObj.refreshActn();
|
|
|
- if (months.length > 0) {
|
|
|
- const monthCur = monthsList[mbIndex];
|
|
|
- const monthDown = monthsList[mbIndex + 1];
|
|
|
- const monthOrder = monthCur.order;
|
|
|
- monthCur.order = monthDown.order;
|
|
|
- monthDown.order = monthOrder;
|
|
|
- monthsList.sort(function (a, b) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const next = sheet.zh_data[row + count], nextUpdate = {id: next.id};
|
|
|
+ for (let iRow = count - 1; iRow >= 0; iRow--) {
|
|
|
+ const posData = sheet.zh_data[iRow + row];
|
|
|
+ if (posData) {
|
|
|
+ data.postData.push({id: posData.id, order: sheet.zh_data[iRow + row + 1].order});
|
|
|
+ nextUpdate.order = posData.order;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.postData.push(nextUpdate);
|
|
|
+ console.log(data);
|
|
|
+ if (data.postData.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', data, function () {
|
|
|
+ _.forEach(data.postData, function (item) {
|
|
|
+ const cl = _.find(materialBillsData, { id: item.id });
|
|
|
+ cl.order = item.order;
|
|
|
+ });
|
|
|
+ materialBillsData.sort(function (a, b) {
|
|
|
return a.order - b.order
|
|
|
});
|
|
|
- const materialMonthSheet = materialMonthSpread.getActiveSheet();
|
|
|
- SpreadJsObj.reLoadSheetData(materialMonthSheet);
|
|
|
- }
|
|
|
- });
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ const sel = selection[0];
|
|
|
+ if (sel) {
|
|
|
+ sheet.setSelection(sheet.zh_data.indexOf(first), sel.col, sel.rowCount, sel.colCount);
|
|
|
+ }
|
|
|
+ if (months.length > 0) {
|
|
|
+ _.forEach(data.postData, function (item) {
|
|
|
+ const cl = _.find(monthsList, { mb_id: item.id });
|
|
|
+ cl.order = item.order;
|
|
|
+ });
|
|
|
+ monthsList.sort(function (a, b) {
|
|
|
+ return a.order - b.order
|
|
|
+ });
|
|
|
+ const materialMonthSheet = materialMonthSpread.getActiveSheet();
|
|
|
+ SpreadJsObj.reLoadSheetData(materialMonthSheet);
|
|
|
+ }
|
|
|
+ materialSpreadObj.refreshActn();
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
selectionChanged: function (e, info) {
|
|
|
const sel = info.sheet.getSelections()[0];
|
|
|
@@ -414,6 +537,7 @@ $(document).ready(() => {
|
|
|
materialSpreadObj.refreshActn(sel.rowCount);
|
|
|
const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
materialSpreadObj.setReadOnly(true);
|
|
|
+ console.log(data);
|
|
|
},
|
|
|
editEnded: function (e, info) {
|
|
|
if (info.sheet.zh_setting) {
|
|
|
@@ -487,11 +611,14 @@ $(document).ready(() => {
|
|
|
// console.log(select);
|
|
|
|
|
|
// 更新至服务器
|
|
|
- postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', { type:'update', updateData: select, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
m_tp = result.m_tp;
|
|
|
if (materialTax) {
|
|
|
m_tax_tp = result.m_tax_tp;
|
|
|
}
|
|
|
+ if (isStageSelf) {
|
|
|
+ materialSpreadObj.updateMaterialData(result);
|
|
|
+ }
|
|
|
resetTpTable();
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
// 判断如果是更改了编号,名称,单位,月信息价需要跟着改变值
|
|
|
@@ -520,11 +647,14 @@ $(document).ready(() => {
|
|
|
select.is_summary = info.sheet.getValue(info.row, info.col) ? 1 : 0;
|
|
|
delete select.waitingLoading;
|
|
|
// 更新至服务器
|
|
|
- postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', { type:'update', updateData: select, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
m_tp = result.m_tp;
|
|
|
if (materialTax) {
|
|
|
m_tax_tp = result.m_tax_tp;
|
|
|
}
|
|
|
+ if (isStageSelf) {
|
|
|
+ materialSpreadObj.updateMaterialData(result);
|
|
|
+ }
|
|
|
resetTpTable();
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
}, function () {
|
|
|
@@ -651,8 +781,16 @@ $(document).ready(() => {
|
|
|
}
|
|
|
// console.log(data);
|
|
|
// 更新至服务器
|
|
|
- postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', { type:'paste', updateData: data, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
materialBillsData = result.info;
|
|
|
+ m_tp = result.m_tp;
|
|
|
+ if (materialTax) {
|
|
|
+ m_tax_tp = result.m_tax_tp;
|
|
|
+ }
|
|
|
+ if (isStageSelf) {
|
|
|
+ materialSpreadObj.updateMaterialData(result);
|
|
|
+ materialSpreadObj.getMaterialBillsData();
|
|
|
+ }
|
|
|
// SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
materialSpreadObj.materialSheetReset();
|
|
|
// SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
@@ -671,10 +809,6 @@ $(document).ready(() => {
|
|
|
monthFunGather.monthsListSet();
|
|
|
// SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
|
|
|
}
|
|
|
- m_tp = result.m_tp;
|
|
|
- if (materialTax) {
|
|
|
- m_tax_tp = result.m_tax_tp;
|
|
|
- }
|
|
|
resetTpTable();
|
|
|
// materialSpreadObj.refreshActn();
|
|
|
}, function () {
|
|
|
@@ -691,6 +825,8 @@ $(document).ready(() => {
|
|
|
materialSpread.bind(spreadNS.Events.SelectionChanged, materialSpreadObj.selectionChanged);
|
|
|
materialSpread.bind(spreadNS.Events.ClipboardPasted, materialSpreadObj.clipboardPasted);
|
|
|
SpreadJsObj.addDeleteBind(materialSpread, materialSpreadObj.deletePress);
|
|
|
+ materialSpread.bind(spreadNS.Events.EditEnded, materialSpreadObj.editEnded);
|
|
|
+ materialSpread.bind(spreadNS.Events.ButtonClicked, materialSpreadObj.buttonClicked);
|
|
|
const sheet = materialSpread.getActiveSheet();
|
|
|
sheet.suspendPaint();
|
|
|
// const basic_range = sheet.getRange(-1, 8, -1, 1);
|
|
|
@@ -895,23 +1031,23 @@ $(document).ready(() => {
|
|
|
// toastr.warning('请勿同时删除多行或多列数据');
|
|
|
// }
|
|
|
// console.log(sel, select, col);
|
|
|
- // if (orgValue === null || col.field === 'type' || col.field === 'is_summary') {
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // select[col.field] = null;
|
|
|
- // 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(sheet, sel.row);
|
|
|
- // materialExponentData.splice(sel.row, 1, select);
|
|
|
- // }, function () {
|
|
|
- // select[col.field] = orgValue;
|
|
|
- // SpreadJsObj.reLoadRowData(sheet, sel.row);
|
|
|
- // });
|
|
|
+ // if (orgValue === null || col.field === 'type' || col.field === 'is_summary') {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // select[col.field] = null;
|
|
|
+ // 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(sheet, sel.row);
|
|
|
+ // materialExponentData.splice(sel.row, 1, select);
|
|
|
+ // }, function () {
|
|
|
+ // select[col.field] = orgValue;
|
|
|
+ // SpreadJsObj.reLoadRowData(sheet, sel.row);
|
|
|
+ // });
|
|
|
// }
|
|
|
return;
|
|
|
},
|
|
|
@@ -1016,115 +1152,35 @@ $(document).ready(() => {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(materialSpreadSetting, materialCol);
|
|
|
+ SpreadJsObj.initSheet(materialSpread.getActiveSheet(), materialSpreadSetting);
|
|
|
+ materialSpreadObj.getMaterialBillsData();
|
|
|
+ SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
+
|
|
|
materialMonthSpread.bind(spreadNS.Events.ClipboardPasted, materialMonthSpreadObj.clipboardPasted);
|
|
|
SpreadJsObj.addDeleteBind(materialMonthSpread, materialMonthSpreadObj.deletePress);
|
|
|
+ materialMonthSpread.bind(spreadNS.Events.EditEnded, materialMonthSpreadObj.editEnded);
|
|
|
|
|
|
- if (!readOnly) {
|
|
|
- $('#add').click(materialSpreadObj.add);
|
|
|
- $('#del').click(materialSpreadObj.del);
|
|
|
- $('#up-move').click(materialSpreadObj.upMove);
|
|
|
- $('#down-move').click(materialSpreadObj.downMove);
|
|
|
- materialSpread.bind(spreadNS.Events.EditEnded, materialSpreadObj.editEnded);
|
|
|
- materialSpread.bind(spreadNS.Events.ButtonClicked, materialSpreadObj.buttonClicked);
|
|
|
- materialMonthSpread.bind(spreadNS.Events.EditEnded, materialMonthSpreadObj.editEnded);
|
|
|
-
|
|
|
- // 右键菜单
|
|
|
- $.contextMenu({
|
|
|
- selector: '#material-spread',
|
|
|
- build: function ($trigger, e) {
|
|
|
- const target = SpreadJsObj.safeRightClickSelection($trigger, e, materialSpread);
|
|
|
- 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) {
|
|
|
- materialSpreadObj.add(materialSpread.getActiveSheet());
|
|
|
- },
|
|
|
- },
|
|
|
- 'delete': {
|
|
|
- name: '删除材料',
|
|
|
- icon: 'fa-remove',
|
|
|
- callback: function (key, opt) {
|
|
|
- materialSpreadObj.del(materialSpread.getActiveSheet());
|
|
|
- },
|
|
|
- disabled: function (key, opt) {
|
|
|
- const sheet = materialSpread.getActiveSheet();
|
|
|
- const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- const sel = sheet.getSelections()[0];
|
|
|
- materialSpreadObj.refreshActn(sel.rowCount);
|
|
|
- if (!readOnly && select && materialBase.isUsed(select) && sel.rowCount === 1) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- }
|
|
|
- });
|
|
|
- $('.changeRate').click(function () {
|
|
|
- $('#rateInput').val(parseInt($(this).data('value')));
|
|
|
- $('#rateInput').siblings('.dropdown-menu').hide();
|
|
|
- });
|
|
|
- $('#rateInput').click(function () {
|
|
|
- $(this).siblings('.dropdown-menu').show();
|
|
|
- })
|
|
|
- // 回车提交
|
|
|
- $('#rateInput').on('keypress', function () {
|
|
|
- if(window.event.keyCode === 13) {
|
|
|
- $(this).blur();
|
|
|
+ // 期切换
|
|
|
+ $('#myTab a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ showWaitingView();
|
|
|
+ setTimeout(function () {
|
|
|
+ materialSpreadObj.getMaterialBillsData();
|
|
|
+ materialSpreadObj.materialSheetReset(true);
|
|
|
+ // SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
+ // 消耗量表格更新
|
|
|
+ let html = '';
|
|
|
+ calcBase = _.find(calcBaseList, { ms_id: $('#myTab').find('.active').data('msid') }).calcBase;
|
|
|
+ for (let iBase = 0; iBase < calcBase.length; iBase++) {
|
|
|
+ html += '<tr><td>' + calcBase[iBase].name + '</td><td>' + calcBase[iBase].code + '</td><td>' + calcBase[iBase].value + '</td></tr>';
|
|
|
}
|
|
|
- });
|
|
|
- $('#rateInput').blur(function () {
|
|
|
- const _self = $(this);
|
|
|
- setTimeout(function () {
|
|
|
- let rate = parseFloat(_self.val());
|
|
|
- if (_.isNaN(rate)) {
|
|
|
- toastr.error('请输入0-100之前的整数值');
|
|
|
- $('#rateInput').val(materialRate);
|
|
|
- return;
|
|
|
- }
|
|
|
- rate = _.round(rate);
|
|
|
- if(rate < 0 || rate > 100) {
|
|
|
- toastr.error('请输入0-100之前的整数值');
|
|
|
- $('#rateInput').val(materialRate);
|
|
|
- return;
|
|
|
- }
|
|
|
- $('#rateInput').siblings('.dropdown-menu').hide();
|
|
|
- console.log(rate, materialRate);
|
|
|
- if (rate !== materialRate) {
|
|
|
- postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
|
|
|
- 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(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 : '');
|
|
|
- materialRate = rate;
|
|
|
- $('#rateInput').val(rate);
|
|
|
- });
|
|
|
- } else {
|
|
|
- $('#rateInput').val(rate);
|
|
|
- }
|
|
|
- }, 500);
|
|
|
- });
|
|
|
- // $('#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), 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(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 : '');
|
|
|
- // });
|
|
|
- // });
|
|
|
+ $('#calcBase').html(html);
|
|
|
+ closeWaitingView();
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
|
|
|
+ if (!readOnly || editForAudit) {
|
|
|
$('#expr_select button').on('click', function () {
|
|
|
const code = $(this).text();
|
|
|
// $('#expr').val($('#expr').val() + code);
|
|
|
@@ -1274,11 +1330,17 @@ $(document).ready(() => {
|
|
|
if (materialTax) {
|
|
|
m_tax_tp = result.m_tax_tp;
|
|
|
}
|
|
|
- resetTpTable();
|
|
|
+
|
|
|
const sheet = materialSpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
const index = materialBillsData.indexOf(select);
|
|
|
+ console.log(select, index, result.info);
|
|
|
let newIndex = index;
|
|
|
+ if (isStageSelf) {
|
|
|
+ materialSpreadObj.updateMaterialData(result);
|
|
|
+ result.info = materialSpreadObj.updateOneMaterialBill(result.info);
|
|
|
+ console.log(result.info);
|
|
|
+ }
|
|
|
if($('#bills0_list').is(':checked')) {
|
|
|
const newMaterialBillsData = _.filter(materialBillsData, function (item) {
|
|
|
return item.quantity !== null && item.quantity !== 0;
|
|
|
@@ -1289,9 +1351,114 @@ $(document).ready(() => {
|
|
|
}
|
|
|
materialBillsData.splice(index, 1, result.info);
|
|
|
SpreadJsObj.reLoadRowData(sheet, newIndex);
|
|
|
+ resetTpTable();
|
|
|
$('#bcyy').modal('hide');
|
|
|
});
|
|
|
});
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!readOnly && !editForAudit) {
|
|
|
+ $('#add').click(materialSpreadObj.add);
|
|
|
+ $('#del').click(materialSpreadObj.del);
|
|
|
+ $('#up-move').click(materialSpreadObj.upMove);
|
|
|
+ $('#down-move').click(materialSpreadObj.downMove);
|
|
|
+
|
|
|
+ // 右键菜单
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#material-spread',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ const target = SpreadJsObj.safeRightClickSelection($trigger, e, materialSpread);
|
|
|
+ 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) {
|
|
|
+ materialSpreadObj.add(materialSpread.getActiveSheet());
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 'delete': {
|
|
|
+ name: '删除材料',
|
|
|
+ icon: 'fa-remove',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ materialSpreadObj.del(materialSpread.getActiveSheet());
|
|
|
+ },
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const sheet = materialSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ materialSpreadObj.refreshActn(sel.rowCount);
|
|
|
+ if (!readOnly && select && materialBase.isUsed(select) && sel.rowCount === 1) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('.changeRate').click(function () {
|
|
|
+ $('#rateInput').val(parseInt($(this).data('value')));
|
|
|
+ $('#rateInput').siblings('.dropdown-menu').hide();
|
|
|
+ });
|
|
|
+ $('#rateInput').click(function () {
|
|
|
+ $(this).siblings('.dropdown-menu').show();
|
|
|
+ })
|
|
|
+ // 回车提交
|
|
|
+ $('#rateInput').on('keypress', function () {
|
|
|
+ if(window.event.keyCode === 13) {
|
|
|
+ $(this).blur();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('#rateInput').blur(function () {
|
|
|
+ const _self = $(this);
|
|
|
+ setTimeout(function () {
|
|
|
+ let rate = parseFloat(_self.val());
|
|
|
+ if (_.isNaN(rate)) {
|
|
|
+ toastr.error('请输入0-100之前的整数值');
|
|
|
+ $('#rateInput').val(materialRate);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ rate = _.round(rate);
|
|
|
+ if(rate < 0 || rate > 100) {
|
|
|
+ toastr.error('请输入0-100之前的整数值');
|
|
|
+ $('#rateInput').val(materialRate);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $('#rateInput').siblings('.dropdown-menu').hide();
|
|
|
+ console.log(rate, materialRate);
|
|
|
+ if (rate !== materialRate) {
|
|
|
+ postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
|
|
|
+ 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(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 : '');
|
|
|
+ materialRate = rate;
|
|
|
+ $('#rateInput').val(rate);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $('#rateInput').val(rate);
|
|
|
+ }
|
|
|
+ }, 500);
|
|
|
+ });
|
|
|
+ // $('#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), 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(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 : '');
|
|
|
+ // });
|
|
|
+ // });
|
|
|
|
|
|
// 创建月信息价
|
|
|
$('#make-month').click(function() {
|
|
|
@@ -1377,6 +1544,114 @@ $(document).ready(() => {
|
|
|
materialSpreadObj.refreshActn();
|
|
|
});
|
|
|
|
|
|
+ let gljLib;
|
|
|
+ const gljLibCellDoubleClick = function (e, info) {
|
|
|
+ if (readOnly || editForAudit) return;
|
|
|
+ const gljSheet = info.sheet;
|
|
|
+ if (!gljSheet.zh_setting || !gljSheet.zh_tree) { return; }
|
|
|
+
|
|
|
+ const gljTree = gljSheet.zh_tree;
|
|
|
+ const gljNode = gljTree.nodes[info.row];
|
|
|
+ const sheet = materialSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ if (!gljNode) return;
|
|
|
+
|
|
|
+ if (gljNode && gljNode.is_leaf === 0) {
|
|
|
+ toastr.warning('非最底层项目下,不应添加');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ postData(window.location.pathname + '/save', { type:'add-glj', postData: gljNode, order: select ? select.order : null }, function (result) {
|
|
|
+ if (result) {
|
|
|
+ // 比order大的+1
|
|
|
+ const maxData = select ? _.filter(materialBillsData, (item) => { return item.order > select.order }) : [];
|
|
|
+ _.forEach(maxData, function (item) {
|
|
|
+ const cl = _.find(materialBillsData, { id: item.id });
|
|
|
+ cl.order = item.order + 1;
|
|
|
+ });
|
|
|
+ materialBillsData.push(result.info);
|
|
|
+ materialBillsData.sort(function (a, b) {
|
|
|
+ return a.order - b.order
|
|
|
+ });
|
|
|
+ console.log(materialBillsData);
|
|
|
+ if (isStageSelf) {
|
|
|
+ materialSpreadObj.updateMaterialData(result);
|
|
|
+ materialSpreadObj.getMaterialBillsData();
|
|
|
+ }
|
|
|
+ // sheet.addRows(materialBillsData.length - 1, 1);
|
|
|
+ // SpreadJsObj.reLoadRowData(sheet, materialBillsData.length - 1);
|
|
|
+ let newMaterialBillsData = materialBillsData;
|
|
|
+ if($('#bills0_list').is(':checked')) {
|
|
|
+ newMaterialBillsData = _.filter(materialBillsData, function (item) {
|
|
|
+ return item.quantity !== null && item.quantity !== 0;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, newMaterialBillsData);
|
|
|
+ // materialSpreadObj.materialSheetReset();
|
|
|
+ sheet.setSelection(sheet.zh_data.indexOf(select) + 1, 0, 1, 1);
|
|
|
+ materialSpreadObj.refreshActn();
|
|
|
+ // 月信息价需要同时添加空白的list
|
|
|
+ if (months.length > 0) {
|
|
|
+ const one_month ={ mb_id: result.info.id, code: result.info.code, name: result.info.name, origin: result.info.origin, unit: result.info.unit, order: result.info.order };
|
|
|
+ for (const m of months) {
|
|
|
+ one_month[m] = null;
|
|
|
+ }
|
|
|
+ _.forEach(maxData, function (item) {
|
|
|
+ const cl = _.find(monthsList, { mb_id: item.id });
|
|
|
+ cl.order = item.order + 1;
|
|
|
+ });
|
|
|
+ monthsList.push(one_month);
|
|
|
+ monthsList.sort(function (a, b) {
|
|
|
+ return a.order - b.order
|
|
|
+ });
|
|
|
+ console.log(monthsList);
|
|
|
+ // const newMonthsList = _.filter(monthsList, function (item) {
|
|
|
+ // return _.findIndex(newMaterialBillsData, { code: item.code }) !== -1;
|
|
|
+ // });
|
|
|
+ // materialMonthSpread.getActiveSheet().addRows(newMonthsList.length - 1, 1);
|
|
|
+ // SpreadJsObj.reLoadRowData(materialMonthSpread.getActiveSheet(), newMonthsList.length - 1);
|
|
|
+ monthFunGather.monthsListSet();
|
|
|
+ // materialMonthSpreadObj.monthsListSet();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ const gljLibSetting = {
|
|
|
+ selector: '#material-tab',
|
|
|
+ stdType: 'glj',
|
|
|
+ libs: gljLists,
|
|
|
+ treeSetting: {
|
|
|
+ id: 'glj_id',
|
|
|
+ pid: 'glj_pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ keys: ['id', 'list_id', 'glj_id'],
|
|
|
+ },
|
|
|
+ spreadSetting: {
|
|
|
+ cols: [
|
|
|
+ {title: '编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
+ {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
|
|
|
+ {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
|
|
|
+ {title: '参考上涨幅度', field: 'rise_range', hAlign: 1, width: 50, formatter: '@', readOnly: true},
|
|
|
+ {title: '参考下跌幅度', field: 'fall_range', hAlign: 1, width: 50, formatter: '@', readOnly: true},
|
|
|
+ ],
|
|
|
+ treeCol: 0,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ headColWidth: [30],
|
|
|
+ selectedBackColor: '#fffacd',
|
|
|
+ },
|
|
|
+ spreadClassCss: 'sjs-material',
|
|
|
+ cellDoubleClick: gljLibCellDoubleClick,
|
|
|
+ page: 'material',
|
|
|
+ tid: window.location.pathname.split('/')[2],
|
|
|
+ };
|
|
|
+
|
|
|
$.subMenu({
|
|
|
menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
|
|
|
toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
|
|
|
@@ -1400,6 +1675,7 @@ $(document).ready(() => {
|
|
|
callback: function () {
|
|
|
materialSpread.refresh();
|
|
|
materialMonthSpread.refresh();
|
|
|
+ if (gljLib) gljLib.spread.refresh();
|
|
|
const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
|
|
|
setLocalCache('material_month_' + materialID, width);
|
|
|
}
|
|
|
@@ -1408,9 +1684,15 @@ $(document).ready(() => {
|
|
|
$.divResizer({
|
|
|
select: '#main-resize',
|
|
|
callback: function () {
|
|
|
+ let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
|
|
|
+ $(".sp-wrap").height(bcontent-30);
|
|
|
+ const height = $('.bcontent-wrap').height();
|
|
|
+ const cutHeight = isStageSelf ? getObjHeight($('#myTab')) : 0;
|
|
|
+ $('.sjs-height-material').height($('.sjs-height-1').height() - cutHeight);
|
|
|
+ updateSjsHeight();
|
|
|
materialSpread.refresh();
|
|
|
materialMonthSpread.refresh();
|
|
|
- const height = $('#material-spread').height();
|
|
|
+ if (gljLib) gljLib.spread.refresh();
|
|
|
setLocalCache('material_bills_' + materialID, height);
|
|
|
}
|
|
|
});
|
|
|
@@ -1421,7 +1703,7 @@ $(document).ready(() => {
|
|
|
const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
if (!tab.hasClass('active')) {
|
|
|
$('a', '.side-menu').removeClass('active');
|
|
|
- $('.tab-content .tab-select-show').removeClass('active');
|
|
|
+ $('.tab-content .tab-pane').removeClass('active');
|
|
|
tab.addClass('active');
|
|
|
tabPanel.addClass('active');
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
@@ -1429,6 +1711,12 @@ $(document).ready(() => {
|
|
|
const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
|
|
|
setLocalCache('material_month_' + materialID, width);
|
|
|
materialMonthSpread.refresh();
|
|
|
+ } else if (tab.attr('content') === '#material-tab') {
|
|
|
+ if (!gljLib) {
|
|
|
+ gljLib = $.gljLib(gljLibSetting);
|
|
|
+ }
|
|
|
+ updateSjsHeight();
|
|
|
+ gljLib.spread.refresh();
|
|
|
}
|
|
|
} else {
|
|
|
removeLocalCache('material_month_' + materialID);
|
|
|
@@ -1437,13 +1725,13 @@ $(document).ready(() => {
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
}
|
|
|
materialSpread.refresh();
|
|
|
- materialMonthSpread.refresh();
|
|
|
+ // materialMonthSpread.refresh();
|
|
|
});
|
|
|
// 根据浏览器记录展开收起
|
|
|
- if (getLocalCache('material_month_' + materialID)) {
|
|
|
+ if (getLocalCache('material_month_' + materialID) && !isStageSelf) {
|
|
|
const tab = $('.right-nav a[content="#month-tab"]'), tabPanel = $(tab.attr('content'));
|
|
|
$('a', '.side-menu').removeClass('active');
|
|
|
- $('.tab-content .tab-select-show').removeClass('active');
|
|
|
+ $('.tab-content .tab-pane').removeClass('active');
|
|
|
tab.addClass('active');
|
|
|
tabPanel.addClass('active');
|
|
|
$('#right-view').width(getLocalCache('material_month_' + materialID) + '%');
|
|
|
@@ -1451,13 +1739,30 @@ $(document).ready(() => {
|
|
|
materialSpread.refresh();
|
|
|
materialMonthSpread.refresh();
|
|
|
}
|
|
|
+ const cutHeight = isStageSelf ? getObjHeight($('#myTab')) : 0;
|
|
|
if (getLocalCache('material_bills_' + materialID)) {
|
|
|
- $('#material-spread').height(getLocalCache('material_bills_' + materialID));
|
|
|
+ $('.bcontent-wrap').height(getLocalCache('material_bills_' + materialID));
|
|
|
const cHeader = getObjHeight($(".c-header"));
|
|
|
- const sjs1 = getObjHeight($('.sjs-height-1'));
|
|
|
- $(".bcontent-wrap").height($(window).height()-cHeader-sjs1-90+53);
|
|
|
+ const bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
|
|
|
+ $(".sp-wrap").height(bcontent-30);
|
|
|
+ $('.sjs-height-1').height($(window).height()-cHeader-bcontent-90+53);
|
|
|
+ $('.sjs-height-material').height($('.sjs-height-1').height() - cutHeight);
|
|
|
+ updateSjsHeight();
|
|
|
materialSpread.refresh();
|
|
|
materialMonthSpread.refresh();
|
|
|
+ if (gljLib) gljLib.spread.refresh();
|
|
|
+ } else {
|
|
|
+ $('.sjs-height-material').height($('.sjs-height-1').height() - cutHeight);
|
|
|
+ updateSjsHeight();
|
|
|
+ materialSpread.refresh();
|
|
|
+ materialMonthSpread.refresh();
|
|
|
+ if (gljLib) gljLib.spread.refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ function updateSjsHeight() {
|
|
|
+ $('.sjs-height-material-month').height($('.sjs-height-1').height() - getObjHeight($('.sjs-bar-1')));
|
|
|
+ $('.material-table-height').height($('.bcontent-wrap').height() - getObjHeight($('.bc-bar')));
|
|
|
+ $('.sjs-material').height($('.sjs-height-1').height() - getObjHeight($('.sjs-bar')));
|
|
|
}
|
|
|
function getObjHeight(select) {
|
|
|
return select.length > 0 ? select.height() : 0;
|