|
@@ -960,13 +960,18 @@ $(document).ready(function() {
|
|
|
if (info.newSelections) {
|
|
if (info.newSelections) {
|
|
|
if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row || info.newSelections[0].rowCount !== info.oldSelections[0].rowCount) {
|
|
if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row || info.newSelections[0].rowCount !== info.oldSelections[0].rowCount) {
|
|
|
const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
- $('#move-new-node').text(node ? node.code : '');
|
|
|
|
|
|
|
+ $('.move-new-node').text(node ? node.code : '');
|
|
|
}
|
|
}
|
|
|
info.sheet.setSelection(info.newSelections[0].row, 0, 1, info.sheet.getColumnCount());
|
|
info.sheet.setSelection(info.newSelections[0].row, 0, 1, info.sheet.getColumnCount());
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
moveSpread.bind(spreadNS.Events.SelectionChanged, moveTreeSpreadObj.selectionChanged);
|
|
moveSpread.bind(spreadNS.Events.SelectionChanged, moveTreeSpreadObj.selectionChanged);
|
|
|
|
|
+ const move2Spread = SpreadJsObj.createNewSpread($('#move2-contract-spread')[0]);
|
|
|
|
|
+ const move2Sheet = move2Spread.getActiveSheet();
|
|
|
|
|
+ SpreadJsObj.initSheet(move2Sheet, moveSpreadSetting);
|
|
|
|
|
+ move2Spread.bind(spreadNS.Events.SelectionChanged, moveTreeSpreadObj.selectionChanged);
|
|
|
|
|
+
|
|
|
$('#cons-move').on('shown.bs.modal', function () {
|
|
$('#cons-move').on('shown.bs.modal', function () {
|
|
|
const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
if (!(node && node.c_code)) {
|
|
if (!(node && node.c_code)) {
|
|
@@ -976,8 +981,8 @@ $(document).ready(function() {
|
|
|
}
|
|
}
|
|
|
$('#move-node').text(node.c_code);
|
|
$('#move-node').text(node.c_code);
|
|
|
const parentNode = _.find(contractTree.nodes, { contract_id: node.contract_pid });
|
|
const parentNode = _.find(contractTree.nodes, { contract_id: node.contract_pid });
|
|
|
- $('#move-parent-node').text(parentNode ? parentNode.code : '');
|
|
|
|
|
- $('#move-new-node').text(parentNode ? parentNode.code : '');
|
|
|
|
|
|
|
+ $('.move-parent-node').text(parentNode ? parentNode.code : '');
|
|
|
|
|
+ $('.move-new-node').text(parentNode ? parentNode.code : '');
|
|
|
const onlyTree = _.cloneDeep(_.filter(contractTree.nodes, function (item) {
|
|
const onlyTree = _.cloneDeep(_.filter(contractTree.nodes, function (item) {
|
|
|
return item.code !== undefined && item.c_code === undefined;
|
|
return item.code !== undefined && item.c_code === undefined;
|
|
|
}));
|
|
}));
|
|
@@ -1054,6 +1059,127 @@ $(document).ready(function() {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ $('#cons-move2').on('shown.bs.modal', function () {
|
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
|
|
+ if (!(node && node.code)) {
|
|
|
|
|
+ toastr.error('节点编号不存在');
|
|
|
|
|
+ $('#cons-move2').modal('hide');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ $('.move-parent-node').text(node ? node.code : '');
|
|
|
|
|
+ $('.move-new-node').text(node ? node.code : '');
|
|
|
|
|
+ const onlyTree = _.cloneDeep(_.filter(contractTree.nodes, function (item) {
|
|
|
|
|
+ return item.code !== undefined && item.c_code === undefined;
|
|
|
|
|
+ }));
|
|
|
|
|
+ for (const t of onlyTree) {
|
|
|
|
|
+ if (!t.is_leaf && _.findIndex(onlyTree, { contract_pid: t.contract_id }) === -1) {
|
|
|
|
|
+ t.is_leaf = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ moveTree.loadDatas(onlyTree);
|
|
|
|
|
+ SpreadJsObj.loadSheetData(move2Sheet, SpreadJsObj.DataType.Tree, moveTree);
|
|
|
|
|
+ const contracts = _.filter(node.children, function (item) {
|
|
|
|
|
+ return item.c_code !== undefined;
|
|
|
|
|
+ });
|
|
|
|
|
+ let html = '';
|
|
|
|
|
+ for(const c of contracts) {
|
|
|
|
|
+ html += `<tr>
|
|
|
|
|
+ <td class="text-center"><input class="" checked type="checkbox" contract_id="${c.id}" /></td>
|
|
|
|
|
+ <td>${c.c_code}</td>
|
|
|
|
|
+ <td>${c.name}</td>
|
|
|
|
|
+ </tr>`
|
|
|
|
|
+ }
|
|
|
|
|
+ $('#move2-contracts').html(html);
|
|
|
|
|
+ // 找出node对应父节点并选中,底色也要跟着更新
|
|
|
|
|
+ const parentIndex = _.findIndex(moveTree.nodes, { contract_id: node.contract_id });
|
|
|
|
|
+ if (parentIndex !== -1) {
|
|
|
|
|
+ move2Sheet.setSelection(parentIndex, 0, 1, move2Sheet.getColumnCount());
|
|
|
|
|
+ SpreadJsObj.reloadRowsBackColor(move2Sheet, [0, parentIndex]);
|
|
|
|
|
+ }
|
|
|
|
|
+ move2Spread.refresh();
|
|
|
|
|
+ $('#select-move2-all').prop('checked', true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ $('#select-move2-all').click(function () {
|
|
|
|
|
+ const checkAll = $(this).prop('checked');
|
|
|
|
|
+ $('#move2-contracts').find('input[type="checkbox"]').prop('checked', checkAll);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ $('#move2-contracts').on('change', 'input[type="checkbox"]', function () {
|
|
|
|
|
+ const allChecked = $('#move2-contracts').find('input[type="checkbox"]').length === $('#move2-contracts').find('input[type="checkbox"]:checked').length;
|
|
|
|
|
+ $('#select-move2-all').prop('checked', allChecked);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ $('#move2-contract-btn').click(function () {
|
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
|
|
+ if (!(node && node.code)) {
|
|
|
|
|
+ toastr.error('节点编号不存在');
|
|
|
|
|
+ $('#cons-move2').modal('hide');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const newNode = SpreadJsObj.getSelectObject(move2Sheet);
|
|
|
|
|
+ const newParentNode = _.find(contractTree.nodes, { contract_id: newNode.contract_id });
|
|
|
|
|
+ if (node.contract_id === newParentNode.contract_id) {
|
|
|
|
|
+ toastr.warning('合同所属节点无变化');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 要移动的合同已勾选
|
|
|
|
|
+ const data = [];
|
|
|
|
|
+ let newOrder = newParentNode.children ? newParentNode.children.length + 1 : 1;
|
|
|
|
|
+ $('#move2-contracts').find('input[type="checkbox"]:checked').each(function () {
|
|
|
|
|
+ const contractId = $(this).attr('contract_id');
|
|
|
|
|
+ const contractNode = _.find(node.children, { id: contractId });
|
|
|
|
|
+ data.push({
|
|
|
|
|
+ id: contractNode.id,
|
|
|
|
|
+ contract_pid: newParentNode.contract_id,
|
|
|
|
|
+ level: newParentNode.level + 1,
|
|
|
|
|
+ order: newOrder,
|
|
|
|
|
+ full_path: newParentNode.full_path + '-' + contractNode.contract_id,
|
|
|
|
|
+ });
|
|
|
|
|
+ newOrder += 1;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (data.length === 0) {
|
|
|
|
|
+ toastr.warning('请勾选要移动的合同');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (node.children.length === data.length) {
|
|
|
|
|
+ node.is_leaf = 1;
|
|
|
|
|
+ data.push({
|
|
|
|
|
+ id: node.id,
|
|
|
|
|
+ is_leaf: 1,
|
|
|
|
|
+ });
|
|
|
|
|
+ } else if (node.children.length > 1) {
|
|
|
|
|
+ // 可能需要移动node的children数组比data里面选的减值
|
|
|
|
|
+ for (const [i, child] of node.children.entries()) {
|
|
|
|
|
+ if (!_.find(data, { id: child.id })) {
|
|
|
|
|
+ if (i !== child.order) {
|
|
|
|
|
+ child.order = i;
|
|
|
|
|
+ data.push({
|
|
|
|
|
+ id: child.id,
|
|
|
|
|
+ order: child.order,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (newParentNode.is_leaf === 1) {
|
|
|
|
|
+ newParentNode.is_leaf = 0;
|
|
|
|
|
+ data.push({
|
|
|
|
|
+ id: newParentNode.id,
|
|
|
|
|
+ is_leaf: 0,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(data, newParentNode);
|
|
|
|
|
+ postData(window.location.pathname + '/update', {postType: 'update', postData: data, updateAll: true}, function (result) {
|
|
|
|
|
+ toastr.success('合同已移动成功');
|
|
|
|
|
+ const refreshNode = contractTree.loadPostData(result);
|
|
|
|
|
+ contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
|
|
+ const newNode = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
|
|
+ contractTreeSpreadObj.changeContractTab(newNode, true);
|
|
|
|
|
+ $('#cons-move2').modal('hide');
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
contractContextMenuOptions.items.create = {
|
|
contractContextMenuOptions.items.create = {
|
|
|
name: '新增节点',
|
|
name: '新增节点',
|
|
|
icon: 'fa-plus',
|
|
icon: 'fa-plus',
|
|
@@ -1285,7 +1411,40 @@ $(document).ready(function() {
|
|
|
if (!tree) return true;
|
|
if (!tree) return true;
|
|
|
const first = sheet.zh_tree.nodes[row];
|
|
const first = sheet.zh_tree.nodes[row];
|
|
|
const valid = !sheet.zh_setting.readOnly;
|
|
const valid = !sheet.zh_setting.readOnly;
|
|
|
- return !(valid && first && first.c_code && !first.settle_code && first.level > 1);
|
|
|
|
|
|
|
+ return !(valid && first && first.c_code && first.level > 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ contractContextMenuOptions.items.move2 = {
|
|
|
|
|
+ name: '移动本节点下合同至其它节点',
|
|
|
|
|
+ icon: 'fa-arrow-left',
|
|
|
|
|
+ callback: function (key, opt) {
|
|
|
|
|
+ $('#cons-move2').modal('show');
|
|
|
|
|
+ },
|
|
|
|
|
+ visible: function (key, opt) {
|
|
|
|
|
+ const sheet = contractSheet;
|
|
|
|
|
+ const selection = sheet.getSelections();
|
|
|
|
|
+ const sel = selection ? selection[0] : sheet.getSelections()[0];
|
|
|
|
|
+ const row = sel ? sel.row : -1;
|
|
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
|
|
+ if (!tree) return false;
|
|
|
|
|
+ const first = sheet.zh_tree.nodes[row];
|
|
|
|
|
+ const valid = !sheet.zh_setting.readOnly;
|
|
|
|
|
+ return valid && first && first.code !== undefined;
|
|
|
|
|
+ },
|
|
|
|
|
+ disabled: function (key, opt) {
|
|
|
|
|
+ const sheet = contractSheet;
|
|
|
|
|
+ const selection = sheet.getSelections();
|
|
|
|
|
+ const sel = selection ? selection[0] : sheet.getSelections()[0];
|
|
|
|
|
+ const row = sel ? sel.row : -1;
|
|
|
|
|
+ if (sel.rowCount > 1) return true;
|
|
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
|
|
+ if (!tree) return true;
|
|
|
|
|
+ const first = sheet.zh_tree.nodes[row];
|
|
|
|
|
+ console.log(first);
|
|
|
|
|
+ const valid = !sheet.zh_setting.readOnly;
|
|
|
|
|
+ return !(valid && first && first.code !== undefined && first.children.length > 0 && _.findIndex(first.children, function (item) {
|
|
|
|
|
+ return item.c_code !== undefined;
|
|
|
|
|
+ }) !== -1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
contractContextMenuOptions.items.batchInsert = {
|
|
contractContextMenuOptions.items.batchInsert = {
|