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
776eb3a7
authored
Apr 15, 2023
by
咱哥丶
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构VUE3【站内信-模板管理】
parent
c461800e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
89 deletions
+145
-89
src/api/system/notify/template/index.ts
+5
-4
src/views/system/notify/template/NotifyTemplateForm.vue
+140
-0
src/views/system/notify/template/index.vue
+0
-0
src/views/system/notify/template/template.data.ts
+0
-85
No files found.
src/api/system/notify/template/index.ts
View file @
776eb3a7
import
request
from
'@/config/axios'
export
interface
NotifyTemplateVO
{
id
:
number
id
:
number
|
null
name
:
string
nickname
:
string
code
:
string
content
:
string
type
:
number
type
:
number
|
null
params
:
string
status
:
number
status
:
number
|
null
remark
:
string
}
...
...
@@ -19,7 +20,7 @@ export interface NotifyTemplatePageReqVO extends PageParam {
}
export
interface
NotifySendReqVO
{
userId
:
number
userId
:
number
|
null
templateCode
:
string
templateParams
:
Map
<
String
,
Object
>
}
...
...
src/views/system/notify/template/NotifyTemplateForm.vue
0 → 100644
View file @
776eb3a7
<
template
>
<Dialog
:title=
"dialogTitle"
v-model=
"dialogVisible"
>
<el-form
ref=
"formRef"
:model=
"formData"
:rules=
"formRules"
label-width=
"140px"
v-loading=
"formLoading"
>
<el-form-item
label=
"模版编码"
prop=
"code"
>
<el-input
v-model=
"formData.code"
placeholder=
"请输入模版编码"
/>
</el-form-item>
<el-form-item
label=
"模板名称"
prop=
"name"
>
<el-input
v-model=
"formData.name"
placeholder=
"请输入模版名称"
/>
</el-form-item>
<el-form-item
label=
"发件人名称"
prop=
"nickname"
>
<el-input
v-model=
"formData.nickname"
placeholder=
"请输入发件人名称"
/>
</el-form-item>
<el-form-item
label=
"模板内容"
prop=
"content"
>
<el-input
type=
"textarea"
v-model=
"formData.content"
placeholder=
"请输入模板内容"
/>
</el-form-item>
<el-form-item
label=
"类型"
prop=
"type"
>
<el-select
v-model=
"formData.type"
placeholder=
"请选择类型"
>
<el-option
v-for=
"dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
:key=
"dict.value"
:label=
"dict.label"
:value=
"parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"开启状态"
prop=
"status"
>
<el-radio-group
v-model=
"formData.status"
>
<el-radio
v-for=
"dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key=
"dict.value"
:label=
"parseInt(dict.value as string)"
>
{{
dict
.
label
}}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"备注"
prop=
"remark"
>
<el-input
v-model=
"formData.remark"
placeholder=
"请输入备注"
/>
</el-form-item>
</el-form>
<template
#
footer
>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
</
template
>
</Dialog>
</template>
<
script
setup
lang=
"ts"
>
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
*
as
NotifyTemplateApi
from
'@/api/system/notify/template'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
const
message
=
useMessage
()
// 消息弹窗
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
dialogTitle
=
ref
(
''
)
// 弹窗的标题
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formType
=
ref
(
''
)
// 表单的类型
const
formData
=
ref
<
NotifyTemplateApi
.
NotifyTemplateVO
>
({
id
:
null
,
name
:
''
,
nickname
:
''
,
code
:
''
,
content
:
''
,
type
:
null
,
params
:
''
,
status
:
CommonStatusEnum
.
ENABLE
,
remark
:
''
})
const
formRules
=
reactive
({
type
:
[{
required
:
true
,
message
:
'消息类型不能为空'
,
trigger
:
'change'
}],
status
:
[{
required
:
true
,
message
:
'开启状态不能为空'
,
trigger
:
'blur'
}],
code
:
[{
required
:
true
,
message
:
'模板编码不能为空'
,
trigger
:
'blur'
}],
name
:
[{
required
:
true
,
message
:
'模板名称不能为空'
,
trigger
:
'blur'
}],
nickname
:
[{
required
:
true
,
message
:
'发件人姓名不能为空'
,
trigger
:
'blur'
}],
content
:
[{
required
:
true
,
message
:
'模板内容不能为空'
,
trigger
:
'blur'
}]
})
const
formRef
=
ref
()
// 表单 Ref
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
dialogVisible
.
value
=
true
dialogTitle
.
value
=
type
formType
.
value
=
type
resetForm
()
// 修改时,设置数据
if
(
id
)
{
formLoading
.
value
=
true
try
{
formData
.
value
=
await
NotifyTemplateApi
.
getNotifyTemplateApi
(
id
)
}
finally
{
formLoading
.
value
=
false
}
}
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
submitForm
=
async
()
=>
{
// 校验表单
if
(
!
formRef
)
return
const
valid
=
await
formRef
.
value
.
validate
()
if
(
!
valid
)
return
formLoading
.
value
=
true
try
{
const
data
=
formData
.
value
as
NotifyTemplateApi
.
NotifyTemplateVO
if
(
formType
.
value
===
'create'
)
{
await
NotifyTemplateApi
.
createNotifyTemplateApi
(
data
)
message
.
success
(
'新增成功'
)
}
else
{
await
NotifyTemplateApi
.
updateNotifyTemplateApi
(
data
)
message
.
success
(
'修改成功'
)
}
dialogVisible
.
value
=
false
// 发送操作成功的事件
emit
(
'success'
)
}
finally
{
formLoading
.
value
=
false
}
}
/** 重置表单 */
const
resetForm
=
()
=>
{
formData
.
value
=
{
id
:
null
,
name
:
''
,
nickname
:
''
,
code
:
''
,
content
:
''
,
type
:
null
,
params
:
''
,
status
:
CommonStatusEnum
.
ENABLE
,
remark
:
''
}
formRef
.
value
?.
resetFields
()
}
</
script
>
src/views/system/notify/template/index.vue
View file @
776eb3a7
This diff is collapsed.
Click to expand it.
src/views/system/notify/template/template.data.ts
deleted
100644 → 0
View file @
c461800e
import
type
{
VxeCrudSchema
}
from
'@/hooks/web/useVxeCrudSchemas'
// 表单校验
export
const
rules
=
reactive
({
name
:
[
required
],
code
:
[
required
],
content
:
[
required
],
type
:
[
required
],
status
:
[
required
]
})
// CrudSchema
const
crudSchemas
=
reactive
<
VxeCrudSchema
>
({
primaryKey
:
'id'
,
primaryTitle
:
'编号'
,
primaryType
:
null
,
action
:
true
,
actionWidth
:
'260'
,
// 3个按钮默认200,如有删减对应增减即可
columns
:
[
{
title
:
'模版编码'
,
field
:
'code'
,
isSearch
:
true
},
{
title
:
'模板名称'
,
field
:
'name'
,
isSearch
:
true
},
{
title
:
'发件人名称'
,
field
:
'nickname'
},
{
title
:
'类型'
,
field
:
'type'
,
dictType
:
DICT_TYPE
.
SYSTEM_NOTIFY_TEMPLATE_TYPE
,
dictClass
:
'number'
},
{
title
:
'模版内容'
,
field
:
'content'
,
table
:
{
width
:
300
},
form
:
{
component
:
'Input'
,
componentProps
:
{
type
:
'textarea'
,
rows
:
4
},
colProps
:
{
span
:
24
}
}
},
{
title
:
'状态'
,
field
:
'status'
,
dictType
:
DICT_TYPE
.
COMMON_STATUS
,
dictClass
:
'number'
,
isSearch
:
true
},
{
title
:
'备注'
,
field
:
'remark'
},
{
title
:
'创建时间'
,
field
:
'createTime'
,
isForm
:
false
,
formatter
:
'formatDate'
,
search
:
{
show
:
true
,
itemRender
:
{
name
:
'XDataTimePicker'
}
},
table
:
{
width
:
180
}
}
]
})
export
const
{
allSchemas
}
=
useVxeCrudSchemas
(
crudSchemas
)
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