This commit is contained in:
Ray.Hao
2025-04-22 00:03:50 +08:00
4 changed files with 12 additions and 12 deletions

View File

@@ -26,7 +26,7 @@
v-on="item.events || {}" v-on="item.events || {}"
/> />
<component <component
:is="componentMap.get(item?.type ?? 'input')" :is="componentMap.get(item.type)"
v-else v-else
v-model.trim="queryParams[item.prop]" v-model.trim="queryParams[item.prop]"
v-bind="{ style: { width: '100%' }, ...item.attrs }" v-bind="{ style: { width: '100%' }, ...item.attrs }"
@@ -71,7 +71,7 @@ const emit = defineEmits<{
resetClick: [queryParams: IObject]; resetClick: [queryParams: IObject];
}>(); }>();
// 组件映射表 // 组件映射表
const componentMap = new Map<ISearchComponent, Component>([ const componentMap = new Map<ISearchComponent, any>([
/* eslint-disable */ /* eslint-disable */
// @ts-ignore // @ts-ignore
["input", markRaw(ElInput)], // @ts-ignore ["input", markRaw(ElInput)], // @ts-ignore

View File

@@ -44,7 +44,7 @@ export interface ISearchConfig {
// 标签冒号(默认false) // 标签冒号(默认false)
colon?: boolean; colon?: boolean;
// 表单项(默认:[]) // 表单项(默认:[])
formItems?: IFormItems; formItems?: IFormItems<ISearchComponent>;
// 是否开启展开和收缩(默认true) // 是否开启展开和收缩(默认true)
isExpandable?: boolean; isExpandable?: boolean;
// 默认展示的表单项数量(默认3) // 默认展示的表单项数量(默认3)
@@ -176,7 +176,7 @@ export interface IModalConfig<T = any> {
// form组件属性 // form组件属性
form?: IForm; form?: IForm;
// 表单项 // 表单项
formItems: IFormItems; formItems: IFormItems<IComponentType>;
// 提交之前处理 // 提交之前处理
beforeSubmit?: (data: T) => void; beforeSubmit?: (data: T) => void;
// 提交的网络请求函数(需返回promise) // 提交的网络请求函数(需返回promise)
@@ -186,9 +186,9 @@ export interface IModalConfig<T = any> {
export type IForm = Partial<Omit<FormProps, "model" | "rules">>; export type IForm = Partial<Omit<FormProps, "model" | "rules">>;
// 表单项 // 表单项
export type IFormItems = Array<{ export type IFormItems<T = IComponentType> = Array<{
// 组件类型(如input,select,radio,custom等) // 组件类型(如input,select,radio,custom等)
type: IComponentType; type: T;
// 标签提示 // 标签提示
tips?: string | IObject; tips?: string | IObject;
// 标签文本 // 标签文本
@@ -226,5 +226,5 @@ export interface IPageForm {
// form组件属性 // form组件属性
form?: IForm; form?: IForm;
// 表单项 // 表单项
formItems: IFormItems; formItems: IFormItems<IComponentType>;
} }

View File

@@ -18,7 +18,7 @@ function usePage() {
contentRef.value?.fetchPageData({ ...queryParams, ...filterParams }, true); contentRef.value?.fetchPageData({ ...queryParams, ...filterParams }, true);
} }
// 新增 // 新增
function handleAddClick(RefImpl?: Ref<PageContentInstance>) { function handleAddClick(RefImpl?: Ref<PageModalInstance>) {
if (RefImpl) { if (RefImpl) {
RefImpl?.value.setModalVisible(); RefImpl?.value.setModalVisible();
RefImpl?.value.handleDisabled(false); RefImpl?.value.handleDisabled(false);
@@ -31,7 +31,7 @@ function usePage() {
async function handleEditClick( async function handleEditClick(
row: IObject, row: IObject,
callback?: (result?: IObject) => IObject, callback?: (result?: IObject) => IObject,
RefImpl?: Ref<PageContentInstance> RefImpl?: Ref<PageModalInstance>
) { ) {
if (RefImpl) { if (RefImpl) {
RefImpl.value?.setModalVisible(); RefImpl.value?.setModalVisible();
@@ -49,7 +49,7 @@ function usePage() {
async function handleViewClick( async function handleViewClick(
row: IObject, row: IObject,
callback?: (result?: IObject) => IObject, callback?: (result?: IObject) => IObject,
RefImpl?: Ref<PageContentInstance> RefImpl?: Ref<PageModalInstance>
) { ) {
if (RefImpl) { if (RefImpl) {
RefImpl.value?.setModalVisible(); RefImpl.value?.setModalVisible();

View File

@@ -114,7 +114,7 @@
<script setup lang="ts"> <script setup lang="ts">
import UserAPI from "@/api/system/user.api"; import UserAPI from "@/api/system/user.api";
import type { IObject, IOperateData, PageContentInstance } from "@/components/CURD/types"; import type { IObject, IOperateData, PageModalInstance } from "@/components/CURD/types";
import usePage from "@/components/CURD/usePage"; import usePage from "@/components/CURD/usePage";
import addModalConfig from "./config/add"; import addModalConfig from "./config/add";
import addModalConfig2 from "./config/add2"; import addModalConfig2 from "./config/add2";
@@ -196,7 +196,7 @@ const handleOperateClick2 = (data: IOperateData) => {
// 打开二级弹窗 // 打开二级弹窗
const openSecondModal = () => { const openSecondModal = () => {
handleAddClick(addModalRef2 as Ref<PageContentInstance>); handleAddClick(addModalRef2 as Ref<PageModalInstance>);
}; };
const secondSubmit = () => { const secondSubmit = () => {
ElMessage.success("二级弹窗提交成功"); ElMessage.success("二级弹窗提交成功");