Commit 16574395697669052b000df857a886c0a3121a11

Authored by Cyrus Zhou
Committed by GitHub
1 parent 8dd8a5ed

修复 updateSchema 多个field 属性时,第二个无效问题。 (#2493)

* Table BasicColumn 添加 editDynamicDisabled
Co-authored-by: Cyrus Zhou <6802207@qq.com>
使用方式同 Form FormSchema dynamicDisabled
```
export const Columns: BasicColumn[] = [
  {
    title: 'Title',
    dataIndex: 'Title',
    editRow: true,
    editComponent: 'Select',
    editDynamicDisabled: ({ record }) => record.isDisabled,
  },

* editComponentProps onChange 功能恢复
Co-authored-by: Cyrus Zhou <6802207@qq.com>
说明:
...omit(compProps, 'onChange')
这会忽略 onChange ,导致 editComponentProps onChange 被取消

如下功能将不支持:
```
editComponentProps: ({ record }) => {
  return {
    options: effectTypeData,
    onChange: () => {
    },
  };
},
```

* tableData == null 报错

* ApiSelect 第一次选择触发required错误提示问题

* 恢复 虽然可以解决第一次选择提示报错问题,但是会导致 onChange: (e: any, options: any) => 无法获得 options 的值

* 修复标签页切换灰屏不显示内容问题
Co-authored-by: Cyrus Zhou <6802207@qq.com>
问题描述页面没有用 div 包括 会提示 Component inside <Transition> renders non-element root node that cannot be animated ,
导致页灰屏必须刷新页面才可以显示内容

* 添加 Form ApiTransfer
## 使用方式
api 方式:
```
    ......
    component: 'ApiTransfer',
    componentProps: {
       api: sysUserSelector,
       labelField: 'name',
       valueField: 'id',
    },
    .....
```
数据方式:
```
     ....
     componentProps: {
      dataSource: [
        { title: 'Test01', key: '0', disabled: false, description: 'description 01' },
        { title: 'Test02', key: '1', disabled: false, description: 'description 02' },
        { title: 'Test03', key: '2', disabled: false, description: 'description 03' },
        { title: 'Test04', key: '3', disabled: false, description: 'description 04' },
        { title: 'Test05', key: '4', disabled: false, description: 'description 05' },
      ],
    },
    ....
```

* style: eslint 书写规范

* fix: 频繁切换页面导致灰屏

* fix: 修复 updateSchema 多个field 属性时,第二个无效问题。

如:
```
updateSchema([
          {
            field: 'password',
            ifShow: !unref(isUpdate),
          },
          {
            field: 'confirm',
            ifShow: !unref(isUpdate),
          },
        ]);
        ```

Co-authored-by: CyrusZhou <6802207@qq.com>
.vscode/settings.json
@@ -138,5 +138,23 @@ @@ -138,5 +138,23 @@
138 ], 138 ],
139 "vetur.format.scriptInitialIndent": true, 139 "vetur.format.scriptInitialIndent": true,
140 "vetur.format.styleInitialIndent": true, 140 "vetur.format.styleInitialIndent": true,
141 - "vetur.validation.script": false 141 + "vetur.validation.script": false,
  142 + "MicroPython.executeButton": [
  143 + {
  144 + "text": "▶",
  145 + "tooltip": "运行",
  146 + "alignment": "left",
  147 + "command": "extension.executeFile",
  148 + "priority": 3.5
  149 + }
  150 + ],
  151 + "MicroPython.syncButton": [
  152 + {
  153 + "text": "$(sync)",
  154 + "tooltip": "同步",
  155 + "alignment": "left",
  156 + "command": "extension.execute",
  157 + "priority": 4
  158 + }
  159 + ]
142 } 160 }
src/components/Form/src/hooks/useFormEvents.ts
@@ -220,15 +220,19 @@ export function useFormEvents({ @@ -220,15 +220,19 @@ export function useFormEvents({
220 return; 220 return;
221 } 221 }
222 const schema: FormSchema[] = []; 222 const schema: FormSchema[] = [];
223 - updateData.forEach((item) => {  
224 - unref(getSchema).forEach((val) => { 223 + unref(getSchema).forEach((val) => {
  224 + let _val;
  225 + updateData.forEach((item) => {
225 if (val.field === item.field) { 226 if (val.field === item.field) {
226 - const newSchema = deepMerge(val, item);  
227 - schema.push(newSchema as FormSchema);  
228 - } else {  
229 - schema.push(val); 227 + _val = item;
230 } 228 }
231 }); 229 });
  230 + if (_val !== undefined && val.field === _val.field) {
  231 + const newSchema = deepMerge(val, _val);
  232 + schema.push(newSchema as FormSchema);
  233 + } else {
  234 + schema.push(val);
  235 + }
232 }); 236 });
233 _setDefaultValue(schema); 237 _setDefaultValue(schema);
234 238
src/components/Tree/src/types/tree.ts
@@ -134,7 +134,7 @@ export const treeProps = buildProps({ @@ -134,7 +134,7 @@ export const treeProps = buildProps({
134 type: Boolean, 134 type: Boolean,
135 default: false, 135 default: false,
136 }, 136 },
137 - treeWrapperClassName: String 137 + treeWrapperClassName: String,
138 }); 138 });
139 139
140 export type TreeProps = ExtractPropTypes<typeof treeProps>; 140 export type TreeProps = ExtractPropTypes<typeof treeProps>;
src/layouts/page/index.vue
@@ -15,7 +15,9 @@ @@ -15,7 +15,9 @@
15 appear 15 appear
16 > 16 >
17 <keep-alive v-if="openCache" :include="getCaches"> 17 <keep-alive v-if="openCache" :include="getCaches">
18 - <component :is="Component" :key="route.fullPath" /> 18 + <div :key="route.name">
  19 + <component :is="Component" :key="route.fullPath" />
  20 + </div>
19 </keep-alive> 21 </keep-alive>
20 <div v-else :key="route.name"> 22 <div v-else :key="route.name">
21 <component :is="Component" :key="route.fullPath" /> 23 <component :is="Component" :key="route.fullPath" />
src/utils/dateUtil.ts
@@ -15,4 +15,3 @@ export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): str @@ -15,4 +15,3 @@ export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): str
15 } 15 }
16 16
17 export const dateUtil = dayjs; 17 export const dateUtil = dayjs;
18 -  
src/utils/index.ts
@@ -36,7 +36,7 @@ export function setObjToUrlParams(baseUrl: string, obj: any): string { @@ -36,7 +36,7 @@ export function setObjToUrlParams(baseUrl: string, obj: any): string {
36 // 深度合并 36 // 深度合并
37 export function deepMerge<T = any>(src: any = {}, target: any = {}): T { 37 export function deepMerge<T = any>(src: any = {}, target: any = {}): T {
38 let key: string; 38 let key: string;
39 - const res: any = cloneDeep(src) 39 + const res: any = cloneDeep(src);
40 for (key in target) { 40 for (key in target) {
41 res[key] = isObject(res[key]) ? deepMerge(res[key], target[key]) : (res[key] = target[key]); 41 res[key] = isObject(res[key]) ? deepMerge(res[key], target[key]) : (res[key] = target[key]);
42 } 42 }