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
8a8154e1
authored
Mar 23, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vue3 重构:REVIEW 公众号账号
parent
202031d4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
41 deletions
+52
-41
src/views/mp/account/AccountForm.vue
+10
-11
src/views/mp/account/index.vue
+32
-27
src/views/system/dept/index.vue
+10
-3
No files found.
src/views/mp/account/
f
orm.vue
→
src/views/mp/account/
AccountF
orm.vue
View file @
8a8154e1
<
template
>
<
template
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
>
<el-form
ref=
"formRef"
:model=
"formData"
:rules=
"rules"
label-width=
"120px"
>
<el-form
ref=
"formRef"
:model=
"formData"
:rules=
"rules"
label-width=
"120px"
v-loading=
"formLoading"
>
<el-form-item
label=
"名称"
prop=
"name"
>
<el-form-item
label=
"名称"
prop=
"name"
>
<el-input
v-model=
"formData.name"
placeholder=
"请输入名称"
/>
<el-input
v-model=
"formData.name"
placeholder=
"请输入名称"
/>
</el-form-item>
</el-form-item>
...
@@ -57,16 +63,13 @@
...
@@ -57,16 +63,13 @@
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<
template
#
footer
>
<
template
#
footer
>
<div
class=
"dialog-footer"
>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
@
click=
"modelVisible = false"
>
取 消
</el-button>
<el-button
@
click=
"modelVisible = false"
>
取 消
</el-button>
</div>
</
template
>
</
template
>
</Dialog>
</Dialog>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
*
as
AccountApi
from
'@/api/mp/account'
import
*
as
AccountApi
from
'@/api/mp/account'
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
...
@@ -74,7 +77,6 @@ const modelVisible = ref(false) // 弹窗的是否展示
...
@@ -74,7 +77,6 @@ const modelVisible = ref(false) // 弹窗的是否展示
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
// 表单参数
const
formData
=
ref
({
const
formData
=
ref
({
id
:
undefined
,
id
:
undefined
,
name
:
''
,
name
:
''
,
...
@@ -85,7 +87,6 @@ const formData = ref({
...
@@ -85,7 +87,6 @@ const formData = ref({
aesKey
:
''
,
aesKey
:
''
,
remark
:
''
remark
:
''
})
})
// 表单校验
const
rules
=
reactive
({
const
rules
=
reactive
({
name
:
[{
required
:
true
,
message
:
'名称不能为空'
,
trigger
:
'blur'
}],
name
:
[{
required
:
true
,
message
:
'名称不能为空'
,
trigger
:
'blur'
}],
account
:
[{
required
:
true
,
message
:
'公众号账号不能为空'
,
trigger
:
'blur'
}],
account
:
[{
required
:
true
,
message
:
'公众号账号不能为空'
,
trigger
:
'blur'
}],
...
@@ -96,7 +97,7 @@ const rules = reactive({
...
@@ -96,7 +97,7 @@ const rules = reactive({
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
/** 打开弹窗 */
/** 打开弹窗 */
const
open
Modal
=
async
(
type
:
string
,
id
?:
number
)
=>
{
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
modelVisible
.
value
=
true
modelVisible
.
value
=
true
modelTitle
.
value
=
t
(
'action.'
+
type
)
modelTitle
.
value
=
t
(
'action.'
+
type
)
formType
.
value
=
type
formType
.
value
=
type
...
@@ -111,12 +112,10 @@ const openModal = async (type: string, id?: number) => {
...
@@ -111,12 +112,10 @@ const openModal = async (type: string, id?: number) => {
}
}
}
}
}
}
defineExpose
({
open
Modal
})
// 提供 openModal
方法,用于打开弹窗
defineExpose
({
open
})
// 提供 open
方法,用于打开弹窗
/** 提交表单 */
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
/** 提交按钮 */
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
// 校验表单
// 校验表单
if
(
!
formRef
)
return
if
(
!
formRef
)
return
...
...
src/views/mp/account/index.vue
View file @
8a8154e1
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
:model=
"queryParams"
:model=
"queryParams"
ref=
"queryFormRef"
ref=
"queryFormRef"
:inline=
"true"
:inline=
"true"
label-width=
"
90
px"
label-width=
"
68
px"
>
>
<el-form-item
label=
"名称"
prop=
"name"
>
<el-form-item
label=
"名称"
prop=
"name"
>
<el-input
<el-input
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
<el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<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>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
type=
"primary"
@
click=
"open
Modal('create')"
v-hasPermi=
"['mp:account:create']"
<el-button
type=
"primary"
@
click=
"open
Form('create')"
v-hasPermi=
"['mp:account:create']"
>
><Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
</el-button>
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
...
@@ -46,6 +46,14 @@
...
@@ -46,6 +46,14 @@
alt=
"二维码"
alt=
"二维码"
style=
"height: 100px; display: inline-block"
style=
"height: 100px; display: inline-block"
/>
/>
<el-button
link
type=
"primary"
@
click=
"handleGenerateQrCode(scope.row)"
v-hasPermi=
"['mp:account:qr-code']"
>
生成二维码
</el-button>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"备注"
align=
"center"
prop=
"remark"
/>
<el-table-column
label=
"备注"
align=
"center"
prop=
"remark"
/>
...
@@ -54,30 +62,26 @@
...
@@ -54,30 +62,26 @@
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"open
Modal
('update', scope.row.id)"
@
click=
"open
Form
('update', scope.row.id)"
v-hasPermi=
"['mp:account:update']"
v-hasPermi=
"['mp:account:update']"
>
编辑
>
编辑
</el-button>
</el-button>
<el-button
<el-button
link
link
type=
"danger"
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['mp:account:delete']"
v-hasPermi=
"['mp:account:delete']"
>
删除
>
</el-button>
删除
<el-button
link
type=
"primary"
@
click=
"handleGenerateQrCode(scope.row)"
v-hasPermi=
"['mp:account:qr-code']"
>
生成二维码
</el-button>
</el-button>
<el-button
<el-button
link
link
type=
"danger"
type=
"danger"
@
click=
"handleCleanQuota(scope.row)"
@
click=
"handleCleanQuota(scope.row)"
v-hasPermi=
"['mp:account:clear-quota']"
v-hasPermi=
"['mp:account:clear-quota']"
>
清空 API 配额
>
清空 API 配额
</el-button>
</el-button>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -91,23 +95,20 @@
...
@@ -91,23 +95,20 @@
@
pagination=
"getList"
@
pagination=
"getList"
/>
/>
</content-wrap>
</content-wrap>
<!-- 对话框(添加 / 修改) -->
<!-- 对话框(添加 / 修改) -->
<
account-form
ref=
"modal
Ref"
@
success=
"getList"
/>
<
AccountForm
ref=
"form
Ref"
@
success=
"getList"
/>
</template>
</template>
<
script
setup
lang=
"ts"
name=
"MpAccount"
>
<
script
setup
lang=
"ts"
name=
"MpAccount"
>
import
*
as
AccountApi
from
'@/api/mp/account'
import
*
as
AccountApi
from
'@/api/mp/account'
import
AccountForm
from
'./
f
orm.vue'
import
AccountForm
from
'./
AccountF
orm.vue'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
// 遮罩层
const
loading
=
ref
(
true
)
const
loading
=
ref
(
true
)
// 列表的加载中
// 总条数
const
total
=
ref
(
0
)
// 列表的总页数
const
total
=
ref
(
0
)
const
list
=
ref
([])
// 列表的数据
// 公众号账号列表
const
list
=
ref
([])
// 查询参数
const
queryParams
=
reactive
({
const
queryParams
=
reactive
({
pageNo
:
1
,
pageNo
:
1
,
pageSize
:
10
,
pageSize
:
10
,
...
@@ -134,6 +135,7 @@ const handleQuery = () => {
...
@@ -134,6 +135,7 @@ const handleQuery = () => {
queryParams
.
pageNo
=
1
queryParams
.
pageNo
=
1
getList
()
getList
()
}
}
/** 重置按钮操作 */
/** 重置按钮操作 */
const
resetQuery
=
()
=>
{
const
resetQuery
=
()
=>
{
queryFormRef
.
value
.
resetFields
()
queryFormRef
.
value
.
resetFields
()
...
@@ -141,9 +143,9 @@ const resetQuery = () => {
...
@@ -141,9 +143,9 @@ const resetQuery = () => {
}
}
/** 添加/修改操作 */
/** 添加/修改操作 */
const
modal
Ref
=
ref
()
const
form
Ref
=
ref
()
const
open
Modal
=
(
type
:
string
,
id
?:
number
)
=>
{
const
open
Form
=
(
type
:
string
,
id
?:
number
)
=>
{
modalRef
.
value
.
openModal
(
type
,
id
)
formRef
.
value
.
open
(
type
,
id
)
}
}
/** 删除按钮操作 */
/** 删除按钮操作 */
...
@@ -158,6 +160,7 @@ const handleDelete = async (id) => {
...
@@ -158,6 +160,7 @@ const handleDelete = async (id) => {
await
getList
()
await
getList
()
}
catch
{}
}
catch
{}
}
}
/** 生成二维码的按钮操作 */
/** 生成二维码的按钮操作 */
const
handleGenerateQrCode
=
async
(
row
)
=>
{
const
handleGenerateQrCode
=
async
(
row
)
=>
{
try
{
try
{
...
@@ -170,6 +173,7 @@ const handleGenerateQrCode = async (row) => {
...
@@ -170,6 +173,7 @@ const handleGenerateQrCode = async (row) => {
await
getList
()
await
getList
()
}
catch
{}
}
catch
{}
}
}
/** 清空二维码 API 配额的按钮操作 */
/** 清空二维码 API 配额的按钮操作 */
const
handleCleanQuota
=
async
(
row
)
=>
{
const
handleCleanQuota
=
async
(
row
)
=>
{
try
{
try
{
...
@@ -181,6 +185,7 @@ const handleCleanQuota = async (row) => {
...
@@ -181,6 +185,7 @@ const handleCleanQuota = async (row) => {
}
catch
{}
}
catch
{}
}
}
/** 初始化 **/
onMounted
(()
=>
{
onMounted
(()
=>
{
getList
()
getList
()
})
})
...
...
src/views/system/dept/index.vue
View file @
8a8154e1
<
template
>
<
template
>
<ContentWrap>
<!-- 搜索工作栏 -->
<!-- 搜索工作栏 -->
<el-form
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<ContentWrap>
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"部门名称"
prop=
"title"
>
<el-form-item
label=
"部门名称"
prop=
"title"
>
<el-input
v-model=
"queryParams.name"
placeholder=
"请输入部门名称"
clearable
/>
<el-input
v-model=
"queryParams.name"
placeholder=
"请输入部门名称"
clearable
/>
</el-form-item>
</el-form-item>
...
@@ -113,7 +119,7 @@ const isExpandAll = ref(true) // 是否展开,默认全部展开
...
@@ -113,7 +119,7 @@ const isExpandAll = ref(true) // 是否展开,默认全部展开
const
refreshTable
=
ref
(
true
)
// 重新渲染表格状态
const
refreshTable
=
ref
(
true
)
// 重新渲染表格状态
const
loading
=
ref
(
true
)
// 列表的加载中
const
loading
=
ref
(
true
)
// 列表的加载中
//获取用户列表
//
获取用户列表
const
getUserList
=
async
()
=>
{
const
getUserList
=
async
()
=>
{
const
res
=
await
getSimpleUserList
()
const
res
=
await
getSimpleUserList
()
userOption
.
value
=
res
userOption
.
value
=
res
...
@@ -157,6 +163,7 @@ const getList = async () => {
...
@@ -157,6 +163,7 @@ const getList = async () => {
loading
.
value
=
false
loading
.
value
=
false
}
}
}
}
/** 重置按钮操作 */
/** 重置按钮操作 */
const
resetQuery
=
()
=>
{
const
resetQuery
=
()
=>
{
queryParams
.
pageNo
=
1
queryParams
.
pageNo
=
1
...
...
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