vue3-vuecmf-table
介绍
vue3-vuecmf-table是一款基于vue3、Element Plus和TypeScript的多功能列表组件,支持树形列表数据,内置搜索、筛选、分页、行展开、详情、编辑、导出和导入EXCEL等功能。
项目托管地址:
演示
安装
使用
导入组件
在项目的main.ts 文件中导入组件,如下
模板中使用
若你只需要列表展示、搜索及导出数据,无需表单及增删等按钮,可以使用下面“基础功能”方式使用。
后端API示例
属性
| 属性 | 必须 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|---|
| server | 是 | 加载列表数据的后端API链接,必须 | string | - | 空 |
| save_server | 否 | 保存单条数据的后端API链接,若add_btn_visible属性为true或edit_btn_visible属性返回true时,此属性必须 | string | - | 空 |
| import_server | 否 | 导入数据的后端API链接,若列表需要批量导入数据时,此属性必须 | string | - | 空 |
| del_server | 否 | 删除行数据的后端API链接,若del_btn_visible属性返回true时,此属性必须 | string | - | 空 |
| upload_server | 否 | 文件上传后端API链接,若表单中包含有上传文件控件时,此属性必须 | string | - | 空 |
| token | 否 | 后端需要的token信息 | string | - | 空 |
| page | 否 | 当前页码的参数名 | string | - | page |
| limit | 否 | 每页显示条数 | number | - | 20 |
| height | 否 | 列表表格高度 | string | - | 300px |
| size | 否 | 列表中的按钮及表单样式大小 | string | large, default, small | default |
| operate_width | 否 | 操作列的宽度, 若行中有操作按钮,此值必须大于0,否则 操作列不显示 | number | - | 0 |
| detail_btn_visible | 否 | 是否显示行详情按钮 , 默认不显示 | function | - | (select_row: AnyObject) => false |
| add_btn_visible | 否 | 是否显示新增按钮 , 默认不显示 | boolean | - | false |
| edit_btn_visible | 否 | 是否显示行编辑按钮 , 默认不显示 | function | - | (select_row: AnyObject) => false |
| del_btn_visible | 否 | 是否显示行删除按钮 , 默认不显示 | function | - | (select_row: AnyObject) => false |
| checkbox | 否 | 是否显示行选择复选框 | boolean | - | false |
| expand | 否 | 是否显示行展开功能 | boolean | - | false |
| selectable | 否 | 行是否可以选择的回调函数 | function | - | () => true |
| load_form | 否 | 表单加载前的回调函数 | function | - | (tableService: AnyObject, select_row: AnyObject) => Promise.resolve(true) |
| row_key | 否 | 树形数据唯一键字段,列表数据为树形时(即包含 children 字段时)此项必须 | string | - | 空 |
| default_expand_all | 否 | 列表数据为树形时(即包含 children 字段时)是否全部展开 | boolean | - | true |
| export_file_name | 否 | 列表数据导出的文件名称 | string | - | 当前日期 |
| expand_action | 否 | 每行的操作按钮是否展开显示 | boolean | - | true |
| form_dialog_width | 否 | 表单弹窗的宽度 | string | - | 50% |
插槽
插槽在模板中的具体使用,请参考“模板中使用”中的“完整功能”
| 插槽名 | 说明 |
|---|---|
| headerAction | 表格头部左边的自定义按钮操作 |
| rowAction | 列表每行操作列的按钮操作自定义 |
| formatRow | 每行中的每个字段内容 自定义格式化内容显示: 可获取参数有 { row, field },row=当前行数据,field=字段名 |
| rowExpand | 行展开 自定义显示内容,可获取参数有 { row, index } row=当前行数据,index=行索引号 |
事件
| 事件名 | 说明 | 参数 |
|---|---|---|
| exception | 列表加载数据异常事件 | msg 异常信息 |
| beforeLoadTable | 列表表格数据加载前的回调 | tableService 列表服务类对象 |
| afterLoadTable | 列表表格数据加载完后的回调 | table_config 列表配置对象 |
vue-vuecmf-dialog
介绍
vue-vuecmf-dialog弹窗组件是基于vue3、Element Plus和TypeScript构建,支持最大化、最小化、还原及弹窗主体内容自适应屏幕功能。
项目托管地址:
演示
安装
使用
导入组件
然后在项目的main.ts 引入,如下
import { createApp } from 'vue'
import App from './App.vue'
import './registerServiceWorker'
/*导入组件*/
import VuecmfDialog from "vue-vuecmf-dialog"
createApp(App).use(VuecmfDialog).mount('#app')
模板中使用
<template>
<h3>vue-vuecmf-dialog demo</h3>
<el-button
size="default"
type="primary"
@click=" showDlg = true " >打开对话框</el-button>
<vuecmf-dialog
:model_value="showDlg"
title="标题"
@updateVisible="updateVisible"
@close="close"
@toggleScreen="toggleScreen">
<template #content>
<div> 这是一个可以最大化、最小化及还原的 对话框</div>
</template>
<template #footer>
<el-button type="primary" @click=" showDlg = false ">关闭</el-button>
</template>
</vuecmf-dialog>
</template>
<script lang="ts">
import {defineComponent, ref} from 'vue';
export default defineComponent({
name: 'App',
setup(){
const showDlg = ref()
showDlg.value = false
const updateVisible = (val:any) => {
console.log('val=', val)
showDlg.value = val
}
const close = ():void => {
console.log('dialog closed!')
}
const toggleScreen = (is_max: boolean):void => {
console.log('dialog is max:', is_max)
}
return {
showDlg,
updateVisible,
close,
toggleScreen
}
}
});
</script>
属性
| 属性 | 必须 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|---|
| title | 否 | 对话框标题,支持html | string | - | 空 |
| max_screen | 否 | 是否全屏显示 | bool | - | false |
| width | 否 | 对话框宽度 | string | - | 50% |
| top | 否 | 对话框顶部相对于窗口的偏移距离 | string | - | 15vh |
| model_value | 否 | 是否显示对话框 | bool | - | false |
| custom_class | 否 | Dialog 的自定义样式类名 | string | - | 空 |
| close_on_click_modal | 否 | 是否可以通过点击 modal 关闭 Dialog | bool | - | false |
| close_on_press_escape | 否 | 是否可以通过按下 ESC 关闭 Dialog | bool | - | true |
| show_close | 否 | 是否显示关闭按钮 | bool | - | true |
| scroll_top | 否 | 每次打开弹窗是否滚动到弹窗头部位置 | bool | - | true |
| modal | 否 | 是否显示遮罩层 | bool | - | true |
| append_to_body | 否 | Dialog 自身是否插入至 body 元素上。 嵌套的 Dialog 必须指定该属性并赋值为 true | bool | - | false |
事件
| 事件名 | 说明 | 参数 |
|---|---|---|
| open | Dialog 打开时的回调 | - |
| opened | Dialog 打开后的回调 | - |
| close | Dialog 关闭的回调 | - |
| closed | Dialog 关闭后的回调 | - |
| updateVisible | 弹窗关闭时,重置为弹窗不显示 | - |
| toggleScreen | 弹窗最大化及还原时的回调 | is_max: bool值,当前弹窗是否最大化 |
vue-vuecmf-editor
介绍
vue-vuecmf-editor是一款基于vue3、Element Plus和TypeScript构建的HTML5富文本编辑器。
项目托管地址:
演示
安装
使用
导入组件
然后在项目的main.ts 引入,如下
import { createApp } from 'vue'
import App from './App.vue'
import './registerServiceWorker'
//导入
import VuecmfEditor from "vue-vuecmf-editor"
createApp(App).use(VuecmfEditor).mount('#app')
模板中使用
<template>
<h3>vuecmf-editor demo</h3>
<vuecmf-editor
id="myeditor"
:content="contentHtml"
@on-change="getContent"
></vuecmf-editor>
<button @click="save">保存</button>
</template>
<script lang="ts">
import {defineComponent, ref} from 'vue';
export default defineComponent({
name: 'App',
components: {
},
setup(){
const contentHtml = ref('Hello world!')
const getContent = (content:string, id: string) => {
console.log('id=', id)
contentHtml.value = content
}
const save = ():void => {
alert(contentHtml.value)
}
return {
getContent,
contentHtml,
save
}
}
});
</script>
属性
| 属性 | 必须 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|---|
| id | 是 | 编辑器id | string | - | - |
| content | 否 | 编辑器内容 | string | - | 空 |
| height | 否 | 编辑器高度 | string | - | 300px |
| size | 否 | 编辑器中工具条大小样式 | string | default, large, small | default |
| tools | 否 | 自定义工具条,多个英文逗号分隔。例如 heading,table,code | string | heading 标题 align-left 左对齐 align-center 居中对齐 align-right 右对齐 bold 加粗 italic 斜体 underline 下横线 strikethrough 删除线 superscript 上角标 subscript 下角标 quote-left 块引用 link 添加超链接 unlink 取消超链接 font 字体 font-size 字大小 font-color 字体颜色 font-bg-color 文本背景色 indent 增加缩进 outdent 减少缩进 list-ol 有序列表 list-ul 无序列表 select-all 全选 remove-format 清除格式 cut 剪切 copy 复制 hr 插入水平线 table 插入表格 image 插入图片 film 插入视频 code 插入代码 redo 恢复 undo 撤销 | 空 |
事件
| 事件名 | 说明 | 参数 |
|---|---|---|
| on-change | 添加或修改编辑器中的内容时,触发此事件 | content: 编辑器内容, id: 编辑器ID |