Browse Source

chore: format code style (#3808)

* first commit

* style: format code style

* style: format code style
zhang 1 year ago
parent
commit
ef5285385f

+ 2 - 6
src/components/Form/src/hooks/useFormEvents.ts

@@ -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';
@@ -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;

+ 0 - 4
src/components/Table/src/BasicTable.vue

@@ -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>

+ 1 - 3
src/components/Table/src/components/editable/EditableCell.vue

@@ -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;
@@ -508,7 +506,7 @@
   }
   .@{prefix-cls} {
     position: relative;
-    min-height: 24px; //设置高度让其始终可被hover
+    min-height: 24px; // 设置高度让其始终可被hover
 
     &__wrapper {
       display: flex;

+ 2 - 2
src/components/Upload/src/components/ImageUpload.vue

@@ -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;
       });

+ 2 - 2
src/components/Upload/src/components/UploadPreviewModal.vue

@@ -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);

+ 6 - 4
src/components/Upload/src/props.ts

@@ -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: {

+ 12 - 17
src/views/demo/comp/upload/Upload1.vue

@@ -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>

+ 5 - 5
src/views/demo/comp/upload/Upload2.vue

@@ -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',
@@ -52,5 +54,3 @@
     },
   });
 </script>
-
-<style scoped></style>

+ 6 - 6
src/views/demo/comp/upload/Upload3.vue

@@ -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',
@@ -69,5 +71,3 @@
     },
   });
 </script>
-
-<style scoped></style>

+ 11 - 13
src/views/demo/comp/upload/Upload4.vue

@@ -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',
@@ -82,8 +84,8 @@
       component: 'Upload',
       label: '字段6',
       componentProps: {
-        maxNumber:2,
-        previewColumns: ({ handleRemove, handleAdd}) => {
+        maxNumber: 2,
+        previewColumns: ({ handleRemove, handleAdd }) => {
           return [
             {
               title: 'url6',
@@ -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' },
@@ -115,7 +117,7 @@
                   createVNode(
                     Button,
                     {
-                      danger:true,
+                      danger: true,
                       onclick: () => {
                         handleRemove({ url6: record.url6 }, 'url6');
                       },
@@ -125,7 +127,6 @@
                 ]);
               },
             },
-            
           ];
         },
         beforePreviewData: (arg) => {
@@ -158,7 +159,6 @@
           });
         },
       },
-      
     },
   ];
   const [registerPreview, { getFieldsValue: getFieldsValuePreview }] = useForm({
@@ -176,5 +176,3 @@
     },
   });
 </script>
-
-<style scoped></style>

+ 4 - 4
src/views/demo/comp/upload/index.vue

@@ -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>

+ 0 - 1
src/views/demo/form/AppendForm.vue

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

+ 1 - 1
src/views/demo/form/CustomerForm.vue

@@ -80,7 +80,6 @@
     },
     {
       field: 'field3',
-      // component: 'Input',
       label: '自定义Slot',
       slot: 'f3',
       colProps: {
@@ -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);

+ 1 - 4
src/views/demo/form/RuleForm.vue

@@ -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();

+ 0 - 5
src/views/demo/form/index.vue

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

+ 0 - 1
src/views/demo/table/AuthColumn.vue

@@ -135,7 +135,6 @@
       width: 250,
       title: 'Action',
       dataIndex: 'action',
-      // slots: { customRender: 'action' },
     },
     showSelectionBar: true, // 显示多选状态栏
   });

+ 0 - 6
src/views/demo/table/CustomerCell.vue

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

+ 0 - 1
src/views/demo/table/EditRowTable.vue

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

+ 0 - 1
src/views/demo/table/ExpandTable.vue

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

+ 0 - 3
src/views/demo/table/tableData.tsx

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

+ 1 - 1
src/views/demo/tree/EditTree.vue

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