【优化】table组件查询取消选中、Editor校验修复

This commit is contained in:
俞宝山
2025-12-24 00:45:52 +08:00
parent e4de5d5d2c
commit 5869bad091
3 changed files with 21 additions and 58 deletions

View File

@@ -434,14 +434,16 @@
// 刷新
const refresh = (bool = false) => {
bool &&
(data.localPagination = Object.assign(
if (bool) {
data.localPagination = Object.assign(
{},
{
current: 1,
pageSize: data.localPagination.pageSize
}
))
)
clearSelected()
}
loadData()
getTableProps()
}

View File

@@ -1,53 +0,0 @@
<template>
<a-popconfirm
title="删除此信息?"
:open="deleteVisible"
@openChange="deleteVisibleChange"
@confirm="deleteBatch"
>
<a-button danger>
<template #icon><delete-outlined /></template>
{{ props.buttonName }}
</a-button>
</a-popconfirm>
</template>
<script setup name="commonBatchDelete">
import { message } from 'ant-design-vue'
const deleteVisible = ref(false)
const emit = defineEmits({ batchDelete: null })
const props = defineProps({
buttonName: {
type: String,
default: () => '批量删除'
},
selectedRowKeys: {
type: Array,
default: () => []
}
})
// 参数校验
const deleteVisibleChange = () => {
if (deleteVisible.value) {
deleteVisible.value = false
return false
}
if (props.selectedRowKeys.length < 1) {
message.warning('请选择一条或多条数据')
deleteVisible.value = false
return false
} else {
deleteVisible.value = true
}
}
// 批量删除
const deleteBatch = () => {
const params = props.selectedRowKeys.map((m) => {
return {
id: m
}
})
// 发起方法调用,谁的谁来实现
emit('batchDelete', params)
}
</script>

View File

@@ -14,8 +14,9 @@
import '@wangeditor/editor/dist/css/style.css' // 引入 css
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
import fileApi from '@/api/dev/fileApi'
import { Form } from 'ant-design-vue'
const emit = defineEmits(['update:value'])
const emit = defineEmits(['update:value', 'change', 'blur'])
const props = defineProps({
value: {
@@ -41,6 +42,8 @@
}
})
const formItemContext = Form.useInjectFormItemContext()
// 编辑器实例,必须用 shallowRef
const editorRef = shallowRef()
const toolbarConfig = {}
@@ -105,7 +108,18 @@
)
// 监听输入
watch(contentValue, (newValue) => {
emit('update:value', newValue)
let value = newValue
// 校验是否为空,如果为空则设置为'',否则表单校验会认为有值
if (editorRef.value && editorRef.value.isEmpty()) {
value = ''
} else if (newValue === '<p><br></p>') {
value = ''
}
emit('update:value', value)
emit('change', value)
nextTick(() => {
formItemContext.onFieldChange()
})
})
// 记录 editor 实例,重要!
const handleCreated = (editor) => {