Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cf959599
authored
Mar 19, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vue3 重构:Review 敏感词管理
parent
45058a9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
src/views/system/sensitiveWord/form.vue
+6
-5
src/views/system/sensitiveWord/index.vue
+13
-11
No files found.
src/views/system/sensitiveWord/form.vue
View file @
cf959599
...
...
@@ -48,6 +48,7 @@
<
script
setup
lang=
"ts"
>
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
*
as
SensitiveWordApi
from
'@/api/system/sensitiveWord'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
...
...
@@ -56,11 +57,10 @@ const modelVisible = ref(false) // 弹窗的是否展示
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
tags
=
ref
([])
const
formData
=
ref
({
id
:
undefined
,
name
:
''
,
status
:
true
,
status
:
CommonStatusEnum
.
ENABLE
,
description
:
''
,
tags
:
[]
})
...
...
@@ -69,6 +69,7 @@ const formRules = reactive({
tags
:
[{
required
:
true
,
message
:
'标签不能为空'
,
trigger
:
'blur'
}]
})
const
formRef
=
ref
()
// 表单 Ref
const
tags
=
ref
([])
// todo @blue-syd:在 openModal 里加载下
/** 打开弹窗 */
const
openModal
=
async
(
type
:
string
,
id
?:
number
)
=>
{
...
...
@@ -101,10 +102,10 @@ const submitForm = async () => {
try
{
const
data
=
formData
.
value
as
unknown
as
SensitiveWordApi
.
SensitiveWordVO
if
(
formType
.
value
===
'create'
)
{
await
SensitiveWordApi
.
createSensitiveWordApi
(
data
)
await
SensitiveWordApi
.
createSensitiveWordApi
(
data
)
// TODO @blue-syd:去掉 API 后缀
message
.
success
(
t
(
'common.createSuccess'
))
}
else
{
await
SensitiveWordApi
.
updateSensitiveWordApi
(
data
)
await
SensitiveWordApi
.
updateSensitiveWordApi
(
data
)
// TODO @blue-syd:去掉 API 后缀
message
.
success
(
t
(
'common.updateSuccess'
))
}
modelVisible
.
value
=
false
...
...
@@ -120,7 +121,7 @@ const resetForm = () => {
formData
.
value
=
{
id
:
undefined
,
name
:
''
,
status
:
true
,
status
:
CommonStatusEnum
.
ENABLE
,
description
:
''
,
tags
:
[]
}
...
...
src/views/system/sensitiveWord/index.vue
View file @
cf959599
...
...
@@ -40,7 +40,6 @@
:default-time=
"[new Date('1 00:00:00'), new Date('1 23:59:59')]"
/>
</el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
...
...
@@ -82,9 +81,11 @@
:key=
"index"
v-for=
"(tag, index) in scope.row.tags"
:index=
"index"
class=
"mr-5px"
>
{{
tag
}}
</el-tag>
</
template
>
</el-table-column>
<el-table-column
...
...
@@ -132,14 +133,13 @@ import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
download
from
'@/utils/download'
import
*
as
SensitiveWordApi
from
'@/api/system/sensitiveWord'
import
ConfigForm
from
'./form.vue'
import
ConfigForm
from
'./form.vue'
// TODO @blue-syd:组件名不对
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
loading
=
ref
(
true
)
// 列表的加载中
const
total
=
ref
(
0
)
// 列表的总页数
const
list
=
ref
([])
// 列表的数据
const
tags
=
ref
([])
const
queryParams
=
reactive
({
pageNo
:
1
,
pageSize
:
10
,
...
...
@@ -150,12 +150,13 @@ const queryParams = reactive({
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
exportLoading
=
ref
(
false
)
// 导出的加载中
const
tags
=
ref
([])
/** 查询参数列表 */
const
getList
=
async
()
=>
{
loading
.
value
=
true
try
{
const
data
=
await
SensitiveWordApi
.
getSensitiveWordPageApi
(
queryParams
)
const
data
=
await
SensitiveWordApi
.
getSensitiveWordPageApi
(
queryParams
)
// TODO @blue-syd:去掉 API 后缀哈
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
finally
{
...
...
@@ -163,12 +164,6 @@ const getList = async () => {
}
}
/** 初始化标签select*/
const
getTags
=
async
()
=>
{
const
data
=
await
SensitiveWordApi
.
getSensitiveWordTagsApi
()
tags
.
value
=
data
}
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
...
...
@@ -187,6 +182,8 @@ const openModal = (type: string, id?: number) => {
modalRef
.
value
.
openModal
(
type
,
id
)
}
// TODO @blue-syd:还少一个【测试】按钮的功能,参见 http://dashboard.yudao.iocoder.cn/system/sensitive-word
/** 删除按钮操作 */
const
handleDelete
=
async
(
id
:
number
)
=>
{
try
{
...
...
@@ -207,7 +204,7 @@ const handleExport = async () => {
await
message
.
exportConfirm
()
// 发起导出
exportLoading
.
value
=
true
const
data
=
await
SensitiveWordApi
.
exportSensitiveWordApi
(
queryParams
)
const
data
=
await
SensitiveWordApi
.
exportSensitiveWordApi
(
queryParams
)
// TODO @blue-syd:去掉 API 后缀哈
download
.
excel
(
data
,
'敏感词.xls'
)
}
catch
{
}
finally
{
...
...
@@ -215,6 +212,11 @@ const handleExport = async () => {
}
}
/** 获得 Tag 标签列表 */
const
getTags
=
async
()
=>
{
tags
.
value
=
await
SensitiveWordApi
.
getSensitiveWordTagsApi
()
// TODO @blue-syd:去掉 API 后缀哈
}
/** 初始化 **/
onMounted
(()
=>
{
getTags
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment