|
|
@@ -1789,6 +1789,78 @@ $(document).ready(function() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ const calcTemplateSelect = (function(){
|
|
|
+ let ctrlBills = {}, first = 1;
|
|
|
+ const tree = createNewPathTree('gather', {
|
|
|
+ id: 'tree_id', pid: 'tree_pid', order: 'tree_order',
|
|
|
+ level: 'tree_level', isLeaf: 'tree_is_leaf', fullPath: 'tree_full_path',
|
|
|
+ rootId: -1, calcFields: [], keys: ['id', 'master_id', 'tree_id'],
|
|
|
+ });
|
|
|
+ tree.loadDatas(templateFolder);
|
|
|
+ const templates = createAncillaryGcl({ id: 'id', masterId: 'folder_id', sort: [['create_time', 'desc']] });
|
|
|
+ templates.loadDatas(posCalcTemplate);
|
|
|
+ templates.eachPart(function(masterId, items) {
|
|
|
+ const parent = masterId ? tree.nodes.find(x => { return x.id === masterId; }) : null;
|
|
|
+ for (const i of items) {
|
|
|
+ i.is_calc_template = 1;
|
|
|
+ tree.addNode(i, parent, false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tree.sortTreeNode();
|
|
|
+ const spread = SpreadJsObj.createNewSpread($('#sct-spread')[0]);
|
|
|
+ const sheet = spread.getActiveSheet();
|
|
|
+ SpreadJsObj.initSheet(sheet, {
|
|
|
+ cols: [
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 300, formatter: '@', cellType: 'tree'},
|
|
|
+ // {title: '创建人', colSpan: '1', rowSpan: '1', field: 'user_name', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ getFont: function (sheet, data, row, col, defaultFont) {
|
|
|
+ return !data.is_calc_template ? defaultFont : 'bold ' + defaultFont;
|
|
|
+ },
|
|
|
+ getColor: function(sheet, data, row, col, defaultColor) {
|
|
|
+ return data && data.id === ctrlBills.calc_template ? spreadColor.common.invalid : defaultColor;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Tree, tree);
|
|
|
+ const select = function(node) {
|
|
|
+ ctrlBills = node;
|
|
|
+ SpreadJsObj.reloadRowBackColor(sheet, 0, tree.nodes.length);
|
|
|
+ $('#select-calc-template').modal('show');
|
|
|
+ };
|
|
|
+ $('#select-calc-template-ok').click(function() {
|
|
|
+ const ct = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ if (!ct) return;
|
|
|
+ if (!ct.is_calc_template) {
|
|
|
+ toastr.warning('请勿选择文件夹');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (ct.id === ctrlBills.calc_template) {
|
|
|
+ toastr.warning('选择的计算模板与之前相同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const updateData = {postType: 'extra', postData: { id: ctrlBills.id, tender_id: ctrlBills.tender_id, ledger_id: ctrlBills.ledger_id, calc_template: ct.id }};
|
|
|
+ postData(window.location.pathname + '/update', updateData, function (result) {
|
|
|
+ const refreshNode = ledgerTree.loadPostData(result);
|
|
|
+ treeOperationObj.refreshTree(ledgerSheet, refreshNode);
|
|
|
+ posCalcDetail.loadCurDetailData();
|
|
|
+ $('#select-calc-template').modal('hide');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ $('#select-calc-template').on('shown.bs.modal', function() {
|
|
|
+ if (first) {
|
|
|
+ spread.refresh();
|
|
|
+ first = 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return { select }
|
|
|
+ })();
|
|
|
let batchInsertObj, contractExprObj;
|
|
|
$.contextMenu.types.batchInsert = function (item, opt, root) {
|
|
|
const self = this;
|
|
|
@@ -1916,6 +1988,20 @@ $(document).ready(function() {
|
|
|
billsContextMenuOptions.items.sprBase = '----';
|
|
|
}
|
|
|
if (!readOnly) {
|
|
|
+ billsContextMenuOptions.items.selectCalcTmpl = {
|
|
|
+ name: '选择计算模板',
|
|
|
+ callback: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ calcTemplateSelect.select(node);
|
|
|
+ },
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ return !node || !node.b_code;
|
|
|
+ },
|
|
|
+ visible: function(key, opt) {
|
|
|
+ return !readOnly;
|
|
|
+ }
|
|
|
+ };
|
|
|
billsContextMenuOptions.items.batchInsert = {
|
|
|
name: '批量插入',
|
|
|
type: 'batchInsert',
|