|
@@ -11,6 +11,41 @@ const billsGuidance = (function () {
|
|
|
function _isDef(v) {
|
|
|
return typeof v !== 'undefined' && v !== null;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ function sortByCode(arr) {
|
|
|
+ function recurCompare(a, b, index){
|
|
|
+ if (a[index] && !b[index]) {
|
|
|
+ return 1;
|
|
|
+ } else if (!a[index] && b[index]) {
|
|
|
+ return -1;
|
|
|
+ } else if (a[index] && b[index]) {
|
|
|
+ let aV = a[index],
|
|
|
+ bV = b[index];
|
|
|
+ if (!isNaN(aV) && !isNaN(bV)) {
|
|
|
+ aV = parseFloat(a[index]);
|
|
|
+ bV = parseFloat(b[index]);
|
|
|
+ }
|
|
|
+ if (aV > bV) {
|
|
|
+ return 1;
|
|
|
+ } else if (aV < bV) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return recurCompare(a, b, index + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ arr.sort(function (a, b) {
|
|
|
+ if (!_isDef(a.code) || !_isDef(b.code)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ let aArr = a.code.split('-'),
|
|
|
+ bArr = b.code.split('-');
|
|
|
+ return recurCompare(aArr, bArr, 0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
const locked = lockUtil.getLocked();
|
|
|
let moduleName = 'stdBillsGuidance';
|
|
|
//上下拖动的拖动条高度
|
|
@@ -76,10 +111,13 @@ const billsGuidance = (function () {
|
|
|
],
|
|
|
events: {
|
|
|
SelectionChanged: function (sender, info) {
|
|
|
- billsInitSel(info.newSelections[0].row);
|
|
|
+ billsInitSel(info.newSelections[0].row, info.oldSelections[0]);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ const selectedBgColor = '#DFE8F9';
|
|
|
+ const searchBgColor = 'lemonChiffon';
|
|
|
+
|
|
|
//项目指引类型
|
|
|
const itemType = {
|
|
|
job: 0,
|
|
@@ -127,10 +165,49 @@ const billsGuidance = (function () {
|
|
|
hAlign: 0,
|
|
|
font: "Arial"
|
|
|
}
|
|
|
- }]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 40,
|
|
|
+ readOnly: true,
|
|
|
+ head: {
|
|
|
+ titleNames: ["输出特征"],
|
|
|
+ spanCols: [1],
|
|
|
+ spanRows: [1],
|
|
|
+ vAlign: [1],
|
|
|
+ hAlign: [1],
|
|
|
+ font: ["Arial"]
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ field: "outputItemCharacter",
|
|
|
+ vAlign: 1,
|
|
|
+ hAlign: 1,
|
|
|
+ font: "Arial"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 40,
|
|
|
+ readOnly: true,
|
|
|
+ head: {
|
|
|
+ titleNames: ["必填"],
|
|
|
+ spanCols: [1],
|
|
|
+ spanRows: [1],
|
|
|
+ vAlign: [1],
|
|
|
+ hAlign: [1],
|
|
|
+ font: ["Arial"]
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ field: "required",
|
|
|
+ vAlign: 1,
|
|
|
+ hAlign: 1,
|
|
|
+ font: "Arial"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
headers: [
|
|
|
{name: '项目指引', dataCode: 'name', width: 400, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
+ {name: '输出特征', dataCode: 'outputItemCharacter', width: 40, vAlign: 'center', hAlign: 'center'},
|
|
|
+ {name: '必填', dataCode: 'required', width: 40, vAlign: 'center', hAlign: 'center'},
|
|
|
],
|
|
|
events: {
|
|
|
SelectionChanged: function (sender, info) {
|
|
@@ -139,8 +216,14 @@ const billsGuidance = (function () {
|
|
|
EditEnded: function (sender, args) {
|
|
|
edit(args.sheet, [{row: args.row, col: args.col}]);
|
|
|
},
|
|
|
+ ButtonClicked: function (sender, args) {
|
|
|
+ edit(args.sheet, [{row: args.row, col: args.col}]);
|
|
|
+ },
|
|
|
RangeChanged: function (sender, args) {
|
|
|
edit(args.sheet, args.changedCells);
|
|
|
+ },
|
|
|
+ CellDoubleClick: function(sender, args) {
|
|
|
+ locateAtRation(args.row);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -259,6 +342,7 @@ const billsGuidance = (function () {
|
|
|
for(let i = 0, len = headers.length; i < len; i++){
|
|
|
sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
+ sheet.getCell(0, i, GC.Spread.Sheets.SheetArea.colHeader).wordWrap(true);
|
|
|
if(headers[i].formatter){
|
|
|
sheet.setFormatter(-1, i, headers[i].formatter);
|
|
|
}
|
|
@@ -275,7 +359,6 @@ const billsGuidance = (function () {
|
|
|
return;
|
|
|
}
|
|
|
const Events = GC.Spread.Sheets.Events;
|
|
|
- let sheet = workBook.getActiveSheet();
|
|
|
for(let event in events){
|
|
|
workBook.bind(Events[event], events[event]);
|
|
|
}
|
|
@@ -305,6 +388,12 @@ const billsGuidance = (function () {
|
|
|
bindEvent(module.workBook, module.events);
|
|
|
}
|
|
|
lockUtil.lockSpreads([module.workBook], locked);
|
|
|
+ if (locked) {
|
|
|
+ // 锁定表格后双击事件失效了,但是需要双击定位,因此重新绑定双击
|
|
|
+ if (module === guideItem) {
|
|
|
+ module.workBook.bind('CellDoubleClick', module.events.CellDoubleClick);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//清空表数据
|
|
|
//@param {Object}sheet {Array}headers {Number}rowCount @return {void}
|
|
@@ -325,15 +414,22 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
//清单表焦点控制
|
|
|
//@param {Number}row @return {void}
|
|
|
- function billsInitSel(row){
|
|
|
+ function billsInitSel(row, oldSel){
|
|
|
let guideSheet = guideItem.workBook.getActiveSheet();
|
|
|
cleanData(guideSheet, guideItem.headers, -1);
|
|
|
let node = bills.tree.items[row];
|
|
|
if(!node){
|
|
|
return;
|
|
|
}
|
|
|
+ const billSheet = bills.workBook.getActiveSheet();
|
|
|
+ setBgColor(billSheet, row, selectedBgColor);
|
|
|
+ if (oldSel && row !== oldSel.row) {
|
|
|
+ const orgNode = bills.tree.items[oldSel.row]
|
|
|
+ setBgColor(billSheet, oldSel.row, orgNode && orgNode.isSearch ? searchBgColor : 'white');
|
|
|
+ }
|
|
|
bills.tree.selected = node;
|
|
|
//显示备注
|
|
|
$('.main-side-bottom').find('textarea').val(node.data.comment ? node.data.comment : '');
|
|
@@ -341,6 +437,7 @@ const billsGuidance = (function () {
|
|
|
getItemsByBills(libID, node.data.ID, function (rstData) {
|
|
|
initTree(node.guidance, guideSheet, guideItem.treeSetting, rstData);
|
|
|
setNodesExpandState(node.guidance.tree.items, curExpandState);
|
|
|
+ showCheckBox(guideSheet, node.guidance.tree.items);
|
|
|
renderSheetFunc(guideSheet, function () {
|
|
|
TREE_SHEET_HELPER.refreshNodesVisible(node.guidance.tree.roots, guideSheet, true);
|
|
|
});
|
|
@@ -352,12 +449,36 @@ const billsGuidance = (function () {
|
|
|
} else{
|
|
|
setNodesExpandState(node.guidance.tree.items, curExpandState);
|
|
|
node.guidance.controller.showTreeData();
|
|
|
+ showCheckBox(guideSheet, node.guidance.tree.items);
|
|
|
//设置底色
|
|
|
setNodesColor(guideSheet, node.guidance.tree.items);
|
|
|
//项目指引初始焦点
|
|
|
guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ function showCheckBox(sheet, nodes) {
|
|
|
+ // const checkBoxType = locked ? sheetCommonObj.getReadOnlyCheckBox() : sheetCommonObj.getCheckBox();
|
|
|
+ const checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
|
|
|
+ const baseType = new GC.Spread.Sheets.CellTypes.Base();
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ nodes.forEach(node => {
|
|
|
+ const row = node.serialNo();
|
|
|
+ if (node.depth() % 2 === 0 && _isDef(node.data.type) && node.data.type === itemType.job) {
|
|
|
+ sheet.setCellType(row, 1, checkBoxType);
|
|
|
+ sheet.setCellType(row, 2, checkBoxType);
|
|
|
+ sheet.setValue(row, 1, node.data.outputItemCharacter || false);
|
|
|
+ sheet.setValue(row, 2, node.data.required || false);
|
|
|
+ } else {
|
|
|
+ sheet.setCellType(row, 1, baseType);
|
|
|
+ sheet.setCellType(row, 2, baseType);
|
|
|
+ sheet.setValue(row, 1, '');
|
|
|
+ sheet.setValue(row, 2, '');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//设置项目节点展开收起状态:展开全部、收起定额
|
|
|
//@param {Array}nodes(当前清单下的所有项目指引节点) {Number}expandState(展开全部1或收起定额0).
|
|
|
function setNodesExpandState(nodes, expandState) {
|
|
@@ -386,20 +507,25 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 设置行底色
|
|
|
+ function setBgColor(sheet, row, color) {
|
|
|
+ const style = new GC.Spread.Sheets.Style();
|
|
|
+ style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
+ style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
+ style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
+ style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
+ style.backColor = color;
|
|
|
+ sheet.setStyle(row, -1, style);
|
|
|
+
|
|
|
+ }
|
|
|
//根据奇偶层级设置节点底色,奇数层为蓝色(树节点深度为偶数)
|
|
|
//@param {Object}sheet {Array}nodes @return {void}
|
|
|
function setNodesColor(sheet, nodes) {
|
|
|
- const color = '#DFE8F9';
|
|
|
renderSheetFunc(sheet, function () {
|
|
|
for(let node of nodes){
|
|
|
- let style = new GC.Spread.Sheets.Style();
|
|
|
- style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
- style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
- style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
- style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
|
- let nDepth = node.depth();
|
|
|
- style.backColor = nDepth % 2 == 0 && _isDef(node.data.type) && node.data.type === itemType.job ? color : 'White';
|
|
|
- sheet.setStyle(node.serialNo(), -1, style);
|
|
|
+ const nDepth = node.depth();
|
|
|
+ const color = nDepth % 2 == 0 && _isDef(node.data.type) && node.data.type === itemType.job ? selectedBgColor : 'White';
|
|
|
+ setBgColor(sheet, node.serialNo(), color);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -697,7 +823,7 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
//初始化定额条目
|
|
|
//@param {Number}rationLibId @return {void}
|
|
|
- function initRationItems(rationLibId){
|
|
|
+ function initRationItems(rationLibId, successCb){
|
|
|
$.bootstrapLoading.start();
|
|
|
//获取定额章节树
|
|
|
let sectionSheet = section.workBook.getActiveSheet();
|
|
@@ -709,7 +835,8 @@ const billsGuidance = (function () {
|
|
|
initTree(section, section.workBook.getActiveSheet(), section.treeSetting, sectionDatas);
|
|
|
//初始焦点在第一行(切换库)
|
|
|
sectionSheet.setActiveCell(0, 0);
|
|
|
- rstData.sort(function (a, b) {
|
|
|
+ sortByCode(rstData);
|
|
|
+ /* rstData.sort(function (a, b) {
|
|
|
let rst = 0;
|
|
|
if(a.code > b.code){
|
|
|
rst = 1;
|
|
@@ -718,10 +845,13 @@ const billsGuidance = (function () {
|
|
|
rst = -1;
|
|
|
}
|
|
|
return rst;
|
|
|
- });
|
|
|
+ }); */
|
|
|
ration.datas = rstData;
|
|
|
sectionInitSel(0);
|
|
|
$.bootstrapLoading.end();
|
|
|
+ if (successCb) {
|
|
|
+ successCb();
|
|
|
+ }
|
|
|
}, function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
@@ -729,12 +859,16 @@ const billsGuidance = (function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 可用的定额库ID
|
|
|
+ const rationLibIDs = [];
|
|
|
//初始化定额库选择
|
|
|
//@param {String}compilationId @return {void}
|
|
|
function initRationLibs(compilationId){
|
|
|
CommonAjax.post('/rationRepository/api/getRationLibsByCompilation', {compilationId: compilationId}, function (rstData) {
|
|
|
$('#rationLibSel').empty();
|
|
|
for(let rationLib of rstData){
|
|
|
+ rationLibIDs.push(+rationLib.ID);
|
|
|
let opt = `<option value="${rationLib.ID}">${rationLib.dispName}</option>`;
|
|
|
$('#rationLibSel').append(opt);
|
|
|
}
|
|
@@ -746,6 +880,23 @@ const billsGuidance = (function () {
|
|
|
})
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 变更定额库
|
|
|
+ function changeRationLib(libID, successCb) {
|
|
|
+ $('#rationLibSel').val(libID);
|
|
|
+ initRationItems(libID, successCb);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置清单名称文本色
|
|
|
+ function setBillsForeColor(billsNodes) {
|
|
|
+ const sheet = bills.workBook.getActiveSheet();
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ for(let bills of billsNodes){
|
|
|
+ const row = bills.serialNo();
|
|
|
+ sheet.setStyle(row, 1, { foreColor: bills.data.hasGuide ? 'darkgreen' : 'black' });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
//清单设置悬浮提示信息
|
|
|
//@param {Array}billsNodes(清单节点) {Array}jobs(总的工作内容数据) {Array}items(总的项目特征数据)
|
|
|
function setBillsHint(billsNodes, jobs, items) {
|
|
@@ -866,26 +1017,42 @@ const billsGuidance = (function () {
|
|
|
module.tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
|
|
|
module.controller = TREE_SHEET_CONTROLLER.createNew(module.tree, sheet, treeSetting);
|
|
|
module.tree.loadDatas(datas);
|
|
|
+ if(module === bills){
|
|
|
+ module.tree.roots.forEach(root => {
|
|
|
+ root.setExpanded(false);
|
|
|
+ })
|
|
|
+ }
|
|
|
module.controller.showTreeData();
|
|
|
if(module === bills){
|
|
|
setBillsHint(bills.tree.items, stdBillsJobData, stdBillsFeatureData);
|
|
|
+ setBillsForeColor(bills.tree.items);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//更新清单备注
|
|
|
- function updateBillsComment(updateData, callback) {
|
|
|
+ function updateBillsComment(updateData, callback, errCB) {
|
|
|
CommonAjax.post('/stdBillsEditor/updateBills', updateData, function () {
|
|
|
if (callback) {
|
|
|
callback();
|
|
|
}
|
|
|
+ }, function () {
|
|
|
+ if(errCB) {
|
|
|
+ errCB();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
//更新项目指引
|
|
|
//@param {Array}updateDatas {Function}callback @return {void}
|
|
|
- function updateGuideItems(updateDatas, callback){
|
|
|
+ function updateGuideItems(updateDatas, callback, errCB){
|
|
|
CommonAjax.post('/billsGuidance/api/updateItems', {updateDatas: updateDatas}, function (rstData) {
|
|
|
if(callback){
|
|
|
callback(rstData);
|
|
|
}
|
|
|
+ }, function () {
|
|
|
+ if(errCB) {
|
|
|
+ errCB();
|
|
|
+ }
|
|
|
+ $.bootstrapLoading.end();
|
|
|
});
|
|
|
}
|
|
|
//编辑后自动去除换行符回车符
|
|
@@ -897,26 +1064,34 @@ const billsGuidance = (function () {
|
|
|
//同步节点数据
|
|
|
let syncDatas = [];
|
|
|
for(let cell of cells){
|
|
|
- let text = sheet.getValue(cell.row, cell.col);
|
|
|
- text = text ? text.toString() : '';
|
|
|
- text = text.replace(deESC, '');
|
|
|
- sheet.setValue(cell.row, cell.col, text);
|
|
|
+ const field = guideItem.headers[cell.col].dataCode;
|
|
|
let node = bills.tree.selected.guidance.tree.items[cell.row];
|
|
|
- if(node.data.name != text){
|
|
|
- syncDatas.push({node: node, text: text});
|
|
|
- updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {name: text}});
|
|
|
+ if (field === 'name') {
|
|
|
+ let text = sheet.getValue(cell.row, cell.col);
|
|
|
+ text = text ? text.toString() : '';
|
|
|
+ text = text.replace(deESC, '');
|
|
|
+ sheet.setValue(cell.row, cell.col, text);
|
|
|
+ if(node.data.name != text){
|
|
|
+ syncDatas.push({node: node, text: text, field, cell});
|
|
|
+ updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {name: text}});
|
|
|
+ }
|
|
|
+ } else if (field === 'outputItemCharacter' || field === 'required') {
|
|
|
+ const val = !sheet.getValue(cell.row, cell.col);
|
|
|
+ sheet.setValue(cell.row, cell.col, val);
|
|
|
+ syncDatas.push({node: node, text: val, field, cell });
|
|
|
+ updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {[field]: val}});
|
|
|
}
|
|
|
}
|
|
|
if(updateDatas.length > 0){
|
|
|
updateGuideItems(updateDatas, function () {
|
|
|
for(let syncData of syncDatas){
|
|
|
- syncData.node.data.name = syncData.text;
|
|
|
+ syncData.node.data[syncData.field] = syncData.text;
|
|
|
}
|
|
|
}, function () {
|
|
|
//失败恢复
|
|
|
renderSheetFunc(sheet, function () {
|
|
|
for(let syncData of syncDatas){
|
|
|
- sheet.setValue(syncData.node.serialNo(), 0, syncData.node.data.name ? syncData.node.data.name : '');
|
|
|
+ sheet.setValue(syncData.node.serialNo(), syncData.cell.col, syncData.node.data[syncData.field] ? syncData.node.data[syncData.field] : '');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
@@ -965,10 +1140,19 @@ const billsGuidance = (function () {
|
|
|
let newNode = controller.insertByIDS(updateData.updateData.ID, updateData.updateData.ParentID, updateData.updateData.NextSiblingID);
|
|
|
//同步data
|
|
|
Object.assign(newNode.data, updateData.updateData);
|
|
|
- sheet.setValue(newNode.serialNo(), 0, newNode.data.name);
|
|
|
+ const row = newNode.serialNo();
|
|
|
+ sheet.setValue(row, 0, newNode.data.name);
|
|
|
+ if (newNode.data.outputItemCharacter !== undefined) {
|
|
|
+ sheet.setValue(row, 1, newNode.data.outputItemCharacter);
|
|
|
+ }
|
|
|
+ showCheckBox(sheet, [newNode]);
|
|
|
refreshBtn(newNode);
|
|
|
}
|
|
|
}
|
|
|
+ if (!bills.tree.selected.data.hasGuide && bills.tree.selected.guidance.tree.items.length) {
|
|
|
+ bills.tree.selected.data.hasGuide = true;
|
|
|
+ setBillsForeColor([bills.tree.selected]);
|
|
|
+ }
|
|
|
if(callback){
|
|
|
callback();
|
|
|
}
|
|
@@ -1060,6 +1244,11 @@ const billsGuidance = (function () {
|
|
|
guideItemInitSel(sheet.getActiveRowIndex());
|
|
|
refreshBtn(bills.tree.selected.guidance.tree.selected);
|
|
|
setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
+ showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
+ if (bills.tree.selected.data.hasGuide && !bills.tree.selected.guidance.tree.items.length) {
|
|
|
+ bills.tree.selected.data.hasGuide = false;
|
|
|
+ setBillsForeColor([bills.tree.selected]);
|
|
|
+ }
|
|
|
$.bootstrapLoading.end();
|
|
|
guideItem.workBook.focus(true)
|
|
|
});
|
|
@@ -1095,6 +1284,7 @@ const billsGuidance = (function () {
|
|
|
controller.upLevel();
|
|
|
refreshBtn(bills.tree.selected.guidance.tree.selected);
|
|
|
setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
+ showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
$.bootstrapLoading.end();
|
|
|
guideItem.workBook.focus(true)//31574
|
|
|
});
|
|
@@ -1119,6 +1309,7 @@ const billsGuidance = (function () {
|
|
|
controller.downLevel();
|
|
|
refreshBtn(bills.tree.selected.guidance.tree.selected);
|
|
|
setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
+ showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
$.bootstrapLoading.end();
|
|
|
guideItem.workBook.focus(true)
|
|
|
});
|
|
@@ -1142,6 +1333,7 @@ const billsGuidance = (function () {
|
|
|
controller.upMove();
|
|
|
refreshBtn(bills.tree.selected.guidance.tree.selected);
|
|
|
setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
+ showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
$.bootstrapLoading.end();
|
|
|
guideItem.workBook.focus(true)
|
|
|
});
|
|
@@ -1165,6 +1357,7 @@ const billsGuidance = (function () {
|
|
|
controller.downMove();
|
|
|
refreshBtn(bills.tree.selected.guidance.tree.selected);
|
|
|
setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
+ showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
$.bootstrapLoading.end();
|
|
|
guideItem.workBook.focus(true)
|
|
|
});
|
|
@@ -1378,10 +1571,58 @@ const billsGuidance = (function () {
|
|
|
cleanData(guideItem.workBook.getActiveSheet(), guideItem.headers, -1);
|
|
|
itemObj.controller.showTreeData();
|
|
|
setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
+ showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
|
|
|
}, function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 双击定位定额
|
|
|
+ async function locateAtRation(row) {
|
|
|
+ const node = bills.tree.selected.guidance.tree.items[row];
|
|
|
+ if (!node || !node.data.rationID) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const rationItem = ration.datas.find(item => item.ID === node.data.rationID);
|
|
|
+ // 当前库没有找到,需要后端查找
|
|
|
+ if (!rationItem) {
|
|
|
+ const findedRation = await ajaxPost('/rationRepository/api/getRationByID',{ ID: node.data.rationID });
|
|
|
+ if (!findedRation || !rationLibIDs.includes(findedRation.rationRepId)) {
|
|
|
+ alert('无法定位此定额,此定额已被删除');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ changeRationLib(findedRation.rationRepId, () => {
|
|
|
+ located(findedRation.ID, findedRation.sectionId);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ located(rationItem.ID, rationItem.sectionId);
|
|
|
+ }
|
|
|
+ function located(rationID, sectionID) {
|
|
|
+ if (!section.tree) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const sectionNode = section.tree.nodes[section.tree.prefix + sectionID];
|
|
|
+ if (!sectionNode) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 定位到对应章节树
|
|
|
+ const sectionSheet = section.workBook.getActiveSheet();
|
|
|
+ const sectionRow = sectionNode.serialNo();
|
|
|
+ expandSearchNodes(sectionSheet, [sectionNode], section.tree.roots);
|
|
|
+ sectionSheet.setSelection(sectionRow, 0, 1, 1);
|
|
|
+ sectionSheet.showRow(sectionRow, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ sectionInitSel(sectionRow);
|
|
|
+
|
|
|
+ // 定位到对应定额
|
|
|
+ const locatedRationRow = ration.cache.findIndex(item => item.ID === rationID);
|
|
|
+ if (locatedRationRow !== -1) {
|
|
|
+ const rationSheet = ration.workBook.getActiveSheet();
|
|
|
+ rationSheet.setSelection(locatedRationRow, 1, 1, 1);
|
|
|
+ rationSheet.showRow(locatedRationRow, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//初始化右键菜单
|
|
|
//@return {void}
|
|
|
function initContextMenu() {
|
|
@@ -1493,11 +1734,142 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ //展开至搜索出来点的节点
|
|
|
+ //@param {Array}nodes @return {void}
|
|
|
+ function expandSearchNodes(sheet, nodes, roots){
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ function expParentNode(node){
|
|
|
+ if(node.parent){
|
|
|
+ if (!node.parent.expanded) {
|
|
|
+ node.parent.setExpanded(true);
|
|
|
+ }
|
|
|
+ expParentNode(node.parent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(let node of nodes){
|
|
|
+ expParentNode(node);
|
|
|
+ }
|
|
|
+ TREE_SHEET_HELPER.refreshNodesVisible(roots, sheet, true);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清空搜索高亮
|
|
|
+ function clearHighLight(sheet) {
|
|
|
+ renderSheetFunc(sheet, () => {
|
|
|
+ for (let i = 0; i < sheet.getRowCount(); i++){
|
|
|
+ setBgColor(sheet, i, 'white')
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清空搜索状态
|
|
|
+
|
|
|
+ // 关闭搜索清单结果
|
|
|
+ function closeSearchBills(sheet) {
|
|
|
+ if (!bills.tree) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $('#searchBillsResult').hide();
|
|
|
+ bills.tree.items.forEach(node => {
|
|
|
+ node.isSearch = false;
|
|
|
+ });
|
|
|
+ clearHighLight(sheet);
|
|
|
+ setBgColor(sheet, sheet.getActiveRowIndex(), selectedBgColor);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 搜索清单
|
|
|
+ function searchBills() {
|
|
|
+ if (!bills.tree || !bills.workBook) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const sheet = bills.workBook.getActiveSheet();
|
|
|
+ const str = $('#searchBillText').val().trim();
|
|
|
+ // 空搜索字符,关闭搜索
|
|
|
+ if (!str) {
|
|
|
+ if ($('#searchBillsResult').is(':visible')) {
|
|
|
+ closeSearchBills(sheet);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 过滤清单
|
|
|
+ const result = bills.tree.items.filter(item => {
|
|
|
+ const codeIs = item.data.code ? item.data.code.indexOf(str) !== -1 : false;
|
|
|
+ const nameIs = item.data.name ? item.data.name.indexOf(str) !== -1 : false;
|
|
|
+ return codeIs || nameIs;
|
|
|
+ });
|
|
|
+ if (!result.length) {
|
|
|
+ closeSearchBills(sheet);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 显示搜索结果
|
|
|
+ $("#searchBillsResult").show();
|
|
|
+ $('#searchBillsCount').text(result.length);
|
|
|
+
|
|
|
+ //展开搜索出来的节点
|
|
|
+ expandSearchNodes(sheet, result, bills.tree.roots);
|
|
|
+ // 标黄结果
|
|
|
+ clearHighLight(sheet);
|
|
|
+ const col = sheet.getActiveColumnIndex();
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ bills.controller.setTreeSelected(result[0]);
|
|
|
+ bills.tree.items.forEach(node => {
|
|
|
+ if (result.includes(node)) {
|
|
|
+ setBgColor(sheet, node.serialNo(), searchBgColor);
|
|
|
+ node.isSearch = true; // 标记为搜索结果,防止被焦点行变更恢复颜色
|
|
|
+ } else {
|
|
|
+ node.isSearch = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ //搜索初始定位
|
|
|
+ const row = sheet.getActiveRowIndex();
|
|
|
+ sheet.setSelection(result[0].serialNo(), col, 1, 1);
|
|
|
+ billsInitSel(result[0].serialNo(), { row });
|
|
|
+ sheet.showRow(result[0].serialNo(), GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+
|
|
|
+ let curIndex = 0;
|
|
|
+
|
|
|
+ // 上一条
|
|
|
+ $('#preBill').unbind('click');
|
|
|
+ $('#preBill').bind('click', () => {
|
|
|
+ const node = result[curIndex - 1];
|
|
|
+ if (!node) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ curIndex -= 1;
|
|
|
+ const col = sheet.getActiveColumnIndex();
|
|
|
+ const row = node.serialNo();
|
|
|
+ const orgRow = sheet.getActiveRowIndex();
|
|
|
+ sheet.setSelection(row, col, 1, 1);
|
|
|
+ billsInitSel(row, { row: orgRow });
|
|
|
+ sheet.showRow(row, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 下一条
|
|
|
+ $('#nextBills').unbind('click');
|
|
|
+ $('#nextBills').bind('click', () => {
|
|
|
+ const node = result[curIndex + 1];
|
|
|
+ if (!node) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ curIndex += 1;
|
|
|
+ const col = sheet.getActiveColumnIndex();
|
|
|
+ const row = node.serialNo();
|
|
|
+ const orgRow = sheet.getActiveRowIndex();
|
|
|
+ sheet.setSelection(row, col, 1, 1);
|
|
|
+ billsInitSel(row, { row: orgRow });
|
|
|
+ sheet.showRow(row, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//初始化个按钮点击
|
|
|
//@return {void}
|
|
|
function initBtn(){
|
|
|
$('#insert').click(function () {
|
|
|
- insert([{type: itemType.job, name: ''}], false);
|
|
|
+ insert([{type: itemType.job, name: '', outputItemCharacter: true }], false);
|
|
|
});
|
|
|
$('#delConfirm').click(function () {
|
|
|
del();
|
|
@@ -1522,6 +1894,22 @@ const billsGuidance = (function () {
|
|
|
$('#downMove').click(function () {
|
|
|
downMove();
|
|
|
});
|
|
|
+ // 收起清单至第二层
|
|
|
+ $('#expandToSecond').click(function() {
|
|
|
+ if (!bills.tree || !bills.workBook) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ bills.tree.roots.forEach(root => {
|
|
|
+ root.setExpanded(true);
|
|
|
+ root.children.forEach(item => {
|
|
|
+ item.setExpanded(false);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ const billSheet = bills.workBook.getActiveSheet();
|
|
|
+ renderSheetFunc(billSheet, function () {
|
|
|
+ TREE_SHEET_HELPER.refreshNodesVisible(bills.tree.roots, billSheet, true);
|
|
|
+ });
|
|
|
+ })
|
|
|
//收起定额、展开全部
|
|
|
$('#expandContract').click(function () {
|
|
|
//目前状态时展开全部节点状态,点击则收起定额
|
|
@@ -1563,6 +1951,21 @@ const billsGuidance = (function () {
|
|
|
insert(insertDatas, false);
|
|
|
}
|
|
|
});
|
|
|
+ // 搜索清单
|
|
|
+ $("#searchBillBtn").click(searchBills);
|
|
|
+ $('#searchBillText').keyup(function (e) {
|
|
|
+ delayKeyup(function () {
|
|
|
+ $('#searchBillBtn').click();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // 关闭搜索清单
|
|
|
+ $('#closeSearchBills').click(() => {
|
|
|
+ if (!bills.workBook) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const sheet = bills.workBook.getActiveSheet();
|
|
|
+ closeSearchBills(sheet);
|
|
|
+ })
|
|
|
//搜索定额
|
|
|
$('#searchBtn').click(function () {
|
|
|
let searchStr = $('#searchText').val();
|
|
@@ -1627,6 +2030,8 @@ const billsGuidance = (function () {
|
|
|
let updateData = {lastOperator: userAccount, billsLibId: billsLibId, updateId: node.getID(), field: 'comment', data: comment};
|
|
|
updateBillsComment(updateData, function () {
|
|
|
node.data.comment = comment;
|
|
|
+ }, function() {
|
|
|
+ $(me).val(node.data.comment || '');
|
|
|
})
|
|
|
}
|
|
|
});
|
|
@@ -1641,6 +2046,8 @@ const billsGuidance = (function () {
|
|
|
let updateDatas = [{updateType: updateType.update, findData: {ID: node.getID()}, updateData: {comment: comment}}];
|
|
|
updateGuideItems(updateDatas, function (rstData) {
|
|
|
node.data.comment = comment;
|
|
|
+ }, function() {
|
|
|
+ $(me).val(node.data.comment || '');
|
|
|
});
|
|
|
}
|
|
|
});
|