Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
46899aa3
提交
46899aa3
authored
6月 04, 2021
作者:
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(demo): `switch` use in table
演示在table中渲染switch列并响应修改switch的动作
上级
41854121
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
7 行删除
+43
-7
system.ts
mock/demo/system.ts
+9
-0
system.ts
src/api/demo/system.ts
+4
-0
role.data.ts
src/views/demo/system/role/role.data.ts
+30
-7
没有找到文件。
mock/demo/system.ts
浏览文件 @
46899aa3
...
@@ -153,6 +153,15 @@ export default [
...
@@ -153,6 +153,15 @@ export default [
},
},
},
},
{
{
url
:
'/basic-api/system/setRoleStatus'
,
timeout
:
500
,
method
:
'post'
,
response
:
({
query
})
=>
{
const
{
id
,
status
}
=
query
;
return
resultSuccess
({
id
,
status
});
},
},
{
url
:
'/basic-api/system/getAllRoleList'
,
url
:
'/basic-api/system/getAllRoleList'
,
timeout
:
100
,
timeout
:
100
,
method
:
'get'
,
method
:
'get'
,
...
...
src/api/demo/system.ts
浏览文件 @
46899aa3
...
@@ -15,6 +15,7 @@ import { defHttp } from '/@/utils/http/axios';
...
@@ -15,6 +15,7 @@ import { defHttp } from '/@/utils/http/axios';
enum
Api
{
enum
Api
{
AccountList
=
'/system/getAccountList'
,
AccountList
=
'/system/getAccountList'
,
DeptList
=
'/system/getDeptList'
,
DeptList
=
'/system/getDeptList'
,
setRoleStatus
=
'/system/setRoleStatus'
,
MenuList
=
'/system/getMenuList'
,
MenuList
=
'/system/getMenuList'
,
RolePageList
=
'/system/getRoleListByPage'
,
RolePageList
=
'/system/getRoleListByPage'
,
GetAllRoleList
=
'/system/getAllRoleList'
,
GetAllRoleList
=
'/system/getAllRoleList'
,
...
@@ -34,3 +35,6 @@ export const getRoleListByPage = (params?: RolePageParams) =>
...
@@ -34,3 +35,6 @@ export const getRoleListByPage = (params?: RolePageParams) =>
export
const
getAllRoleList
=
(
params
?:
RoleParams
)
=>
export
const
getAllRoleList
=
(
params
?:
RoleParams
)
=>
defHttp
.
get
<
RoleListGetResultModel
>
({
url
:
Api
.
GetAllRoleList
,
params
});
defHttp
.
get
<
RoleListGetResultModel
>
({
url
:
Api
.
GetAllRoleList
,
params
});
export
const
setRoleStatus
=
(
id
:
number
,
status
:
string
)
=>
defHttp
.
post
({
url
:
Api
.
setRoleStatus
,
params
:
{
id
,
status
}
});
src/views/demo/system/role/role.data.ts
浏览文件 @
46899aa3
import
{
BasicColumn
}
from
'/@/components/Table'
;
import
{
BasicColumn
}
from
'/@/components/Table'
;
import
{
FormSchema
}
from
'/@/components/Table'
;
import
{
FormSchema
}
from
'/@/components/Table'
;
import
{
h
}
from
'vue'
;
import
{
h
}
from
'vue'
;
import
{
Tag
}
from
'ant-design-vue'
;
import
{
Switch
}
from
'ant-design-vue'
;
import
{
setRoleStatus
}
from
'/@/api/demo/system'
;
import
{
useMessage
}
from
'/@/hooks/web/useMessage'
;
export
const
columns
:
BasicColumn
[]
=
[
export
const
columns
:
BasicColumn
[]
=
[
{
{
title
:
'角色名称'
,
title
:
'角色名称'
,
...
@@ -21,13 +24,33 @@ export const columns: BasicColumn[] = [
...
@@ -21,13 +24,33 @@ export const columns: BasicColumn[] = [
{
{
title
:
'状态'
,
title
:
'状态'
,
dataIndex
:
'status'
,
dataIndex
:
'status'
,
width
:
8
0
,
width
:
12
0
,
customRender
:
({
record
})
=>
{
customRender
:
({
record
})
=>
{
const
status
=
record
.
status
;
if
(
!
Reflect
.
has
(
record
,
'pendingStatus'
))
{
const
enable
=
~~
status
===
0
;
record
.
pendingStatus
=
false
;
const
color
=
enable
?
'green'
:
'red'
;
}
const
text
=
enable
?
'启用'
:
'停用'
;
return
h
(
Switch
,
{
return
h
(
Tag
,
{
color
:
color
},
()
=>
text
);
checked
:
record
.
status
===
'1'
,
checkedChildren
:
'已启用'
,
unCheckedChildren
:
'已禁用'
,
loading
:
record
.
pendingStatus
,
onChange
(
checked
:
boolean
)
{
record
.
pendingStatus
=
true
;
const
newStatus
=
checked
?
'1'
:
'0'
;
const
{
createMessage
}
=
useMessage
();
setRoleStatus
(
record
.
id
,
newStatus
)
.
then
(()
=>
{
record
.
status
=
newStatus
;
createMessage
.
success
(
`已成功修改角色状态`
);
})
.
catch
(()
=>
{
createMessage
.
error
(
'修改角色状态失败'
);
})
.
finally
(()
=>
{
record
.
pendingStatus
=
false
;
});
},
});
},
},
},
},
{
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论