mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-12-09 20:37:48 +00:00
优化类型
This commit is contained in:
69
src/components/common-autocomplete/public.d.ts
vendored
69
src/components/common-autocomplete/public.d.ts
vendored
@@ -1,5 +1,37 @@
|
||||
import {CommonPage} from "../public";
|
||||
import {CommonTableColumn} from "../common-table/public";
|
||||
import { CommonPage } from '../public'
|
||||
import { CommonTableColumn } from '../common-table/public'
|
||||
import { InputProps } from 'element-plus'
|
||||
|
||||
/**
|
||||
* 搜索参数
|
||||
*/
|
||||
export interface CommonSearchParam {
|
||||
/** 搜索关键字 */
|
||||
query: string;
|
||||
/** 分页信息 */
|
||||
page: CommonPage;
|
||||
}
|
||||
|
||||
export interface CommonSelectPageOption {
|
||||
tabs: Array<{ id: string, label: string }>;
|
||||
/** 搜索方法 */
|
||||
searchMethod: (tabId: string, callback: (items: Array<any>) => void) => Promise<any>;
|
||||
}
|
||||
|
||||
export interface CommonAutocompleteOption {
|
||||
/** 自动完成表格列配置 */
|
||||
columns: Array<CommonTableColumn>;
|
||||
/** 空数据提示信息 */
|
||||
emptyMessage?: string;
|
||||
/** 搜索方法 */
|
||||
searchMethod: (param: CommonSearchParam,
|
||||
callback: (result: {
|
||||
/** 返回分分页 */
|
||||
page: CommonPage,
|
||||
/** 返回的数据 */
|
||||
items: Array<any>
|
||||
}) => void) => Promise<any>;
|
||||
}
|
||||
|
||||
export interface CommonAutocompleteProps {
|
||||
// 自动完成配置
|
||||
@@ -41,38 +73,7 @@ export interface CommonAutocompleteProps {
|
||||
// 最低高度
|
||||
minHeight?: string;
|
||||
// input自定义属性
|
||||
inputAttrs?: any;
|
||||
inputAttrs?: InputProps;
|
||||
// 验证事件
|
||||
validateEvent?: boolean;
|
||||
}
|
||||
|
||||
export interface CommonSelectPageOption {
|
||||
tabs: Array<{ id: string, label: string }>;
|
||||
/**搜索方法*/
|
||||
searchMethod: (tabId: string, callback: (items: Array<any>) => void) => Promise<any>;
|
||||
}
|
||||
|
||||
export interface CommonAutocompleteOption {
|
||||
/**自动完成表格列配置*/
|
||||
columns: Array<CommonTableColumn>;
|
||||
/**空数据提示信息*/
|
||||
emptyMessage?: string;
|
||||
/**搜索方法*/
|
||||
searchMethod: (param: CommonSearchParam,
|
||||
callback: (result: {
|
||||
/**返回分分页*/
|
||||
page: CommonPage,
|
||||
/**返回的数据*/
|
||||
items: Array<any>
|
||||
}) => void) => Promise<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索参数
|
||||
*/
|
||||
export interface CommonSearchParam {
|
||||
/** 搜索关键字 */
|
||||
query: string;
|
||||
/**分页信息*/
|
||||
page: CommonPage;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ const props = defineProps({
|
||||
const inputType = computed(() => useInputType(props.option))
|
||||
|
||||
const modelAttrs = computed(() => {
|
||||
if (['el-input', 'el-select', 'common-autocomplete', 'el-autocomplete', 'el-cascader'].includes(inputType.value)) {
|
||||
if (['el-input', 'el-select', 'common-autocomplete', 'el-autocomplete', 'el-cascader', 'el-tree-select'].includes(inputType.value)) {
|
||||
return Object.assign({ clearable: true }, props.option.attrs || {})
|
||||
}
|
||||
return props.option.attrs
|
||||
@@ -74,9 +74,30 @@ const children = computed(() => {
|
||||
|
||||
<template>
|
||||
<el-form-item
|
||||
:label="label"
|
||||
:prop="option.prop"
|
||||
>
|
||||
<template #label>
|
||||
<span>{{ label }}</span>
|
||||
<el-tooltip
|
||||
v-if="option.tooltip||option.tooltipFunc"
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
:disabled="!option.tooltip"
|
||||
:content="option.tooltip"
|
||||
placement="top-start"
|
||||
>
|
||||
<span>
|
||||
<el-link
|
||||
:underline="false"
|
||||
@click="option.tooltipFunc"
|
||||
>
|
||||
<common-icon
|
||||
icon="QuestionFilled"
|
||||
/>
|
||||
</el-link>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<component
|
||||
:is="inputType"
|
||||
v-model="modelValue"
|
||||
|
||||
@@ -132,7 +132,7 @@ defineExpose({
|
||||
/>
|
||||
<slot
|
||||
:form="form"
|
||||
name="before-buttons"
|
||||
name="default"
|
||||
/>
|
||||
<el-form-item v-if="showButtons">
|
||||
<el-button
|
||||
@@ -161,6 +161,7 @@ defineExpose({
|
||||
</el-form-item>
|
||||
<slot
|
||||
:form="form"
|
||||
name="after-buttons"
|
||||
/>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
94
src/components/common-form/public.d.ts
vendored
94
src/components/common-form/public.d.ts
vendored
@@ -1,67 +1,71 @@
|
||||
import {RuleItem} from "async-validator/dist-types/interface";
|
||||
import {FormInstance, FormProps} from "element-plus";
|
||||
|
||||
export interface CommonFormProps extends FormProps {
|
||||
/**配置选项*/
|
||||
options: Array<CommonFormOption>;
|
||||
/**label宽度*/
|
||||
labelWidth: string;
|
||||
/**model对象*/
|
||||
model: any;
|
||||
/**是否在rule改变时执行验证*/
|
||||
validateOnRuleChange: boolean;
|
||||
/**提交按钮的label*/
|
||||
submitLabel: string;
|
||||
/**重置按钮label*/
|
||||
resetLabel: string;
|
||||
/**返回按钮label*/
|
||||
backLabel: string;
|
||||
/**是否显示按钮区域*/
|
||||
showButtons: boolean;
|
||||
/**是否显示提交按钮*/
|
||||
showSubmit: boolean;
|
||||
/**是否显示重置按钮*/
|
||||
showReset: boolean;
|
||||
/**提交逻辑*/
|
||||
submitForm: (form: FormInstance) => void;
|
||||
/**返回地址*/
|
||||
backUrl: string;
|
||||
}
|
||||
import { RuleItem } from 'async-validator/dist-types/interface'
|
||||
import { FormInstance, FormProps } from 'element-plus'
|
||||
|
||||
export interface CommonFormOption {
|
||||
/**表单类型*/
|
||||
/** 表单类型 */
|
||||
type: 'input' | 'input-number' | 'cascader' | 'radio'
|
||||
| 'radio-group' | 'radio-button' | 'checkbox' | 'checkbox-group' | 'checkbox-button' | 'date-picker'
|
||||
| 'time-picker' | 'switch' | 'select' | 'option' | 'slider' | 'transfer' | 'upload' | 'common-icon-select' | 'common-autocomplete' | 'tree-select';
|
||||
/**数据值*/
|
||||
/** 数据值 */
|
||||
value?: any;
|
||||
/**属性名*/
|
||||
/** 属性名 */
|
||||
prop: string | string[];
|
||||
/**表单标签*/
|
||||
/** 表单标签 */
|
||||
label?: string;
|
||||
/**用于国际化的label*/
|
||||
/** 用于国际化的label */
|
||||
labelKey?: string;
|
||||
/**是否必填,后面解析成为rules的一部分*/
|
||||
/** 是否必填,后面解析成为rules的一部分 */
|
||||
required?: boolean;
|
||||
/**正则表达式验证,解析成为rules的一部分*/
|
||||
/** 正则表达式验证,解析成为rules的一部分 */
|
||||
pattern?: string | RegExp;
|
||||
/**正则表达式验证消息*/
|
||||
/** 正则表达式验证消息 */
|
||||
patternMsg?: string;
|
||||
/**是否禁用*/
|
||||
/** 是否禁用 */
|
||||
disabled?: boolean;
|
||||
/**是否只读*/
|
||||
/** 是否只读 */
|
||||
readonly?: boolean;
|
||||
/**占位提示符*/
|
||||
/** 占位提示符 */
|
||||
placeholder?: string;
|
||||
/**其他可用属性*/
|
||||
/** 其他可用属性 */
|
||||
attrs?: {
|
||||
showPassword: boolean,
|
||||
[key: string]: any
|
||||
};
|
||||
/**有些控件柚子节点*/
|
||||
/** 有些控件柚子节点 */
|
||||
children?: Array<CommonFormOption>;
|
||||
/**async-validator验证器*/
|
||||
/** async-validator验证器 */
|
||||
rules: Array<RuleItem>;
|
||||
/**change事件*/
|
||||
change: (val: any) => void
|
||||
/** change事件 */
|
||||
change: (val: any) => void;
|
||||
/** 提示信息 */
|
||||
tooltip: string;
|
||||
/** 提示函数 */
|
||||
tooltipFunc: () => void;
|
||||
}
|
||||
|
||||
export interface CommonFormProps extends FormProps {
|
||||
/** 配置选项 */
|
||||
options: Array<CommonFormOption>;
|
||||
/** label宽度 */
|
||||
labelWidth: string;
|
||||
/** model对象 */
|
||||
model: any;
|
||||
/** 是否在rule改变时执行验证 */
|
||||
validateOnRuleChange: boolean;
|
||||
/** 提交按钮的label */
|
||||
submitLabel: string;
|
||||
/** 重置按钮label */
|
||||
resetLabel: string;
|
||||
/** 返回按钮label */
|
||||
backLabel: string;
|
||||
/** 是否显示按钮区域 */
|
||||
showButtons: boolean;
|
||||
/** 是否显示提交按钮 */
|
||||
showSubmit: boolean;
|
||||
/** 是否显示重置按钮 */
|
||||
showReset: boolean;
|
||||
/** 提交逻辑 */
|
||||
submitForm: (form: FormInstance) => void;
|
||||
/** 返回地址 */
|
||||
backUrl: string;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
clearable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
validateEvent: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
@@ -93,7 +97,7 @@ const selectIcon = icon => {
|
||||
</el-button>
|
||||
</label>
|
||||
<el-button
|
||||
v-if="vModel"
|
||||
v-if="clearable&&vModel"
|
||||
type="danger"
|
||||
:disabled="disabled||readonly"
|
||||
size="small"
|
||||
|
||||
28
src/components/common-menu/public.d.ts
vendored
28
src/components/common-menu/public.d.ts
vendored
@@ -1,23 +1,16 @@
|
||||
import {RouteRecordRaw} from "vue-router";
|
||||
|
||||
export interface CommonMenuItemProps {
|
||||
/**menu配置*/
|
||||
menuItem: CommonMenuItem;
|
||||
/**index序号*/
|
||||
index: number | string;
|
||||
}
|
||||
import { RouteRecordRaw } from 'vue-router'
|
||||
|
||||
/**
|
||||
* 菜单对象
|
||||
*/
|
||||
export interface CommonMenuItem {
|
||||
/**是否是下拉Dropdown样式*/
|
||||
/** 是否是下拉Dropdown样式 */
|
||||
isDropdown?: boolean;
|
||||
/**是否是分割元素*/
|
||||
/** 是否是分割元素 */
|
||||
isSplit?: boolean;
|
||||
/**自定义样式*/
|
||||
/** 自定义样式 */
|
||||
menuCls?: string;
|
||||
/**路由地址*/
|
||||
/** 路由地址 */
|
||||
index?: string;
|
||||
/** 路由 */
|
||||
route?: RouteRecordRaw;
|
||||
@@ -33,10 +26,17 @@ export interface CommonMenuItem {
|
||||
iconIf?: () => string;
|
||||
/** click事件 */
|
||||
click?: () => string;
|
||||
/**子菜单*/
|
||||
/** 子菜单 */
|
||||
children?: Array<CommonMenuItem>;
|
||||
/**自定义属性*/
|
||||
/** 自定义属性 */
|
||||
attrs: {
|
||||
[key: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommonMenuItemProps {
|
||||
/** menu配置 */
|
||||
menuItem: CommonMenuItem;
|
||||
/** index序号 */
|
||||
index: number | string;
|
||||
}
|
||||
|
||||
11
src/components/common-table/public.d.ts
vendored
11
src/components/common-table/public.d.ts
vendored
@@ -1,6 +1,5 @@
|
||||
import {ButtonProps, TableProps} from "element-plus";
|
||||
import {CommonPage} from "../public";
|
||||
import {PaginationProps} from "element-plus/es/components/pagination/src/pagination";
|
||||
import { ButtonProps, LinkProps, TableProps, PaginationProps } from 'element-plus'
|
||||
import { CommonPage } from '../public'
|
||||
|
||||
/**
|
||||
* 表格列定义
|
||||
@@ -25,7 +24,7 @@ export interface CommonTableColumn {
|
||||
// 可选属性
|
||||
attrs: any;
|
||||
// 链接可选属性
|
||||
linkAttrs: any;
|
||||
linkAttrs: LinkProps;
|
||||
// 点击事件
|
||||
click: (data: any) => any;
|
||||
// 格式化函数
|
||||
@@ -62,9 +61,9 @@ export interface CommonTableProps extends TableProps<any> {
|
||||
pageAlign?: 'left' | 'center' | 'right';
|
||||
/** 其他分页配置项 */
|
||||
pageAttrs?: PaginationProps;
|
||||
/**loading状态*/
|
||||
/** loading状态 */
|
||||
loading?: boolean;
|
||||
/**loading显示消息*/
|
||||
/** loading显示消息 */
|
||||
loadingText?: string;
|
||||
}
|
||||
|
||||
|
||||
4
src/components/public.d.ts
vendored
4
src/components/public.d.ts
vendored
@@ -16,8 +16,12 @@ export interface CommonPage {
|
||||
* element树结构
|
||||
*/
|
||||
export interface CommonTreeNode {
|
||||
/** 树值 */
|
||||
value: string;
|
||||
/** 展示标签 */
|
||||
label: string;
|
||||
/** 子节点 */
|
||||
children?: Array<CommonTreeNode>;
|
||||
/** 是否是叶子节点 */
|
||||
isLeaf?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user