1+ <template >
2+ <a-card :bordered =" false" >
3+ <div class =" table-page-search-wrapper" >
4+ <a-form layout =" inline" >
5+ <a-row :gutter =" 48" >
6+ <a-col :md =" 8" :sm =" 24" >
7+ <a-form-item label =" 角色ID" >
8+ <a-input placeholder =" 请输入" />
9+ </a-form-item >
10+ </a-col >
11+ <a-col :md =" 8" :sm =" 24" >
12+ <a-form-item label =" 状态" >
13+ <a-select placeholder =" 请选择" default-value =" 0" >
14+ <a-select-option value =" 0" >全部</a-select-option >
15+ <a-select-option value =" 1" >关闭</a-select-option >
16+ <a-select-option value =" 2" >运行中</a-select-option >
17+ </a-select >
18+ </a-form-item >
19+ </a-col >
20+ <a-col :md =" 8" :sm =" 24" >
21+ <span class =" table-page-search-submitButtons" >
22+ <a-button type =" primary" >查询</a-button >
23+ <a-button style =" margin-left : 8px " >重置</a-button >
24+ </span >
25+ </a-col >
26+ </a-row >
27+ </a-form >
28+ </div >
29+
30+ <s-table
31+ size =" default"
32+ :columns =" columns"
33+ :data =" loadData"
34+ >
35+ <div
36+ slot =" expandedRowRender"
37+ slot-scope =" record"
38+ style =" margin : 0 " >
39+ <a-row
40+ :gutter =" 24"
41+ :style =" { marginBottom: '12px' }" >
42+ <a-col :span =" 12" v-for =" (role, index) in record.permissions" :key =" index" :style =" { marginBottom: '12px' }" >
43+ <a-col :span =" 4" >
44+ <span >{{ role.permissionName }}:</span >
45+ </a-col >
46+ <a-col :span =" 20" v-if =" role.actionEntitySet.length > 0" >
47+ <a-tag color =" cyan" v-for =" (action, k) in role.actionEntitySet" :key =" k" >{{ action.describe }}</a-tag >
48+ </a-col >
49+ <a-col :span =" 20" v-else >-</a-col >
50+ </a-col >
51+ </a-row >
52+ </div >
53+ <span slot =" action" slot-scope =" text, record" >
54+ <a @click =" handleEdit(record)" >编辑</a >
55+ <a-divider type =" vertical" />
56+ <a-dropdown >
57+ <a class =" ant-dropdown-link" >
58+ 更多 <a-icon type =" down" />
59+ </a >
60+ <a-menu slot =" overlay" >
61+ <a-menu-item >
62+ <a href =" javascript:;" >详情</a >
63+ </a-menu-item >
64+ <a-menu-item >
65+ <a href =" javascript:;" >禁用</a >
66+ </a-menu-item >
67+ <a-menu-item >
68+ <a href =" javascript:;" >删除</a >
69+ </a-menu-item >
70+ </a-menu >
71+ </a-dropdown >
72+ </span >
73+ </s-table >
74+
75+ <a-modal
76+ title =" 操作"
77+ style =" top : 20px ;"
78+ :width =" 800"
79+ v-model =" visible"
80+ @ok =" handleOk"
81+ >
82+ <a-form :autoFormCreate =" (form)=>{this.form = form}" >
83+
84+ <a-form-item
85+ :labelCol =" labelCol"
86+ :wrapperCol =" wrapperCol"
87+ label =' 唯一识别码'
88+ hasFeedback
89+ validateStatus =' success'
90+ >
91+ <a-input placeholder =' 唯一识别码' v-model =" mdl.id" id =' no' disabled =" disabled" />
92+ </a-form-item >
93+
94+ <a-form-item
95+ :labelCol =" labelCol"
96+ :wrapperCol =" wrapperCol"
97+ label =' 角色名称'
98+ hasFeedback
99+ validateStatus =' success'
100+ >
101+ <a-input placeholder =' 起一个名字' v-model =" mdl.name" id =' role_name' />
102+ </a-form-item >
103+
104+ <a-form-item
105+ :labelCol =" labelCol"
106+ :wrapperCol =" wrapperCol"
107+ label =' 状态'
108+ hasFeedback
109+ validateStatus =' warning'
110+ >
111+ <a-select v-model =" mdl.status" >
112+ <a-select-option value =' 1' >正常</a-select-option >
113+ <a-select-option value =' 2' >禁用</a-select-option >
114+ </a-select >
115+ </a-form-item >
116+
117+ <a-form-item
118+ :labelCol =" labelCol"
119+ :wrapperCol =" wrapperCol"
120+ label =' 描述'
121+ hasFeedback
122+ >
123+ <a-textarea :rows =" 5" v-model =" mdl.describe" placeholder =" ..." id =' describe' />
124+ </a-form-item >
125+
126+ <a-divider />
127+
128+ <a-form-item
129+ :labelCol =" labelCol"
130+ :wrapperCol =" wrapperCol"
131+ label =' 拥有权限'
132+ hasFeedback
133+ >
134+ <a-row :gutter =" 16" v-for =" (permission, index) in mdl.permissions" :key =" index" >
135+ <a-col :span =" 4" >
136+ {{ permission.permissionName }}:
137+ </a-col >
138+ <a-col :span =" 20" >
139+ <a-checkbox-group :options =" permission.actionsOptions" />
140+ </a-col >
141+ </a-row >
142+
143+ </a-form-item >
144+
145+ </a-form >
146+ </a-modal >
147+
148+ </a-card >
149+ </template >
150+
151+ <script >
152+ import STable from ' @/components/table/'
153+ import { getRoleList , getServiceList } from ' @/api/manage'
154+
155+ export default {
156+ name: " TableList" ,
157+ components: {
158+ STable
159+ },
160+ data () {
161+ return {
162+ description: ' 列表使用场景:后台管理中的权限管理以及角色管理,可用于基于 RBAC 设计的角色权限控制,颗粒度细到每一个操作类型。' ,
163+
164+ visible: false ,
165+ labelCol: {
166+ xs: { span: 24 },
167+ sm: { span: 5 },
168+ },
169+ wrapperCol: {
170+ xs: { span: 24 },
171+ sm: { span: 16 },
172+ },
173+ form: null ,
174+ mdl: {},
175+
176+ // 高级搜索 展开/关闭
177+ advanced: false ,
178+ // 查询参数
179+ queryParam: {},
180+ // 表头
181+ columns: [
182+ {
183+ title: ' 唯一识别码' ,
184+ dataIndex: ' id'
185+ },
186+ {
187+ title: ' 角色名称' ,
188+ dataIndex: ' name' ,
189+ },
190+ {
191+ title: ' 状态' ,
192+ dataIndex: ' status'
193+ },
194+ {
195+ title: ' 创建时间' ,
196+ dataIndex: ' createTime' ,
197+ sorter: true
198+ }, {
199+ title: ' 操作' ,
200+ width: ' 150px' ,
201+ dataIndex: ' action' ,
202+ scopedSlots: { customRender: ' action' },
203+ }
204+ ],
205+ // 加载数据方法 必须为 Promise 对象
206+ loadData : parameter => {
207+ return getRoleList (parameter)
208+ .then (res => {
209+ return res .result
210+ })
211+ },
212+
213+ selectedRowKeys: [],
214+ selectedRows: []
215+ }
216+ },
217+ created () {
218+ getServiceList ().then (res => {
219+ console .log (' getServiceList.call()' , res)
220+ })
221+
222+ getRoleList ().then (res => {
223+ console .log (' getRoleList.call()' , res)
224+ })
225+ },
226+ methods: {
227+ handleEdit (record ) {
228+ this .mdl = Object .assign ({}, record)
229+
230+ this .mdl .permissions .forEach (permission => {
231+ permission .actionsOptions = permission .actionEntitySet .map (action => {
232+ return { label: action .describe , value: action .action , defaultCheck: action .defaultCheck }
233+ })
234+ })
235+
236+ this .visible = true
237+ },
238+ handleOk () {
239+
240+ },
241+ onChange (selectedRowKeys , selectedRows ) {
242+ this .selectedRowKeys = selectedRowKeys
243+ this .selectedRows = selectedRows
244+ },
245+ toggleAdvanced () {
246+ this .advanced = ! this .advanced
247+ },
248+ },
249+ watch: {
250+ /*
251+ 'selectedRows': function (selectedRows) {
252+ this.needTotalList = this.needTotalList.map(item => {
253+ return {
254+ ...item,
255+ total: selectedRows.reduce( (sum, val) => {
256+ return sum + val[item.dataIndex]
257+ }, 0)
258+ }
259+ })
260+ }
261+ */
262+ }
263+ }
264+ </script >
0 commit comments