-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
351 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<template> | ||
<div class="page-container"> | ||
<el-form | ||
ref="formRef" | ||
:model="form" | ||
:label-position="formOption.labelPosition" | ||
label-width="120px" | ||
> | ||
<!-- <div class="">标题</div> --> | ||
<el-row v-for="(f, fix) in formOption.formIten" :key="fix" :gutter="f.gutter || 30"> | ||
<el-col | ||
v-for="(fItem, fItemIx) in f.itemList" | ||
:key="fItemIx" | ||
:xs="f.xs || 24" | ||
:sm="f.sm || 24" | ||
:md="f.md || 12" | ||
:lg="f.lg || 8" | ||
:xl="f.xl || 8" | ||
> | ||
<el-form-item :label="fItem.label" :prop="fItem.prop"> | ||
<!-- 输入框 --> | ||
<el-input | ||
v-if="fItem.type === 'input'" | ||
v-model="form[fItem.prop]" | ||
:type="fItem.inputType" | ||
></el-input> | ||
<!-- 日期选择器 --> | ||
<el-date-picker | ||
v-else-if="fItem.type === 'dateTime'" | ||
v-model="form[fItem.prop]" | ||
type="datetimerange" | ||
range-separator="To" | ||
start-placeholder="Start date" | ||
end-placeholder="End date" | ||
> | ||
</el-date-picker> | ||
<!-- 单选框 --> | ||
<el-radio-group v-else-if="fItem.type === 'radio'" v-model="form.resource"> | ||
<el-radio | ||
v-for="(radio, radioIx) in fItem.options" | ||
:key="radioIx" | ||
:label="radio.label" | ||
></el-radio> | ||
</el-radio-group> | ||
<!-- 下拉选择框 --> | ||
<el-select | ||
v-else-if="fItem.type === 'select'" | ||
v-model="form[fItem.prop]" | ||
:placeholder="fItem.placeholder" | ||
> | ||
<el-option | ||
v-for="(select, selectIx) in fItem.options" | ||
:key="selectIx" | ||
:label="select.label" | ||
:value="select.value" | ||
></el-option> | ||
</el-select> | ||
<el-checkbox-group v-else-if="fItem.type === 'checkbox'" v-model="form[fItem.prop]"> | ||
<el-checkbox | ||
v-for="(checkbox, checkboxIx) in fItem.options" | ||
:key="checkboxIx" | ||
:label="checkbox.label" | ||
:name="form[fItem.prop]" | ||
></el-checkbox> | ||
</el-checkbox-group> | ||
</el-form-item> | ||
</el-col> | ||
</el-row> | ||
<el-form-item> | ||
<el-button type="primary" @click="submitForm()">Create</el-button> | ||
<el-button @click="resetForm()">Reset</el-button> | ||
</el-form-item> | ||
</el-form> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { onMounted, reactive, PropType } from 'vue'; | ||
import { FormProps } from './types/from'; | ||
const props = defineProps({ | ||
formOption: { | ||
type: Object as PropType<FormProps>, | ||
default: () => {}, | ||
}, | ||
}); | ||
console.log(props); | ||
const form = reactive<any>({}); | ||
onMounted(() => {}); | ||
const submitForm = () => {}; | ||
const resetForm = () => {}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.page-container { | ||
padding: 20px; | ||
background-color: #{$main-bg-color}; | ||
} | ||
</style> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export interface FormProps { | ||
labelPosition: string; | ||
formIten: Array<FormItemProps>; | ||
} | ||
|
||
export interface FormItemProps { | ||
gutter: number; | ||
xs?: number; | ||
sm?: number; | ||
md?: number; | ||
lg?: number; | ||
xl?: number; | ||
itemList: Array<FormItemListProps>; | ||
} | ||
|
||
/** | ||
* @param(type) input:输入框、dataTime:日期选择器、radio:单选框、select:下拉选择框 | ||
* @param(label) 标签名 | ||
* @param(prop) form表单双向绑定字段 | ||
* @param(options) 选择项数据 | ||
* @param(inputType) input输入框类型 type为input生效 | ||
* @param(placeholder) 占位符 | ||
*/ | ||
export interface FormItemListProps { | ||
type: string; | ||
label: string; | ||
prop: string; | ||
options?: Array<FormSelectOptProps>; | ||
inputType?: string; | ||
placeholder?: string; | ||
} | ||
|
||
export interface FormSelectOptProps { | ||
label: string; | ||
value: string | number | boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.