|
@@ -9,103 +9,87 @@
|
|
|
*/
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
- let gsSpread;
|
|
|
- stageIm.init(stage, imType);
|
|
|
- const gsTree = stageIm.getGsTree();
|
|
|
-
|
|
|
- function getSelectDetailData() {
|
|
|
- const rowIndex = parseInt($('#im-list').attr('rowIndex'));
|
|
|
- const data = stageIm.getImData()[rowIndex];
|
|
|
- return data;
|
|
|
- }
|
|
|
-
|
|
|
- function reLoadDetailData() {
|
|
|
- const data = getSelectDetailData();
|
|
|
- $('#edit-detail').show();
|
|
|
- $('#save-detail').hide();
|
|
|
- $('#cancel-detail').hide();
|
|
|
- $('#bgl-code').val(data && data.bgl_code ? data.bgl_code : '');
|
|
|
- $('#bw-name').val(data && data.bw ? data.bw : '');
|
|
|
- $('#start-peg').val(data && data.start_peg ? data.start_peg : '');
|
|
|
- $('#end-peg').val(data && data.end_peg ? data.end_peg : '');
|
|
|
- $('#unit-name').val(data && data.jldy ? data.jldy : '');
|
|
|
- $('#drawing-code').val(data && data.drawing_code ? data.drawing_code : '');
|
|
|
- $('#calc-memo').val(data && data.calc_memo ? data.calc_memo : '');
|
|
|
- if (data && data.calc_img) {
|
|
|
- $('#calc-img').html('<img src="/' + data.calc_img + '" class="d-100" width="100%">');
|
|
|
- } else {
|
|
|
- $('#calc-img').html('');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- function loadPosData() {
|
|
|
- const data = getSelectDetailData();
|
|
|
- const html = [];
|
|
|
- if (data) {
|
|
|
- const rowIndex = parseInt($('#leaf-xmj-list').attr('rowIndex'));
|
|
|
- const leafXmj = data.leafXmjs[rowIndex];
|
|
|
- if (leafXmj) {
|
|
|
- for (const p of leafXmj.pos) {
|
|
|
+ autoFlashHeight();
|
|
|
+ const detailSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
|
|
|
+ {title: '中间计量表号', colSpan: '1', rowSpan: '1', field: 'im_code', hAlign: 0, width: 150, formatter: '@', readOnly: true},
|
|
|
+ {title: '交工证书/凭证号', colSpan: '1', rowSpan: '1', field: 'doc_code', hAlign: 0, width: 180, formatter: '@'},
|
|
|
+ {title: '分布分项工程', colSpan: '1', rowSpan: '1', field: 'fbfx', hAlign: 0, width: 150, formatter: '@', readOnly: true},
|
|
|
+ {title: '本期计量数量/金额', colSpan: '1', rowSpan: '1', field: 'jl', hAlign: 2, width: 220, formatter: '@', readOnly: true},
|
|
|
+ ],
|
|
|
+ headRows: 1,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRowHeight: [32],
|
|
|
+ defaultRowHeight: 32,
|
|
|
+ readOnly: readOnly,
|
|
|
+ };
|
|
|
+ const detailSpread = SpreadJsObj.createNewSpread($('#detail-spread')[0]);
|
|
|
+ SpreadJsObj.initSheet(detailSpread.getActiveSheet(), detailSpreadSetting);
|
|
|
+ const detailOperationObj = {
|
|
|
+ // 部位明细
|
|
|
+ loadPosData: function () {
|
|
|
+ const data = SpreadJsObj.getSelectObject(detailSpread.getActiveSheet());
|
|
|
+ const html = [];
|
|
|
+ if (data) {
|
|
|
+ const rowIndex = parseInt($('#leaf-xmj-list').attr('rowIndex'));
|
|
|
+ const leafXmj = data.leafXmjs[rowIndex];
|
|
|
+ if (leafXmj) {
|
|
|
+ for (const p of leafXmj.pos) {
|
|
|
+ html.push('<tr>');
|
|
|
+ html.push('<td>', p.name, '</td>');
|
|
|
+ html.push('<td>', p.qty, '</td>');
|
|
|
+ html.push('<td>', p.jl, '</td>');
|
|
|
+ html.push('</tr>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#pos-list').html(html.join(''));
|
|
|
+ },
|
|
|
+ // 项目节明细
|
|
|
+ loadLeafXmjsData: function () {
|
|
|
+ const data = SpreadJsObj.getSelectObject(detailSpread.getActiveSheet());
|
|
|
+ const html = [];
|
|
|
+ if (data && data.leafXmjs) {
|
|
|
+ for (const lx of data.leafXmjs) {
|
|
|
html.push('<tr>');
|
|
|
- html.push('<td>', p.name, '</td>');
|
|
|
- html.push('<td>', p.qty, '</td>');
|
|
|
- html.push('<td>', p.jl, '</td>');
|
|
|
+ html.push('<td>', lx.code , '</td>');
|
|
|
+ html.push('<td>', lx.name , '</td>');
|
|
|
+ html.push('<td>', lx.jl , '</td>');
|
|
|
html.push('</tr>');
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- $('#pos-list').html(html.join(''));
|
|
|
- }
|
|
|
-
|
|
|
- function loadLeafXmjsData() {
|
|
|
- const data = getSelectDetailData();
|
|
|
- const html = [];
|
|
|
- if (data && data.leafXmjs) {
|
|
|
- for (const lx of data.leafXmjs) {
|
|
|
- html.push('<tr>');
|
|
|
- html.push('<td>', lx.code , '</td>');
|
|
|
- html.push('<td>', lx.name , '</td>');
|
|
|
- html.push('<td>', lx.jl , '</td>');
|
|
|
- html.push('</tr>');
|
|
|
+ $('#leaf-xmj-list').html(html.join(''));
|
|
|
+ $('#leaf-xmj-list').attr('rowIndex', 0);
|
|
|
+ $('tr:first', '#leaf-xmj-list').addClass('table-warning');
|
|
|
+ detailOperationObj.loadPosData();
|
|
|
+ $('tr', '#leaf-xmj-list').bind('click', function () {
|
|
|
+ $('tr.table-warning', '#leaf-xmj-list').removeClass('table-warning');
|
|
|
+ $(this).addClass('table-warning');
|
|
|
+ $('#leaf-xmj-list').attr('rowIndex', this.rowIndex - 1);
|
|
|
+ detailOperationObj.loadPosData();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 中间计量数据
|
|
|
+ reLoadDetailData: function () {
|
|
|
+ const data = SpreadJsObj.getSelectObject(detailSpread.getActiveSheet());
|
|
|
+ $('#edit-detail').show();
|
|
|
+ $('#save-detail').hide();
|
|
|
+ $('#cancel-detail').hide();
|
|
|
+ $('#bgl-code').val(data && data.bgl_code ? data.bgl_code : '');
|
|
|
+ $('#bw-name').val(data && data.bw ? data.bw : '');
|
|
|
+ $('#start-peg').val(data && data.start_peg ? data.start_peg : '');
|
|
|
+ $('#end-peg').val(data && data.end_peg ? data.end_peg : '');
|
|
|
+ $('#unit-name').val(data && data.jldy ? data.jldy : '');
|
|
|
+ $('#drawing-code').val(data && data.drawing_code ? data.drawing_code : '');
|
|
|
+ $('#calc-memo').val(data && data.calc_memo ? data.calc_memo : '');
|
|
|
+ if (data && data.calc_img) {
|
|
|
+ $('#calc-img').html('<img src="/' + data.calc_img + '" class="d-100" width="100%">');
|
|
|
+ } else {
|
|
|
+ $('#calc-img').html('');
|
|
|
}
|
|
|
- }
|
|
|
- $('#leaf-xmj-list').html(html.join(''));
|
|
|
- $('#leaf-xmj-list').attr('rowIndex', 0);
|
|
|
- loadPosData();
|
|
|
- }
|
|
|
-
|
|
|
- function reBuildImData() {
|
|
|
- const imData = stageIm.buildImData();
|
|
|
- const html = [];
|
|
|
- for (const im of imData) {
|
|
|
- html.push('<tr>');
|
|
|
- html.push('<td>');
|
|
|
- html.push(im.code);
|
|
|
- html.push('</td>');
|
|
|
- html.push('<td>');
|
|
|
- html.push(im.im_code);
|
|
|
- html.push('</td>');
|
|
|
- html.push('<td>');
|
|
|
- html.push(im.doc_code);
|
|
|
- html.push('</td>');
|
|
|
- html.push('<td>');
|
|
|
- html.push(im.fbfx);
|
|
|
- html.push('</td>');
|
|
|
- html.push('<td align="right">');
|
|
|
- html.push(im.jl);
|
|
|
- html.push('</td>');
|
|
|
- html.push('</tr>');
|
|
|
- }
|
|
|
- $('#im-list').html(html.join(''));
|
|
|
- $('tr:first', '#im-list').addClass('table-warning');
|
|
|
- $('#im-list').attr('rowIndex', 0);
|
|
|
- reLoadDetailData();
|
|
|
- loadLeafXmjsData();
|
|
|
- $('tr', '#im-list').click(function () {
|
|
|
- $('tr.table-warning').removeClass('table-warning');
|
|
|
- $(this).addClass('table-warning');
|
|
|
- $('#im-list').attr('rowIndex', this.rowIndex - 1);
|
|
|
-
|
|
|
+ },
|
|
|
+ selectionChanged: function (e, info) {
|
|
|
$('#edit-detail').show();
|
|
|
$('#cancel-detail').hide();
|
|
|
$('#save-detail').hide();
|
|
@@ -116,12 +100,125 @@ $(document).ready(() => {
|
|
|
$('#unit-name').attr('readonly', '');
|
|
|
$('#drawing-code').attr('readonly', '');
|
|
|
$('#calc-memo').attr('readonly', '');
|
|
|
- reLoadDetailData();
|
|
|
- loadLeafXmjsData();
|
|
|
- });
|
|
|
- $('tr', '#leaf-xmj-list').click(function () {
|
|
|
- loadPosData();
|
|
|
- });
|
|
|
+ detailOperationObj.reLoadDetailData();
|
|
|
+ detailOperationObj.loadLeafXmjsData();
|
|
|
+ },
|
|
|
+ editEnded: function(e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if (col.field !== 'doc_code') {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ if (data) {
|
|
|
+ const updateData = {lid: data.lid}
|
|
|
+ if (data.uuid) {
|
|
|
+ updateData.uuid = data.uuid;
|
|
|
+ } else {
|
|
|
+ updateData.code = data.code;
|
|
|
+ updateData.name = data.name;
|
|
|
+ updateData.unit = data.unit;
|
|
|
+ updateData.unit_price = data.unit_price;
|
|
|
+ }
|
|
|
+ updateData.doc_code = info.editingText;
|
|
|
+ postData(window.location.pathname + '/save', updateData, function (result) {
|
|
|
+ stageIm.loadUpdateDetailData(result);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clipboardPasted: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting && info.sheet.zh_data) {
|
|
|
+ const col = info.sheet.zh_setting.cols[info.cellRange.col];
|
|
|
+ if (info.cellRange.colCount > 1) {
|
|
|
+ toast('请勿同时复制粘贴多列数据', 'warning');
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (col.field !== 'doc_code') {
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const datas = [];
|
|
|
+ for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
|
|
|
+ const curRow = info.cellRange.row + iRow;
|
|
|
+ const data = info.sheet.zh_data[curRow];
|
|
|
+ if (data) {
|
|
|
+ const updateData = {lid: data.lid};
|
|
|
+ if (data.uuid) {
|
|
|
+ updateData.uuid = data.uuid;
|
|
|
+ } else {
|
|
|
+ updateData.code = data.code;
|
|
|
+ updateData.name = data.name;
|
|
|
+ updateData.unit = data.unit;
|
|
|
+ updateData.unit_price = data.unit_price;
|
|
|
+ }
|
|
|
+ updateData.doc_code = info.sheet.getText(curRow, info.cellRange.col).replace('\n', '');
|
|
|
+ datas.push(updateData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (datas.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', datas, function (result) {
|
|
|
+ stageIm.loadUpdateDetailData(result);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deletePress: function (sheet) {
|
|
|
+ if (sheet.zh_setting) {
|
|
|
+ const datas = [];
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
|
|
|
+ const col = sheet.zh_setting.cols[iCol];
|
|
|
+ for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
|
|
|
+ const data = sheet.zh_data[iRow];
|
|
|
+ if (col.field === 'doc_code') {
|
|
|
+ const updateData = {lid: data.lid};
|
|
|
+ if (data.uuid) {
|
|
|
+ updateData.uuid = data.uuid;
|
|
|
+ updateData.doc_code = null;
|
|
|
+ datas.push(updateData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (datas.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', datas, function (result) {
|
|
|
+ stageIm.loadUpdateDetailData(result);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ };
|
|
|
+ detailSpread.bind(spreadNS.Events.SelectionChanged, detailOperationObj.selectionChanged);
|
|
|
+ if (!readOnly) {
|
|
|
+ detailSpread.bind(spreadNS.Events.EditEnded, detailOperationObj.editEnded);
|
|
|
+ detailSpread.bind(spreadNS.Events.ClipboardPasted, detailOperationObj.clipboardPasted);
|
|
|
+ SpreadJsObj.addDeleteBind(detailSpread, detailOperationObj.deletePress);
|
|
|
+ }
|
|
|
+
|
|
|
+ let gsSpread;
|
|
|
+ stageIm.init(stage, imType);
|
|
|
+ const gsTree = stageIm.getGsTree();
|
|
|
+
|
|
|
+ function reBuildImData() {
|
|
|
+ const imData = stageIm.buildImData();
|
|
|
+ SpreadJsObj.loadSheetData(detailSpread.getActiveSheet(), SpreadJsObj.DataType.Data, imData);
|
|
|
+ detailOperationObj.reLoadDetailData();
|
|
|
+ detailOperationObj.loadLeafXmjsData();
|
|
|
}
|
|
|
|
|
|
postData(window.location.pathname + '/load', { loadType: 'all' }, function (data) {
|
|
@@ -451,8 +548,8 @@ $(document).ready(() => {
|
|
|
};
|
|
|
// 加载草图组成
|
|
|
$('#edit-img').on('show.bs.modal', function () {
|
|
|
- const data = getSelectDetailData();
|
|
|
- const items = data.calc_img_org !== undefined ? JSON.parse(data.calc_img_org) : [];
|
|
|
+ const data = SpreadJsObj.getSelectObject(detailSpread.getActiveSheet());
|
|
|
+ const items = data.calc_img_org ? JSON.parse(data.calc_img_org) : [];
|
|
|
const html = [];
|
|
|
for (const item of items) {
|
|
|
const itemStyle = 'top:' + item.top + ';' + 'left:' + item.left + ';' + 'width:' + item.width + ';' + 'height:' + item.height + ';';
|