Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
shop-vite-main
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
front-base-project
shop-vite-main
Commits
97769221
提交
97769221
authored
12月 20, 2024
作者:
郁骅焌
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
通知公告
上级
643495bc
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
107 行增加
和
3 行删除
+107
-3
NoticeManagementEdit.vue
...ticeManagement/vabAutoComponents/NoticeManagementEdit.vue
+107
-3
没有找到文件。
src/views/system/noticeManagement/vabAutoComponents/NoticeManagementEdit.vue
浏览文件 @
97769221
<
template
>
<vab-dialog
v-model=
"dialogFormVisible"
append-to-body
:title=
"title"
width=
"780px"
@
close=
"close"
>
<vab-dialog
v-model=
"dialogFormVisible"
append-to-body
destroy-on-close
:title=
"title"
width=
"780px"
@
close=
"close"
>
<el-form
ref=
"formRef"
label-width=
"80px"
:model=
"form"
:rules=
"rules"
>
<el-row>
<el-col
:span=
"12"
>
...
...
@@ -23,7 +23,10 @@
</el-col>
<el-col
:span=
"24"
>
<el-form-item
label=
"内容"
>
<editor
v-model=
"form.noticeContent"
:min-height=
"192"
/>
<div
class=
"notice-editor-container"
>
<toolbar
:editor=
"editorRef"
style=
"border-bottom: 1px solid var(--el-border-color)"
/>
<editor
v-model=
"form.noticeContent"
class=
"wang-editor-content"
:default-config=
"editorConfig"
@
on-created=
"handleCreated"
/>
</div>
</el-form-item>
</el-col>
</el-row>
...
...
@@ -36,8 +39,14 @@
</template>
<
script
lang=
"ts"
setup
>
import
type
{
IDomEditor
}
from
'@wangeditor/editor'
import
{
Editor
,
Toolbar
}
from
'@wangeditor/editor-for-vue'
import
'@wangeditor/editor/dist/css/style.css'
import
type
{
FormInstance
}
from
'element-plus'
import
{
doAdd
,
doEdit
,
getNotice
}
from
'/@/api/noticeManagement'
import
{
getToken
}
from
'/@/utils/token'
type
InsertFnType
=
(
url
:
string
,
alt
:
string
,
href
:
string
)
=>
void
defineOptions
({
name
:
'NoticeManagementEdit'
,
...
...
@@ -48,6 +57,31 @@ const { sys_notice_type, sys_notice_status } = proxy.useDict('sys_notice_type',
const
emit
=
defineEmits
([
'fetch-data'
])
const
editorRef
=
shallowRef
<
IDomEditor
|
undefined
>
()
const
editorConfig
=
reactive
<
any
>
({
placeholder
:
'请输入内容...'
,
MENU_CONF
:
{
uploadImage
:
{
server
:
`
${
import
.
meta
.
env
.
VITE_APP_BASE_URL
}
/common/upload`
,
// 您的服务器地址,注意:当前接口格式特殊与其他vab接口不同,请查看vip文档
fieldName
:
'file'
,
allowedFileTypes
:
[
'image/*'
],
headers
:
{
Authorization
:
`Bearer
${
getToken
()}
`
,
},
// 如需传递token请写到在这里
// 自定义插入图片
customInsert
(
res
:
any
,
insertFn
:
InsertFnType
)
{
// TS 语法
// customInsert(res, insertFn) { // JS 语法
// res 即服务端的返回结果
// 从 res 中找到 url alt href ,然后插入图片
console
.
log
(
res
)
insertFn
(
res
.
url
,
res
.
originalFilename
,
res
.
url
)
},
},
},
})
const
formRef
=
ref
<
FormInstance
>
()
const
form
=
ref
<
any
>
({
noticeId
:
undefined
,
...
...
@@ -63,12 +97,24 @@ const rules = reactive<any>({
const
title
=
ref
<
string
>
(
''
)
const
dialogFormVisible
=
ref
<
boolean
>
(
false
)
// 组件销毁时,也及时销毁编辑器
onBeforeUnmount
(()
=>
{
const
editor
=
editorRef
.
value
if
(
editor
==
null
)
return
editor
.
destroy
()
})
const
handleCreated
=
(
editor
:
IDomEditor
)
=>
{
editorRef
.
value
=
editor
}
const
showEdit
=
(
row
?:
any
)
=>
{
reset
()
if
(
row
&&
row
.
noticeId
)
{
title
.
value
=
'编辑'
getNotice
(
row
.
noticeId
).
then
((
response
:
any
)
=>
{
form
.
value
=
response
.
data
const
{
data
}
=
response
form
.
value
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
dialogFormVisible
.
value
=
true
})
}
else
{
...
...
@@ -90,6 +136,7 @@ function reset() {
}
const
close
=
()
=>
{
editorRef
.
value
?.
clear
()
formRef
.
value
?.
clearValidate
()
formRef
.
value
?.
resetFields
()
emit
(
'fetch-data'
)
...
...
@@ -127,3 +174,60 @@ defineExpose({
}
}
</
style
>
<
style
lang=
"scss"
>
.notice-editor-container
{
padding
:
0
!important
;
//
margin
:
-19px
-19px
19px
-19px
;
overflow
:
hidden
!important
;
background
:
var
(
--el-background-color
)
!important
;
border
:
1px
solid
var
(
--el-border-color
)
!important
;
&.w-e-full-screen-container
{
z-index
:
9999
!important
;
}
.w-e-bar-divider
{
display
:
none
;
}
.w-e-toolbar-init
{
border-bottom
:
1px
solid
var
(
--el-border-color
)
!important
;
}
.wang-editor-content
{
//
width
:
70%
;
min-height
:
calc
(
var
(
--el-container-height
)
-
110px
)
!important
;
//
margin
:
20px
auto
20px
auto
;
background-color
:
var
(
--el-color-white
);
border
:
0
;
}
#w-e-textarea-1
{
//
margin
:
var
(
--el-margin
)
!important
;
}
.w-e-text-placeholder
{
top
:
10px
!important
;
}
.wang-editor-footer
{
width
:
70%
;
margin
:
auto
;
}
@media
(
max-width
:
768px
)
{
.wang-editor-title
,
.wang-editor-content
,
.wang-editor-footer
{
width
:
90%
;
}
}
}
.wang-editor-dialog
{
img
{
max-width
:
100%
;
}
}
</
style
>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论