This commit is contained in:
icssoa 2023-06-13 13:31:03 +08:00
parent fee911acf2
commit 96a7aa0939
21 changed files with 628 additions and 83 deletions

View File

@ -69,6 +69,13 @@ declare namespace Eps {
[key: string]: any; [key: string]: any;
} }
interface DemoUserEntity {
/**
*
*/
[key: string]: any;
}
interface DictInfoEntity { interface DictInfoEntity {
/** /**
* *
@ -83,6 +90,27 @@ declare namespace Eps {
[key: string]: any; [key: string]: any;
} }
interface FinanceDrawEntity {
/**
*
*/
[key: string]: any;
}
interface FinanceInvoiceInfoEntity {
/**
*
*/
[key: string]: any;
}
interface InfoCarEntity {
/**
*
*/
[key: string]: any;
}
interface IotDeviceEntity { interface IotDeviceEntity {
/** /**
* *
@ -125,6 +153,27 @@ declare namespace Eps {
[key: string]: any; [key: string]: any;
} }
interface UserAddressEntity {
/**
*
*/
[key: string]: any;
}
interface UserAuthEntity {
/**
*
*/
[key: string]: any;
}
interface UserCreditEntity {
/**
*
*/
[key: string]: any;
}
interface UserInfoEntity { interface UserInfoEntity {
/** /**
* *
@ -1118,6 +1167,63 @@ declare namespace Eps {
request: Service["request"]; request: Service["request"];
} }
interface DemoUser {
/**
* delete
*/
delete(data?: any): Promise<any>;
/**
* update
*/
update(data?: any): Promise<any>;
/**
* info
*/
info(data?: any): Promise<DemoUserEntity>;
/**
* list
*/
list(data?: any): Promise<DemoUserEntity[]>;
/**
* page
*/
page(data?: any): Promise<{
pagination: { size: number; page: number; total: number };
list: DemoUserEntity[];
[key: string]: any;
}>;
/**
* add
*/
add(data?: any): Promise<any>;
/**
*
*/
permission: {
delete: string;
update: string;
info: string;
list: string;
page: string;
add: string;
};
/**
*
*/
_permission: {
delete: boolean;
update: boolean;
info: boolean;
list: boolean;
page: boolean;
add: boolean;
};
/**
*
*/
request: Service["request"];
}
interface DictInfo { interface DictInfo {
/** /**
* delete * delete
@ -1238,6 +1344,183 @@ declare namespace Eps {
request: Service["request"]; request: Service["request"];
} }
interface FinanceDraw {
/**
* update
*/
update(data?: any): Promise<any>;
/**
* info
*/
info(data?: any): Promise<FinanceDrawEntity>;
/**
* list
*/
list(data?: any): Promise<FinanceDrawEntity[]>;
/**
* page
*/
page(data?: any): Promise<{
pagination: { size: number; page: number; total: number };
list: FinanceDrawEntity[];
[key: string]: any;
}>;
/**
* delete
*/
delete(data?: any): Promise<any>;
/**
* add
*/
add(data?: any): Promise<any>;
/**
*
*/
permission: {
update: string;
info: string;
list: string;
page: string;
delete: string;
add: string;
};
/**
*
*/
_permission: {
update: boolean;
info: boolean;
list: boolean;
page: boolean;
delete: boolean;
add: boolean;
};
/**
*
*/
request: Service["request"];
}
interface FinanceInvoice {
/**
* orders
*/
orders(data?: any): Promise<any>;
/**
* delete
*/
delete(data?: any): Promise<any>;
/**
* update
*/
update(data?: any): Promise<any>;
/**
* info
*/
info(data?: any): Promise<FinanceInvoiceInfoEntity>;
/**
* list
*/
list(data?: any): Promise<FinanceInvoiceInfoEntity[]>;
/**
* page
*/
page(data?: any): Promise<{
pagination: { size: number; page: number; total: number };
list: FinanceInvoiceInfoEntity[];
[key: string]: any;
}>;
/**
* add
*/
add(data?: any): Promise<any>;
/**
*
*/
permission: {
orders: string;
delete: string;
update: string;
info: string;
list: string;
page: string;
add: string;
};
/**
*
*/
_permission: {
orders: boolean;
delete: boolean;
update: boolean;
info: boolean;
list: boolean;
page: boolean;
add: boolean;
};
/**
*
*/
request: Service["request"];
}
interface InfoCar {
/**
* delete
*/
delete(data?: any): Promise<any>;
/**
* update
*/
update(data?: any): Promise<any>;
/**
* info
*/
info(data?: any): Promise<InfoCarEntity>;
/**
* list
*/
list(data?: any): Promise<InfoCarEntity[]>;
/**
* page
*/
page(data?: any): Promise<{
pagination: { size: number; page: number; total: number };
list: InfoCarEntity[];
[key: string]: any;
}>;
/**
* add
*/
add(data?: any): Promise<any>;
/**
*
*/
permission: {
delete: string;
update: string;
info: string;
list: string;
page: string;
add: string;
};
/**
*
*/
_permission: {
delete: boolean;
update: boolean;
info: boolean;
list: boolean;
page: boolean;
add: boolean;
};
/**
*
*/
request: Service["request"];
}
interface IotDevice { interface IotDevice {
/** /**
* delete * delete
@ -1685,6 +1968,177 @@ declare namespace Eps {
request: Service["request"]; request: Service["request"];
} }
interface UserAddress {
/**
* delete
*/
delete(data?: any): Promise<any>;
/**
* update
*/
update(data?: any): Promise<any>;
/**
* info
*/
info(data?: any): Promise<UserAddressEntity>;
/**
* list
*/
list(data?: any): Promise<UserAddressEntity[]>;
/**
* page
*/
page(data?: any): Promise<{
pagination: { size: number; page: number; total: number };
list: UserAddressEntity[];
[key: string]: any;
}>;
/**
* add
*/
add(data?: any): Promise<any>;
/**
*
*/
permission: {
delete: string;
update: string;
info: string;
list: string;
page: string;
add: string;
};
/**
*
*/
_permission: {
delete: boolean;
update: boolean;
info: boolean;
list: boolean;
page: boolean;
add: boolean;
};
/**
*
*/
request: Service["request"];
}
interface UserAuth {
/**
* update
*/
update(data?: any): Promise<any>;
/**
* info
*/
info(data?: any): Promise<UserAuthEntity>;
/**
* list
*/
list(data?: any): Promise<UserAuthEntity[]>;
/**
* page
*/
page(data?: any): Promise<{
pagination: { size: number; page: number; total: number };
list: UserAuthEntity[];
[key: string]: any;
}>;
/**
* delete
*/
delete(data?: any): Promise<any>;
/**
* add
*/
add(data?: any): Promise<any>;
/**
*
*/
permission: {
update: string;
info: string;
list: string;
page: string;
delete: string;
add: string;
};
/**
*
*/
_permission: {
update: boolean;
info: boolean;
list: boolean;
page: boolean;
delete: boolean;
add: boolean;
};
/**
*
*/
request: Service["request"];
}
interface UserCredit {
/**
* delete
*/
delete(data?: any): Promise<any>;
/**
* update
*/
update(data?: any): Promise<any>;
/**
* info
*/
info(data?: any): Promise<UserCreditEntity>;
/**
* list
*/
list(data?: any): Promise<UserCreditEntity[]>;
/**
* page
*/
page(data?: any): Promise<{
pagination: { size: number; page: number; total: number };
list: UserCreditEntity[];
[key: string]: any;
}>;
/**
* add
*/
add(data?: any): Promise<any>;
/**
*
*/
permission: {
delete: string;
update: string;
info: string;
list: string;
page: string;
add: string;
};
/**
*
*/
_permission: {
delete: boolean;
update: boolean;
info: boolean;
list: boolean;
page: boolean;
add: boolean;
};
/**
*
*/
request: Service["request"];
}
interface UserInfo { interface UserInfo {
/** /**
* delete * delete
@ -1766,12 +2220,14 @@ declare namespace Eps {
}; };
}; };
cloud: { db: CloudDb; func: { info: CloudFuncInfo; log: CloudFuncLog } }; cloud: { db: CloudDb; func: { info: CloudFuncInfo; log: CloudFuncLog } };
demo: { goods: DemoGoods }; demo: { goods: DemoGoods; user: DemoUser };
dict: { info: DictInfo; type: DictType }; dict: { info: DictInfo; type: DictType };
finance: { draw: FinanceDraw; invoice: FinanceInvoice };
info: { car: InfoCar };
iot: { device: IotDevice; message: IotMessage; mqtt: IotMqtt }; iot: { device: IotDevice; message: IotMessage; mqtt: IotMqtt };
recycle: { data: RecycleData }; recycle: { data: RecycleData };
space: { info: SpaceInfo; type: SpaceType }; space: { info: SpaceInfo; type: SpaceType };
task: { info: TaskInfo }; task: { info: TaskInfo };
user: { info: UserInfo }; user: { address: UserAddress; auth: UserAuth; credit: UserCredit; info: UserInfo };
}; };
} }

View File

@ -1 +1 @@
[["/admin/base/comm","",[["/personUpdate","post"],["/uploadMode","get"],["/permmenu","get"],["/person","get"],["/upload","post"],["/logout","post"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/open","",[["/refreshToken","get"],["/captcha","get"],["/login","post"],["/html","get"],["/eps","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/department","BaseSysDepartmentEntity",[["/delete","post"],["/update","post"],["/order","post"],["/list","post"],["/add","post"],["/page"],["/info"]]],["/admin/base/sys/log","BaseSysLogEntity",[["/setKeep","post"],["/getKeep","get"],["/clear","post"],["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/menu","BaseSysMenuEntity",[["/create","post"],["/delete","post"],["/update","post"],["/parse","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/param","BaseSysParamEntity",[["/delete","post"],["/update","post"],["/html","get"],["/info","get"],["/page","post"],["/add","post"],["/list"]]],["/admin/base/sys/role","BaseSysRoleEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/user","BaseSysUserEntity",[["/delete","post"],["/update","post"],["/move","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/db","CloudDBEntity",[["/initEntity","post"],["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/info","CloudFuncInfoEntity",[["/invoke","post"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/log","CloudFuncLogEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/demo/goods","DemoGoodsEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/info","DictInfoEntity",[["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/type","DictTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/device","IotDeviceEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/message","IotMessageEntity",[["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/iot/mqtt","",[["/publish","post"],["/config","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/recycle/data","RecycleDataEntity",[["/restore","post"],["/info","get"],["/page","post"],["/list"],["/update"],["/delete"],["/add"]]],["/admin/space/info","SpaceInfoEntity",[["/getConfig","get"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/space/type","SpaceTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/task/info","TaskInfoEntity",[["/delete","post"],["/update","post"],["/start","post"],["/once","post"],["/stop","post"],["/info","get"],["/page","post"],["/log","get"],["/add","post"],["/list"]]],["/admin/user/info","UserInfoEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/chat/message","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/chat/session","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/test","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]]] [["/admin/base/comm","",[["/personUpdate","post"],["/uploadMode","get"],["/permmenu","get"],["/person","get"],["/upload","post"],["/logout","post"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/open","",[["/refreshToken","get"],["/captcha","get"],["/login","post"],["/html","get"],["/eps","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/department","BaseSysDepartmentEntity",[["/delete","post"],["/update","post"],["/order","post"],["/list","post"],["/add","post"],["/page"],["/info"]]],["/admin/base/sys/log","BaseSysLogEntity",[["/setKeep","post"],["/getKeep","get"],["/clear","post"],["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/menu","BaseSysMenuEntity",[["/create","post"],["/delete","post"],["/update","post"],["/parse","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/param","BaseSysParamEntity",[["/delete","post"],["/update","post"],["/html","get"],["/info","get"],["/page","post"],["/add","post"],["/list"]]],["/admin/base/sys/role","BaseSysRoleEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/user","BaseSysUserEntity",[["/delete","post"],["/update","post"],["/move","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/db","CloudDBEntity",[["/initEntity","post"],["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/info","CloudFuncInfoEntity",[["/invoke","post"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/log","CloudFuncLogEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/demo/goods","DemoGoodsEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/demo/user","DemoUserEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/info","DictInfoEntity",[["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/type","DictTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/finance/draw","FinanceDrawEntity",[["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/delete"],["/add"]]],["/admin/finance/invoice","FinanceInvoiceInfoEntity",[["/orders","get"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/info/car","InfoCarEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/device","IotDeviceEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/message","IotMessageEntity",[["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/iot/mqtt","",[["/publish","post"],["/config","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/recycle/data","RecycleDataEntity",[["/restore","post"],["/info","get"],["/page","post"],["/list"],["/update"],["/delete"],["/add"]]],["/admin/space/info","SpaceInfoEntity",[["/getConfig","get"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/space/type","SpaceTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/task/info","TaskInfoEntity",[["/delete","post"],["/update","post"],["/start","post"],["/once","post"],["/stop","post"],["/info","get"],["/page","post"],["/log","get"],["/add","post"],["/list"]]],["/admin/user/address","UserAddressEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/user/auth","UserAuthEntity",[["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/delete"],["/add"]]],["/admin/user/credit","UserCreditEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/user/info","UserInfoEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/chat/message","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/chat/session","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/test","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]]]

View File

@ -9,7 +9,7 @@
"lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix" "lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix"
}, },
"dependencies": { "dependencies": {
"@cool-vue/crud": "^6.2.2", "@cool-vue/crud": "^6.3.1",
"@element-plus/icons-vue": "^2.0.10", "@element-plus/icons-vue": "^2.0.10",
"@vueuse/core": "^9.1.0", "@vueuse/core": "^9.1.0",
"@wangeditor/editor": "^5.1.23", "@wangeditor/editor": "^5.1.23",

View File

@ -517,10 +517,11 @@ declare namespace ClForm {
hideLoading(): void; hideLoading(): void;
setData(prop: string, value: any): void; setData(prop: string, value: any): void;
bindForm(data: obj): void; bindForm(data: obj): void;
setOptions(prop: string, list: Array<{ label: string; value?: any }>): void;
setProps(prop: string, value: any): void;
getForm(prop?: string): any; getForm(prop?: string): any;
setForm(prop: string, value: any): void; setForm(prop: string, value: any): void;
setOptions(prop: string, list: { label: string; value?: any; [key: string]: any }[]): void;
setProps(prop: string, value: any): void;
setConfig(path: string, value: any): void;
showItem(props: string[] | string): void; showItem(props: string[] | string): void;
hideItem(props: string[] | string): void; hideItem(props: string[] | string): void;
toggleItem(prop: string, flag?: boolean): void; toggleItem(prop: string, flag?: boolean): void;

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-vue/crud", "name": "@cool-vue/crud",
"version": "6.2.2", "version": "6.3.1",
"private": false, "private": false,
"main": "./dist/index.umd.min.js", "main": "./dist/index.umd.min.js",
"typings": "types/index.d.ts", "typings": "types/index.d.ts",

View File

@ -80,7 +80,7 @@ export default defineComponent({
<div <div
class={["cl-crud", { "is-border": props.border }]} class={["cl-crud", { "is-border": props.border }]}
style={{ padding: props.padding }}> style={{ padding: props.padding }}>
{slots.default && slots.default()} {slots.default?.()}
</div> </div>
); );
}; };

View File

@ -253,7 +253,7 @@ export default defineComponent({
class="cl-dialog__container" class="cl-dialog__container"
style={{ height: props.height }} style={{ height: props.height }}
key={cacheKey.value}> key={cacheKey.value}>
{slots.default && slots.default()} {slots.default?.()}
</div> </div>
); );
}, },

View File

@ -116,7 +116,7 @@ export default defineComponent({
); );
}, },
default: () => { default: () => {
slots.default && slots.default(); slots.default?.();
} }
} }
)} )}

View File

@ -15,7 +15,7 @@ export default defineComponent({
{props.label} {props.label}
</span> </span>
{slots.default && slots.default()} {slots.default?.()}
</div> </div>
); );
}; };

View File

@ -11,6 +11,12 @@ export default defineComponent({
props: { props: {
label: String, label: String,
// 展开状态
expand: {
type: Boolean,
default: true
},
// 是否能展开、收起
isExpand: { isExpand: {
type: Boolean, type: Boolean,
default: true default: true
@ -18,21 +24,23 @@ export default defineComponent({
}, },
setup(props, { slots }) { setup(props, { slots }) {
const isExpand = ref(props.isExpand); const visible = ref(props.expand);
async function toExpand() { function toExpand() {
isExpand.value = !isExpand.value; if (props.isExpand) {
visible.value = !visible.value;
}
} }
return () => { return () => {
return ( return (
<div class={["cl-form-card", { "is-expand": isExpand.value }]}> <div class={["cl-form-card", { "is-expand": visible.value }]}>
<div class="cl-form-card__header" v-show={props.label} onClick={toExpand}> <div class="cl-form-card__header" v-show={props.label} onClick={toExpand}>
<span>{props.label}</span> <span>{props.label}</span>
<el-icon> <el-icon v-show={props.isExpand}>
<arrow-down v-show={!isExpand.value} /> <arrow-down v-show={!visible.value} />
<arrow-up v-show={isExpand.value} /> <arrow-up v-show={visible.value} />
</el-icon> </el-icon>
</div> </div>
<div class="cl-form-card__container">{slots.default?.()}</div> <div class="cl-form-card__container">{slots.default?.()}</div>

View File

@ -8,37 +8,63 @@ declare type Form = Vue.Ref<any>;
// 操作 // 操作
export function useAction({ config, form, Form }: { config: Config; form: obj; Form: Form }) { export function useAction({ config, form, Form }: { config: Config; form: obj; Form: Form }) {
// 设置数据 // 设置数据
function set({ prop, options, hidden, path, props }: any, data?: any): any { function set(
{
prop,
key,
path
}: { prop?: string; key?: "options" | "props" | "hidden" | "hidden-toggle"; path?: string },
data?: any
) {
let p: string = path || ""; let p: string = path || "";
if (path) {
dataset(config, p, data);
} else {
let d: any;
if (prop) { if (prop) {
p = `items[prop:${prop}]`; function deep(arr: ClForm.Item[]) {
arr.forEach((e) => {
if (e.prop == prop) {
d = e;
} else {
if (e.children) {
deep(e.children);
}
}
});
} }
if (options) { deep(config.items);
p += `.component.options`;
} }
if (props) { if (d) {
p += `.component.props`; switch (key) {
} case "options":
d.component.options = data;
break;
if (hidden) { case "props":
p += ".hidden"; Object.assign(d.component.props, data);
} break;
return dataset(config, p, data); case "hidden":
} d.hidden = data;
break;
// 合并数据 case "hidden-toggle":
function merge(options: any, value: any): any { d.hidden = data === undefined ? !d.hidden : !data;
return set( break;
{
...options, default:
isMerge: true Object.assign(d, data);
}, break;
value }
); } else {
console.error(`prop "${prop}" not found`);
}
}
} }
// 获取表单值 // 获取表单值
@ -63,33 +89,30 @@ export function useAction({ config, form, Form }: { config: Config; form: obj; F
// 设置表单项的下拉数据列表 // 设置表单项的下拉数据列表
function setOptions(prop: string, value: any[]) { function setOptions(prop: string, value: any[]) {
set({ options: true, prop }, value); set({ prop, key: "options" }, value);
} }
// 设置表单项的组件参数 // 设置表单项的组件参数
function setProps(prop: string, value: any) { function setProps(prop: string, value: any) {
merge({ props: true, prop }, value); set({ prop, key: "props" }, value);
} }
// 切换表单项的显示、隐藏 // 切换表单项的显示、隐藏
function toggleItem(prop: string, value?: boolean) { function toggleItem(prop: string, value?: boolean) {
if (value === undefined) { set({ prop, key: "hidden-toggle" }, value);
value = set({ prop, hidden: true });
}
set({ hidden: true, prop }, !value);
} }
// 对部分表单项隐藏 // 对部分表单项隐藏
function hideItem(...props: string[]) { function hideItem(...props: string[]) {
props.forEach((prop) => { props.forEach((prop) => {
set({ hidden: true, prop }, true); set({ prop, key: "hidden" }, true);
}); });
} }
// 对部分表单项显示 // 对部分表单项显示
function showItem(...props: string[]) { function showItem(...props: string[]) {
props.forEach((prop) => { props.forEach((prop) => {
set({ hidden: true, prop }, false); set({ prop, key: "hidden" }, false);
}); });
} }
@ -221,6 +244,7 @@ export function useApi({ Form }: { Form: Form }) {
"getForm", "getForm",
"setForm", "setForm",
"setData", "setData",
"setConfig",
"setOptions", "setOptions",
"setProps", "setProps",
"toggleItem", "toggleItem",

View File

@ -244,11 +244,22 @@ export default defineComponent({
// 合并配置 // 合并配置
for (const i in config) { for (const i in config) {
switch (i) { switch (i) {
// 动态处理 // 表单项
case "items": case "items":
config.items = (options.items || []).map((e) => getValue(e)); function deep(arr: any[]): any[] {
return arr.map((e) => {
const d = getValue(e);
return {
...d,
children: d?.children ? deep(d.children) : undefined
};
});
}
config.items = deep(options.items || []);
break; break;
// 合并处理 // 事件、参数、操作
case "on": case "on":
case "op": case "op":
case "props": case "props":
@ -256,7 +267,7 @@ export default defineComponent({
case "_data": case "_data":
deepMerge(config[i], options[i] || {}); deepMerge(config[i], options[i] || {});
break; break;
// 赋值 // 标题、宽度
case "title": case "title":
case "width": case "width":
default: default:

View File

@ -209,7 +209,8 @@ const Table = useTable({
{ {
label: "创建时间", label: "创建时间",
prop: "createTime", prop: "createTime",
sortable: "desc" sortable: "desc",
width: 160
}, },
{ {
type: "op", type: "op",

View File

@ -47,12 +47,15 @@ const Upsert = useUpsert({
} }
} }
}, },
{ () => {
return {
label: "手机号", label: "手机号",
prop: "phone", prop: "phone",
hidden: Upsert.value?.mode == "update",
component: { component: {
name: "el-input" name: "el-input"
} }
};
} }
] ]
}, },
@ -102,7 +105,7 @@ const Upsert = useUpsert({
} }
], ],
plugins: [setFocus()], plugins: [setFocus("account")],
onOpened() { onOpened() {
Upsert.value?.setOptions("work", [ Upsert.value?.setOptions("work", [
@ -115,6 +118,10 @@ const Upsert = useUpsert({
value: 2 value: 2
} }
]); ]);
// Upsert.value?.setProps("account", {
// disabled: Upsert.value?.mode == "update"
// });
}, },
onClose(action, done) { onClose(action, done) {

View File

@ -12,13 +12,19 @@ export function setFocus(prop?: string): ClForm.Plugin {
const name = prop || exposed.config.items[0].prop; const name = prop || exposed.config.items[0].prop;
if (name) { if (name) {
exposed.config.items.find((e) => { function deep(arr: ClForm.Item[]) {
if (e.prop == name) { arr.forEach((e) => {
if (e.prop == name && name) {
if (e.component) { if (e.component) {
e.component.ref = setRefs(name); e.component.ref = setRefs(name);
} }
} else {
deep(e.children || []);
} }
}); });
}
deep(exposed.config.items);
onOpen(() => { onOpen(() => {
refs[name]?.focus(); refs[name]?.focus();

View File

@ -297,7 +297,6 @@
&.no-label { &.no-label {
& > .el-form-item__label { & > .el-form-item__label {
padding: 0; padding: 0;
width: 0 !important;
} }
} }
} }
@ -455,7 +454,7 @@
display: grid; display: grid;
grid-template-rows: 0fr; grid-template-rows: 0fr;
.cl-form-item__children { > .cl-form-item__children {
margin: 10px 10px 10px 0px; margin: 10px 10px 10px 0px;
min-height: 0; min-height: 0;
overflow: hidden; overflow: hidden;
@ -463,12 +462,16 @@
} }
&.is-expand { &.is-expand {
.cl-form-card__container { > .cl-form-card__container {
border: 1px solid var(--el-border-color); border: 1px solid var(--el-border-color);
border-radius: var(--el-border-radius-base); border-radius: var(--el-border-radius-base);
grid-template-rows: 1fr; grid-template-rows: 1fr;
} }
} }
.cl-form-card {
margin-left: 10px;
}
} }
.cl-dialog { .cl-dialog {

View File

@ -0,0 +1,25 @@
declare const _default: import("vue").DefineComponent<{
label: StringConstructor;
expand: {
type: BooleanConstructor;
default: boolean;
};
isExpand: {
type: BooleanConstructor;
default: boolean;
};
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
label: StringConstructor;
expand: {
type: BooleanConstructor;
default: boolean;
};
isExpand: {
type: BooleanConstructor;
default: boolean;
};
}>>, {
expand: boolean;
isExpand: boolean;
}>;
export default _default;

View File

@ -4,6 +4,7 @@ interface Options {
scope?: any; scope?: any;
item?: any; item?: any;
slots?: any; slots?: any;
children?: any[] & any;
custom?: (vnode: any) => any; custom?: (vnode: any) => any;
render?: "slot" | null; render?: "slot" | null;
[key: string]: any; [key: string]: any;

View File

@ -1,9 +1,11 @@
import { Merge, ModuleConfig } from "/@/cool"; import { Merge, ModuleConfig } from "/@/cool";
import Crud from "@cool-vue/crud"; import Crud from "@cool-vue/crud";
// 调试或者自定义crud
// import Crud from "../../../packages/crud/src";
import "@cool-vue/crud/dist/index.css"; import "@cool-vue/crud/dist/index.css";
// 调试、自定义crud
// import Crud from "../../../packages/crud/src";
// import "../../../packages/crud/src/static/index.scss";
export default (): Merge<ModuleConfig, CrudOptions> => { export default (): Merge<ModuleConfig, CrudOptions> => {
return { return {
options: { options: {

View File

@ -67,11 +67,11 @@ const Table = useTable({
} }
} }
}, },
{ label: "删除条数", prop: "count", minWidth: 120, sortable: "custom" }, { label: "删除条数", prop: "count", minWidth: 100, sortable: "custom" },
{ label: "创建时间", prop: "createTime", minWidth: 160, sortable: "desc" }, { label: "创建时间", prop: "createTime", minWidth: 160, sortable: "desc" },
{ {
type: "op", type: "op",
minWidth: 150, width: 120,
buttons: [ buttons: [
{ {
label: "恢复", label: "恢复",

View File

@ -280,10 +280,10 @@
"@babel/helper-validator-identifier" "^7.19.1" "@babel/helper-validator-identifier" "^7.19.1"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
"@cool-vue/crud@^6.2.2": "@cool-vue/crud@^6.3.1":
version "6.2.2" version "6.3.1"
resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-6.2.2.tgz#4e24bfb157307b5aef249476b4a41acd61217e30" resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-6.3.1.tgz#871d9788d43576337af92ebae5b770dd16ee7826"
integrity sha512-0NBn8ZtbjJ85HkuVWueEmJ8+Uvc+yNezGO12f3AuHn0Ru1uVk5Dmy3EFDK5XhoWurOmTgk1lDaG3/G+CCgtCtw== integrity sha512-mbAaumXavoVW4wtShZpQb0lKG9VHGfvrsUgnVt78zi7TVB32+9duasMjf2Y3gz6HM1p1FODMPhfkCOXGbpOHyA==
dependencies: dependencies:
array.prototype.flat "^1.2.4" array.prototype.flat "^1.2.4"
core-js "^3.21.1" core-js "^3.21.1"