fix: 使用ElDialog:destroy-on-close属性解决对话框重新加载

This commit is contained in:
dhb52 2023-04-14 15:08:58 +08:00
parent 813e7d2776
commit 92da7e341b
2 changed files with 7 additions and 20 deletions

View File

@ -140,7 +140,7 @@
</el-table> </el-table>
<!-- 添加或修改自动回复的对话框 --> <!-- 添加或修改自动回复的对话框 -->
<el-dialog :title="title" v-model="showReplyFormDialog" width="800px" append-to-body> <el-dialog :title="title" v-model="showReplyFormDialog" width="800px" destroy-on-close>
<el-form ref="formRef" :model="replyForm" :rules="rules" label-width="80px"> <el-form ref="formRef" :model="replyForm" :rules="rules" label-width="80px">
<el-form-item label="消息类型" prop="requestMessageType" v-if="msgType === MsgType.Message"> <el-form-item label="消息类型" prop="requestMessageType" v-if="msgType === MsgType.Message">
<el-select v-model="replyForm.requestMessageType" placeholder="请选择"> <el-select v-model="replyForm.requestMessageType" placeholder="请选择">
@ -167,7 +167,7 @@
<el-input v-model="replyForm.requestKeyword" placeholder="请输入内容" clearable /> <el-input v-model="replyForm.requestKeyword" placeholder="请输入内容" clearable />
</el-form-item> </el-form-item>
<el-form-item label="回复消息"> <el-form-item label="回复消息">
<WxReplySelect :objData="objData" v-if="hackResetWxReplySelect" /> <WxReplySelect :objData="objData" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -195,7 +195,7 @@ const message = useMessage()
const formRef = ref() const formRef = ref()
// Follow: Message: Keyword: // Follow: Message: Keyword:
// tab.name // tab.nameenumapi
enum MsgType { enum MsgType {
Follow = 1, Follow = 1,
Message = 2, Message = 2,
@ -277,9 +277,6 @@ const rules = {
requestMatch: [{ required: true, message: '请求的关键字的匹配不能为空', trigger: 'blur' }] requestMatch: [{ required: true, message: '请求的关键字的匹配不能为空', trigger: 'blur' }]
} }
// WxReplySelect
const hackResetWxReplySelect = ref(false)
const onAccountChanged = (id?: number) => { const onAccountChanged = (id?: number) => {
queryParams.accountId = id queryParams.accountId = id
getList() getList()
@ -314,7 +311,6 @@ const handleTabChange = (tabName: TabPaneName) => {
/** 新增按钮操作 */ /** 新增按钮操作 */
const handleAdd = () => { const handleAdd = () => {
reset() reset()
resetEditor()
// //
objData.value = { objData.value = {
type: 'text', type: 'text',
@ -328,7 +324,6 @@ const handleAdd = () => {
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row: any) => { const handleUpdate = async (row: any) => {
reset() reset()
resetEditor()
const data = await MpAutoReplyApi.getAutoReply(row.id) const data = await MpAutoReplyApi.getAutoReply(row.id)
// //
@ -386,7 +381,7 @@ const handleSubmit = async () => {
} }
showReplyFormDialog.value = false showReplyFormDialog.value = false
getList() await getList()
} }
// //
@ -408,14 +403,6 @@ const cancel = () => {
reset() reset()
} }
// Editor
const resetEditor = () => {
hackResetWxReplySelect.value = false //
nextTick(() => {
hackResetWxReplySelect.value = true //
})
}
const handleDelete = async (row) => { const handleDelete = async (row) => {
await message.confirm('是否确认删除此数据?') await message.confirm('是否确认删除此数据?')
await MpAutoReplyApi.deleteAutoReply(row.id) await MpAutoReplyApi.deleteAutoReply(row.id)

View File

@ -190,10 +190,9 @@
v-model="showMessageBox" v-model="showMessageBox"
@click="showMessageBox = true" @click="showMessageBox = true"
width="50%" width="50%"
destroy-on-close
> >
<template #footer> <WxMsg :user-id="userId" />
<WxMsg :user-id="userId" v-if="showMessageBox" />
</template>
</el-dialog> </el-dialog>
</ContentWrap> </ContentWrap>
</template> </template>
@ -262,6 +261,7 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = async () => { const resetQuery = async () => {
// accountIdreset
const accountId = queryParams.accountId const accountId = queryParams.accountId
queryFormRef.value?.resetFields() queryFormRef.value?.resetFields()
queryParams.accountId = accountId queryParams.accountId = accountId