Commit 295d675b6d10982a72fdb2b97cc133bab54ada64
1 parent
1e604e83
fix: save button render invalidate and bind data source submit method not validate permission
Showing
2 changed files
with
46 additions
and
26 deletions
@@ -5036,7 +5036,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | @@ -5036,7 +5036,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | ||
5036 | } | 5036 | } |
5037 | 5037 | ||
5038 | getToken() | 5038 | getToken() |
5039 | - | 5039 | + |
5040 | var updateButtonContainer = this.updateButtonContainer | 5040 | var updateButtonContainer = this.updateButtonContainer |
5041 | // var lockUnlock = this.actions.actions.lockUnlock.funct | 5041 | // var lockUnlock = this.actions.actions.lockUnlock.funct |
5042 | // var selectAll = this.actions.actions.selectAll.funct | 5042 | // var selectAll = this.actions.actions.selectAll.funct |
@@ -5044,6 +5044,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | @@ -5044,6 +5044,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | ||
5044 | defHttp.get('/yt/role/me/permissions') | 5044 | defHttp.get('/yt/role/me/permissions') |
5045 | .then(res => { | 5045 | .then(res => { |
5046 | USER_PERMISSION.permission = res | 5046 | USER_PERMISSION.permission = res |
5047 | + console.log({USER_PERMISSION}) | ||
5047 | updateButtonContainer() | 5048 | updateButtonContainer() |
5048 | // var flag = hasSavePermission() | 5049 | // var flag = hasSavePermission() |
5049 | // if (!flag) { | 5050 | // if (!flag) { |
@@ -5978,30 +5979,28 @@ App.prototype.updateButtonContainer = function() | @@ -5978,30 +5979,28 @@ App.prototype.updateButtonContainer = function() | ||
5978 | this.buttonContainer.appendChild(this.shareButton); | 5979 | this.buttonContainer.appendChild(this.shareButton); |
5979 | 5980 | ||
5980 | // TODO thingsKit 保存按钮 | 5981 | // TODO thingsKit 保存按钮 |
5981 | - var flag = hasSavePermission() | ||
5982 | - if (flag) { | ||
5983 | - this.saveButton = document.createElement('div'); | ||
5984 | - this.saveButton.className = 'geBtn gePrimaryBtn'; | ||
5985 | - this.saveButton.style.display = 'inline-block'; | ||
5986 | - this.saveButton.style.backgroundColor = '#F2931E'; | ||
5987 | - this.saveButton.style.borderColor = '#F08705'; | ||
5988 | - this.saveButton.style.backgroundImage = 'none'; | ||
5989 | - this.saveButton.style.marginTop = '-10px'; | ||
5990 | - this.saveButton.style.lineHeight = '28px'; | ||
5991 | - this.saveButton.style.minWidth = '0px'; | ||
5992 | - this.saveButton.style.cssFloat = 'right'; | ||
5993 | - this.saveButton.setAttribute('title', '保存'); | ||
5994 | - mxUtils.write(this.saveButton, '保存'); | ||
5995 | - mxEvent.addListener(this.saveButton, 'click', mxUtils.bind(this, function() | ||
5996 | - { | ||
5997 | - this.currentFile.ui.actions.get( | ||
5998 | - (this.currentFile.mode == null || !this.currentFile.isEditable()) | ||
5999 | - ? 'saveAs' | ||
6000 | - : 'save') | ||
6001 | - .funct(); | ||
6002 | - })); | ||
6003 | - this.buttonContainer.appendChild(this.saveButton); | ||
6004 | - } | 5982 | + this.saveButton = document.createElement('div'); |
5983 | + this.saveButton.className = 'geBtn gePrimaryBtn'; | ||
5984 | + this.saveButton.style.display = 'inline-block'; | ||
5985 | + this.saveButton.style.backgroundColor = '#F2931E'; | ||
5986 | + this.saveButton.style.borderColor = '#F08705'; | ||
5987 | + this.saveButton.style.backgroundImage = 'none'; | ||
5988 | + this.saveButton.style.marginTop = '-10px'; | ||
5989 | + this.saveButton.style.lineHeight = '28px'; | ||
5990 | + this.saveButton.style.minWidth = '0px'; | ||
5991 | + this.saveButton.style.cssFloat = 'right'; | ||
5992 | + this.saveButton.setAttribute('title', '保存'); | ||
5993 | + this.saveButton.setAttribute('id', 'thingskitSaveButton'); | ||
5994 | + mxUtils.write(this.saveButton, '保存'); | ||
5995 | + mxEvent.addListener(this.saveButton, 'click', mxUtils.bind(this, function() | ||
5996 | + { | ||
5997 | + this.currentFile.ui.actions.get( | ||
5998 | + (this.currentFile.mode == null || !this.currentFile.isEditable()) | ||
5999 | + ? 'saveAs' | ||
6000 | + : 'save') | ||
6001 | + .funct(); | ||
6002 | + })); | ||
6003 | + this.buttonContainer.appendChild(this.saveButton); | ||
6005 | 6004 | ||
6006 | 6005 | ||
6007 | 6006 | ||
@@ -6062,6 +6061,11 @@ App.prototype.updateButtonContainer = function() | @@ -6062,6 +6061,11 @@ App.prototype.updateButtonContainer = function() | ||
6062 | { | 6061 | { |
6063 | this.fetchAndShowNotification(urlParams['notif']); | 6062 | this.fetchAndShowNotification(urlParams['notif']); |
6064 | } | 6063 | } |
6064 | + } else { | ||
6065 | + if (!hasSavePermission()) { | ||
6066 | + var el = document.getElementById('thingskitSaveButton') | ||
6067 | + el && el.remove() | ||
6068 | + } | ||
6065 | } | 6069 | } |
6066 | }; | 6070 | }; |
6067 | 6071 |
@@ -418,7 +418,7 @@ Format.prototype.immediateRefresh = function () { | @@ -418,7 +418,7 @@ Format.prototype.immediateRefresh = function () { | ||
418 | const basicAttr = sidebarInstance.enumCellBasicAttribute | 418 | const basicAttr = sidebarInstance.enumCellBasicAttribute |
419 | const componentType = cell.getAttribute(basicAttr.COMPONENT_TYPE) | 419 | const componentType = cell.getAttribute(basicAttr.COMPONENT_TYPE) |
420 | const hasPermission = sidebarInstance.getComponentPermission(componentType) | 420 | const hasPermission = sidebarInstance.getComponentPermission(componentType) |
421 | - return !!hasPermission.length | 421 | + return !!hasPermission.length && hasSavePermission() |
422 | } | 422 | } |
423 | 423 | ||
424 | var addClickHandler = mxUtils.bind( | 424 | var addClickHandler = mxUtils.bind( |
@@ -5898,6 +5898,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5898,6 +5898,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5898 | $(panel).addClass('data-source__submit-panel').append(`<button type="button" lay-submit lay-filter="formDataSource" class="layui-btn">保存</button>`) | 5898 | $(panel).addClass('data-source__submit-panel').append(`<button type="button" lay-submit lay-filter="formDataSource" class="layui-btn">保存</button>`) |
5899 | $(container).append(panel) | 5899 | $(container).append(panel) |
5900 | form.on('submit(formDataSource)', async function (data) { | 5900 | form.on('submit(formDataSource)', async function (data) { |
5901 | + if (!hasSavePermission()) { | ||
5902 | + UseLayUi.topErrorMsg('没有权限') | ||
5903 | + return | ||
5904 | + } | ||
5901 | const { field } = data | 5905 | const { field } = data |
5902 | const value = getValueOnSubmit(field) | 5906 | const value = getValueOnSubmit(field) |
5903 | await to(autoSaveGraphInfo()) | 5907 | await to(autoSaveGraphInfo()) |
@@ -6261,6 +6265,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6261,6 +6265,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6261 | * @description | 6265 | * @description |
6262 | */ | 6266 | */ |
6263 | async function submit(callback) { | 6267 | async function submit(callback) { |
6268 | + if (!hasPermission()) return | ||
6264 | const data = Array.from({ length: addRowNumber }).map((_, row) => form.val(getRowFilter(row))).filter(item => Object.keys(item).length) | 6269 | const data = Array.from({ length: addRowNumber }).map((_, row) => form.val(getRowFilter(row))).filter(item => Object.keys(item).length) |
6265 | const defaultImageConfig = form.val(enumActionEl.DEFAULT_IMAGE_FILTER) | 6270 | const defaultImageConfig = form.val(enumActionEl.DEFAULT_IMAGE_FILTER) |
6266 | defaultImageConfig[enumConst.DEFAULT_IMAGE_FLAG] = true | 6271 | defaultImageConfig[enumConst.DEFAULT_IMAGE_FLAG] = true |
@@ -6709,6 +6714,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6709,6 +6714,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6709 | * @description 保存 | 6714 | * @description 保存 |
6710 | */ | 6715 | */ |
6711 | async function submit(callback) { | 6716 | async function submit(callback) { |
6717 | + if (!hasPermission()) return | ||
6712 | const data = Array.from({ length: addRowNumber }).map((_, row) => form.val(getRowFilter(row))).filter(item => Object.keys(item).length) | 6718 | const data = Array.from({ length: addRowNumber }).map((_, row) => form.val(getRowFilter(row))).filter(item => Object.keys(item).length) |
6713 | if (!validate(data)) return | 6719 | if (!validate(data)) return |
6714 | const formModal = { | 6720 | const formModal = { |
@@ -6963,6 +6969,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6963,6 +6969,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6963 | * @description 编辑数据交互 | 6969 | * @description 编辑数据交互 |
6964 | */ | 6970 | */ |
6965 | async function submit(callback) { | 6971 | async function submit(callback) { |
6972 | + if (!hasPermission()) return | ||
6966 | const formVal = form.val(enumActionEl.FORM_FILTER) | 6973 | const formVal = form.val(enumActionEl.FORM_FILTER) |
6967 | const isParamsSetting = formVal[enumConst.ACTION] === enumActionType.PARAMS_SETTING | 6974 | const isParamsSetting = formVal[enumConst.ACTION] === enumActionType.PARAMS_SETTING |
6968 | const { COMPONENT_TYPE } = Sidebar.prototype.enumCellBasicAttribute | 6975 | const { COMPONENT_TYPE } = Sidebar.prototype.enumCellBasicAttribute |
@@ -7381,6 +7388,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7381,6 +7388,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7381 | } | 7388 | } |
7382 | 7389 | ||
7383 | async function submit(callback) { | 7390 | async function submit(callback) { |
7391 | + if (!hasPermission()) return | ||
7384 | const tableData = Array.from({ length: addRowNumber }).map((_, index) => form.val(getRowFilter(index))).filter(obj => Object.keys(obj).length) | 7392 | const tableData = Array.from({ length: addRowNumber }).map((_, index) => form.val(getRowFilter(index))).filter(obj => Object.keys(obj).length) |
7385 | if (!validate(tableData)) return | 7393 | if (!validate(tableData)) return |
7386 | const formVal = form.val(enumActionEl.FORM_FILTER) | 7394 | const formVal = form.val(enumActionEl.FORM_FILTER) |
@@ -7618,6 +7626,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7618,6 +7626,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7618 | } | 7626 | } |
7619 | 7627 | ||
7620 | async function submit(callback) { | 7628 | async function submit(callback) { |
7629 | + if (!hasPermission()) return | ||
7630 | + | ||
7621 | const enableValue = form.val(enumActionEl.ENABLE_FILTER) | 7631 | const enableValue = form.val(enumActionEl.ENABLE_FILTER) |
7622 | const closeValue = form.val(enumActionEl.CLOSE_FILTER) | 7632 | const closeValue = form.val(enumActionEl.CLOSE_FILTER) |
7623 | 7633 | ||
@@ -8344,6 +8354,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8344,6 +8354,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8344 | ` | 8354 | ` |
8345 | } | 8355 | } |
8346 | 8356 | ||
8357 | + function hasPermission() { | ||
8358 | + let flag = hasSavePermission() | ||
8359 | + if (!flag) UseLayUi.topErrorMsg('没有权限') | ||
8360 | + return flag | ||
8361 | + } | ||
8362 | + | ||
8347 | // 异步设置此处才能生效 -- 设置默认select和样式和初始化侧边栏生成组件和事件绑定 | 8363 | // 异步设置此处才能生效 -- 设置默认select和样式和初始化侧边栏生成组件和事件绑定 |
8348 | setTimeout(() => { | 8364 | setTimeout(() => { |
8349 | 8365 |