Skip to content

Commit 0b6110a

Browse files
committed
feat(form-page): add form page demo
1 parent 4ddee05 commit 0b6110a

File tree

43 files changed

+1389
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1389
-116
lines changed

CHANGELOG.zh_CN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
- 新增 base64 文件流下载
66
- 优化上传组件及示例
7+
- 新增可编辑行示例
8+
- 新增个人页
9+
- 新增表单页
710

811
### 🎫 Chores
912

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ yarn clean:lib # 删除node_modules,兼容window系统
232232

233233
## 正在开发的功能
234234

235+
- [ ] 新分支全局国家化
236+
- [ ] 示例 page 页面
235237
- [ ] 主题配置
236238
- [ ] 黑暗主题
237239
- [ ] 打包 CDN

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"@iconify/iconify": "^2.0.0-rc.2",
2525
"@vueuse/core": "^4.0.0-beta.41",
26-
"ant-design-vue": "^2.0.0-rc.1",
26+
"ant-design-vue": "^2.0.0-beta.15",
2727
"apexcharts": "3.22.0",
2828
"axios": "^0.21.0",
2929
"echarts": "^4.9.0",

src/components/Basic/src/BasicHelp.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
bottom: 0,
4949
}),
5050
},
51+
placement: {
52+
type: String as PropType<string>,
53+
defualt: 'right',
54+
},
5155
},
5256
setup(props, { slots }) {
5357
const getOverlayStyleRef = computed(() => {
@@ -97,7 +101,7 @@
97101
overlayClassName: 'base-help__wrap',
98102
autoAdjustOverflow: true,
99103
overlayStyle: unref(getOverlayStyleRef),
100-
placement: 'right',
104+
placement: props.placement,
101105
getPopupContainer: () => getPopupContainer(),
102106
},
103107
{

src/components/Footer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as AppFooter } from './src/index.vue';
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<template>
2+
<div class="app-footer" :style="{ width: getWidth }">
3+
<div class="app-footer__left">
4+
<slot name="left" />
5+
</div>
6+
<div class="app-footer__right">
7+
<slot name="right" />
8+
</div>
9+
</div>
10+
</template>
11+
<script lang="ts">
12+
import { defineComponent, computed, unref } from 'vue';
13+
import { SIDE_BAR_MINI_WIDTH, SIDE_BAR_SHOW_TIT_MINI_WIDTH } from '/@/enums/appEnum';
14+
import { appStore } from '/@/store/modules/app';
15+
import { menuStore } from '/@/store/modules/menu';
16+
export default defineComponent({
17+
name: 'AppFooter',
18+
setup() {
19+
const getMiniWidth = computed(() => {
20+
const {
21+
menuSetting: { collapsedShowTitle },
22+
} = appStore.getProjectConfig;
23+
return collapsedShowTitle ? SIDE_BAR_SHOW_TIT_MINI_WIDTH : SIDE_BAR_MINI_WIDTH;
24+
});
25+
26+
const getWidth = computed(() => {
27+
const { getCollapsedState, getMenuWidthState } = menuStore;
28+
const width = getCollapsedState ? unref(getMiniWidth) : getMenuWidthState;
29+
return `calc(100% - ${width}px)`;
30+
});
31+
32+
return { getWidth };
33+
},
34+
});
35+
</script>
36+
<style lang="less" scoped>
37+
.app-footer {
38+
position: fixed;
39+
right: 0;
40+
bottom: 0;
41+
z-index: 99;
42+
display: flex;
43+
width: 100%;
44+
align-items: center;
45+
padding: 0 24px;
46+
line-height: 44px;
47+
background: #fff;
48+
border-top: 1px solid #f0f0f0;
49+
box-shadow: 0 -6px 16px -8px rgba(0, 0, 0, 0.08), 0 -9px 28px 0 rgba(0, 0, 0, 0.05),
50+
0 -12px 48px 16px rgba(0, 0, 0, 0.03);
51+
transition: width 0.3s;
52+
53+
&__left {
54+
flex: 1 1;
55+
}
56+
}
57+
</style>

src/components/Form/src/BasicForm.vue

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Form v-bind="$attrs" ref="formElRef" :model="formModel">
2+
<Form v-bind="{ ...$attrs, ...$props }" ref="formElRef" :model="formModel">
33
<Row :class="getProps.compact ? 'compact-form-row' : ''">
44
<slot name="formHeader" />
55
<template v-for="schema in getSchema" :key="schema.field">
@@ -54,8 +54,8 @@
5454
const formModel = reactive({});
5555
5656
const actionState = reactive({
57-
resetAction: () => {},
58-
submitAction: () => {},
57+
resetAction: {},
58+
submitAction: {},
5959
});
6060
6161
const advanceState = reactive<AdvanceState>({
@@ -67,7 +67,7 @@
6767
6868
const defaultValueRef = ref<any>({});
6969
const propsRef = ref<Partial<FormProps>>({});
70-
const schemaRef = ref<FormSchema[] | null>(null);
70+
const schemaRef = ref<Nullable<FormSchema[]>>(null);
7171
const formElRef = ref<Nullable<FormActionType>>(null);
7272
7373
const getMergePropsRef = computed(
@@ -98,7 +98,15 @@
9898
for (const schema of schemas) {
9999
const { defaultValue, component } = schema;
100100
if (defaultValue && dateItemType.includes(component!)) {
101-
schema.defaultValue = moment(defaultValue);
101+
if (!Array.isArray(defaultValue)) {
102+
schema.defaultValue = moment(defaultValue);
103+
} else {
104+
const def: moment.Moment[] = [];
105+
defaultValue.forEach((item) => {
106+
def.push(moment(item));
107+
});
108+
schema.defaultValue = def;
109+
}
102110
}
103111
}
104112
return schemas as FormSchema[];
@@ -139,8 +147,8 @@
139147
formModel,
140148
getSchema,
141149
defaultValueRef,
142-
formElRef: formElRef as any,
143-
schemaRef: schemaRef as any,
150+
formElRef: formElRef as Ref<FormActionType>,
151+
schemaRef: schemaRef as Ref<FormSchema[]>,
144152
handleFormValues,
145153
actionState,
146154
});
@@ -156,6 +164,13 @@
156164
}
157165
);
158166
167+
watch(
168+
() => getSchema.value,
169+
() => {
170+
initDefault();
171+
}
172+
);
173+
159174
/**
160175
* @description:设置表单
161176
*/

src/components/Form/src/FormItem.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,21 @@ export default defineComponent({
250250
}
251251

252252
function renderLabelHelpMessage() {
253-
const { label, helpMessage, helpComponentProps } = props.schema;
253+
const { label, helpMessage, helpComponentProps, subLabel } = props.schema;
254+
const renderLabel = subLabel ? (
255+
<span>
256+
{label} <span style="color:#00000073">{subLabel}</span>
257+
</span>
258+
) : (
259+
label
260+
);
254261
if (!helpMessage || (Array.isArray(helpMessage) && helpMessage.length === 0)) {
255-
return label;
262+
return renderLabel;
256263
}
257264
return (
258265
<span>
259-
{label}
260-
<BasicHelp class="mx-1" text={helpMessage} {...helpComponentProps} />
266+
{renderLabel}
267+
<BasicHelp placement="top" class="mx-1" text={helpMessage} {...helpComponentProps} />
261268
</span>
262269
);
263270
}
@@ -291,6 +298,7 @@ export default defineComponent({
291298
const { colProps = {}, colSlot, renderColContent, component } = props.schema;
292299
if (!componentMap.has(component)) return null;
293300
const { baseColProps = {} } = props.formProps;
301+
294302
const realColProps = { ...baseColProps, ...colProps };
295303
const { isIfShow, isShow } = getShow();
296304
const getContent = () => {

src/components/Form/src/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function createPlaceholderMessage(component: ComponentType) {
77
if (component.includes('Input') || component.includes('Complete')) {
88
return '请输入';
99
}
10-
if (component.includes('Picker') && !component.includes('Range')) {
10+
if (component.includes('Picker')) {
1111
return '请选择';
1212
}
1313
if (

src/components/Form/src/hooks/useLabelWidth.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,26 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
2525
const { labelCol = {}, wrapperCol = {} } = schemaItem.itemProps || {};
2626
const { labelWidth, disabledLabelWidth } = schemaItem;
2727

28-
const { labelWidth: globalLabelWidth } = unref(propsRef) as any;
28+
const {
29+
labelWidth: globalLabelWidth,
30+
labelCol: globalLabelCol,
31+
wrapperCol: globWrapperCol,
32+
} = unref(propsRef) as any;
33+
2934
// 如果全局有设置labelWidth, 则所有item使用
30-
if ((!globalLabelWidth && !labelWidth) || disabledLabelWidth) {
35+
if ((!globalLabelWidth && !labelWidth && !globalLabelCol) || disabledLabelWidth) {
3136
return { labelCol, wrapperCol };
3237
}
3338
let width = labelWidth || globalLabelWidth;
39+
const col = { ...globalLabelCol, ...labelCol };
40+
const wrapCol = { ...globWrapperCol, ...wrapperCol };
3441

3542
if (width) {
3643
width = isNumber(width) ? `${width}px` : width;
3744
}
3845
return {
39-
labelCol: { style: { width }, ...labelCol },
40-
wrapperCol: { style: { width: `calc(100% - ${width})` }, ...wrapperCol },
46+
labelCol: { style: { width }, ...col },
47+
wrapperCol: { style: { width: `calc(100% - ${width})` }, ...wrapCol },
4148
};
4249
});
4350
}

0 commit comments

Comments
 (0)