chore: format code style (#3808)

* first commit

* style: format code style

* style: format code style
This commit is contained in:
zhang 2024-05-06 08:46:25 +08:00 committed by GitHub
parent ba5b8f8506
commit ef5285385f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 59 additions and 95 deletions

View File

@ -4,11 +4,7 @@ import type { NamePath } from 'ant-design-vue/lib/form/interface';
import { unref, toRaw, nextTick } from 'vue'; import { unref, toRaw, nextTick } from 'vue';
import { isArray, isFunction, isObject, isString, isDef, isNil } from '@/utils/is'; import { isArray, isFunction, isObject, isString, isDef, isNil } from '@/utils/is';
import { deepMerge } from '@/utils'; import { deepMerge } from '@/utils';
import { import { dateItemType, defaultValueComponents, isIncludeSimpleComponents } from '../helper';
dateItemType,
defaultValueComponents,
isIncludeSimpleComponents,
} from '../helper';
import { dateUtil } from '@/utils/dateUtil'; import { dateUtil } from '@/utils/dateUtil';
import { cloneDeep, has, uniqBy, get } from 'lodash-es'; import { cloneDeep, has, uniqBy, get } from 'lodash-es';
import { error } from '@/utils/log'; import { error } from '@/utils/log';
@ -76,7 +72,7 @@ export function useFormEvents({
const validKeys: string[] = []; const validKeys: string[] = [];
fields.forEach((key) => { fields.forEach((key) => {
const schema = unref(getSchema).find((item) => item.field === key); const schema = unref(getSchema).find((item) => item.field === key);
let value = get(values, key); const value = get(values, key);
const hasKey = has(values, key); const hasKey = has(values, key);
const { componentProps } = schema || {}; const { componentProps } = schema || {};
let _props = componentProps as any; let _props = componentProps as any;

View File

@ -32,13 +32,9 @@
<HeaderCell :column="column" /> <HeaderCell :column="column" />
</slot> </slot>
</template> </template>
<!-- 增加对antdv3.x兼容 -->
<template #bodyCell="data"> <template #bodyCell="data">
<slot name="bodyCell" v-bind="data || {}"></slot> <slot name="bodyCell" v-bind="data || {}"></slot>
</template> </template>
<!-- <template #[`header-${column.dataIndex}`] v-for="(column, index) in columns" :key="index">-->
<!-- <HeaderCell :column="column" />-->
<!-- </template>-->
</Table> </Table>
</div> </div>
</template> </template>

View File

@ -369,11 +369,9 @@
if (!props.record.editValueRefs) props.record.editValueRefs = {}; if (!props.record.editValueRefs) props.record.editValueRefs = {};
props.record.editValueRefs[props.column.dataIndex as any] = currentValueRef; props.record.editValueRefs[props.column.dataIndex as any] = currentValueRef;
} }
/* eslint-disable */
props.record.onCancelEdit = () => { props.record.onCancelEdit = () => {
isArray(props.record?.cancelCbs) && props.record?.cancelCbs.forEach((fn) => fn()); isArray(props.record?.cancelCbs) && props.record?.cancelCbs.forEach((fn) => fn());
}; };
/* eslint-disable */
props.record.onSubmitEdit = async () => { props.record.onSubmitEdit = async () => {
if (isArray(props.record?.submitCbs)) { if (isArray(props.record?.submitCbs)) {
if (!props.record?.onValid?.()) return; if (!props.record?.onValid?.()) return;
@ -508,7 +506,7 @@
} }
.@{prefix-cls} { .@{prefix-cls} {
position: relative; position: relative;
min-height: 24px; //hover min-height: 24px; // hover
&__wrapper { &__wrapper {
display: flex; display: flex;

View File

@ -193,8 +193,8 @@
const list = (fileList.value || []) const list = (fileList.value || [])
.filter((item) => item?.status === UploadResultStatus.DONE) .filter((item) => item?.status === UploadResultStatus.DONE)
.map((item: any) => { .map((item: any) => {
if(item?.response && props?.resultField){ if (item?.response && props?.resultField) {
return item?.response return item?.response;
} }
return item?.url || item?.response?.url; return item?.url || item?.response?.url;
}); });

View File

@ -19,10 +19,10 @@
import { downloadByUrl } from '@/utils/file/download'; import { downloadByUrl } from '@/utils/file/download';
import { createPreviewColumns, createPreviewActionColumn } from './data'; import { createPreviewColumns, createPreviewActionColumn } from './data';
import { useI18n } from '@/hooks/web/useI18n'; import { useI18n } from '@/hooks/web/useI18n';
import { isArray } from '@/utils/is'; import { isArray, isFunction } from '@/utils/is';
import { BasicColumn } from '@/components/Table'; import { BasicColumn } from '@/components/Table';
import { isFunction } from '@/utils/is';
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const props = defineProps(previewProps); const props = defineProps(previewProps);

View File

@ -15,12 +15,14 @@ type SortableOptions = Merge<
} }
>; >;
type previewColumnsFnType = { type previewColumnsFnType = {
handleRemove:(record:Record<string,any>,key:string)=>any, handleRemove: (record: Record<string, any>, key: string) => any;
handleAdd:(record:Record<string,any>,key:string)=>any, handleAdd: (record: Record<string, any>, key: string) => any;
} };
export const previewType = { export const previewType = {
previewColumns: { previewColumns: {
type: [Array,Function] as PropType<BasicColumn[] | ((arg:previewColumnsFnType) => BasicColumn[])>, type: [Array, Function] as PropType<
BasicColumn[] | ((arg: previewColumnsFnType) => BasicColumn[])
>,
required: false, required: false,
}, },
beforePreviewData: { beforePreviewData: {

View File

@ -1,28 +1,23 @@
<template> <template>
<Alert message="基础示例" />
<Alert message="基础示例" /> <BasicUpload
<BasicUpload :maxSize="20"
:maxSize="20" :maxNumber="10"
:maxNumber="10" @change="handleChange"
@change="handleChange" :api="uploadApi"
:api="uploadApi" class="my-5"
class="my-5" :accept="['image/*']"
:accept="['image/*']" />
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { BasicUpload } from '@/components/Upload';
import { uploadApi } from '@/api/sys/upload';
import { useMessage } from '@/hooks/web/useMessage';
const { createMessage } = useMessage();
import { Alert } from 'ant-design-vue'; import { Alert } from 'ant-design-vue';
import { BasicUpload } from '@/components/Upload';
import { useMessage } from '@/hooks/web/useMessage';
import { uploadApi } from '@/api/sys/upload';
const { createMessage } = useMessage();
function handleChange(list: string[]) { function handleChange(list: string[]) {
createMessage.success(`已上传文件${JSON.stringify(list)}`); createMessage.success(`已上传文件${JSON.stringify(list)}`);
} }
</script> </script>
<style scoped>
</style>

View File

@ -4,11 +4,13 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { uploadApi } from '@/api/sys/upload';
import { useMessage } from '@/hooks/web/useMessage';
const { createMessage } = useMessage();
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { Alert } from 'ant-design-vue'; import { Alert } from 'ant-design-vue';
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { useMessage } from '@/hooks/web/useMessage';
import { uploadApi } from '@/api/sys/upload';
const { createMessage } = useMessage();
const schemasValiate: FormSchema[] = [ const schemasValiate: FormSchema[] = [
{ {
field: 'field1', field: 'field1',
@ -52,5 +54,3 @@
}, },
}); });
</script> </script>
<style scoped></style>

View File

@ -1,14 +1,16 @@
<template> <template>
<Alert message="嵌入表单,加入resultFiled自定义返回值" /> <Alert message="嵌入表单,加入resultFiled自定义返回值" />
<BasicForm @register="registerCustom" class="my-5" /> <BasicForm @register="registerCustom" class="my-5" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { uploadApi } from '@/api/sys/upload';
import { useMessage } from '@/hooks/web/useMessage';
const { createMessage } = useMessage();
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { Alert } from 'ant-design-vue'; import { Alert } from 'ant-design-vue';
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { useMessage } from '@/hooks/web/useMessage';
import { uploadApi } from '@/api/sys/upload';
const { createMessage } = useMessage();
const schemasCustom: FormSchema[] = [ const schemasCustom: FormSchema[] = [
{ {
field: 'field3', field: 'field3',
@ -69,5 +71,3 @@
}, },
}); });
</script> </script>
<style scoped></style>

View File

@ -4,12 +4,14 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { uploadApi } from '@/api/sys/upload';
import { useMessage } from '@/hooks/web/useMessage';
const { createMessage } = useMessage();
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { Alert, Button } from 'ant-design-vue';
import { createVNode } from 'vue'; import { createVNode } from 'vue';
import { Alert, Button } from 'ant-design-vue';
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { useMessage } from '@/hooks/web/useMessage';
import { uploadApi } from '@/api/sys/upload';
const { createMessage } = useMessage();
const schemasPreview: FormSchema[] = [ const schemasPreview: FormSchema[] = [
{ {
field: 'field5', field: 'field5',
@ -82,8 +84,8 @@
component: 'Upload', component: 'Upload',
label: '字段6', label: '字段6',
componentProps: { componentProps: {
maxNumber:2, maxNumber: 2,
previewColumns: ({ handleRemove, handleAdd}) => { previewColumns: ({ handleRemove, handleAdd }) => {
return [ return [
{ {
title: 'url6', title: 'url6',
@ -101,8 +103,8 @@
createVNode( createVNode(
Button, Button,
{ {
type:"primary", type: 'primary',
style:"margin:4px", style: 'margin:4px',
onclick: () => { onclick: () => {
handleAdd( handleAdd(
{ url6: 'https://vebn.oss-cn-beijing.aliyuncs.com/vben/logo.png' }, { url6: 'https://vebn.oss-cn-beijing.aliyuncs.com/vben/logo.png' },
@ -115,7 +117,7 @@
createVNode( createVNode(
Button, Button,
{ {
danger:true, danger: true,
onclick: () => { onclick: () => {
handleRemove({ url6: record.url6 }, 'url6'); handleRemove({ url6: record.url6 }, 'url6');
}, },
@ -125,7 +127,6 @@
]); ]);
}, },
}, },
]; ];
}, },
beforePreviewData: (arg) => { beforePreviewData: (arg) => {
@ -158,7 +159,6 @@
}); });
}, },
}, },
}, },
]; ];
const [registerPreview, { getFieldsValue: getFieldsValuePreview }] = useForm({ const [registerPreview, { getFieldsValue: getFieldsValuePreview }] = useForm({
@ -176,5 +176,3 @@
}, },
}); });
</script> </script>
<style scoped></style>

View File

@ -1,9 +1,9 @@
<template> <template>
<PageWrapper title="上传组件示例"> <PageWrapper title="上传组件示例">
<Upload1></Upload1> <Upload1 />
<Upload2></Upload2> <Upload2 />
<Upload3></Upload3> <Upload3 />
<Upload4></Upload4> <Upload4 />
</PageWrapper> </PageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>

View File

@ -45,7 +45,6 @@
}, },
{ {
field: '0', field: '0',
// component: 'Input',
label: ' ', label: ' ',
slot: 'add', slot: 'add',
}, },

View File

@ -80,7 +80,6 @@
}, },
{ {
field: 'field3', field: 'field3',
// component: 'Input',
label: '自定义Slot', label: '自定义Slot',
slot: 'f3', slot: 'f3',
colProps: { colProps: {
@ -233,6 +232,7 @@
createMessage.success('click search,values:' + JSON.stringify(values)); createMessage.success('click search,values:' + JSON.stringify(values));
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.local_form) .local_typeValue { :deep(.local_form) .local_typeValue {
width: calc(100% - 120px); width: calc(100% - 120px);

View File

@ -119,14 +119,11 @@
rules: [ rules: [
{ {
required: true, required: true,
// @ts-ignore validator: async (_, value) => {
validator: async (rule, value) => {
if (!value) { if (!value) {
/* eslint-disable-next-line */
return Promise.reject('值不能为空'); return Promise.reject('值不能为空');
} }
if (value === '1') { if (value === '1') {
/* eslint-disable-next-line */
return Promise.reject('值不能为1'); return Promise.reject('值不能为1');
} }
return Promise.resolve(); return Promise.resolve();

View File

@ -160,7 +160,6 @@
colProps: { colProps: {
span: 8, span: 8,
}, },
// componentProps:{},
// can func // can func
componentProps: ({ schema, formModel }) => { componentProps: ({ schema, formModel }) => {
console.log('form:', schema); console.log('form:', schema);
@ -460,7 +459,6 @@
}, },
{ {
field: 'field31', field: 'field31',
// component: 'Input',
label: '下拉本地搜索', label: '下拉本地搜索',
helpMessage: ['ApiSelect组件', '远程数据源本地搜索', '只发起一次请求获取所有选项'], helpMessage: ['ApiSelect组件', '远程数据源本地搜索', '只发起一次请求获取所有选项'],
required: true, required: true,
@ -475,7 +473,6 @@
}, },
{ {
field: 'field32', field: 'field32',
// component: 'Input',
label: '下拉远程搜索', label: '下拉远程搜索',
helpMessage: ['ApiSelect组件', '将关键词发送到接口进行远程搜索'], helpMessage: ['ApiSelect组件', '将关键词发送到接口进行远程搜索'],
required: true, required: true,
@ -690,7 +687,6 @@
}, },
{ {
field: 'selectA', field: 'selectA',
// component: 'Select',
label: '互斥SelectA', label: '互斥SelectA',
slot: 'selectA', slot: 'selectA',
defaultValue: [], defaultValue: [],
@ -700,7 +696,6 @@
}, },
{ {
field: 'selectB', field: 'selectB',
// component: 'Select',
label: '互斥SelectB', label: '互斥SelectB',
slot: 'selectB', slot: 'selectB',
defaultValue: [], defaultValue: [],

View File

@ -135,7 +135,6 @@
width: 250, width: 250,
title: 'Action', title: 'Action',
dataIndex: 'action', dataIndex: 'action',
// slots: { customRender: 'action' },
}, },
showSelectionBar: true, // showSelectionBar: true, //
}); });

View File

@ -38,14 +38,12 @@
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
helpMessage: <div>这个是tsx渲染出来的helpMessage</div>, helpMessage: <div>这个是tsx渲染出来的helpMessage</div>,
// slots: { customRender: 'id' },
}, },
{ {
title: '头像', title: '头像',
dataIndex: 'avatar', dataIndex: 'avatar',
width: 100, width: 100,
helpMessage: h('div', '这是vue h函数渲染出来的helpMessage'), helpMessage: h('div', '这是vue h函数渲染出来的helpMessage'),
// slots: { customRender: 'avatar' },
}, },
{ {
title: '分类', title: '分类',
@ -53,7 +51,6 @@
width: 80, width: 80,
align: 'center', align: 'center',
defaultHidden: true, defaultHidden: true,
// slots: { customRender: 'category' },
}, },
{ {
title: '姓名', title: '姓名',
@ -65,13 +62,11 @@
dataIndex: 'imgArr', dataIndex: 'imgArr',
helpMessage: ['这是简单模式的图片列表', '只会显示一张在表格中', '但点击可预览多张图片'], helpMessage: ['这是简单模式的图片列表', '只会显示一张在表格中', '但点击可预览多张图片'],
width: 140, width: 140,
// slots: { customRender: 'img' },
}, },
{ {
title: '照片列表2', title: '照片列表2',
dataIndex: 'imgs', dataIndex: 'imgs',
width: 160, width: 160,
// slots: { customRender: 'imgs' },
}, },
{ {
title: '地址', title: '地址',
@ -80,7 +75,6 @@
{ {
title: '编号', title: '编号',
dataIndex: 'no', dataIndex: 'no',
// slots: { customRender: 'no' },
}, },
{ {
title: '开始时间', title: '开始时间',

View File

@ -238,7 +238,6 @@
width: 160, width: 160,
title: 'Action', title: 'Action',
dataIndex: 'action', dataIndex: 'action',
// slots: { customRender: 'action' },
}, },
}); });

View File

@ -54,7 +54,6 @@
title: 'Action', title: 'Action',
dataIndex: 'action', dataIndex: 'action',
fixed: 'right', fixed: 'right',
// slots: { customRender: 'action' },
}, },
}); });
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {

View File

@ -142,13 +142,11 @@ export function getCustomHeaderColumns(): BasicColumn[] {
// title: '姓名', // title: '姓名',
dataIndex: 'name', dataIndex: 'name',
width: 120, width: 120,
// slots: { title: 'customTitle' },
}, },
{ {
// title: '地址', // title: '地址',
dataIndex: 'address', dataIndex: 'address',
width: 120, width: 120,
// slots: { title: 'customAddress' },
sorter: true, sorter: true,
}, },
@ -252,7 +250,6 @@ export function getFormConfig(): Partial<FormProps> {
{ {
field: `field11`, field: `field11`,
label: `Slot示例`, label: `Slot示例`,
// component: 'Select',
slot: 'custom', slot: 'custom',
colProps: { colProps: {
xl: 12, xl: 12,

View File

@ -87,7 +87,7 @@
} }
const actionList: TreeActionItem[] = [ const actionList: TreeActionItem[] = [
{ {
// show:()=>boolean; // show:() => boolean;
render: (node) => { render: (node) => {
return h(PlusOutlined, { return h(PlusOutlined, {
class: 'ml-2', class: 'ml-2',