This commit is contained in:
神仙都没用 2024-12-30 14:24:14 +08:00
parent a3666a2b8f
commit e931fd7ec6
5 changed files with 35 additions and 30 deletions

View File

@ -98,23 +98,23 @@ const Table = useTable({
{ {
prop: 'name', prop: 'name',
label: '姓名', label: '姓名',
minWidth: 150 minWidth: 120
}, },
{ {
prop: 'nickName', prop: 'nickName',
label: '昵称', label: '昵称',
minWidth: 150 minWidth: 120
}, },
{ {
prop: 'departmentName', prop: 'departmentName',
label: '部门名称', label: '部门名称',
minWidth: 150 minWidth: 120
}, },
{ {
prop: 'roleName', prop: 'roleName',
label: '角色', label: '角色',
headerAlign: 'center', headerAlign: 'center',
minWidth: 150, minWidth: 160,
dict: [], dict: [],
formatter(row) { formatter(row) {
return row.roleName?.split(','); return row.roleName?.split(',');
@ -123,7 +123,7 @@ const Table = useTable({
{ {
prop: 'status', prop: 'status',
label: '状态', label: '状态',
minWidth: 120, minWidth: 100,
component: { component: {
name: 'cl-switch' name: 'cl-switch'
} }
@ -131,12 +131,13 @@ const Table = useTable({
{ {
prop: 'phone', prop: 'phone',
label: '手机号码', label: '手机号码',
minWidth: 150 minWidth: 120
}, },
{ {
prop: 'remark', prop: 'remark',
label: '备注', label: '备注',
minWidth: 150 minWidth: 200,
showOverflowTooltip: true
}, },
{ {
prop: 'createTime', prop: 'createTime',

View File

@ -1,17 +1,13 @@
import { defineComponent, } from 'vue'; import { defineComponent, } from 'vue';
import { CrudProps } from '../..';
export default defineComponent({ export default defineComponent({
name: 'cl-render', name: 'cl-render',
props: { props: {
...CrudProps,
modelValue: null, modelValue: null,
scope: Object, placeholder: String,
prop: String,
disabled: Boolean,
isDisabled: Boolean,
row: Object,
column: Object,
placeholder: String
}, },
setup(props, { slots, }) { setup(props, { slots, }) {

10
src/plugins/crud/index.ts Normal file
View File

@ -0,0 +1,10 @@
export const CrudProps = {
prop: String, // Key
column: Object, // 列数据
row: Object, // 行数据
index: Number, // 行索引
scope: Object, // 表单作用域
disabled: Boolean, // 是否禁用
isEdit: Boolean, // 是否编辑
isDisabled: Boolean // 是否禁用
};

View File

@ -10,7 +10,6 @@
:title="title" :title="title"
:scrollbar="isScroll" :scrollbar="isScroll"
append-to-body append-to-body
v-bind="$attrs"
> >
<div class="cl-editor-preview"> <div class="cl-editor-preview">
<el-tabs v-if="list.length > 1" v-model="active" type="card" @tab-change="onTabChange"> <el-tabs v-if="list.length > 1" v-model="active" type="card" @tab-change="onTabChange">
@ -34,7 +33,9 @@
:name="`cl-editor-${name}`" :name="`cl-editor-${name}`"
height="100%" height="100%"
preview preview
v-if="name"
/> />
<el-text v-else>{{ content }}</el-text>
<slot name="append"></slot> <slot name="append"></slot>
</div> </div>
@ -51,8 +52,9 @@
import { useClipboard } from '@vueuse/core'; import { useClipboard } from '@vueuse/core';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import { isObject, isString } from 'lodash-es'; import { isObject, isString } from 'lodash-es';
import { nextTick, ref, computed, type PropType } from 'vue'; import { nextTick, ref, computed, type PropType, useAttrs, mergeProps } from 'vue';
import { useCool } from '/@/cool'; import { useCool } from '/@/cool';
import { CrudProps } from '../../crud';
interface TabItem { interface TabItem {
name: string; name: string;
@ -61,12 +63,10 @@ interface TabItem {
} }
const props = defineProps({ const props = defineProps({
...CrudProps,
modelValue: String, modelValue: String,
title: String, title: String,
name: { name: String,
type: String,
required: true
},
text: { text: {
type: String, type: String,
default: '点击查看' default: '点击查看'
@ -84,10 +84,8 @@ const props = defineProps({
default: '60%' default: '60%'
}, },
formatter: Function, formatter: Function,
// //
tabs: Array as PropType<TabItem[]>, tabs: Array as PropType<TabItem[]>,
// //
props: Object props: Object
}); });
@ -154,6 +152,8 @@ async function open(data?: string | TabItem[]) {
visible.value = true; visible.value = true;
} }
function onOpened() {}
// //
function setContent(val: any) { function setContent(val: any) {
if (isString(val)) { if (isString(val)) {

View File

@ -131,7 +131,7 @@
</template> </template>
<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, mergeProps } from 'vue';
import { isArray, isEmpty, isNumber } from 'lodash-es'; import { isArray, isEmpty, isNumber } from 'lodash-es';
import VueDraggable from 'vuedraggable'; import VueDraggable from 'vuedraggable';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
@ -144,8 +144,10 @@ import { getUrls, getType } from '../utils';
import { useUpload } from '../hooks'; import { useUpload } from '../hooks';
import UploadItem from './upload-item/index.vue'; import UploadItem from './upload-item/index.vue';
import type { Upload } from '../types'; import type { Upload } from '../types';
import { CrudProps } from '../../crud';
const props = defineProps({ const props = defineProps({
...CrudProps,
// //
modelValue: { modelValue: {
type: [String, Array], type: [String, Array],
@ -200,15 +202,11 @@ const props = defineProps({
// //
beforeUpload: Function, beforeUpload: Function,
// //
prefixPath: String, prefixPath: String
// CRUD穿
isEdit: Boolean,
scope: Object,
prop: String,
isDisabled: Boolean
}); });
mergeProps(props, CrudProps);
const emit = defineEmits(['update:modelValue', 'change', 'upload', 'success', 'error', 'progress']); const emit = defineEmits(['update:modelValue', 'change', 'upload', 'success', 'error', 'progress']);
const { refs, setRefs } = useCool(); const { refs, setRefs } = useCool();