Skip to content

Commit ab5dfc1

Browse files
committed
fix(component): fix schema-form vIf logic #83
1 parent e26fd98 commit ab5dfc1

File tree

6 files changed

+203
-55
lines changed

6 files changed

+203
-55
lines changed

README.md

+47-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@
1313
- [gitee 地址](https://gitee.com/buqiyuan/vue3-antd-admin)
1414
- 根据 JSON 生成 typescript 的工具:[http://json2ts.com/](http://json2ts.com/)
1515

16+
## 安装使用
17+
18+
- 获取项目代码
19+
20+
```bash
21+
git clone https://github.com/buqiyuan/vue3-antd-admin
22+
```
23+
24+
- 安装依赖
25+
26+
```bash
27+
cd vue3-antd-admin
28+
29+
yarn install
30+
31+
```
32+
33+
- 运行
34+
35+
```bash
36+
yarn serve
37+
```
38+
39+
- 打包
40+
41+
```bash
42+
yarn build
43+
```
44+
1645
## vscode 配置
1746

1847
安装项目根目录.vscode 推荐的插件,再安装 Volar,并禁用 Vetur,重启 vscode 即可。
@@ -31,18 +60,28 @@
3160
- [ ] 纯前端导出 PDF 自动分页
3261
- [ ] 其他...
3362

34-
### Project setup
35-
36-
```shell
37-
yarn install
38-
#
39-
yarn --frozen-lockfile
40-
```
41-
4263
## 更新日志
4364

4465
[CHANGELOG](./CHANGELOG.md)
4566

67+
## Git 贡献提交规范
68+
69+
- 参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 规范 ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
70+
71+
- `feat` 增加新功能
72+
- `fix` 修复问题/BUG
73+
- `style` 代码风格相关无影响运行结果的
74+
- `perf` 优化/性能提升
75+
- `refactor` 重构
76+
- `revert` 撤销修改
77+
- `test` 测试相关
78+
- `docs` 文档/注释
79+
- `chore` 依赖更新/脚手架配置修改等
80+
- `workflow` 工作流改进
81+
- `ci` 持续集成
82+
- `types` 类型定义文件更改
83+
- `wip` 开发中
84+
4685
### 赞赏
4786

4887
如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持!

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,30 @@
3030
"@vueuse/core": "^7.5.5",
3131
"ant-design-vue": "3.0.0-beta.9",
3232
"axios": "^0.25.0",
33-
"core-js": "^3.20.3",
33+
"core-js": "^3.21.0",
3434
"dayjs": "^1.10.7",
3535
"file-saver": "^2.0.5",
3636
"lodash-es": "^4.17.21",
3737
"mitt": "^3.0.0",
3838
"mockjs": "^1.1.0",
3939
"nprogress": "^1.0.0-1",
40-
"pinia": "2.0.10",
40+
"pinia": "2.0.11",
4141
"qs": "^6.10.3",
4242
"socket.io-client": "4.4.1",
4343
"sortablejs": "^1.14.0",
4444
"vue": "^3.2.29",
4545
"vue-i18n": "^9.2.0-beta.30",
4646
"vue-router": "^4.0.12",
47-
"xlsx": "^0.17.5"
47+
"xlsx": "^0.18.0"
4848
},
4949
"devDependencies": {
5050
"@commitlint/cli": "^16.1.0",
5151
"@commitlint/config-conventional": "^16.0.0",
5252
"@types/lodash-es": "^4.17.5",
53-
"@types/node": "^17.0.13",
53+
"@types/node": "^17.0.14",
5454
"@types/webpack-env": "^1.16.3",
55-
"@typescript-eslint/eslint-plugin": "^5.10.1",
56-
"@typescript-eslint/parser": "^5.10.1",
55+
"@typescript-eslint/eslint-plugin": "^5.10.2",
56+
"@typescript-eslint/parser": "^5.10.2",
5757
"@vue/cli-plugin-babel": "^5.0.0-rc.2",
5858
"@vue/cli-plugin-eslint": "^5.0.0-rc.2",
5959
"@vue/cli-plugin-router": "^5.0.0-rc.2",
@@ -73,7 +73,7 @@
7373
"husky": "^7.0.4",
7474
"less": "^4.1.2",
7575
"less-loader": "10.2.0",
76-
"lint-staged": "^12.3.2",
76+
"lint-staged": "^12.3.3",
7777
"path-browserify": "^1.0.1",
7878
"postcss-html": "^1.3.0",
7979
"prettier": "^2.5.1",

src/components/core/schema-form/schema-form-item.vue

-5
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,8 @@
214214
label,
215215
dynamicRules,
216216
required,
217-
field,
218217
} = props.schemaItem;
219218
220-
if (field == 'field5') {
221-
console.log('rules', props.schemaItem);
222-
}
223-
224219
if (isFunction(dynamicRules)) {
225220
return dynamicRules(unref(getValues)) as ValidationRule[];
226221
}

src/components/core/schema-form/schema-form.vue

+1-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@
134134
show = isShow({ schemaItem: formItem, formModel, field: formItem.field });
135135
}
136136
if (Object.is(show, false) && key === 'vIf') {
137-
formModel[formItem.field] = undefined;
138-
} else if (Object.is(show, true) && key === 'vIf') {
139-
formModel[formItem.field] = cacheFormModel[formItem.field];
137+
Reflect.deleteProperty(formModel, formItem.field);
140138
}
141139
return show;
142140
} else {

src/views/demos/form/basic-form/form-schema.ts

+39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
11
import type { FormItemSchema } from '@/components/core/schema-form/types/form';
22

33
export const schemas: FormItemSchema[] = [
4+
{
5+
field: 'type',
6+
component: 'RadioGroup',
7+
label: '类型',
8+
defaultValue: 1,
9+
colProps: {
10+
span: 8,
11+
},
12+
componentProps: {
13+
options: [
14+
{
15+
label: '类型一',
16+
value: 1,
17+
},
18+
{
19+
label: '类型二',
20+
value: 2,
21+
},
22+
],
23+
},
24+
},
25+
{
26+
field: 'isExtenal',
27+
component: 'Switch',
28+
label: '是否外链',
29+
colProps: {
30+
span: 8,
31+
},
32+
vIf: ({ formModel }) => formModel['type'] === 2,
33+
},
34+
{
35+
field: 'isEbed',
36+
component: 'Switch',
37+
label: '是否内嵌',
38+
colProps: {
39+
span: 8,
40+
},
41+
vIf: ({ formModel }) => formModel['type'] === 2 && formModel['isExtenal'],
42+
},
443
{
544
field: 'field1',
645
component: 'Input',

0 commit comments

Comments
 (0)