Skip to content

Commit

Permalink
chore: format code style (#3808)
Browse files Browse the repository at this point in the history
* first commit

* style: format code style

* style: format code style
  • Loading branch information
zwtvip committed May 6, 2024
1 parent ba5b8f8 commit ef52853
Show file tree
Hide file tree
Showing 21 changed files with 54 additions and 90 deletions.
8 changes: 2 additions & 6 deletions src/components/Form/src/hooks/useFormEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import type { NamePath } from 'ant-design-vue/lib/form/interface';
import { unref, toRaw, nextTick } from 'vue';
import { isArray, isFunction, isObject, isString, isDef, isNil } from '@/utils/is';
import { deepMerge } from '@/utils';
import {
dateItemType,
defaultValueComponents,
isIncludeSimpleComponents,
} from '../helper';
import { dateItemType, defaultValueComponents, isIncludeSimpleComponents } from '../helper';
import { dateUtil } from '@/utils/dateUtil';
import { cloneDeep, has, uniqBy, get } from 'lodash-es';
import { error } from '@/utils/log';
Expand Down Expand Up @@ -76,7 +72,7 @@ export function useFormEvents({
const validKeys: string[] = [];
fields.forEach((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 { componentProps } = schema || {};
let _props = componentProps as any;
Expand Down
4 changes: 0 additions & 4 deletions src/components/Table/src/BasicTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@
<HeaderCell :column="column" />
</slot>
</template>
<!-- 增加对antdv3.x兼容 -->
<template #bodyCell="data">
<slot name="bodyCell" v-bind="data || {}"></slot>
</template>
<!-- <template #[`header-${column.dataIndex}`] v-for="(column, index) in columns" :key="index">-->
<!-- <HeaderCell :column="column" />-->
<!-- </template>-->
</Table>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,9 @@
if (!props.record.editValueRefs) props.record.editValueRefs = {};
props.record.editValueRefs[props.column.dataIndex as any] = currentValueRef;
}
/* eslint-disable */
props.record.onCancelEdit = () => {
isArray(props.record?.cancelCbs) && props.record?.cancelCbs.forEach((fn) => fn());
};
/* eslint-disable */
props.record.onSubmitEdit = async () => {
if (isArray(props.record?.submitCbs)) {
if (!props.record?.onValid?.()) return;
Expand Down Expand Up @@ -508,7 +506,7 @@
}
.@{prefix-cls} {
position: relative;
min-height: 24px; //设置高度让其始终可被hover
min-height: 24px; // 设置高度让其始终可被hover
&__wrapper {
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Upload/src/components/ImageUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@
const list = (fileList.value || [])
.filter((item) => item?.status === UploadResultStatus.DONE)
.map((item: any) => {
if(item?.response && props?.resultField){
return item?.response
if (item?.response && props?.resultField) {
return item?.response;
}
return item?.url || item?.response?.url;
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/Upload/src/components/UploadPreviewModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import { downloadByUrl } from '@/utils/file/download';
import { createPreviewColumns, createPreviewActionColumn } from './data';
import { useI18n } from '@/hooks/web/useI18n';
import { isArray } from '@/utils/is';
import { isArray, isFunction } from '@/utils/is';
import { BasicColumn } from '@/components/Table';
import { isFunction } from '@/utils/is';
import { useMessage } from '@/hooks/web/useMessage';
const { createMessage } = useMessage();
const props = defineProps(previewProps);
Expand Down
10 changes: 6 additions & 4 deletions src/components/Upload/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ type SortableOptions = Merge<
}
>;
type previewColumnsFnType = {
handleRemove:(record:Record<string,any>,key:string)=>any,
handleAdd:(record:Record<string,any>,key:string)=>any,
}
handleRemove: (record: Record<string, any>, key: string) => any;
handleAdd: (record: Record<string, any>, key: string) => any;
};
export const previewType = {
previewColumns: {
type: [Array,Function] as PropType<BasicColumn[] | ((arg:previewColumnsFnType) => BasicColumn[])>,
type: [Array, Function] as PropType<
BasicColumn[] | ((arg: previewColumnsFnType) => BasicColumn[])
>,
required: false,
},
beforePreviewData: {
Expand Down
29 changes: 12 additions & 17 deletions src/views/demo/comp/upload/Upload1.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
<template>

<Alert message="基础示例" />
<BasicUpload
:maxSize="20"
:maxNumber="10"
@change="handleChange"
:api="uploadApi"
class="my-5"
:accept="['image/*']"
/>

<Alert message="基础示例" />
<BasicUpload
:maxSize="20"
:maxNumber="10"
@change="handleChange"
:api="uploadApi"
class="my-5"
:accept="['image/*']"
/>
</template>

<script setup lang="ts">
import { Alert } from 'ant-design-vue';
import { BasicUpload } from '@/components/Upload';
import { uploadApi } from '@/api/sys/upload';
import { useMessage } from '@/hooks/web/useMessage';
import { uploadApi } from '@/api/sys/upload';
const { createMessage } = useMessage();
import { Alert } from 'ant-design-vue';
function handleChange(list: string[]) {
createMessage.success(`已上传文件${JSON.stringify(list)}`);
}
</script>

<style scoped>
</style>
10 changes: 5 additions & 5 deletions src/views/demo/comp/upload/Upload2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
</template>

<script setup lang="ts">
import { uploadApi } from '@/api/sys/upload';
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();
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { Alert } from 'ant-design-vue';
const schemasValiate: FormSchema[] = [
{
field: 'field1',
Expand Down Expand Up @@ -52,5 +54,3 @@
},
});
</script>

<style scoped></style>
12 changes: 6 additions & 6 deletions src/views/demo/comp/upload/Upload3.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<template>
<Alert message="嵌入表单,加入resultFiled自定义返回值" />
<BasicForm @register="registerCustom" class="my-5" />
<BasicForm @register="registerCustom" class="my-5" />
</template>

<script setup lang="ts">
import { uploadApi } from '@/api/sys/upload';
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();
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { Alert } from 'ant-design-vue';
const schemasCustom: FormSchema[] = [
{
field: 'field3',
Expand Down Expand Up @@ -69,5 +71,3 @@
},
});
</script>

<style scoped></style>
24 changes: 11 additions & 13 deletions src/views/demo/comp/upload/Upload4.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
</template>

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

<style scoped></style>
8 changes: 4 additions & 4 deletions src/views/demo/comp/upload/index.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<PageWrapper title="上传组件示例">
<Upload1></Upload1>
<Upload2></Upload2>
<Upload3></Upload3>
<Upload4></Upload4>
<Upload1 />
<Upload2 />
<Upload3 />
<Upload4 />
</PageWrapper>
</template>
<script lang="ts" setup>
Expand Down
1 change: 0 additions & 1 deletion src/views/demo/form/AppendForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
},
{
field: '0',
// component: 'Input',
label: ' ',
slot: 'add',
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/form/CustomerForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
},
{
field: 'field3',
// component: 'Input',
label: '自定义Slot',
slot: 'f3',
colProps: {
Expand Down Expand Up @@ -233,6 +232,7 @@
createMessage.success('click search,values:' + JSON.stringify(values));
}
</script>
<style lang="less" scoped>
:deep(.local_form) .local_typeValue {
width: calc(100% - 120px);
Expand Down
5 changes: 1 addition & 4 deletions src/views/demo/form/RuleForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,11 @@
rules: [
{
required: true,
// @ts-ignore
validator: async (rule, value) => {
validator: async (_, value) => {
if (!value) {
/* eslint-disable-next-line */
return Promise.reject('值不能为空');
}
if (value === '1') {
/* eslint-disable-next-line */
return Promise.reject('值不能为1');
}
return Promise.resolve();
Expand Down
5 changes: 0 additions & 5 deletions src/views/demo/form/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
colProps: {
span: 8,
},
// componentProps:{},
// can func
componentProps: ({ schema, formModel }) => {
console.log('form:', schema);
Expand Down Expand Up @@ -460,7 +459,6 @@
},
{
field: 'field31',
// component: 'Input',
label: '下拉本地搜索',
helpMessage: ['ApiSelect组件', '远程数据源本地搜索', '只发起一次请求获取所有选项'],
required: true,
Expand All @@ -475,7 +473,6 @@
},
{
field: 'field32',
// component: 'Input',
label: '下拉远程搜索',
helpMessage: ['ApiSelect组件', '将关键词发送到接口进行远程搜索'],
required: true,
Expand Down Expand Up @@ -690,7 +687,6 @@
},
{
field: 'selectA',
// component: 'Select',
label: '互斥SelectA',
slot: 'selectA',
defaultValue: [],
Expand All @@ -700,7 +696,6 @@
},
{
field: 'selectB',
// component: 'Select',
label: '互斥SelectB',
slot: 'selectB',
defaultValue: [],
Expand Down
1 change: 0 additions & 1 deletion src/views/demo/table/AuthColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
width: 250,
title: 'Action',
dataIndex: 'action',
// slots: { customRender: 'action' },
},
showSelectionBar: true, // 显示多选状态栏
});
Expand Down
Loading

0 comments on commit ef52853

Please sign in to comment.