|
@@ -395,15 +395,16 @@ const billsGuidance = (function () {
|
|
|
};
|
|
|
|
|
|
/* 清单材料表 */
|
|
|
+ const materialHeaders = [
|
|
|
+ {name: '材料编码', dataCode: 'code', width: 90, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
+ {name: '材料名称', dataCode: 'name', width: 150, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
+ {name: '规格', dataCode: 'specs', width: 130, vAlign: 'center', hAlign: 'left', formatter: '@'}
|
|
|
+ ];
|
|
|
const billMaterial = {
|
|
|
dom: $('#bill-material-spread'),
|
|
|
workBook: null,
|
|
|
cache: [],
|
|
|
- headers: [
|
|
|
- {name: '材料编码', dataCode: 'code', width: 110, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
- {name: '材料名称', dataCode: 'name', width: 150, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
- {name: '规格', dataCode: 'specs', width: 150, vAlign: 'center', hAlign: 'left', formatter: '@'}
|
|
|
- ],
|
|
|
+ headers: materialHeaders,
|
|
|
events: {
|
|
|
EditEnded: function (sender, args) {
|
|
|
editMaterials(args.sheet, [{row: args.row, col: args.col}]);
|
|
@@ -414,6 +415,29 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /* 清单辅助材料录入表 */
|
|
|
+ const billMaterialHelper = {
|
|
|
+ dom: $('#bill-material-helper-spread'),
|
|
|
+ workBook: null,
|
|
|
+ cache: [],
|
|
|
+ headers: materialHeaders,
|
|
|
+ events: {
|
|
|
+ // 双击添加到清单材料表
|
|
|
+ CellDoubleClick: function (sender, args) {
|
|
|
+ // 模拟清单材料表编辑(共用同一个接口)
|
|
|
+ if (!billMaterialHelper.cache[args.row]) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const code = billMaterialHelper.cache[args.row].code;
|
|
|
+ const row = billMaterial.cache.length;
|
|
|
+ const targetSheet = billMaterial.workBook.getSheet(0);
|
|
|
+ targetSheet.setValue(row, 0, code);
|
|
|
+ const changedCells = [{ row, col: 0 }];
|
|
|
+ editMaterials(billMaterial.workBook.getSheet(0), changedCells);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 显示清单材料数据
|
|
|
function showBillMaterialData(sheet, headers, datas, emptyRow = 0){
|
|
|
let fuc = function () {
|
|
@@ -440,14 +464,20 @@ const billsGuidance = (function () {
|
|
|
billMaterial.cache = [];
|
|
|
try {
|
|
|
$.bootstrapLoading.start();
|
|
|
- billMaterial.cache = await ajaxPost('/billsGuidance/api/getBillMaterials', { libID, billID: bills.tree.selected.data.ID });
|
|
|
+ const { billMaterials, allGljList } = await ajaxPost('/billsGuidance/api/getBillMaterials', { libID, billID: bills.tree.selected.data.ID });
|
|
|
+ billMaterial.cache = billMaterials;
|
|
|
+ console.log(allGljList);
|
|
|
sortByCode(billMaterial.cache);
|
|
|
+ billMaterialHelper.cache = allGljList
|
|
|
+ sortByCode(billMaterialHelper.cache);
|
|
|
} catch (error) {
|
|
|
$('#alert-info').text(error.message);
|
|
|
$('#alert').modal('show');
|
|
|
} finally {
|
|
|
showBillMaterialData(billMaterial.workBook.getSheet(0), billMaterial.headers, billMaterial.cache, 30);
|
|
|
billMaterial.workBook.getSheet(0).showRow(0, GC.Spread.Sheets.VerticalPosition.top);
|
|
|
+ showBillMaterialData(billMaterialHelper.workBook.getSheet(0), billMaterialHelper.headers, billMaterialHelper.cache);
|
|
|
+ billMaterialHelper.workBook.getSheet(0).showRow(0, GC.Spread.Sheets.VerticalPosition.top);
|
|
|
$.bootstrapLoading.end();
|
|
|
}
|
|
|
}
|
|
@@ -580,6 +610,9 @@ const billsGuidance = (function () {
|
|
|
sheet.getRange(-1, 1, -1, -1).locked(true);
|
|
|
sheet.getRange(-1, 2, -1, -1).locked(true);
|
|
|
}
|
|
|
+ else if (module === billMaterialHelper) {
|
|
|
+ sheet.options.isProtected = true;
|
|
|
+ }
|
|
|
setOptions(module.workBook, options);
|
|
|
buildHeader(module.workBook.getActiveSheet(), module.headers);
|
|
|
bindEvent(module.workBook, module.events);
|
|
@@ -619,6 +652,7 @@ const billsGuidance = (function () {
|
|
|
cleanData(guideSheet, guideItem.headers, -1);
|
|
|
let node = bills.tree.items[row];
|
|
|
if(!node){
|
|
|
+ $('#editMaterial').addClass('disabled');
|
|
|
return;
|
|
|
}
|
|
|
const billSheet = bills.workBook.getActiveSheet();
|
|
@@ -628,6 +662,7 @@ const billsGuidance = (function () {
|
|
|
setBgColor(billSheet, oldSel.row, orgNode && orgNode.isSearch ? searchBgColor : 'white');
|
|
|
}
|
|
|
bills.tree.selected = node;
|
|
|
+ $('#editMaterial').removeClass('disabled');
|
|
|
//显示备注
|
|
|
$('.main-side-bottom').find('textarea').val(node.data.comment ? node.data.comment : '');
|
|
|
if(!node.guidance.tree){
|
|
@@ -2238,7 +2273,8 @@ const billsGuidance = (function () {
|
|
|
showBillMaterialData(billMaterial.workBook.getSheet(0), billMaterial.headers, billMaterial.cache, 30);
|
|
|
});
|
|
|
$("#bill-material-modal").on('shown.bs.modal', function () {
|
|
|
- if (billMaterial.workBook) {
|
|
|
+ if (billMaterial.workBook && billMaterialHelper.workBook) {
|
|
|
+ billMaterialHelper.workBook.refresh();
|
|
|
billMaterial.workBook.refresh();
|
|
|
getBillMaterials();
|
|
|
}
|
|
@@ -2304,6 +2340,12 @@ const billsGuidance = (function () {
|
|
|
TREE_SHEET_HELPER.refreshNodesVisible(tree.roots, itemSheet, true);
|
|
|
});
|
|
|
});
|
|
|
+ // 配置材料
|
|
|
+ $('#editMaterial').click(function () {
|
|
|
+ if (bills && bills.tree && bills.tree.selected) {
|
|
|
+ $('#bill-material-modal').modal('show');
|
|
|
+ }
|
|
|
+ });
|
|
|
// 插入选中定额
|
|
|
$('#insertRation').click(function () {
|
|
|
let checkedRows = getCheckedRationRows();
|
|
@@ -2535,14 +2577,14 @@ const billsGuidance = (function () {
|
|
|
//初始化视图
|
|
|
//@param {void} @return {void}
|
|
|
function initViews(){
|
|
|
- let modules = [bills, guideItem, section, ration, billMaterial];
|
|
|
+ let modules = [bills, guideItem, section, ration, billMaterial, billMaterialHelper];
|
|
|
initWorkBooks(modules);
|
|
|
lockUtil.lockTools($(document.body), locked);
|
|
|
getLibWithBills(libID);
|
|
|
initDomEvents();
|
|
|
initContextMenu();
|
|
|
initRationContextMenu();
|
|
|
- initBillsContextMenu();
|
|
|
+ //initBillsContextMenu();
|
|
|
initSlideSize();
|
|
|
}
|
|
|
|