Commit 5d480281be1b1701c524e0a544ff948eec3fef2c
Merge branch 'dev-fix-ww' into 'main_dev'
fix: DEFECT-1227 修复客户角色只拥有可视化管理的查看权限 See merge request yunteng/thingskit-scada!61
Showing
2 changed files
with
14 additions
and
6 deletions
| ... | ... | @@ -24,7 +24,7 @@ const GLOBAL_TOKEN = (() => { | 
| 24 | 24 | * @type {{JWT_TOKEN: {value: string}}} | 
| 25 | 25 | */ | 
| 26 | 26 | const common = ls.get(GLOBAL_STORAGE_KEY) | 
| 27 | - | |
| 27 | + | |
| 28 | 28 | return isShareMode | 
| 29 | 29 | ? { | 
| 30 | 30 | token: common && common.SHARE_JWT_TOKEN && common.SHARE_JWT_TOKEN.value, | 
| ... | ... | @@ -56,8 +56,15 @@ const USER_PERMISSION = { | 
| 56 | 56 | permission: [] | 
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | +const IS_CUSTOMER_USER = (() => { | |
| 60 | + const ls = createStorage({ storage: localStorage }) | |
| 61 | + const common = ls.get(GLOBAL_STORAGE_KEY) || { USER__INFO__: {} } | |
| 62 | + const userInfo = common.USER__INFO__.value || {} | |
| 63 | + return (userInfo.roles || [])[0] === 'CUSTOMER_USER' | |
| 64 | +})() | |
| 65 | + | |
| 59 | 66 | const hasSavePermission = () => { | 
| 60 | - return USER_PERMISSION.permission.includes(CAN_WRITE) | |
| 67 | + return USER_PERMISSION.permission.includes(CAN_WRITE) && !IS_CUSTOMER_USER | |
| 61 | 68 | } | 
| 62 | 69 | |
| 63 | 70 | const GLOBAL_WS_URL = () => { | 
| ... | ... | @@ -67,3 +74,4 @@ const GLOBAL_WS_URL = () => { | 
| 67 | 74 | } | 
| 68 | 75 | |
| 69 | 76 | |
| 77 | + | ... | ... | 
| ... | ... | @@ -136,7 +136,7 @@ LocalFile.prototype.getLatestVersion = function (success, error) { | 
| 136 | 136 | LocalFile.prototype.saveFile = function (title, revision, success, error, useCurrentData) { | 
| 137 | 137 | // TODO thingskit 保存权限 | 
| 138 | 138 | var flag = hasSavePermission() | 
| 139 | - if (!flag) return error({error: '没有权限'}) | |
| 139 | + if (!flag) return error({ error: '没有权限' }) | |
| 140 | 140 | if (title != this.title) { | 
| 141 | 141 | this.fileHandle = null; | 
| 142 | 142 | this.desc = null; | 
| ... | ... | @@ -147,7 +147,7 @@ LocalFile.prototype.saveFile = function (title, revision, success, error, useCur | 
| 147 | 147 | // Updates data after changing file name | 
| 148 | 148 | if (!useCurrentData) { | 
| 149 | 149 | this.updateFileData(); | 
| 150 | - } | |
| 150 | + } | |
| 151 | 151 | var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()); | 
| 152 | 152 | this.setShadowModified(false); | 
| 153 | 153 | var savedData = this.getData(); | 
| ... | ... | @@ -162,7 +162,7 @@ LocalFile.prototype.saveFile = function (title, revision, success, error, useCur | 
| 162 | 162 | }); | 
| 163 | 163 | |
| 164 | 164 | var doSave = mxUtils.bind(this, function (data) { | 
| 165 | - if(!this.fileHandle) { | |
| 165 | + if (!this.fileHandle) { | |
| 166 | 166 | this.fileHandle = { | 
| 167 | 167 | kind: 'file', | 
| 168 | 168 | name: '未命名.xml' | 
| ... | ... | @@ -215,7 +215,7 @@ LocalFile.prototype.saveFile = function (title, revision, success, error, useCur | 
| 215 | 215 | }; | 
| 216 | 216 | configurationContentList.push(configurationContent); | 
| 217 | 217 | var parmam = { configurationId: Editor.configurationId, configurationContentList }; | 
| 218 | - defHttp.put("/yt/configuration/content", parmam).then(res => { | |
| 218 | + !IS_CUSTOMER_USER && defHttp.put("/yt/configuration/content", parmam).then(res => { | |
| 219 | 219 | // console.log(res) | 
| 220 | 220 | }) | 
| 221 | 221 | } | ... | ... |