|
@@ -5,6 +5,9 @@
|
|
|
* @date 2018/02/05
|
|
|
* @version
|
|
|
*/
|
|
|
+function checkTzMeasureType () {
|
|
|
+ return tender.measure_type === measureType.tz.value;
|
|
|
+}
|
|
|
|
|
|
function loadContent(data) {
|
|
|
const html = [];
|
|
@@ -39,6 +42,7 @@ function loadContents(data) {
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
autoFlashHeight();
|
|
|
+ // 初始化台账
|
|
|
const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
|
|
|
SpreadJsObj.addDeleteBind(ledgerSpread);
|
|
|
const ledgerTree = createNewPathTree('ledger', {
|
|
@@ -51,12 +55,19 @@ $(document).ready(function() {
|
|
|
preUrl: '/ledger'
|
|
|
});
|
|
|
ledgerTree.loadDatas(ledger);
|
|
|
+ treeCalc.calculateAll(ledgerTree, ['total_price']);
|
|
|
SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
|
|
|
+ // 加载台账数据到界面
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
|
|
|
|
|
|
+
|
|
|
+ // 初始化 部位明细
|
|
|
+ const pos = new PosData({
|
|
|
+ id: 'id', masterId: 'lid',
|
|
|
+ });
|
|
|
const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
|
|
|
- SpreadJsObj.initSheet(posSpread.getActiveSheet(), posSpreadSetting);
|
|
|
|
|
|
+ // 定义事件
|
|
|
const treeOperationObj = {
|
|
|
getSelectNode: function (sheet) {
|
|
|
if (!sheet || !sheet.zh_tree) {
|
|
@@ -84,12 +95,18 @@ $(document).ready(function() {
|
|
|
const tree = sheet.zh_tree;
|
|
|
if (!tree) { return; }
|
|
|
const node = sheet.zh_tree.nodes[row];
|
|
|
+ const valid = !sheet.zh_setting.readOnly;
|
|
|
|
|
|
- setObjEnable($('#delete'), !sheet.zh_setting.readOnly && node);
|
|
|
- setObjEnable($('#up-move'), !sheet.zh_setting.readOnly && node && node.order > 1);
|
|
|
- setObjEnable($('#down-move'), !sheet.zh_setting.readOnly && node && !tree.isLastSibling(node));
|
|
|
- setObjEnable($('#up-level'), !sheet.zh_setting.readOnly && node && tree.getParent(node));
|
|
|
- setObjEnable($('#down-level'), !sheet.zh_setting.readOnly && node && node.order > 1);
|
|
|
+ setObjEnable($('#delete'), valid && node);
|
|
|
+ setObjEnable($('#up-move'), valid && node && node.order > 1);
|
|
|
+ setObjEnable($('#down-move'), valid && node && !tree.isLastSibling(node));
|
|
|
+ if (checkTzMeasureType()) {
|
|
|
+ const posRange = pos.getMasterRange(node.id);
|
|
|
+ setObjEnable($('#up-level'), valid && node && tree.getParent(node) && (!posRange || posRange.length === 0));
|
|
|
+ } else {
|
|
|
+ setObjEnable($('#up-level'), valid && node && tree.getParent(node));
|
|
|
+ }
|
|
|
+ setObjEnable($('#down-level'), valid && node && node.order > 1);
|
|
|
},
|
|
|
refreshTree: function (sheet, data) {
|
|
|
SpreadJsObj.massOperationSheet(sheet, function () {
|
|
@@ -162,7 +179,7 @@ $(document).ready(function() {
|
|
|
if (!node) { return; }
|
|
|
|
|
|
SpreadJsObj.massOperationSheet(sheet, function () {
|
|
|
- tree.baseOperation('base-operation', node, 'add', function (result) {
|
|
|
+ tree.baseOperation(preUrl + '/ledger/base-operation', node, 'add', function (result) {
|
|
|
self.refreshTree(sheet, result);
|
|
|
self.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
});
|
|
@@ -184,12 +201,16 @@ $(document).ready(function() {
|
|
|
if (!node) { return; }
|
|
|
|
|
|
const count = ledgerTree.getPosterity(node).length;
|
|
|
- tree.baseOperation('base-operation', node, 'delete', function (result) {
|
|
|
+ tree.baseOperation(preUrl + '/ledger/base-operation', node, 'delete', function (result) {
|
|
|
sheet.deleteRows(row, count + 1);
|
|
|
for (const data of result.update) {
|
|
|
SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(data), tree.getPosterity(data).length + 1);
|
|
|
}
|
|
|
self.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
+ for (const data of result.delete) {
|
|
|
+ pos.removeDatasByMasterId(data.id);
|
|
|
+ }
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
@@ -208,7 +229,7 @@ $(document).ready(function() {
|
|
|
const node = tree.nodes[row];
|
|
|
if (!node) { return; }
|
|
|
|
|
|
- tree.baseOperation('base-operation', node, 'up-move', function (result) {
|
|
|
+ tree.baseOperation(preUrl + '/ledger/base-operation', node, 'up-move', function (result) {
|
|
|
for (const data of result.update) {
|
|
|
SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(data), tree.getPosterity(data).length + 1);
|
|
|
}
|
|
@@ -234,7 +255,7 @@ $(document).ready(function() {
|
|
|
const node = tree.nodes[row];
|
|
|
if (!node) { return; }
|
|
|
|
|
|
- tree.baseOperation('base-operation', node, 'down-move', function (result) {
|
|
|
+ tree.baseOperation(preUrl + '/ledger/base-operation', node, 'down-move', function (result) {
|
|
|
for (const data of result.update) {
|
|
|
SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(data), tree.getPosterity(data).length + 1);
|
|
|
}
|
|
@@ -258,7 +279,7 @@ $(document).ready(function() {
|
|
|
const node = tree.nodes[row];
|
|
|
if (!node) { return; }
|
|
|
|
|
|
- tree.baseOperation('base-operation', node, 'up-level', function (result) {
|
|
|
+ tree.baseOperation(preUrl + '/ledger/base-operation', node, 'up-level', function (result) {
|
|
|
self.refreshTree(sheet, result);
|
|
|
self.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
});
|
|
@@ -279,7 +300,7 @@ $(document).ready(function() {
|
|
|
const node = tree.nodes[row];
|
|
|
if (!node) { return; }
|
|
|
|
|
|
- tree.baseOperation('base-operation', node, 'down-level', function (result) {
|
|
|
+ tree.baseOperation(preUrl + '/ledger/base-operation', node, 'down-level', function (result) {
|
|
|
self.refreshTree(sheet, result);
|
|
|
self.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
});
|
|
@@ -301,12 +322,8 @@ $(document).ready(function() {
|
|
|
};
|
|
|
data[col.field] = col.type === 'Number' ? parseFloat(info.editingText) : info.editingText;
|
|
|
|
|
|
- info.sheet.zh_tree.update('update', data, function (result) {
|
|
|
- const rows = [];
|
|
|
- for (const r of result) {
|
|
|
- rows.push(sortData.indexOf(r));
|
|
|
- }
|
|
|
- SpreadJsObj.reLoadRowsData(info.sheet, rows);
|
|
|
+ info.sheet.zh_tree.update(preUrl + '/ledger/update', data, function (result) {
|
|
|
+ treeOperationObj.refreshTree(info.sheet, result);
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -333,7 +350,7 @@ $(document).ready(function() {
|
|
|
nodes.push(node);
|
|
|
}
|
|
|
}
|
|
|
- info.sheet.zh_tree.update('update', datas, function (result) {
|
|
|
+ info.sheet.zh_tree.update('/ledger/update', datas, function (result) {
|
|
|
const rows = [];
|
|
|
for (const data of result) {
|
|
|
rows.push(sortData.indexOf(data));
|
|
@@ -363,7 +380,7 @@ $(document).ready(function() {
|
|
|
nodes.push(node);
|
|
|
}
|
|
|
}
|
|
|
- sheet.zh_tree.update('update-info', datas, function (result) {
|
|
|
+ sheet.zh_tree.update(preUrl + '/ledger/update-info', datas, function (result) {
|
|
|
const rows = [];
|
|
|
for (const data of result) {
|
|
|
rows.push(sortData.indexOf(data));
|
|
@@ -388,30 +405,24 @@ $(document).ready(function() {
|
|
|
const node = tree.nodes[row];
|
|
|
if (!node) { return; }
|
|
|
|
|
|
- tree.pasteBlock('paste-block', node, block, function (result) {
|
|
|
- self.refreshTree(sheet, result);
|
|
|
- self.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
+ postData(preUrl + '/ledger/paste-block', {
|
|
|
+ id: node[tree.setting.id],
|
|
|
+ block: block,
|
|
|
+ }, function (data) {
|
|
|
+ pos.updateDatas(data.pos);
|
|
|
+ tree.loadPostData(data.ledger, function (result) {
|
|
|
+ self.refreshTree(sheet, result);
|
|
|
+ self.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
- batchInsertData: function (spread, data, fun) {
|
|
|
- const self = this;
|
|
|
- const sheet = spread.getActiveSheet();
|
|
|
- const row = sheet.getSelections()[0].row;
|
|
|
-
|
|
|
- const tree = sheet.zh_tree;
|
|
|
- if (!tree) { return; }
|
|
|
-
|
|
|
- const node = tree.nodes[row];
|
|
|
- if (!node) { return; }
|
|
|
-
|
|
|
- tree.batchInsert('batch-insert', node, data, function (result) {
|
|
|
- self.refreshTree(sheet, result);
|
|
|
- self.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
- fun();
|
|
|
- });
|
|
|
- }
|
|
|
+ selectionChanged: function (e, info) {
|
|
|
+ if (info.newSelections[0].row !== info.oldSelections[0].row) {
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
+ }
|
|
|
+ },
|
|
|
};
|
|
|
-
|
|
|
+ // 绑定事件
|
|
|
if (!ledgerSpreadSetting.readOnly) {
|
|
|
ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e, info) {
|
|
|
treeOperationObj.refreshOperationValid(info.sheet, info.newSelections);
|
|
@@ -427,6 +438,7 @@ $(document).ready(function() {
|
|
|
});
|
|
|
ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (e, info) {
|
|
|
});
|
|
|
+ ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, treeOperationObj.selectionChanged);
|
|
|
|
|
|
// 绑定 删除等 顶部按钮
|
|
|
$('#delete').click(function () {
|
|
@@ -516,7 +528,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
},
|
|
|
'pasteBlock': {
|
|
|
- name: '粘贴',
|
|
|
+ name: '粘贴整块',
|
|
|
icon: 'fa-clipboard',
|
|
|
disabled: function (key, opt) {
|
|
|
const block = treeOperationObj.block || [];
|
|
@@ -531,63 +543,129 @@ $(document).ready(function() {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- 'batchInsertChild': {
|
|
|
- name: '批量插入子项',
|
|
|
+ 'batchInsertBillsPos': {
|
|
|
+ name: '批量插入清单部位',
|
|
|
icon: 'fa-sign-in',
|
|
|
disabled: function (key, opt) {
|
|
|
- return false;
|
|
|
- },
|
|
|
- callback: function(key, opt) {
|
|
|
- $('h5', $('#batch')).text('批量插入子项');
|
|
|
- if (!batchInsertObj) {
|
|
|
- batchInsertObj = new BatchInsertObj($('#batch'), key);
|
|
|
+ const sheet = ledgerSpread.getActiveSheet();
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const row = selection[0].row;
|
|
|
+ const select = ledgerTree.nodes[row];
|
|
|
+ if (select) {
|
|
|
+ if (select.code && select.code !== '') {
|
|
|
+ return !ledgerTree.isLeafXmj(select);
|
|
|
+ } else {
|
|
|
+ const parent = ledgerTree.getParent(select);
|
|
|
+ return !(parent && ledgerTree.isLeafXmj(parent));
|
|
|
+ }
|
|
|
} else {
|
|
|
- batchInsertObj.batchType = key;
|
|
|
- batchInsertObj.initView();
|
|
|
+ return false;
|
|
|
}
|
|
|
- $('#batch').modal('show');
|
|
|
- },
|
|
|
- },
|
|
|
- 'batchInsertNext': {
|
|
|
- name: '批量插入后项',
|
|
|
- icon: 'fa-sign-in',
|
|
|
- disabled: function (key, opt) {
|
|
|
- return false;
|
|
|
},
|
|
|
callback: function (key, opt) {
|
|
|
- $('h5', $('#batch')).text('批量插入后项');
|
|
|
if (!batchInsertObj) {
|
|
|
- batchInsertObj = new BatchInsertObj($('#batch'), key);
|
|
|
+ batchInsertObj = new BatchInsertBillsPosObj($('#batch'));
|
|
|
} else {
|
|
|
- batchInsertObj.batchType = key;
|
|
|
batchInsertObj.initView();
|
|
|
}
|
|
|
$('#batch').modal('show');
|
|
|
- },
|
|
|
- },
|
|
|
- 'loadAll': {
|
|
|
- name: '加载全部叶子节点',
|
|
|
- callback: function (key, opt) {
|
|
|
- const sheet = ledgerSpread.getActiveSheet();
|
|
|
- const selection = sheet.getSelections();
|
|
|
- const row = selection[0].row;
|
|
|
- const select = ledgerTree.nodes[row];
|
|
|
- ledgerTree.postData('posterity', null, {id: ledgerTree.getNodeKey(select)}, function (result) {
|
|
|
- let time = new Date();
|
|
|
- select.expanded = true;
|
|
|
- treeOperationObj.refreshTree(sheet, result);
|
|
|
- time = new Date() - time;
|
|
|
- console.log('refreshSpreadView: '+ time);
|
|
|
- treeOperationObj.refreshOperationValid(sheet, sheet.getSelections());
|
|
|
- });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet(), ledgerSpread.getActiveSheet().getSelections());
|
|
|
|
|
|
+
|
|
|
+ // 台账模式加载部位明细数据
|
|
|
+ if (checkTzMeasureType()) {
|
|
|
+ SpreadJsObj.initSheet(posSpread.getActiveSheet(), posSpreadSetting);
|
|
|
+ postData(preUrl + '/pos', null, function (data) {
|
|
|
+ pos.loadDatas(data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 绑定部位明细编辑事件
|
|
|
+ const posOperationObj = {
|
|
|
+ loadCurPosData: function () {
|
|
|
+ const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
|
|
|
+ if (node) {
|
|
|
+ const posData = pos.masterRange[itemsPre + node.id] || [];
|
|
|
+ SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', posData);
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', []);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 编辑单元格响应事件
|
|
|
+ * @param {Object} e
|
|
|
+ * @param {Object} info
|
|
|
+ */
|
|
|
+ editEnding: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const orgText = info.sheet.getCell(info.row, info.row).value();
|
|
|
+ if (orgText === info.editingText || ((!orgText || orgText === '') && (info.editingText === ''))) {
|
|
|
+ console.log(3);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
|
|
|
+ if (info.editingText !== '' && node.children && node.children > 0) {
|
|
|
+ toast('父节点不可插入部位明细', 'error');
|
|
|
+ info.cancel = true;
|
|
|
+ return;
|
|
|
+ } else if (info.editingText !== '' && node.code || node.code !== '') {
|
|
|
+ toast('项目节不可插入部位明细', 'error');
|
|
|
+ info.cancel = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const curPosData = pos.getMasterRange(node.id);
|
|
|
+ const position = curPosData ? curPosData[info.row] : null;
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ const data = {};
|
|
|
+ if (col.field === 'name') {
|
|
|
+ console.log(1);
|
|
|
+ if (info.editingText === '' && position) {
|
|
|
+ console.log(2);
|
|
|
+ toast('部位名称不可为空', 'error', 'exclamation-circle');
|
|
|
+ info.cancel = true;
|
|
|
+ return;
|
|
|
+ } else if (!position) {
|
|
|
+ if (info.editingText !== '') {
|
|
|
+ data.updateType = 'add';
|
|
|
+ data.updateData = {name: info.editingText, lid: node.id, tid: tender.id};
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.updateType = 'update';
|
|
|
+ data.updateData = {id: position.id, name: info.editingText};
|
|
|
+ }
|
|
|
+ } else if (!position) {
|
|
|
+ toast('新增部位请先输入名称', 'warning');
|
|
|
+ } else {
|
|
|
+ data.updateType = 'update';
|
|
|
+ data.updateData = {id: position.id};
|
|
|
+ data.updateData[col.field] = col.type === 'Number' ? parseFloat(info.editingText) : info.editingText;
|
|
|
+ }
|
|
|
+ postData(preUrl+'/pos/update', data, function (result) {
|
|
|
+ pos.updateDatas(result.pos);
|
|
|
+ ledgerTree.loadPostData(result.ledger, function (loadResult) {
|
|
|
+ treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
|
|
|
+ });
|
|
|
+ }, function () {
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ };
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
+ if (!posSpreadSetting.readOnly) {
|
|
|
+ SpreadJsObj.addDeleteBind(posSpread, treeOperationObj.deletePress);
|
|
|
+ posSpread.bind(GC.Spread.Sheets.Events.EditEnding, posOperationObj.editEnding);
|
|
|
+ posSpread.bind(GC.Spread.Sheets.Events.CellClick, function (e, info) {
|
|
|
+ console.log(info.sheet.getCell(info.row, info.col));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
let stdChapter, stdBills, dealBills, searchLedger;
|
|
|
// 展开收起标准清单
|
|
|
$('a', '#side-menu').bind('click', function () {
|
|
@@ -600,87 +678,101 @@ $(document).ready(function() {
|
|
|
$('.c-body.col-8').removeClass('col-8').addClass('col-12');
|
|
|
$('.c-body.col-4').removeClass('col-4').addClass('col-0').hide();
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
+ // 展开工具栏、切换标签
|
|
|
if (!tab.hasClass('active')) {
|
|
|
$('a', '#side-menu').removeClass('active');
|
|
|
tab.addClass('active');
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
$('.tab-content .tab-pane').hide();
|
|
|
tabPanel.show();
|
|
|
- if (tab.attr('content') === '#std-chapter' && !stdChapter) {
|
|
|
- stdChapter = new stdLib($('#std-chapter-spread')[0], 'chapter', {
|
|
|
- id: 'chapter_id',
|
|
|
- pid: 'pid',
|
|
|
- order: 'order',
|
|
|
- level: 'level',
|
|
|
- rootId: -1,
|
|
|
- keys: ['id', 'list_id', 'chapter_id'],
|
|
|
- }, {
|
|
|
- cols: [
|
|
|
- {title: '项目节编号', field: 'code', width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
- {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
- {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true}
|
|
|
- ],
|
|
|
- treeCol: 0,
|
|
|
- emptyRows: 0,
|
|
|
- headRows: 1,
|
|
|
- headRowHeight: [40],
|
|
|
- defaultRowHeight: 21,
|
|
|
- });
|
|
|
- stdChapter.loadLib(1);
|
|
|
- } else if (tab.attr('content') === '#std-bills' && !stdBills) {
|
|
|
- stdBills = new stdLib($('#std-bills-spread')[0], 'bills', {
|
|
|
- id: 'bill_id',
|
|
|
- pid: 'pid',
|
|
|
- order: 'order',
|
|
|
- level: 'level',
|
|
|
- rootId: -1,
|
|
|
- keys: ['id', 'list_id', 'bill_id']
|
|
|
- }, {
|
|
|
- cols: [
|
|
|
- {title: '清单编号', field: 'code', width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
- {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
- {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true}
|
|
|
- ],
|
|
|
- treeCol: 0,
|
|
|
- emptyRows: 0,
|
|
|
- headRows: 1,
|
|
|
- headRowHeight: [40],
|
|
|
- defaultRowHeight: 21,
|
|
|
- });
|
|
|
- stdBills.loadLib(1);
|
|
|
- } else if (tab.attr('content') === '#deal-bills' && !dealBills) {
|
|
|
- dealBills = new DealBills($('#deal-bills-spread')[0], {
|
|
|
- cols: [
|
|
|
- {title: '清单编号', field: 'code', width: 120, formatter: '@', readOnly: true},
|
|
|
- {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
- {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
|
|
|
- {title: '单价', field: 'unit_price', width: 50, readOnly: true},
|
|
|
- {title: '数量', field: 'quantity', width: 50, readOnly: true},
|
|
|
- ],
|
|
|
- emptyRows: 0,
|
|
|
- headRows: 1,
|
|
|
- headRowHeight: [40],
|
|
|
- defaultRowHeight: 21,
|
|
|
- });
|
|
|
- dealBills.loadData();
|
|
|
+ autoFlashHeight();
|
|
|
+ if (tab.attr('content') === '#std-chapter') {
|
|
|
+ if (!stdChapter) {
|
|
|
+ stdChapter = new stdLib($('#std-chapter-spread')[0], 'chapter', {
|
|
|
+ id: 'chapter_id',
|
|
|
+ pid: 'pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ keys: ['id', 'list_id', 'chapter_id'],
|
|
|
+ }, {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', field: 'code', width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
+ {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
+ {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true}
|
|
|
+ ],
|
|
|
+ treeCol: 0,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ });
|
|
|
+ stdChapter.loadLib(1);
|
|
|
+ }
|
|
|
+ stdChapter.spread.refresh();
|
|
|
+ } else if (tab.attr('content') === '#std-bills') {
|
|
|
+ if (!stdBills) {
|
|
|
+ stdBills = new stdLib($('#std-bills-spread')[0], 'bills', {
|
|
|
+ id: 'bill_id',
|
|
|
+ pid: 'pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ keys: ['id', 'list_id', 'bill_id']
|
|
|
+ }, {
|
|
|
+ cols: [
|
|
|
+ {title: '清单编号', field: 'code', width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
+ {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
+ {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true}
|
|
|
+ ],
|
|
|
+ treeCol: 0,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ });
|
|
|
+ stdBills.loadLib(1);
|
|
|
+ }
|
|
|
+ stdBills.spread.refresh();
|
|
|
+ } else if (tab.attr('content') === '#deal-bills') {
|
|
|
+ if (!dealBills) {
|
|
|
+ dealBills = new DealBills($('#deal-bills-spread')[0], {
|
|
|
+ cols: [
|
|
|
+ {title: '清单编号', field: 'code', width: 120, formatter: '@', readOnly: true},
|
|
|
+ {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
+ {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
|
|
|
+ {title: '单价', field: 'unit_price', width: 50, readOnly: true},
|
|
|
+ {title: '数量', field: 'quantity', width: 50, readOnly: true},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ });
|
|
|
+ dealBills.loadData();
|
|
|
+ }
|
|
|
+ dealBills.spread.refresh();
|
|
|
} else if (tab.attr('content') === '#search' && !searchLedger) {
|
|
|
- searchLedger = new SearchLedger($('#search'), {
|
|
|
- cols: [
|
|
|
- {title: '项目节编号', field: 'code', width: 120, formatter: '@', readOnly: true},
|
|
|
- {title: '清单编号', field: 'b_code', width: 120, formatter: '@', readOnly: true},
|
|
|
- {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
- {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
|
|
|
- {title: '单价', field: 'unit_price', width: 50, readOnly: true},
|
|
|
- {title: '数量', field: 'quantity', width: 50, readOnly: true},
|
|
|
- ],
|
|
|
- emptyRows: 3,
|
|
|
- headRows: 1,
|
|
|
- headRowHeight: [40],
|
|
|
- defaultRowHeight: 21,
|
|
|
- })
|
|
|
+ if (!searchLedger) {
|
|
|
+ searchLedger = new SearchLedger($('#search'), {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', field: 'code', width: 120, formatter: '@', readOnly: true},
|
|
|
+ {title: '清单编号', field: 'b_code', width: 120, formatter: '@', readOnly: true},
|
|
|
+ {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
|
|
|
+ {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
|
|
|
+ {title: '单价', field: 'unit_price', width: 50, readOnly: true},
|
|
|
+ {title: '数量', field: 'quantity', width: 50, readOnly: true},
|
|
|
+ ],
|
|
|
+ emptyRows: 3,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ searchLedger.spread.refresh();
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else { // 收起工具栏
|
|
|
tab.removeClass('active');
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
tabPanel.hide();
|
|
@@ -692,7 +784,7 @@ $(document).ready(function() {
|
|
|
class stdLib {
|
|
|
constructor(obj, stdType, treeSetting, spreadSetting) {
|
|
|
this.obj = obj;
|
|
|
- this.url = '/std/' + stdType;
|
|
|
+ this.url = '/api/std/' + stdType;
|
|
|
this.treeSetting = treeSetting;
|
|
|
treeSetting.preUrl = this.url;
|
|
|
this.spreadSetting = spreadSetting;
|
|
@@ -734,7 +826,7 @@ $(document).ready(function() {
|
|
|
constructor (obj, spreadSetting) {
|
|
|
const self = this;
|
|
|
this.obj = obj;
|
|
|
- this.url = '/deal';
|
|
|
+ this.url = preUrl + '/deal';
|
|
|
this.spreadSetting = spreadSetting;
|
|
|
this.spread = SpreadJsObj.createNewSpread(this.obj);
|
|
|
SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
|
|
@@ -748,39 +840,24 @@ $(document).ready(function() {
|
|
|
}, function () {
|
|
|
$('#upload-deal').modal('hide');
|
|
|
});
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
loadData () {
|
|
|
const self = this;
|
|
|
postData(this.url+'/get-data', {}, function (data) {
|
|
|
+ this.data = data;
|
|
|
SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- class BatchInsertObj {
|
|
|
- constructor (obj, batchType) {
|
|
|
+ class BatchInsertBillsPosObj {
|
|
|
+ constructor (obj) {
|
|
|
const self = this;
|
|
|
this.obj = obj;
|
|
|
- this.batchType = batchType;
|
|
|
this.billsCount = 6;
|
|
|
-
|
|
|
- this.xmSpreadSetting = {
|
|
|
- cols: [
|
|
|
- {title: '部位', field: 'bw', width: 80, formatter: '@'},
|
|
|
- {title: '图册号', field: 'drawingCode', formatter: '@', width: 60},
|
|
|
- ],
|
|
|
- emptyRows: 1000,
|
|
|
- headRows: 1,
|
|
|
- headRowHeight: [40],
|
|
|
- };
|
|
|
- for (let iNum = 1; iNum <= this.billsCount; iNum++) {
|
|
|
- this.xmSpreadSetting.cols.push(
|
|
|
- {title: '清单' + iNum, field: 'bills' + iNum, width: 50}
|
|
|
- )
|
|
|
- }
|
|
|
- this.xmSpread = SpreadJsObj.createNewSpread($('.batch-l-t')[0]);
|
|
|
-
|
|
|
- this.gclSpreadSetting = {
|
|
|
+ this.posCount = 1000;
|
|
|
+ // 初始化 清单编号窗口 参数
|
|
|
+ this.qdSpreadSetting = {
|
|
|
cols: [
|
|
|
{title: '编号', field: 'code', width: 80, formatter: '@'},
|
|
|
{title: '名称', field: 'name', width: 120, formatter: '@'},
|
|
@@ -792,10 +869,26 @@ $(document).ready(function() {
|
|
|
headRows: 1,
|
|
|
headRowHeight: [40],
|
|
|
};
|
|
|
- this.gclSpread = SpreadJsObj.createNewSpread($('.batch-l-b')[0]);
|
|
|
-
|
|
|
+ this.qdSpread = SpreadJsObj.createNewSpread($('.batch-l-t', this.obj)[0]);
|
|
|
+ // 初始化 部位数量复核表 参数
|
|
|
+ this.posSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '部位', field: 'bw', width: 80, formatter: '@'},
|
|
|
+ {title: '图册号', field: 'drawingCode', formatter: '@', width: 60},
|
|
|
+ ],
|
|
|
+ emptyRows: this.posCount,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ };
|
|
|
+ for (let iNum = 1; iNum <= this.billsCount; iNum++) {
|
|
|
+ this.posSpreadSetting.cols.push(
|
|
|
+ {title: '清单' + iNum, field: 'bills' + iNum, width: 50}
|
|
|
+ )
|
|
|
+ }
|
|
|
+ this.posSpread = SpreadJsObj.createNewSpread($('.batch-l-b', this.obj)[0]);
|
|
|
+ // 初始化 清单编号、部位数量复核表 表格
|
|
|
this.initView();
|
|
|
-
|
|
|
+ // 初始化 签约清单 参数
|
|
|
this.dealSpreadSetting = {
|
|
|
cols: [
|
|
|
{title: '清单编号', field: 'code', width: 80, formatter: '@', readOnly: true},
|
|
@@ -807,107 +900,112 @@ $(document).ready(function() {
|
|
|
headRows: 1,
|
|
|
headRowHeight: [40],
|
|
|
};
|
|
|
- this.dealSpread = SpreadJsObj.createNewSpread($('.batch-r')[0]);
|
|
|
+ this.dealSpread = SpreadJsObj.createNewSpread($('.batch-r', this.obj)[0]);
|
|
|
SpreadJsObj.initSheet(this.dealSpread.getActiveSheet(), this.dealSpreadSetting);
|
|
|
- postData('/deal/get-data', {}, function (data) {
|
|
|
- SpreadJsObj.loadSheetData(self.dealSpread.getActiveSheet(), 'data', data);
|
|
|
-
|
|
|
- self.dealSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
|
|
|
- const deal = info.sheet.zh_data[info.row];
|
|
|
- const sel = self.gclSpread.getActiveSheet().getSelections()[0];
|
|
|
- self.gclSpread.getActiveSheet().getCell(sel.row, 0).value(deal.code);
|
|
|
- self.gclSpread.getActiveSheet().getCell(sel.row, 1).value(deal.name);
|
|
|
- self.gclSpread.getActiveSheet().getCell(sel.row, 2).value(deal.unit);
|
|
|
- self.gclSpread.getActiveSheet().getCell(sel.row, 3).value(deal.unit_price);
|
|
|
- if (sel.row + 1 === self.gclSpread.getActiveSheet().getRowCount()) {
|
|
|
- const count = sel.row + 2;
|
|
|
- self.gclSpread.getActiveSheet().setRowCount(count);
|
|
|
- self.gclSpread.getActiveSheet().getCell(sel.row + 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + count);
|
|
|
-
|
|
|
- const colCount = self.xmSpread.getActiveSheet().getColumnCount() + 1
|
|
|
- self.xmSpread.getActiveSheet().setColumnCount(colCount);
|
|
|
- self.xmSpread.getActiveSheet().getCell(0, colCount - 1, GC.Spread.Sheets.SheetArea.colHeader).text('数量' + count);
|
|
|
- }
|
|
|
- self.gclSpread.getActiveSheet().setSelection(sel.row + 1, sel.col, 1, 1);
|
|
|
- })
|
|
|
+ // 拉取签约清单数据
|
|
|
+ if (dealBills) {
|
|
|
+ SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
|
|
|
+ } else {
|
|
|
+ postData(preUrl + '/deal/get-data', {}, function (data) {
|
|
|
+ SpreadJsObj.loadSheetData(self.dealSpread.getActiveSheet(), 'data', data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 双击签约清单,自动添加到清单编号窗口
|
|
|
+ this.dealSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
|
|
|
+ const deal = info.sheet.zh_data[info.row];
|
|
|
+ const sel = self.gclSpread.getActiveSheet().getSelections()[0];
|
|
|
+ self.qdSpread.getActiveSheet().getCell(sel.row, 0).value(deal.code);
|
|
|
+ self.qdSpread.getActiveSheet().getCell(sel.row, 1).value(deal.name);
|
|
|
+ self.qdSpread.getActiveSheet().getCell(sel.row, 2).value(deal.unit);
|
|
|
+ self.qdSpread.getActiveSheet().getCell(sel.row, 3).value(deal.unit_price);
|
|
|
+ if (sel.row + 1 === self.gclSpread.getActiveSheet().getRowCount()) {
|
|
|
+ const count = sel.row + 2;
|
|
|
+ self.qdSpread.getActiveSheet().setRowCount(count);
|
|
|
+ self.qdSpread.getActiveSheet().getCell(sel.row + 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + count);
|
|
|
+
|
|
|
+ const colCount = self.posSpread.getActiveSheet().getColumnCount() + 1
|
|
|
+ self.posSpread.getActiveSheet().setColumnCount(colCount);
|
|
|
+ self.posSpread.getActiveSheet().getCell(0, colCount - 1, GC.Spread.Sheets.SheetArea.colHeader).text('数量' + count);
|
|
|
+ }
|
|
|
+ self.qdSpread.getActiveSheet().setSelection(sel.row + 1, sel.col, 1, 1);
|
|
|
});
|
|
|
|
|
|
this.obj.bind('shown.bs.modal', function () {
|
|
|
- self.xmSpread.refresh();
|
|
|
- self.gclSpread.refresh();
|
|
|
+ self.qdSpread.refresh();
|
|
|
+ self.posSpread.refresh();
|
|
|
self.dealSpread.refresh();
|
|
|
});
|
|
|
|
|
|
$('#batch-ok').click(function () {
|
|
|
- treeOperationObj.batchInsertData(ledgerSpread, {
|
|
|
- batchData: self.getBatchData(),
|
|
|
- batchType: self.batchType,
|
|
|
- }, function () {
|
|
|
- self.obj.modal('hide');
|
|
|
- });
|
|
|
+ const sheet = ledgerSpread.getActiveSheet();
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const row = selection[0].row;
|
|
|
+ const select = ledgerTree.nodes[row];
|
|
|
+ if (select) {
|
|
|
+ const insertData = {};
|
|
|
+ insertData.batchType = (select.code && select.code !== '') ? 'child' : 'next';
|
|
|
+ insertData.id = select[ledgerTree.setting.id];
|
|
|
+ insertData.batchData = self.getBatchData();
|
|
|
+ postData(preUrl+'/ledger/batch-insert', insertData, function (data) {
|
|
|
+ pos.updateDatas(data.pos);
|
|
|
+ ledgerTree.loadPostData(data.ledger, function (result) {
|
|
|
+ treeOperationObj.refreshTree(sheet, result);
|
|
|
+ treeOperationObj.refreshOperationValid(sheet, selection);
|
|
|
+ });
|
|
|
+ self.obj.modal('hide');
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
- initView() {
|
|
|
- let time = new Date();
|
|
|
- const xmSheet = this.xmSpread.getActiveSheet();
|
|
|
- SpreadJsObj.initSheet(xmSheet, this.xmSpreadSetting);
|
|
|
- console.log(new Date() - time);
|
|
|
- time = new Date();
|
|
|
-
|
|
|
- SpreadJsObj.beginMassOperation(xmSheet);
|
|
|
- xmSheet.clear(0, 0, xmSheet.getRowCount(), xmSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
|
|
|
- SpreadJsObj.endMassOperation(xmSheet);
|
|
|
- console.log(new Date() - time);
|
|
|
- time = new Date();
|
|
|
-
|
|
|
- const gclSheet = this.gclSpread.getActiveSheet();
|
|
|
- SpreadJsObj.initSheet(gclSheet, this.gclSpreadSetting);
|
|
|
- SpreadJsObj.beginMassOperation(gclSheet);
|
|
|
- gclSheet.setColumnWidth(0, 45, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ // 初始化左侧表格
|
|
|
+ initView () {
|
|
|
+ // 初始化 清单编号
|
|
|
+ const qdSheet = this.qdSpread.getActiveSheet();
|
|
|
+ SpreadJsObj.initSheet(qdSheet, this.qdSpreadSetting);
|
|
|
+ // 清理原有数据
|
|
|
+ SpreadJsObj.beginMassOperation(qdSheet);
|
|
|
+ qdSheet.clear(0, 0, qdSheet.getRowCount(), qdSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
|
|
|
for (let iRow = 1; iRow <= this.billsCount; iRow ++) {
|
|
|
- gclSheet.getCell(iRow - 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + iRow);
|
|
|
+ qdSheet.getCell(iRow - 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + iRow);
|
|
|
}
|
|
|
- gclSheet.clear(0, 0, gclSheet.getRowCount(), gclSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
|
|
|
- SpreadJsObj.endMassOperation(gclSheet);
|
|
|
- console.log(new Date() - time);
|
|
|
- time = new Date();
|
|
|
+ SpreadJsObj.endMassOperation(qdSheet);
|
|
|
+ // 初始化 部位数量复核表
|
|
|
+ const posSheet = this.posSpread.getActiveSheet();
|
|
|
+ SpreadJsObj.initSheet(posSheet, this.posSpreadSetting);
|
|
|
+ // 清理原有数据
|
|
|
+ SpreadJsObj.beginMassOperation(posSheet);
|
|
|
+ posSheet.setColumnWidth(0, 45, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ posSheet.clear(0, 0, posSheet.getRowCount(), posSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
|
|
|
+ SpreadJsObj.endMassOperation(posSheet);
|
|
|
}
|
|
|
+ // 获取界面数据
|
|
|
getBatchData () {
|
|
|
const result = [];
|
|
|
- const xmSheet = this.xmSpread.getActiveSheet(), gclSheet = this.gclSpread.getActiveSheet();
|
|
|
- for (let iRow = 0; iRow < xmSheet.getRowCount(); iRow++) {
|
|
|
- if (xmSheet.getText(iRow, 0) === '') { continue; }
|
|
|
- const xmj = {
|
|
|
- name: xmSheet.getText(iRow, 0),
|
|
|
- children: [],
|
|
|
+ const qdSheet = this.qdSpread.getActiveSheet(), posSheet = this.posSpread.getActiveSheet();
|
|
|
+ for (let iRow = 0; iRow < qdSheet.getRowCount(); iRow++) {
|
|
|
+ if (qdSheet.getText(iRow, 0) === '') { continue; }
|
|
|
+ const qd = {
|
|
|
+ b_code: qdSheet.getText(iRow, 0),
|
|
|
+ name: qdSheet.getText(iRow, 1),
|
|
|
+ unit: qdSheet.getText(iRow, 2),
|
|
|
+ price: _.toNumber(qdSheet.getText(iRow, 3)),
|
|
|
+ pos: [],
|
|
|
};
|
|
|
- result.push(xmj);
|
|
|
- for (let iCol = 2; iCol < xmSheet.getColumnCount(); iCol++) {
|
|
|
- let value;
|
|
|
- try {
|
|
|
- value = parseFloat(xmSheet.getText(iRow, iCol));
|
|
|
- if (value !== 0 && !isNaN(value)) {
|
|
|
- const gcl = {
|
|
|
- b_code: gclSheet.getText(iCol - 2, 0),
|
|
|
- name: gclSheet.getText(iCol - 2, 1),
|
|
|
- unit: gclSheet.getText(iCol - 2, 2),
|
|
|
- quantity: value,
|
|
|
- }
|
|
|
- try {
|
|
|
- gcl.unit_price = parseFloat(gclSheet.getText(iCol - 2, 3));
|
|
|
- } catch (err) {
|
|
|
- }
|
|
|
- if (gcl.b_code !== '' || gcl.name !== '') {
|
|
|
- xmj.children.push(gcl);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
+ result.push(qd);
|
|
|
+ for (let iPosRow = 0; iPosRow < posSheet.getRowCount(); iPosRow++) {
|
|
|
+ const value = _.toNumber(posSheet.getText(iPosRow, iRow + 2));
|
|
|
+ if (value !== 0 && !isNaN(value)) {
|
|
|
+ qd.pos.push({
|
|
|
+ name: posSheet.getText(iPosRow, 0),
|
|
|
+ drawing_code: posSheet.getText(iPosRow, 1),
|
|
|
+ quantity: value,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
class SearchLedger {
|
|
|
constructor(obj, spreadSetting) {
|
|
|
const self = this;
|
|
@@ -946,7 +1044,7 @@ $(document).ready(function() {
|
|
|
const data = {
|
|
|
keyword: $('#searchName').val(),
|
|
|
}
|
|
|
- postData('/search/user', data, (data) => {
|
|
|
+ postData('/api/search/user', data, (data) => {
|
|
|
const resultDiv = $('#searchResult');
|
|
|
$('h5>span', resultDiv).text(data.name);
|
|
|
$('#addAuditor').attr('auditorId', data.id);
|