|
|
@@ -31,10 +31,13 @@ $(document).ready(function() {
|
|
|
{title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 230, formatter: '@', cellType: 'tree'},
|
|
|
{title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 185, formatter: '@', cellType: 'autoTip'},
|
|
|
{title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'},
|
|
|
+ {title: '税率(%)', colSpan: '1', rowSpan: '1', field: 'tax', hAlign: 2, width: 80, type: 'Number'},
|
|
|
{title: '付款金额', colSpan: '1', rowSpan: '1', field: 'pay_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
{title: '扣款金额', colSpan: '1', rowSpan: '1', field: 'cut_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
{title: '应付金额', colSpan: '1', rowSpan: '1', field: 'yf_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
{title: '实付金额', colSpan: '1', rowSpan: '1', field: 'sf_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '应付金额(无税)', colSpan: '1', rowSpan: '1', field: 'yf_excl_tax_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
+ {title: '实付金额(无税)', colSpan: '1', rowSpan: '1', field: 'sf_excl_tax_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
{title: '本期批注', colSpan: '1', rowSpan: '1', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
|
|
|
{title: '备注', colSpan: '1', rowSpan: '1', field: 'memo', hAlign: 0, width: 120, formatter: '@', cellType: 'ellipsisAutoTip'},
|
|
|
],
|
|
|
@@ -372,10 +375,11 @@ $(document).ready(function() {
|
|
|
}
|
|
|
|
|
|
switch (col.field) {
|
|
|
+ case 'tax':
|
|
|
case 'pay_tp':
|
|
|
case 'cut_tp':
|
|
|
case 'sf_tp':
|
|
|
- info.cancel = (node.children && node.children.length > 0);
|
|
|
+ info.cancel = (node.children && node.children.length > 0) || node.had_detail;
|
|
|
if (!info.cancel) {
|
|
|
const detailRange = detailObj.data.getPartData(node.id);
|
|
|
if (detailRange && detailRange.length > 0) info.cancel = true;
|
|
|
@@ -441,11 +445,11 @@ $(document).ready(function() {
|
|
|
if (bDel) datas.push(data);
|
|
|
}
|
|
|
if (datas.length > 0) {
|
|
|
- postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
|
|
|
+ postData(window.location.pathname + '/update', {target: 'ledger', postType: 'update', postData: datas}, function (result) {
|
|
|
const refreshNode = sheet.zh_tree.loadPostData(result);
|
|
|
billsObj.refreshTree(refreshNode);
|
|
|
}, function () {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, sel.row, sel.rowCount);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -505,14 +509,17 @@ $(document).ready(function() {
|
|
|
this.data = createAncillaryGcl({ id: 'id', masterId: 'ledger_id', sort: [['d_order', 'asc']] });
|
|
|
this.dealSpreadSetting = {
|
|
|
cols: [
|
|
|
- {title: '合同编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 230, formatter: '@', readOnly: true},
|
|
|
- {title: '合同名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 185, formatter: '@', readOnly: true},
|
|
|
+ {title: '合同编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 160, formatter: '@', readOnly: true},
|
|
|
+ {title: '合同名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 160, formatter: '@', readOnly: true},
|
|
|
{title: '乙方', colSpan: '1', rowSpan: '1', field: 'party_b', hAlign: 0, width: 150, formatter: '@', readOnly: true},
|
|
|
{title: '合同金额', colSpan: '1', rowSpan: '1', field: 'deal_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
- {title: '付款金额', colSpan: '1', rowSpan: '1', field: 'pay_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
- {title: '扣款金额', colSpan: '1', rowSpan: '1', field: 'cut_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '税率(%)', colSpan: '1', rowSpan: '1', field: 'tax', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
+ {title: '付款金额', colSpan: '1', rowSpan: '1', field: 'pay_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
+ {title: '扣款金额', colSpan: '1', rowSpan: '1', field: 'cut_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
{title: '应付金额', colSpan: '1', rowSpan: '1', field: 'yf_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
- {title: '实付金额', colSpan: '1', rowSpan: '1', field: 'sf_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '实付金额', colSpan: '1', rowSpan: '1', field: 'sf_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
+ {title: '应付金额(无税)', colSpan: '1', rowSpan: '1', field: 'yf_excl_tax_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
+ {title: '实付金额(无税)', colSpan: '1', rowSpan: '1', field: 'sf_excl_tax_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
{title: '本期批注', colSpan: '1', rowSpan: '1', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
|
|
|
{title: '备注', colSpan: '1', rowSpan: '1', field: 'memo', hAlign: 0, width: 120, formatter: '@', cellType: 'ellipsisAutoTip'},
|
|
|
],
|
|
|
@@ -561,12 +568,15 @@ $(document).ready(function() {
|
|
|
};
|
|
|
this.commonSpreadSetting = {
|
|
|
cols: [
|
|
|
- {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 230, formatter: '@'},
|
|
|
- {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 185, formatter: '@'},
|
|
|
+ {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 160, formatter: '@'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 160, formatter: '@'},
|
|
|
+ {title: '税率(%)', colSpan: '1', rowSpan: '1', field: 'tax', hAlign: 2, width: 80, type: 'Number'},
|
|
|
{title: '付款金额', colSpan: '1', rowSpan: '1', field: 'pay_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
{title: '扣款金额', colSpan: '1', rowSpan: '1', field: 'cut_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
{title: '应付金额', colSpan: '1', rowSpan: '1', field: 'yf_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
|
|
|
{title: '实付金额', colSpan: '1', rowSpan: '1', field: 'sf_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '应付金额(无税)', colSpan: '1', rowSpan: '1', field: 'yf_excl_tax_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
+ {title: '实付金额(无税)', colSpan: '1', rowSpan: '1', field: 'sf_excl_tax_tp', hAlign: 2, width: 100, type: 'Number', readOnly: true},
|
|
|
{title: '本期批注', colSpan: '1', rowSpan: '1', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
|
|
|
{title: '备注', colSpan: '1', rowSpan: '1', field: 'memo', hAlign: 0, width: 120, formatter: '@', cellType: 'ellipsisAutoTip'},
|
|
|
],
|
|
|
@@ -641,7 +651,15 @@ $(document).ready(function() {
|
|
|
this.loadDetailData(SpreadJsObj.getSelectObject(billsObj.sheet));
|
|
|
}
|
|
|
refreshSheet() {
|
|
|
- SpreadJsObj.reLoadSheetData(this.sheet);
|
|
|
+ if (this.sheet.zh_data.length === 0) {
|
|
|
+ this.reloadDetailData();
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.reLoadSheetData(this.sheet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reloadDetailData() {
|
|
|
+ const data = this.billsNode ? this.data.getPartData(this.billsNode.id) || [] : [];
|
|
|
+ SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Data, data);
|
|
|
}
|
|
|
loadDetailData(bills) {
|
|
|
detailObj.billsNode = bills;
|
|
|
@@ -652,8 +670,7 @@ $(document).ready(function() {
|
|
|
spreadSetting.readOnly = readOnly;
|
|
|
}
|
|
|
SpreadJsObj.initSheet(this.sheet, spreadSetting);
|
|
|
- const data = bills ? this.data.getPartData(bills.id) || [] : [];
|
|
|
- SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Data, data);
|
|
|
+ this.reloadDetailData();
|
|
|
}
|
|
|
loadRelaData() {
|
|
|
const select = SpreadJsObj.getSelectObject(this.sheet);
|
|
|
@@ -661,36 +678,27 @@ $(document).ready(function() {
|
|
|
}
|
|
|
baseOpr(type) {
|
|
|
const self = this;
|
|
|
- const select = SpreadJsObj.getSelectObject(this.sheet);
|
|
|
-
|
|
|
- const updateData = { target: 'detail', postType: type, postData: { id: select.id } };
|
|
|
if (type === 'delete') {
|
|
|
+ const updateData = { target: 'detail', del: [] };
|
|
|
+ const sel = this.sheet.getSelections()[0];
|
|
|
+ for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
|
|
|
+ const node = this.sheet.zh_data[iRow];
|
|
|
+ if (node) updateData.del.push(node.id);
|
|
|
+ }
|
|
|
+ if (updateData.del.length === 0) return;
|
|
|
+
|
|
|
deleteAfterHint(function () {
|
|
|
postData(window.location.pathname + '/update', updateData, function (result) {
|
|
|
- self.data.updateDatas(result);
|
|
|
+ billsTag.afterDeletePos(result.detail.del.map(x => { return detailObj.data.getItem(x); }));
|
|
|
+ costFile.deleteFileBySubNodeId(result.detail.del);
|
|
|
+ self.data.updateDatas(result.detail);
|
|
|
self.refreshSheet();
|
|
|
- if (sel) {
|
|
|
- sheet.setSelection(sel.row, sel.col, 1, sel.colCount);
|
|
|
- }
|
|
|
+ if (sel) self.sheet.setSelection(sel.row, sel.col, 1, sel.colCount);
|
|
|
+ result.ledger.tree_id = detailObj.billsNode.tree_id;
|
|
|
+ const refreshNode = billsObj.tree.loadPostData({ update: result.ledger });
|
|
|
+ billsObj.refreshTree(refreshNode);
|
|
|
});
|
|
|
- });
|
|
|
- } else {
|
|
|
- postData(window.location.pathname + '/update', updateData, function (result) {
|
|
|
- self.data.updateDatas(result);
|
|
|
- self.refreshSheet();
|
|
|
- if (['up-move', 'down-move'].indexOf(type) > -1) {
|
|
|
- if (sel) {
|
|
|
- sheet.setSelection(tree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
|
|
|
- // SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, tree.nodes.indexOf(node)]);
|
|
|
- }
|
|
|
- } else if (type === 'add') {
|
|
|
- const sel = sheet.getSelections()[0];
|
|
|
- if (sel) {
|
|
|
- sheet.setSelection(tree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
|
|
|
- // SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, tree.nodes.indexOf(refreshData.create[0])]);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ }, '确认删除「当前明细数据」?');
|
|
|
}
|
|
|
}
|
|
|
// 事件
|
|
|
@@ -878,6 +886,7 @@ $(document).ready(function() {
|
|
|
user_name: 'user_name',
|
|
|
lid: 'rela_id',
|
|
|
pos_id: 'rela_sub_id',
|
|
|
+ posMasterId: 'ledger_id',
|
|
|
updateUrl: window.location.pathname + '/tag',
|
|
|
afterModify: function (nodes) {
|
|
|
billsObj.sheet.repaint();
|
|
|
@@ -907,6 +916,105 @@ $(document).ready(function() {
|
|
|
items: {}
|
|
|
};
|
|
|
if (!readOnly) {
|
|
|
+ $('select[name=contract_type]').select2({
|
|
|
+ language: 'zh-CN',
|
|
|
+ width: '100%',
|
|
|
+ multiple: true,
|
|
|
+ maximumSelectionlength: 6,
|
|
|
+ });
|
|
|
+ const importDeal = (function(){
|
|
|
+ let curNode;
|
|
|
+ const contractSelectSpread = SpreadJsObj.createNewSpread($('#contract-spread')[0]);
|
|
|
+ const contractSelectSheet = contractSelectSpread.getActiveSheet();
|
|
|
+ SpreadJsObj.initSheet(contractSelectSheet, {
|
|
|
+ cols: [
|
|
|
+ {title: '选择', colSpan: '1', rowSpan: '1', field: 'selected', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox'},
|
|
|
+ {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 120, formatter: '@', cellType: 'tree'},
|
|
|
+ {title: '合同编号', colSpan: '1', rowSpan: '1', field: 'c_code', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 200, formatter: '@'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ });
|
|
|
+ let contractTree;
|
|
|
+ contractSelectSpread.bind(spreadNS.Events.ButtonClicked, function(e, info) {
|
|
|
+ if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
|
|
|
+
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if (col.field !== 'selected') return;
|
|
|
+
|
|
|
+ const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ node.selected = !node.selected;
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ const posterity = info.sheet.zh_tree.getPosterity(node);
|
|
|
+ for (const p of posterity) {
|
|
|
+ p.selected = node.selected;
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row, posterity.length + 1);
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('#import-deal-type-ok').click(function() {
|
|
|
+ const updateData = { target: 'importContract', ledger_id: curNode.id, cost_id: curNode.cost_id, types: $('[name=contract_type]').val() };
|
|
|
+ if (updateData.types.length === 0) {
|
|
|
+ toastr.warning('请至少选择一种类型');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ postData(window.location.pathname + '/update', updateData, function(result) {
|
|
|
+ detailObj.data.updateDatas(result.detail);
|
|
|
+ detailObj.reloadDetailData();
|
|
|
+ result.ledger.tree_id = curNode.tree_id;
|
|
|
+ const refreshNode = billsObj.tree.loadPostData({ update: result.ledger });
|
|
|
+ billsObj.refreshTree(refreshNode);
|
|
|
+ $('#import-deal-type').modal('hide');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ const importByType = function(node) {
|
|
|
+ curNode = node;
|
|
|
+ $('#import-deal-type').modal('show');
|
|
|
+ };
|
|
|
+ const loadContractTree = function() {
|
|
|
+ postData(window.location.pathname + '/load', { filter: 'contract'}, function(result) {
|
|
|
+ contractTree = createNewPathTree('base', { id: 'contract_id', pid: 'contract_pid', order: 'order', level: 'level', fullPath: 'full_path', rootId: -1 });
|
|
|
+ contractTree.loadDatas(result.contract);
|
|
|
+ SpreadJsObj.loadSheetData(contractSelectSheet, SpreadJsObj.DataType.Tree, contractTree);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ const getSelectContractId = function() {
|
|
|
+ if (!contractTree) return [];
|
|
|
+ return contractTree.nodes.filter(x => { return x.selected && x.c_code; }).map(x => { return x.id; });
|
|
|
+ };
|
|
|
+ $('#import-deal-select').on('shown.bs.modal', function() {
|
|
|
+ contractSelectSpread.refresh();
|
|
|
+ });
|
|
|
+ $('#import-deal-select-ok').click(function() {
|
|
|
+ const updateData = { target: 'importContract', ledger_id: curNode.id, cost_id: curNode.cost_id, ids: getSelectContractId() };
|
|
|
+ if (updateData.ids.length === 0) {
|
|
|
+ toastr.warning('请至少选择一项合同数据');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ postData(window.location.pathname + '/update', updateData, function(result) {
|
|
|
+ detailObj.data.updateDatas(result.detail);
|
|
|
+ detailObj.refreshSheet();
|
|
|
+ result.ledger.tree_id = curNode.tree_id;
|
|
|
+ const refreshNode = billsObj.tree.loadPostData({ update: result.ledger });
|
|
|
+ billsObj.refreshTree(refreshNode);
|
|
|
+ $('#import-deal-select').modal('hide');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ const importBySelect = function(node) {
|
|
|
+ curNode = node;
|
|
|
+ $('#import-deal-select').modal('show');
|
|
|
+ if (!contractTree) loadContractTree();
|
|
|
+ };
|
|
|
+ return {importByType, importBySelect};
|
|
|
+ })();
|
|
|
billsContextMenuOptions.items.create = {
|
|
|
name: '新增',
|
|
|
icon: 'fa-sign-in',
|
|
|
@@ -964,12 +1072,14 @@ $(document).ready(function() {
|
|
|
billsContextMenuOptions.items.importDealByTree = {
|
|
|
name: '导入合同数据(自选)',
|
|
|
callback: function(key, opt, menu, e) {
|
|
|
-
|
|
|
+ const node = SpreadJsObj.getSelectObject(billsObj.sheet);
|
|
|
+ importDeal.importBySelect(node)
|
|
|
},
|
|
|
disabled: function(key, opt) {
|
|
|
const node = SpreadJsObj.getSelectObject(billsObj.sheet);
|
|
|
if (!node) return true;
|
|
|
if (node.children && node.children.length > 0) return true;
|
|
|
+ if (node.had_detail && !node.is_deal) return true;
|
|
|
const detailRange = detailObj.data.getPartData(node.id);
|
|
|
if (!detailRange || detailRange.length === 0) return false;
|
|
|
return !detailRange[0].is_deal;
|
|
|
@@ -978,12 +1088,14 @@ $(document).ready(function() {
|
|
|
billsContextMenuOptions.items.importDealByType = {
|
|
|
name: '导入合同数据(分类)',
|
|
|
callback: function(key, opt, menu, e) {
|
|
|
-
|
|
|
+ const node = SpreadJsObj.getSelectObject(billsObj.sheet);
|
|
|
+ importDeal.importByType(node)
|
|
|
},
|
|
|
disabled: function(key, opt) {
|
|
|
const node = SpreadJsObj.getSelectObject(billsObj.sheet);
|
|
|
if (!node) return true;
|
|
|
if (node.children && node.children.length > 0) return true;
|
|
|
+ if (node.had_detail && !node.is_deal) return true;
|
|
|
const detailRange = detailObj.data.getPartData(node.id);
|
|
|
if (!detailRange || detailRange.length === 0) return false;
|
|
|
return !detailRange[0].is_deal;
|
|
|
@@ -1005,7 +1117,26 @@ $(document).ready(function() {
|
|
|
$.contextMenu(billsContextMenuOptions);
|
|
|
$.contextMenu({
|
|
|
selector: '#detail-spread',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ const target = SpreadJsObj.safeRightClickSelection($trigger, e, detailObj.spread);
|
|
|
+ detailObj.loadRelaData();
|
|
|
+ return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
|
|
|
+ },
|
|
|
items: {
|
|
|
+ del: {
|
|
|
+ name: '删除',
|
|
|
+ icon: 'fa-remove',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ detailObj.baseOpr('delete');
|
|
|
+ },
|
|
|
+ visible: function() {
|
|
|
+ return !readOnly;
|
|
|
+ },
|
|
|
+ disabled: function() {
|
|
|
+ const detail = SpreadJsObj.getSelectObject(detailObj.sheet);
|
|
|
+ return !detail;
|
|
|
+ }
|
|
|
+ },
|
|
|
tag: {
|
|
|
name: '书签',
|
|
|
callback: function (key, opt, menu, e) {
|