|
@@ -157,10 +157,19 @@ $(document).ready(function() {
|
|
|
return;
|
|
|
}
|
|
|
const first = sheet.zh_tree.nodes[row];
|
|
|
- if (first && permission_add && (is_admin || _.findIndex(contractTreeAudits, { uid: user_id }) === -1 || _.findIndex(contractTreeAudits, { contract_id: first.contract_id, uid: user_id }) !== -1)) {
|
|
|
- $('#add-cons-btn').show();
|
|
|
+ if (first && first.c_code) {
|
|
|
+ const parent = tree.getParent(first)
|
|
|
+ if (parent && permission_add && (is_admin || _.findIndex(contractTreeAudits, { uid: user_id }) === -1 || _.findIndex(contractTreeAudits, { contract_id: parent.contract_id, uid: user_id }) !== -1)) {
|
|
|
+ $('#add-cons-btn').show();
|
|
|
+ } else {
|
|
|
+ $('#add-cons-btn').hide();
|
|
|
+ }
|
|
|
} else {
|
|
|
- $('#add-cons-btn').hide();
|
|
|
+ if (first && permission_add && (is_admin || _.findIndex(contractTreeAudits, { uid: user_id }) === -1 || _.findIndex(contractTreeAudits, { contract_id: first.contract_id, uid: user_id }) !== -1)) {
|
|
|
+ $('#add-cons-btn').show();
|
|
|
+ } else {
|
|
|
+ $('#add-cons-btn').hide();
|
|
|
+ }
|
|
|
}
|
|
|
if (!first) {
|
|
|
invalidAll();
|
|
@@ -916,6 +925,20 @@ $(document).ready(function() {
|
|
|
callback: function (key, opt) {
|
|
|
$('#cons-add').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];
|
|
|
+ if (first && first.c_code) {
|
|
|
+ const parent = sheet.zh_tree.getParent(first);
|
|
|
+ return parent && (is_admin || _.findIndex(contractTreeAudits, { uid: user_id }) === -1 || _.findIndex(contractTreeAudits, { contract_id: parent.contract_id, uid: user_id }) !== -1);
|
|
|
+ }
|
|
|
+ return first && (is_admin || _.findIndex(contractTreeAudits, { uid: user_id }) === -1 || _.findIndex(contractTreeAudits, { contract_id: first.contract_id, uid: user_id }) !== -1);
|
|
|
+ },
|
|
|
disabled: function (key, opt) {
|
|
|
const sheet = contractSheet;
|
|
|
const selection = sheet.getSelections();
|