This commit is contained in:
神仙都没用 2024-02-27 18:44:23 +08:00
parent 0f66f0f015
commit 5219edd281
16 changed files with 118 additions and 99 deletions

View File

@ -9,8 +9,8 @@
"lint:eslint": "eslint \"./src/**/*.{vue,ts,tsx}\" --fix" "lint:eslint": "eslint \"./src/**/*.{vue,ts,tsx}\" --fix"
}, },
"dependencies": { "dependencies": {
"@cool-vue/crud": "^7.1.14", "@cool-vue/crud": "^7.1.15",
"@element-plus/icons-vue": "^2.1.0", "@element-plus/icons-vue": "^2.3.1",
"@vueuse/core": "^10.4.0", "@vueuse/core": "^10.4.0",
"@wangeditor/editor": "^5.1.23", "@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12", "@wangeditor/editor-for-vue": "^5.1.12",
@ -19,7 +19,7 @@
"core-js": "^3.32.1", "core-js": "^3.32.1",
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
"echarts": "^5.4.3", "echarts": "^5.4.3",
"element-plus": "^2.5.4", "element-plus": "^2.5.6",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"marked": "^11.1.1", "marked": "^11.1.1",

View File

@ -104,7 +104,9 @@ declare namespace Render {
options?: DictOptions | Vue.Ref<DictOptions>; options?: DictOptions | Vue.Ref<DictOptions>;
props?: Props | Vue.Ref<Props>; props?: Props | Vue.Ref<Props>;
style?: obj; style?: obj;
functionSlot?: boolean; slots?: {
[key: string]: (data?: any) => any;
};
vm?: any; vm?: any;
[key: string]: any; [key: string]: any;
} }
@ -718,11 +720,6 @@ declare interface Config {
events: { events: {
[key: string]: (...args: any[]) => any; [key: string]: (...args: any[]) => any;
}; };
render: {
functionSlots: {
exclude: string[];
};
};
style: { style: {
size: ElementPlus.Size; size: ElementPlus.Size;
colors: string[]; colors: string[];

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-vue/crud", "name": "@cool-vue/crud",
"version": "7.1.14", "version": "7.1.15",
"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

@ -68,12 +68,7 @@ function setConfig(app: App, options: Options = {}) {
} }
} }
}, },
events: {}, events: {}
render: {
functionSlots: {
exclude: ["el-date-picker", "el-cascader", "el-time-select"]
}
}
}, },
options || {} options || {}
); );

View File

@ -31,9 +31,6 @@ const regs: Map<string, any> = new Map();
// 解析节点 // 解析节点
export function parseNode(vnode: any, options: Options): VNode { export function parseNode(vnode: any, options: Options): VNode {
const { scope, prop, slots, children, _data } = options || []; const { scope, prop, slots, children, _data } = options || [];
const {
render: { functionSlots }
} = useConfig();
// 渲染后组件 // 渲染后组件
let comp: VNode | null = null; let comp: VNode | null = null;
@ -85,17 +82,13 @@ export function parseNode(vnode: any, options: Options): VNode {
if (vnode.vm) { if (vnode.vm) {
comp = h(regs.get(vnode.name), props); comp = h(regs.get(vnode.name), props);
} else { } else {
// 是否函数式插槽
const isFunctionSlot =
!functionSlots.exclude?.includes(vnode.name) &&
(vnode.functionSlot === undefined ? true : vnode.functionSlot);
// 渲染组件 // 渲染组件
comp = h( comp = h(toRaw(resolveComponent(vnode.name)), props, {
toRaw(resolveComponent(vnode.name)), default() {
props, return children;
isFunctionSlot ? () => children : children },
); ...vnode.slots
});
} }
// 挂载到 refs 中 // 挂载到 refs 中

View File

@ -97,7 +97,9 @@ export declare function useForm(): {
}; };
} | undefined; } | undefined;
style?: obj | undefined; style?: obj | undefined;
functionSlot?: boolean | undefined; slots?: {
[key: string]: (data?: any) => any;
} | undefined;
vm?: any; vm?: any;
} | undefined; } | undefined;
component?: { component?: {
@ -128,7 +130,9 @@ export declare function useForm(): {
}; };
} | undefined; } | undefined;
style?: obj | undefined; style?: obj | undefined;
functionSlot?: boolean | undefined; slots?: {
[key: string]: (data?: any) => any;
} | undefined;
vm?: any; vm?: any;
} | undefined; } | undefined;
append?: { append?: {
@ -159,7 +163,9 @@ export declare function useForm(): {
}; };
} | undefined; } | undefined;
style?: obj | undefined; style?: obj | undefined;
functionSlot?: boolean | undefined; slots?: {
[key: string]: (data?: any) => any;
} | undefined;
vm?: any; vm?: any;
} | undefined; } | undefined;
rules?: { rules?: {

View File

@ -36,7 +36,9 @@ export declare function useTable(props: any): {
}; };
} | undefined; } | undefined;
style?: obj | undefined; style?: obj | undefined;
functionSlot?: boolean | undefined; slots?: {
[key: string]: (data?: any) => any;
} | undefined;
vm?: any; vm?: any;
}; };
search: { search: {
@ -73,7 +75,9 @@ export declare function useTable(props: any): {
}; };
} | undefined; } | undefined;
style?: obj | undefined; style?: obj | undefined;
functionSlot?: boolean | undefined; slots?: {
[key: string]: (data?: any) => any;
} | undefined;
vm?: any; vm?: any;
}; };
}; };

View File

@ -12,7 +12,10 @@ export default defineComponent({
default: UserFilled default: UserFilled
}, },
size: [String, Number] as PropType<"large" | "default" | "small" | number>, size: [String, Number] as PropType<"large" | "default" | "small" | number>,
shape: String as PropType<"circle" | "square">, shape: {
type: String as PropType<"circle" | "square">,
default: "square"
},
fit: { fit: {
type: String as PropType<"fill" | "contain" | "cover" | "none" | "scale-down">, type: String as PropType<"fill" | "contain" | "cover" | "none" | "scale-down">,
default: "cover" default: "cover"
@ -24,6 +27,8 @@ export default defineComponent({
return ( return (
<el-avatar <el-avatar
style={{ style={{
display: "block",
margin: "auto",
height: props.size + "px", height: props.size + "px",
width: props.size + "px" width: props.size + "px"
}} }}

View File

@ -57,7 +57,7 @@
</template> </template>
<script lang="ts" name="sys-user" setup> <script lang="ts" name="sys-user" setup>
import { useTable, useUpsert, useCrud } from "@cool-vue/crud"; import { useTable, useUpsert, useCrud, setFocus } from "@cool-vue/crud";
import { useCool } from "/@/cool"; import { useCool } from "/@/cool";
import DeptList from "./components/dept-list.vue"; import DeptList from "./components/dept-list.vue";
import UserMove from "./components/user-move.vue"; import UserMove from "./components/user-move.vue";
@ -296,7 +296,9 @@ const Upsert = useUpsert({
}) })
); );
}); });
} },
plugins: [setFocus("name")]
}); });
// //

View File

@ -57,6 +57,20 @@ function open() {
name: "el-input" name: "el-input"
} }
}, },
{
label: "手机号",
prop: "phone",
value: "13255022000",
component: {
name: "el-input",
//
slots: {
prepend() {
return "+86";
}
}
}
},
{ {
label: "年龄", label: "年龄",
prop: "age", prop: "age",

View File

@ -98,7 +98,7 @@ function refresh(params?: any) {
// //
function restore(id?: string) { function restore(id?: string) {
const ids = id ? [id] : Table.value?.selection; const ids = id ? [id] : Table.value?.selection.map((e) => e.id);
ElMessageBox.confirm("此操作将恢复被删除的数据,是否继续?", "提示", { ElMessageBox.confirm("此操作将恢复被删除的数据,是否继续?", "提示", {
type: "warning" type: "warning"

View File

@ -13,8 +13,8 @@ export default (): Merge<ModuleConfig, CrudOptions> => {
label: "CRUD", label: "CRUD",
description: "快速增删改查及一系列辅助组件", description: "快速增删改查及一系列辅助组件",
author: "COOL", author: "COOL",
version: "1.0.3", version: "1.0.4",
updateTime: "2024-02-20", updateTime: "2024-02-27",
demo: "/demo/crud", demo: "/demo/crud",
// 组件全注册 // 组件全注册
@ -44,11 +44,6 @@ export default (): Merge<ModuleConfig, CrudOptions> => {
}, },
// 按钮及提示文案 // 按钮及提示文案
label: locale.zhCn label: locale.zhCn
},
render: {
functionSlots: {
exclude: ["el-date-picker", "el-cascader", "el-time-select", "el-transfer"]
}
} }
}, },

View File

@ -272,7 +272,6 @@ onMounted(() => {
background-color: var(--el-fill-color-light); background-color: var(--el-fill-color-light);
border: 1px solid var(--el-fill-color-light); border: 1px solid var(--el-fill-color-light);
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 10px;
position: relative; position: relative;
audio { audio {

View File

@ -6,7 +6,7 @@
`cl-upload--${type}`, `cl-upload--${type}`,
{ {
'is-disabled': disabled, 'is-disabled': disabled,
'is-drag': drag 'is-multiple': multiple
} }
]" ]"
> >
@ -32,19 +32,14 @@
</template> </template>
<!-- 列表 --> <!-- 列表 -->
<draggable <vue-draggable
class="cl-upload__list" class="cl-upload__list"
tag="div" tag="div"
v-model="list" v-model="list"
ghost-class="Ghost" ghost-class="Ghost"
drag-class="Drag" drag-class="Drag"
:options="{
group: 'Upload',
animation: 300,
draggable: '.is-drag',
disabled: !draggable
}"
item-key="uid" item-key="uid"
:disabled="!draggable"
@end="update" @end="update"
v-if="showFileList" v-if="showFileList"
> >
@ -78,7 +73,7 @@
<component :is="icon" v-if="icon" /> <component :is="icon" v-if="icon" />
<picture-filled v-else /> <picture-filled v-else />
</el-icon> </el-icon>
<span v-if="text">{{ text }}</span> <span class="text" v-if="text">{{ text }}</span>
</div> </div>
</slot> </slot>
</el-upload> </el-upload>
@ -88,7 +83,6 @@
<!-- 列表 --> <!-- 列表 -->
<template #item="{ element: item, index }"> <template #item="{ element: item, index }">
<el-upload <el-upload
class="is-drag"
action="" action=""
:accept="accept" :accept="accept"
:show-file-list="false" :show-file-list="false"
@ -104,7 +98,6 @@
" "
:headers="headers" :headers="headers"
:disabled="disabled" :disabled="disabled"
v-if="showFileList"
> >
<slot name="item" :item="item" :index="index"> <slot name="item" :item="item" :index="index">
<div class="cl-upload__item"> <div class="cl-upload__item">
@ -120,7 +113,7 @@
</slot> </slot>
</el-upload> </el-upload>
</template> </template>
</draggable> </vue-draggable>
</div> </div>
</div> </div>
</template> </template>
@ -128,7 +121,7 @@
<script lang="ts" setup name="cl-upload"> <script lang="ts" setup name="cl-upload">
import { computed, ref, watch, type PropType, nextTick } from "vue"; import { computed, ref, watch, type PropType, nextTick } from "vue";
import { isArray, isNumber } from "lodash-es"; import { isArray, isNumber } from "lodash-es";
import Draggable from "vuedraggable"; import VueDraggable from "vuedraggable";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { PictureFilled, UploadFilled } from "@element-plus/icons-vue"; import { PictureFilled, UploadFilled } from "@element-plus/icons-vue";
import { useForm } from "@cool-vue/crud"; import { useForm } from "@cool-vue/crud";
@ -495,10 +488,6 @@ defineExpose({
user-select: none; user-select: none;
} }
&__item {
margin: 0 5px 5px 0;
}
&__demo { &__demo {
font-size: 13px; font-size: 13px;
@ -515,16 +504,18 @@ defineExpose({
} }
} }
&__file-btn {
margin-bottom: 10px;
}
:deep(.el-upload) { :deep(.el-upload) {
&.is-drag { display: block;
.el-upload-dragger { .el-upload-dragger {
padding: 0; padding: 0;
border: 0; border: 0;
background-color: transparent !important; background-color: transparent !important;
position: relative; position: relative;
background-color: red;
$color: var(--el-color-primary);
&.is-dragover { &.is-dragover {
&::after { &::after {
@ -538,8 +529,7 @@ defineExpose({
pointer-events: none; pointer-events: none;
border-radius: 8px; border-radius: 8px;
box-sizing: border-box; box-sizing: border-box;
border: 1px dashed var(--color-primary); border: 1px dashed var(--el-color-primary);
}
} }
} }
} }
@ -556,6 +546,12 @@ defineExpose({
} }
} }
&.is-multiple {
.cl-upload__item {
margin: 0 5px 5px 0;
}
}
&:not(.is-disabled) { &:not(.is-disabled) {
.cl-upload__demo { .cl-upload__demo {
&:hover { &:hover {
@ -563,13 +559,5 @@ defineExpose({
} }
} }
} }
&--file {
&:not(.is-drag) {
.cl-upload__list {
margin-top: 10px;
}
}
}
} }
</style> </style>

File diff suppressed because one or more lines are too long

View File

@ -282,10 +282,10 @@
"@babel/helper-validator-identifier" "^7.22.20" "@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
"@cool-vue/crud@^7.1.13": "@cool-vue/crud@^7.1.15":
version "7.1.13" version "7.1.15"
resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-7.1.13.tgz#8c150d0f0ccbe466628a1190ac19219054e93cca" resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.1.15.tgz#fca31c2e822657cf3bc663301f61a60a551b5bdf"
integrity sha512-e5Mt5HjYpr89sF+dMqudGHrcSP8KVdzNrn8hHEqgcpc1J7oAxyMtS8Wq2XjJY4XkxSZP7xeBEC6yqNgSQOYKyw== integrity sha512-46AK1mRRvVqas11vFLkkXpE+9Q9ppTIr+pr5Mconcu/PHThf5tCgSTexvtfe8sd1bpA45tFjkJHTVg4IbjqFiA==
dependencies: dependencies:
array.prototype.flat "^1.2.4" array.prototype.flat "^1.2.4"
core-js "^3.21.1" core-js "^3.21.1"
@ -299,7 +299,7 @@
resolved "https://registry.yarnpkg.com/@ctrl/tinycolor/-/tinycolor-3.6.1.tgz#b6c75a56a1947cc916ea058772d666a2c8932f31" resolved "https://registry.yarnpkg.com/@ctrl/tinycolor/-/tinycolor-3.6.1.tgz#b6c75a56a1947cc916ea058772d666a2c8932f31"
integrity sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA== integrity sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA==
"@element-plus/icons-vue@^2.1.0", "@element-plus/icons-vue@^2.3.1": "@element-plus/icons-vue@^2.3.1":
version "2.3.1" version "2.3.1"
resolved "https://registry.yarnpkg.com/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz#1f635ad5fdd5c85ed936481525570e82b5a8307a" resolved "https://registry.yarnpkg.com/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz#1f635ad5fdd5c85ed936481525570e82b5a8307a"
integrity sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg== integrity sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg==
@ -1756,6 +1756,27 @@ element-plus@^2.5.4:
memoize-one "^6.0.0" memoize-one "^6.0.0"
normalize-wheel-es "^1.2.0" normalize-wheel-es "^1.2.0"
element-plus@^2.5.6:
version "2.5.6"
resolved "https://registry.yarnpkg.com/element-plus/-/element-plus-2.5.6.tgz#d63dabc6330c0e2abe6f97cf99013a30140940d1"
integrity sha512-zctKTiyIDmcnMp3K5WG1hglgraW9EbiCLiIDVtaMCS5mPMl2fRKdS0vOFGnECIq9taFoxnyoDwxHD81nv0B4RA==
dependencies:
"@ctrl/tinycolor" "^3.4.1"
"@element-plus/icons-vue" "^2.3.1"
"@floating-ui/dom" "^1.0.1"
"@popperjs/core" "npm:@sxzz/popperjs-es@^2.11.7"
"@types/lodash" "^4.14.182"
"@types/lodash-es" "^4.17.6"
"@vueuse/core" "^9.1.0"
async-validator "^4.2.5"
dayjs "^1.11.3"
escape-html "^1.0.3"
lodash "^4.17.21"
lodash-es "^4.17.21"
lodash-unified "^1.0.2"
memoize-one "^6.0.0"
normalize-wheel-es "^1.2.0"
emoji-regex@^8.0.0: emoji-regex@^8.0.0:
version "8.0.0" version "8.0.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"