This commit is contained in:
神仙都没用 2023-10-18 16:14:13 +08:00
parent 67e94cda63
commit 8109e99653
9 changed files with 41 additions and 48 deletions

View File

@ -9,7 +9,7 @@
"lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix"
},
"dependencies": {
"@cool-vue/crud": "^7.0.1-beta4",
"@cool-vue/crud": "^7.0.1-beta6",
"@element-plus/icons-vue": "^2.1.0",
"@vueuse/core": "^10.4.0",
"@wangeditor/editor": "^5.1.23",

View File

@ -56,8 +56,8 @@ declare type List<T> = Array<DeepPartial<T> | (() => DeepPartial<T>)>;
// 字典选项
declare type DictOptions = {
label: string;
value: any;
label?: string;
value?: any;
color?: string;
type?: string;
[key: string]: any;

View File

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

View File

@ -29,15 +29,14 @@ export function parseTableDict(value: any, item: ClTable.Column) {
// 设置颜色
if (item.dictColor) {
options.forEach((e, i) => {
if (!e.color) {
e.color = style.colors[i];
}
});
}
// 格式化方法
const formatter = item.dictFormatter;
// 多个值
const values = isArray(value) ? value : [value];
// 绑定值
const values = (isArray(value) ? value : [value]).filter((e) => e !== undefined);
// 返回值
const list = values.map((v) => {
@ -48,8 +47,8 @@ export function parseTableDict(value: any, item: ClTable.Column) {
});
// 是否格式化
if (formatter) {
return formatter(list);
if (item.dictFormatter) {
return item.dictFormatter(list);
} else {
return list.map((e) => {
return h(
@ -66,14 +65,14 @@ export function parseTableDict(value: any, item: ClTable.Column) {
/**
* table.op.buttons
*/
export function parseTableOpButtons(buttons: any, { scope }: any) {
export function parseTableOpButtons(buttons: any[], { scope }: any) {
const { crud } = useCore();
const { style } = useConfig();
const slots = useSlots();
const list = getValue(buttons, { scope }) || ["edit", "delete"];
const list: any[] = getValue(buttons, { scope }) || ["edit", "delete"];
return list.map((vnode: any) => {
return list.map((vnode) => {
if (vnode === "info") {
return (
<el-button

View File

@ -74,15 +74,15 @@ export declare function useForm(): {
name?: string | undefined;
options?: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[] | {
value: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[];
@ -105,15 +105,15 @@ export declare function useForm(): {
name?: string | undefined;
options?: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[] | {
value: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[];
@ -136,15 +136,15 @@ export declare function useForm(): {
name?: string | undefined;
options?: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[] | {
value: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[];

View File

@ -13,15 +13,15 @@ export declare function useTable(props: any): {
name?: string | undefined;
options?: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[] | {
value: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[];
@ -41,15 +41,15 @@ export declare function useTable(props: any): {
};
dict: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[] | {
value: {
[x: string]: any;
label: string;
value: any;
label?: string | undefined;
value?: any;
color?: string | undefined;
type?: string | undefined;
}[];

View File

@ -12,7 +12,7 @@ export declare function parseTableDict(value: any, item: ClTable.Column): string
/**
* table.op.buttons
*/
export declare function parseTableOpButtons(buttons: any, { scope }: any): any;
export declare function parseTableOpButtons(buttons: any[], { scope }: any): any[];
/**
*
*/

View File

@ -9,13 +9,7 @@
</cl-row>
<cl-row>
<cl-table
ref="Table"
:default-sort="{
prop: 'createTime',
order: 'descending'
}"
/>
<cl-table ref="Table" />
</cl-row>
<cl-row>
@ -154,7 +148,7 @@ const Table = useTable({
{
prop: "createTime",
label: "创建时间",
sortable: "custom",
sortable: "desc",
minWidth: 160
},
{

View File

@ -282,10 +282,10 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"
"@cool-vue/crud@^7.0.1-beta4":
version "7.0.1-beta4"
resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.1-beta4.tgz#2bc541296edcb2af83aa5c7094795c996beff41f"
integrity sha512-dD0lKPTSR5LGPJU9GHLyx/1fcGDq2Mnw6kj8rCLIqXlnDP78ufmE6iYVk2U23qgjxEDonHnij3/w6OmtRa1Vzg==
"@cool-vue/crud@^7.0.1-beta6":
version "7.0.1-beta6"
resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.1-beta6.tgz#dc3b8d6c607fba4dc2b4b40f6906c8a70f58bb49"
integrity sha512-DtUvZc4EQtfANvPMv9ydfNJxcmXsOaoUiWEf66vRSzDeOZ1K0a1u1Ha0y7R09C2HC2wla8GvKv0ySxM9aDLXNQ==
dependencies:
array.prototype.flat "^1.2.4"
core-js "^3.21.1"