8592fee7
wuxw
开发排版功能
|
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
<div>
<el-card class="box-card">
<div class="button-group">
<el-button type="primary" size="small" @click="handleAdd">
<i class="el-icon-plus"></i>{{ $t('dataPrivilege.add') }}
</el-button>
<el-button type="primary" size="small" @click="handleEdit" :disabled="!currentDataPrivilege.dpId">
<i class="el-icon-edit"></i>{{ $t('dataPrivilege.edit') }}
</el-button>
<el-button type="primary" size="small" @click="handleDelete" :disabled="!currentDataPrivilege.dpId">
<i class="el-icon-delete"></i>{{ $t('dataPrivilege.delete') }}
</el-button>
</div>
<div class="data-privilege-list">
<ul>
<li v-for="(item, index) in dataPrivileges" :key="index"
:class="{ active: item.dpId === currentDataPrivilege.dpId }" @click="handleSelect(item)">
{{ item.name }}
</li>
</ul>
</div>
</el-card>
<!-- 添加数据权限对话框 -->
<add-data-privilege ref="addDataPrivilege" @success="handleRefresh" />
<!-- 编辑数据权限对话框 -->
<edit-data-privilege ref="editDataPrivilege" @success="handleRefresh" />
<!-- 删除数据权限对话框 -->
<delete-data-privilege ref="deleteDataPrivilege" @success="handleRefresh" />
</div>
</template>
<script>
import { listDataPrivilege } from '@/api/org/dataPrivilegeManageApi'
import { getCommunityId } from '@/api/community/communityApi'
import AddDataPrivilege from '@/components/org/addDataPrivilege'
import EditDataPrivilege from '@/components/org/editDataPrivilege'
import DeleteDataPrivilege from '@/components/org/deleteDataPrivilege'
export default {
name: 'DataPrivilegeDiv',
components: {
AddDataPrivilege,
EditDataPrivilege,
DeleteDataPrivilege
},
data() {
return {
dataPrivileges: [],
currentDataPrivilege: {},
communityId: ''
}
},
created() {
this.communityId = getCommunityId()
this.loadData()
},
methods: {
handleRefresh() {
this.loadData()
},
async loadData() {
try {
const params = {
page: 1,
row: 100,
communityId: this.communityId
}
const { data } = await listDataPrivilege(params)
this.dataPrivileges = data
if (data.length > 0) {
this.currentDataPrivilege = data[0]
this.$emit('switch-data-privilege', data[0])
}
} catch (error) {
console.error('Failed to load data privileges:', error)
}
},
handleSelect(item) {
this.currentDataPrivilege = item
this.$emit('switch-data-privilege', item)
},
handleAdd() {
this.$refs.addDataPrivilege.open()
},
handleEdit() {
this.$refs.editDataPrivilege.open(this.currentDataPrivilege)
},
handleDelete() {
this.$refs.deleteDataPrivilege.open(this.currentDataPrivilege)
}
}
}
</script>
<style lang="scss" scoped>
.box-card {
height: 100%;
.button-group {
margin-bottom: 15px;
}
.data-privilege-list {
ul {
list-style: none;
padding: 0;
margin: 0;
li {
padding: 10px;
cursor: pointer;
|