platform-render-component-web
前端组件库vue3版本
项目中使用
下载platform-render-component-web
npm i platform-render-component-web
全局注册platform-render-component-web组件
import PlatformWebComponentV3 from 'platform-render-component-web'
createApp(App).use(PlatformWebComponentV3,{
$global,
$axios,
$api: {
platformApi: 平台API,
applicationApi: 应用API
},
useMenuStore,
useDictStore,
useUserStore
})
组件目录
- 卡片组件
- 部门级联选择器组件
- 描述列表组件
- 弹窗组件
- 人员弹窗选择组件
- 抽屉组件
- 表单组件
- 表单表格组件
- 附件在线预览组件
- 页面列表组件
- 表格组件
- jsx组件
- 动态组件
- svg组件
- 上传组件
卡片组件Card
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| title | 标题 | string | - |
| bodyStyle | 内容body样式 | object | {padding: 0.625rem} |
Slots
例子
<Card title="卡片标题">
...
</Card>
<Card>
<template #title>
...
</template>
...
</Card>
部门级联选择器组件DepartmentCascader
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| model-value / v-model | 绑定值,multiple为false时,类型为string,true时为array | string / array | - |
| options / v-model:options | 选中列表 | array | - |
| multiple | 是否可多选 | boolean | false |
| checkStrictly | 是否取消父子节点关联关系,可选择任意一级选项 | boolean | false |
Events
| 名称 | 说明 |
|---|
| change | 当绑定值变化时触发的事件,参数:value,list |
例子
<DepartmentCascader v-model="formData.departmentValue" v-model:options="formData.departmentList" multiple></DepartmentCascader>
描述列表组件Description
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| descriptionColumn | 列表项 | array | - |
| formData | 表单数据 | object | - |
例子
<Description :formData="formData" :descriptionColumn="descriptionColumn" v-loading="loading">
<template #file>
...
</template>
</Description>
const formData = ref({});
const showPo = ref(false);
const descriptionColumn = [
{ field: 'value',label: '标题'},
{ field: 'value',show: showPo,label: 'PO号' },
{ field: 'value',dictType: 'deliveryOrderBusinessType',label: '商机阶段' },
{ componentName: markRaw(Upload),field: 'accessory',label: '附件',span: 24,disabled: true },
{ slot: 'file',label: '插槽'},
{ label: 'VNode',
render: (h,params) => {
return h('el-button',{
link: true,
type: 'primary',
onClick: () => {
...
}
},'预览')
}
},
]
弹窗组件Dialog
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| model-value / v-model | 是否显示 | boolean | false |
| title | 标题 | string | - |
| width | 宽度 | string | 38.75rem |
| showClose | 是否显示右上角关闭按钮 | boolean | true |
| bodyStyle | 内容body样式 | object | {padding: 0.625rem} |
| closeOnClickModal | 是否可以通过点击 modal 关闭 Dialog | boolean | false |
| onClose | 自定义右上角关闭按钮点击事件 | Function | - |
Slots
| 名称 | 说明 |
|---|
| titleRight | 标题右侧 |
| footer | 底部 |
例子
<Dialog v-model="dialogValue" title="弹窗标题">
...
</Dialog>
人员弹窗选择组件Person
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| model-value / v-model | 是否显示 | boolean | false |
| type | 单选或多选 | string | selection ,可选 radio |
Events
| 名称 | 说明 |
|---|
| confirm | 回调参数:type为radio时是 object,type为selection时是 array |
例子:
<Person v-model="showPersonDialog" type="radio" @confirm="handlePersonConfirm"></Person>
抽屉组件Drawer
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| model-value / v-model | 是否显示 | boolean | false |
| title | 标题 | string | - |
| showClose | 是否显示右上角关闭按钮 | boolean | true |
| onClose | 自定义右上角关闭按钮点击事件 | Function | - |
Slots
| 名称 | 说明 |
|---|
| titleLeft | 标题左侧 |
| titleRight | 标题右侧 |
| footer | 底部 |
例子
<Drawer v-model="drawerValue" title="抽屉标题">
...
</Drawer>
表单组件Form
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| labelWidth | label宽度 | string | 7.5rem |
| formColumn | 表单项 | array | - |
| formData | 表单数据 | object | - |
Slots
| 名称 | 说明 |
|---|
| default | 默认插槽 |
| * | formColumn 中定义 slot 可用 |
事件
| 名称 | 说明 | 参数 |
|---|
| validate | 对整个表单的内容进行验证,返回status,errObject | - |
| resetFields | 重置该表单项,将其值重置为初始值,并移除校验结果 | - |
| clearValidate | 移除校验结果 | - |
例子
<Form ref="FormRef" :formData="formData" :formColumn="formColumn" v-loading="loading">
<template #file>
...
</template>
</Description>
const formData = ref({});
const show = ref(false);
const formColumn = [
{ field: 'value',label: '标题',required: true,props: {},on: {}},
{ field: 'value',label: '隐藏',show: show},
{ field: 'value',label: '禁用',disabled: true},
{ componentName: 'el-select',field: 'value',dictType: 'dictType',label: '字典' },
{ componentName: 'el-select',field: 'value',optionList: [{code: 'code',name: 'name'}],label: '字典' },
{ slot: 'file',field: 'file',label: '插槽'}
]
表单表格组件FormTable
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| loading | 表格loading | boolean | - |
| formData | 表单数据 | object | - |
| tableData | 表格数据 | array | - |
| tableColumn | 表头项 | array | - |
| tableField | 表格绑定的字段名,单元格校验必填时需传 | string | - |
| height | 表格高度 | string / number | 100% |
| canAdd | 是否在表格底部显示添加按钮 | boolean | - |
| onAdd | 自定义添加按钮事件 | Function | - |
Slots
使用default插槽后,tableColumn将无效
事件
| 名称 | 说明 | 参数 |
|---|
| validate | 对整个表单的内容进行验证,返回status,errObject | - |
| resetFields | 重置该表单项,将其值重置为初始值,并移除校验结果 | - |
| clearValidate | 移除校验结果 | - |
例子
<FormTable :loading="loading" canAdd :tableData="formData.contactEntityList" tableField="contactEntityList" :tableColumn="tableColumn" :formData="formData">
<template #slotHeaderName>
...
</template>
<template #slotName="{ row }">
...
</template>
</FormTable>
const formData = ref({contactEntityList: []});
const tableData = ref([]);
const tableColumn = [
{ type: 'index',label: '序号',width: 60,fixed: 'left' },
{ prop: 'name',label: 'VNode',minWidth: 160,fixed: 'left',
render: (h,params) => {
return h('el-button',{
link: true,
type: 'primary',
onClick: () => {
}
},params.row.name)
}
},
{ slotHeader: 'slotHeaderName',prop: 'name',label: '标题插槽',minWidth: 100 },
{ slot: 'slotName',prop: 'slotName',label: '插槽',minWidth: 100 },
]
附件在线预览组件OnlinePreview
不支持 .xls和 .doc格式文件,如有需要,可自行转换成 .xlsx 或 .docx格式
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| model-value / v-model | 是否显示 | boolean | false |
| title | 标题 | string | - |
| src | 附件url | string | - |
例子
<OnlinePreview v-model="showOnlinePreview" :title="onlinePreviewTitle" :src="onlinePreviewSrc"></OnlinePreview>
页面列表组件PageList
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| class | 组件根标签class | string | - |
| searchForm | 搜索表单数据 | object | - |
| searchColumn | 搜索表单项 | array | - |
| labelWidth | 搜索表单项label宽度 | string | 6.25rem |
| loading | 表格loading | boolean | - |
| tableData | 表格数据 | array | - |
| tableColumn | 表头项 | array | - |
| currentPage | 表格当前页 | number | 1 |
| pageSize | 表格每页条数 | number | 20 |
| total | 表格总数量 | number | 0 |
| showPagination | 是否显示分页 | boolean | true |
Slots
| 名称 | 说明 |
|---|
| btnLeft | 按钮区域左侧 |
| btnRight | 按钮区域右侧 |
事件
| 名称 | 说明 | 参数 |
|---|
| setSelection | 设置选中 | row[] |
例子
<PageList ref="PageList" :searchForm="searchForm" :searchColumn="searchColumn" :tableData="tableData" :tableColumn="tableColumn" v-model:currentPage="currentPage" v-model:pageSize="pageSize" :total="total" :loading="loading" @load="load">
<template #file>
...
</template>
<template #btnLeft>
<el-button type="primary"><el-icon><i-ep-Plus /></el-icon>新增客户</el-button>
<el-button type="primary"><el-icon><i-ep-Refresh /></el-icon>刷新</el-button>
<el-button type="primary"><el-icon><i-ep-Upload /></el-icon>导入</el-button>
</template>
<template #slotHeaderName>
...
</template>
<template #slotName="{ row }">
...
</template>
...
</PageList>
const searchForm = ref({});
const descriptionColumn = [
{ componentName: 'el-select',span: 6,label: '客户性质',field: 'goodsCode',dictType: 'deliveryOrderBusinessType',props: {},on: {}},
{ slot: 'file',label: '插槽'},
]
const tableData = ref([]);
const tableColumn = [
{ type: 'index',label: '序号',width: 60,fixed: 'left' },
{ prop: 'name',label: 'VNode',minWidth: 160,fixed: 'left',
render: (h,params) => {
return h('el-button',{
link: true,
type: 'primary',
onClick: () => {
}
},params.row.name)
}
},
{ slotHeader: 'slotHeaderName',prop: 'name',label: '标题插槽',minWidth: 100 },
{ slot: 'slotName',prop: 'slotName',label: '插槽',minWidth: 100 },
]
表格组件PageTable
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| loading | 表格loading | boolean | - |
| tableData | 表格数据 | array | - |
| tableColumn | 表头项 | array | - |
| currentPage | 表格当前页 | number | 1 |
| pageSize | 表格每页条数 | number | 20 |
| total | 表格总数量 | number | 0 |
| showPagination | 是否显示分页 | boolean | true |
| height | 表格高度 | string / number | 100% |
| mountLoad | 是否渲染完成自调用一次 load 方法 | boolean | true |
| canAdd | 是否在表格底部显示添加按钮 | boolean | - |
| onAdd | 自定义添加按钮事件 | Function | - |
Slots
使用default插槽后,tableColumn将无效
Events
| 名称 | 说明 |
|---|
| selectionChange | 回调参数: selection |
事件
| 名称 | 说明 | 参数 |
|---|
| setSelection | 设置选中 | row[] |
例子
<PageTable :tableData="tableData" :tableColumn="tableColumn" :loading="loading" v-model:currentPage="currentPage" v-model:pageSize="pageSize" :total="total" @load="load">
<template #slotHeaderName>
...
</template>
<template #slotName="{ row }">
...
</template>
</PageTable>
<PageTable canAdd :onAdd="handleAddTable" :tableData="tableData" :tableColumn="tableColumn" :showPagination="false">
<template #slotHeaderName>
...
</template>
<template #slotName="{ row }">
...
</template>
</PageTable>
const tableData = ref([]);
const tableColumn = [
{ type: 'index',label: '序号',width: 60,fixed: 'left' },
{ prop: 'name',label: 'VNode',minWidth: 160,fixed: 'left',
render: (h,params) => {
return h('el-button',{
link: true,
type: 'primary',
onClick: () => {
}
},params.row.name)
}
},
{ slotHeader: 'slotHeaderName',prop: 'name',label: '标题插槽',minWidth: 100 },
{ slot: 'slotName',prop: 'slotName',label: '插槽',minWidth: 100 },
]
JSX组件Render
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| render | JSX函数 | Function | - |
例子
<Render :render="render" v-bind="props" />
动态组件RenderComponent
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| is | vue动态组件comonent | string / object<component> | div |
Slots
| 名称 | 说明 |
|---|
| default | 默认插槽 |
| title | 头部插槽 |
| content | 内容插槽 |
| footer | 尾部插槽 |
组件内部已导入el-input , el-select , el-date-picker , el-button 组件,is属性可以是以上字符串,除此之外,is属性需为Object<Component>类型
例子
<RenderComponent v-model="value" is="el-input"></RenderComponent>
svg组件SvgIcon
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| fontSize | svg图标宽度和高度 | string | - |
| name | svg图标名称 | string | - |
| color | svg图标颜色 | string | - |
搭配vite-plugin-svg-icons插件使用,指定svg图标所在文件夹
例子
<SvgIcon name="icon-no-found"></SvgIcon>
上传组件Upload
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|
| model-value / v-model | 绑定值 | array | - |
| listType | 附件列表显示方式 | string | picture ,可选 picture-card , text |
| btnText | listType为text或picture时,上传按钮的名称 | string | 上传文件 |
| disabled | 是否禁用 | boolean | - |
Slots
事件
| 名称 | 说明 |
|---|
| validate | 校验是否仍有附件正在上传中 |
例子
<Upload v-model="list" listType="picture-card"></Upload>