提交 b9348f13 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

fix: 我分享的没有及时刷新

上级 44fd7104
...@@ -7,22 +7,20 @@ ...@@ -7,22 +7,20 @@
</el-col> </el-col>
<el-col :span="8" style="text-overflow:ellipsis;overflow: hidden;white-space: nowrap;font-size: 14px"> <el-col :span="8" style="text-overflow:ellipsis;overflow: hidden;white-space: nowrap;font-size: 14px">
<span>{{ $t('panel.when_share') + ': ' + (granterTime ? new Date(granterTime).format('yyyy年-MM月-dd日') : '') }}</span> <span>{{ $t('panel.when_share') + ': ' + (granterTime ? new Date(granterTime).format('yyyy-MM-dd hh:mm:ss') : '') }}</span>
</el-col> </el-col>
<el-col :span="8" style="text-overflow:ellipsis;overflow: hidden;white-space: nowrap;font-size: 14px"> <el-col :span="8" style="text-overflow:ellipsis;overflow: hidden;white-space: nowrap;font-size: 14px">
<el-link type="primary" disabled class="share-checked"> <!-- 分享维度提醒 先注释 因为后面有可能还是需要的 -->
<!-- <el-checkbox v-model="checked" disabled>组织</el-checkbox> --> <!-- <el-link type="primary" disabled class="share-checked">
{{ $t('panel.org') }} {{ $t('panel.org') }}
</el-link> </el-link>
<el-link type="success" disabled class="share-checked"> <el-link type="success" disabled class="share-checked">
<!-- <el-checkbox v-model="checked" disabled>角色</el-checkbox> -->
{{ $t('panel.role') }} {{ $t('panel.role') }}
</el-link> </el-link>
<el-link type="info" disabled class="share-checked"> <el-link type="info" disabled class="share-checked">
<!-- <el-checkbox v-model="checked" disabled>用户</el-checkbox> -->
{{ $t('panel.user') }} {{ $t('panel.user') }}
</el-link> </el-link> -->
</el-col> </el-col>
</el-row> </el-row>
<el-row style="display: flex;"> <el-row style="display: flex;">
...@@ -68,6 +66,7 @@ ...@@ -68,6 +66,7 @@
<script> <script>
import GrantAuth from '../index' import GrantAuth from '../index'
import { shareTargets, removeShares } from '@/api/panel/share' import { shareTargets, removeShares } from '@/api/panel/share'
import bus from '@/utils/bus'
export default { export default {
name: 'ShareHead', name: 'ShareHead',
components: { GrantAuth }, components: { GrantAuth },
...@@ -135,7 +134,13 @@ export default { ...@@ -135,7 +134,13 @@ export default {
this.granterTime = item.createTime this.granterTime = item.createTime
return item return item
}).sort((a, b) => b.type - a.type) }).sort((a, b) => b.type - a.type)
if (!this.dynamicTags || this.dynamicTags.length === 0) {
this.afterRemoveAll()
}
}) })
},
afterRemoveAll() {
bus.$emit('refresh-my-share-out')
} }
} }
} }
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
> >
<span slot-scope="{ node, data }" class="custom-tree-node"> <span slot-scope="{ node, data }" class="custom-tree-node">
<span> <span>
<span style="margin-left: 6px">{{ data.name }}</span> <span style="margin-left: 6px">{{ node.data.name }}</span>
</span> </span>
<span @click.stop> <span @click.stop>
<div> <div>
<span class="auth-span"> <span class="auth-span">
<el-checkbox v-model="data.checked" /> <el-checkbox v-model="data.checked" @change="nodeStatusChange(data)" />
</span> </span>
</div> </div>
</span> </span>
...@@ -68,7 +68,8 @@ export default { ...@@ -68,7 +68,8 @@ export default {
return !data.hasChildren return !data.hasChildren
} }
}, },
expandNodeIds: [] expandNodeIds: [],
sharesLoad: false
} }
}, },
watch: { watch: {
...@@ -125,33 +126,36 @@ export default { ...@@ -125,33 +126,36 @@ export default {
} else { } else {
param = { conditions: [this.defaultCondition] } param = { conditions: [this.defaultCondition] }
} }
if (!this.sharesLoad) {
this.queryShareNodeIds(() => {
this.sharesLoad = true
this.loadTreeData(param, condition)
})
} else {
this.loadTreeData(param, condition)
}
},
this.queryShareNodeIds(() => { loadTreeData(param, condition) {
loadTable(param).then(res => { loadTable(param).then(res => {
let data = res.data let data = res.data
data = data.map(obj => { data = data.map(obj => {
if (obj.subCount > 0) { if (obj.subCount > 0) {
obj.hasChildren = true obj.hasChildren = true
}
return obj
})
this.setCheckExpandNodes(data)
this.expandNodeIds = []
if (condition && condition.value) {
// data = data.map(node => {
// delete (node.hasChildren)
// return node
// })
this.data = this.buildTree(data)
this.$nextTick(() => {
// this.expandNodeIds.push()
this.expandResult(this.data)
})
} else {
this.data = data
} }
return obj
}) })
this.setCheckExpandNodes(data)
this.expandNodeIds = []
if (condition && condition.value) {
this.data = this.buildTree(data)
this.$nextTick(() => {
this.expandResult(this.data)
})
} else {
this.data = data
}
}) })
}, },
...@@ -185,18 +189,8 @@ export default { ...@@ -185,18 +189,8 @@ export default {
}, },
getSelected() { getSelected() {
// const ids = []
// this.searchChecked(ids)
// return {
// deptIds: ids
// }
// const ids = []
const nodesMap = this.$refs.tree.store.nodesMap
const ids = Object.values(nodesMap).filter(node => node.data.checked).map(item => item.data.deptId)
return { return {
deptIds: ids deptIds: this.shares
} }
}, },
...@@ -221,24 +215,26 @@ export default { ...@@ -221,24 +215,26 @@ export default {
const shares = res.data const shares = res.data
const nodeIds = shares.map(share => share.targetId) const nodeIds = shares.map(share => share.targetId)
this.shares = nodeIds this.shares = nodeIds
// this.$nextTick(() => {
// this.setCheckNodes()
// })
callBack && callBack() callBack && callBack()
}) })
}, },
// setCheckNodes() {
// this.data.forEach(node => {
// const nodeId = node.deptId
// this.shares.includes(nodeId) && (node.checked = true)
// })
// },
setCheckExpandNodes(rows) { setCheckExpandNodes(rows) {
rows.forEach(node => { rows.forEach(node => {
const nodeId = node.deptId const nodeId = node.deptId
this.shares.includes(nodeId) && (node.checked = true) this.shares.includes(nodeId) && (node.checked = true)
}) })
},
nodeStatusChange(val) {
if (val.checked) {
if (!this.shares.includes(val.deptId)) {
this.shares.push(val.deptId)
}
} else {
this.shares = this.shares.filter(deptId => deptId !== val.deptId)
}
} }
} }
......
...@@ -59,8 +59,6 @@ export default { ...@@ -59,8 +59,6 @@ export default {
this.showSearchInput = false this.showSearchInput = false
}, },
save() { save() {
// this.$refs[this.activeName].save(this.$t('commons.share_success'))
// this.$emit('close-grant', 0)
this.fineSave() this.fineSave()
}, },
fineSave() { fineSave() {
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
<div class="my_table"> <div class="my_table">
<el-table <el-table
ref="table" ref="table"
:data="data.filter(node => !keyWord || node[fieldName].toLowerCase().includes(keyWord.toLowerCase()))" :data="tableData"
:show-header="true" :show-header="true"
style="width: 100%" style="width: 100%"
:row-style="{height: '35px'}" :row-style="{height: '35px'}"
@filter-change="filterChange" @select="selectOne"
@select-all="selectAll"
> >
<el-table-column :column-key="fieldName" :label="columnLabel" :prop="fieldName" filter-placement="right-start" :filters="filter_options" :filter-multiple="false" :filter-method="filterHandler" /> <el-table-column :column-key="fieldName" :label="columnLabel" :prop="fieldName" filter-placement="right-start" :filters="filter_options" :filter-multiple="false" :filter-method="filterHandler" />
<el-table-column type="selection" fixd /> <el-table-column type="selection" fixd />
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
import { roleGrid } from '@/api/system/user' import { roleGrid } from '@/api/system/user'
import { formatCondition } from '@/utils/index' import { formatCondition } from '@/utils/index'
import { loadShares } from '@/api/panel/share' import { loadShares } from '@/api/panel/share'
/* import { saveShare, loadShares } from '@/api/panel/share' */
export default { export default {
name: 'GrantRole', name: 'GrantRole',
props: { props: {
...@@ -39,7 +39,15 @@ export default { ...@@ -39,7 +39,15 @@ export default {
filter_options: [{ text: this.$t('panel.no_auth_role'), value: 0 }, { text: this.$t('panel.auth_role'), value: 1 }], filter_options: [{ text: this.$t('panel.no_auth_role'), value: 0 }, { text: this.$t('panel.auth_role'), value: 1 }],
fieldName: 'name', fieldName: 'name',
type: 1, // 类型1代表角色 type: 1, // 类型1代表角色
shares: [] shares: [],
tableData: []
}
},
watch: {
'keyWord': function(val) {
this.tableData = this.data.filter(node => !val || node[this.fieldName].toLowerCase().includes(val.toLowerCase()))
this.setCheckNodes()
} }
}, },
created() { created() {
...@@ -56,48 +64,22 @@ export default { ...@@ -56,48 +64,22 @@ export default {
const param = temp || {} const param = temp || {}
roleGrid(1, 0, param).then(response => { roleGrid(1, 0, param).then(response => {
const data = response.data const data = response.data
// this.total = data.itemCount
this.data = data.listObject this.data = data.listObject
this.tableData = data.listObject
this.queryShareNodeIds() this.queryShareNodeIds()
}) })
}, },
filterHandler(value, row, column) { filterHandler(value, row, column) {
// const property = column['property']
// return row[property] === value
const roleId = row['roleId'] const roleId = row['roleId']
return !(value ^ this.shares.includes(roleId)) return !(value ^ this.shares.includes(roleId))
}, },
filterChange(obj) {
const arr = obj[this.fieldName]
if (arr.length === 0) {
this.initColumnLabel()
} else {
this.columnLabel = this.filter_options[arr[0]].text
}
this.$nextTick(() => {
this.setCheckNodes()
})
},
getSelected() { getSelected() {
return { return {
roleIds: this.$refs.table.store.states.selection.map(item => item.roleId) roleIds: this.shares
} }
}, },
/* save(msg) {
const rows = this.$refs.table.store.states.selection
const request = this.buildRequest(rows)
saveShare(request).then(res => {
this.$success(msg)
return true
}).catch(err => {
this.$error(err.message)
return false
})
}, */
cancel() { cancel() {
}, },
buildRequest(rows) { buildRequest(rows) {
...@@ -126,10 +108,39 @@ export default { ...@@ -126,10 +108,39 @@ export default {
}, },
setCheckNodes() { setCheckNodes() {
this.data.forEach(node => { this.$nextTick(() => {
const nodeId = node.roleId this.$refs.table.store.states.data.forEach(node => {
this.shares.includes(nodeId) && this.$refs.table.toggleRowSelection(node, true) const nodeId = node.roleId
this.shares.includes(nodeId) && this.$refs.table.toggleRowSelection(node, true)
})
}) })
},
selectOne(selection, row) {
if (selection.some(node => node.roleId === row.roleId)) {
// 如果选中了 且 已有分享数据不包含当前节点则添加
if (!this.shares.includes(row.roleId)) {
this.shares.push(row.roleId)
}
} else {
// 如果取消选中 则移除
this.shares = this.shares.filter(nodeId => row.roleId !== nodeId)
// this.shares.splice(this.shares.findIndex(item => item.roleId === row.roleId), 1)
}
},
selectAll(selection) {
// 1.全选
if (selection && selection.length > 0) {
selection.forEach(node => {
if (!this.shares.includes(node.roleId)) {
this.shares.push(node.roleId)
}
})
} else {
// 2.全部取消
const currentNodes = this.$refs.table.store.states.data
const currentNodeIds = currentNodes.map(node => node.roleId)
this.shares = this.shares.filter(nodeId => !currentNodeIds.includes(nodeId))
}
} }
} }
......
...@@ -11,15 +11,7 @@ ...@@ -11,15 +11,7 @@
</span> </span>
<span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ data.name }}</span> <span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ data.name }}</span>
</span> </span>
<!-- <span :class="!!data.msgNode ? 'msg-node-class': ''">
<span v-if="!!data.id">
<el-button
icon="el-icon-picture-outline"
type="text"
/>
</span>
<span style="margin-left: 6px">{{ data.name }}</span>
</span> -->
</span> </span>
</el-tree> </el-tree>
</div> </div>
...@@ -28,9 +20,9 @@ ...@@ -28,9 +20,9 @@
<el-row> <el-row>
<span class="header-title">{{ $t('panel.share_out') }}</span> <span class="header-title">{{ $t('panel.share_out') }}</span>
<div class="block" style="margin-top:8px;"> <div class="block" style="margin-top:8px;">
<el-tree :data="outDatas" :props="defaultProps" :highlight-current="true" node-key="name" :default-expand-all="true" @node-click="viewMyShare"> <el-tree :data="outDatas" :props="defaultProps" :highlight-current="true" node-key="name" :default-expand-all="true">
<span slot-scope="{ data }" class="custom-tree-node father"> <span slot-scope="{ data }" class="custom-tree-node father">
<span style="display: flex; flex: 1 1 0%; width: 0px;"> <span style="display: flex; flex: 1 1 0%; width: 0px;" @click="viewMyShare(data)">
<span v-if="!!data.id"> <span v-if="!!data.id">
<svg-icon icon-class="panel" class="ds-icon-scene" /> <svg-icon icon-class="panel" class="ds-icon-scene" />
</span> </span>
...@@ -79,7 +71,18 @@ export default { ...@@ -79,7 +71,18 @@ export default {
outDatas: [] outDatas: []
} }
}, },
computed: {
panelInfo() {
return this.$store.state.panel.panelInfo
}
},
created() { created() {
bus.$on('refresh-my-share-out', () => {
this.initOutData().then(res => {
this.outDatas = res.data
this.setMainNull()
})
})
this.initData().then(res => { this.initData().then(res => {
this.datas = res.data this.datas = res.data
if (this.msgPanelIds && this.msgPanelIds.length > 0) { if (this.msgPanelIds && this.msgPanelIds.length > 0) {
...@@ -145,7 +148,6 @@ export default { ...@@ -145,7 +148,6 @@ export default {
}) })
}, },
removeCurrent(node) { removeCurrent(node) {
console.log(node)
const param = { const param = {
panelId: node.id panelId: node.id
} }
...@@ -156,6 +158,7 @@ export default { ...@@ -156,6 +158,7 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
removeShares(param).then(res => { removeShares(param).then(res => {
this.panelInfo && this.panelInfo.id && node.id === this.panelInfo.id && this.setMainNull()
this.initOutData().then(res => { this.initOutData().then(res => {
this.outDatas = res.data this.outDatas = res.data
}) })
...@@ -167,6 +170,9 @@ export default { ...@@ -167,6 +170,9 @@ export default {
message: this.$t('commons.delete_cancelled') message: this.$t('commons.delete_cancelled')
}) })
}) })
},
setMainNull() {
this.$store.dispatch('panel/setPanelInfo', { id: null, name: '', preStyle: null })
} }
} }
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
<div class="my_table"> <div class="my_table">
<el-table <el-table
ref="table" ref="table"
:data="data.filter(node => !keyWord || node[fieldName].toLowerCase().includes(keyWord.toLowerCase()))" :data="tableData"
:show-header="true" :show-header="true"
style="width: 100%" style="width: 100%"
:row-style="{height: '35px'}" :row-style="{height: '35px'}"
@filter-change="filterChange" @select="selectOne"
@select-all="selectAll"
> >
<el-table-column <el-table-column
:column-key="fieldName" :column-key="fieldName"
...@@ -47,7 +48,14 @@ export default { ...@@ -47,7 +48,14 @@ export default {
filter_options: [{ text: this.$t('panel.unshared_people'), value: 0 }, { text: this.$t('panel.shared_people'), value: 1 }], filter_options: [{ text: this.$t('panel.unshared_people'), value: 0 }, { text: this.$t('panel.shared_people'), value: 1 }],
fieldName: 'nickName', fieldName: 'nickName',
type: 0, // 类型0代表用户 type: 0, // 类型0代表用户
shares: [] shares: [],
tableData: []
}
},
watch: {
'keyWord': function(val) {
this.tableData = this.data.filter(node => !val || node[this.fieldName].toLowerCase().includes(val.toLowerCase()))
this.setCheckNodes()
} }
}, },
created() { created() {
...@@ -63,48 +71,22 @@ export default { ...@@ -63,48 +71,22 @@ export default {
const param = temp || {} const param = temp || {}
userLists(1, 0, param).then(response => { userLists(1, 0, param).then(response => {
const data = response.data const data = response.data
// this.total = data.itemCount
this.data = data.listObject.filter(ele => ele.id !== this.$store.getters.user.userId) this.data = data.listObject.filter(ele => ele.id !== this.$store.getters.user.userId)
this.tableData = data.listObject.filter(ele => ele.id !== this.$store.getters.user.userId)
this.queryShareNodeIds() this.queryShareNodeIds()
}) })
}, },
filterHandler(value, row, column) { filterHandler(value, row, column) {
// const property = column['property']
// return row[property] === value
const userId = row['userId'] const userId = row['userId']
return !(value ^ this.shares.includes(userId)) return !(value ^ this.shares.includes(userId))
}, },
filterChange(obj) {
const arr = obj[this.fieldName]
if (arr.length === 0) {
this.initColumnLabel()
} else {
this.columnLabel = this.filter_options[arr[0]].text
}
this.$nextTick(() => {
this.setCheckNodes()
})
},
getSelected() { getSelected() {
return { return {
userIds: this.$refs.table.store.states.selection.map(item => item.userId) userIds: this.shares
} }
}, },
/* save(msg) {
const rows = this.$refs.table.store.states.selection
const request = this.buildRequest(rows)
saveShare(request).then(response => {
this.$success(msg)
return true
}).catch(err => {
this.$error(err.message)
return false
})
}, */
cancel() { cancel() {
console.log('user cancel') console.log('user cancel')
}, },
...@@ -134,10 +116,38 @@ export default { ...@@ -134,10 +116,38 @@ export default {
}, },
setCheckNodes() { setCheckNodes() {
this.data.forEach(node => { this.$nextTick(() => {
const nodeId = node.userId this.$refs.table.store.states.data.forEach(node => {
this.shares.includes(nodeId) && this.$refs.table.toggleRowSelection(node, true) const nodeId = node.userId
this.shares.includes(nodeId) && this.$refs.table.toggleRowSelection(node, true)
})
}) })
},
selectOne(selection, row) {
if (selection.some(node => node.userId === row.userId)) {
// 如果选中了 且 已有分享数据不包含当前节点则添加
if (!this.shares.includes(row.userId)) {
this.shares.push(row.userId)
}
} else {
// 如果取消选中 则移除
this.shares = this.shares.filter(nodeId => row.userId !== nodeId)
}
},
selectAll(selection) {
// 1.全选
if (selection && selection.length > 0) {
selection.forEach(node => {
if (!this.shares.includes(node.userId)) {
this.shares.push(node.userId)
}
})
} else {
// 2.全部取消
const currentNodes = this.$refs.table.store.states.data
const currentNodeIds = currentNodes.map(node => node.userId)
this.shares = this.shares.filter(nodeId => !currentNodeIds.includes(nodeId))
}
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<el-tabs v-model="activeName" class="tab-panel" :stretch="true" @tab-click="handleClick"> <el-tabs v-model="activeName" class="tab-panel" :stretch="true" @tab-click="handleClick">
<el-tab-pane name="PanelList"> <el-tab-pane name="PanelList">
<span slot="label"><i class="el-icon-document tablepanel-i" />{{ $t('panel.panel_list') }}</span> <span slot="label"><i class="el-icon-document tablepanel-i" />{{ $t('panel.panel_list') }}</span>
<panel-list ref="panelList" v-if="activeName==='PanelList'" /> <panel-list v-if="activeName==='PanelList'" ref="panelList" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="panels_star" :lazy="true"> <el-tab-pane name="panels_star" :lazy="true">
<span slot="label"><i class="el-icon-star-off tablepanel-i" />{{ $t('panel.store') }}</span> <span slot="label"><i class="el-icon-star-off tablepanel-i" />{{ $t('panel.store') }}</span>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</el-tabs> </el-tabs>
</de-aside-container> </de-aside-container>
<de-main-container> <de-main-container>
<PanelViewShow v-if="mainActiveName==='PanelMain'" :active-tab="activeName" @editPanel="editPanel"/> <PanelViewShow v-if="mainActiveName==='PanelMain'" :active-tab="activeName" @editPanel="editPanel" />
</de-main-container> </de-main-container>
</de-container> </de-container>
</template> </template>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论