You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.3 KiB
116 lines
2.3 KiB
1 year ago
|
<template>
|
||
|
<ElForm :style="getStyle()" :label-width="labelWidth" class="FormConfig" size="mini">
|
||
1 year ago
|
<ElFormItem class="formItem" :rules="rules && rules[item.key]" v-for="(item, index) in formList" :key="item.key"
|
||
1 year ago
|
:label="item.label" :style="gridStyle(item, index)">
|
||
|
<component :is="getComponent(item.type)" v-bind="item.options" />
|
||
1 year ago
|
</ElFormItem>
|
||
|
</ElForm>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
1 year ago
|
import FormInput from "./components/FormInput.vue";
|
||
|
import FormTimePicker from "./components/FormTimePicker.vue";
|
||
1 year ago
|
|
||
1 year ago
|
export default {
|
||
|
name: 'FormConfig',
|
||
|
components: {
|
||
1 year ago
|
FormInput,
|
||
|
FormTimePicker
|
||
1 year ago
|
},
|
||
|
props: {
|
||
|
/**
|
||
|
* {
|
||
|
* label: String;
|
||
|
* key: String;
|
||
1 year ago
|
* type: 'input' | 'timePicker',
|
||
1 year ago
|
* gridArea?: "",
|
||
|
* gridColumn?: "",
|
||
|
* gridRow?: "",
|
||
|
* options?: {}
|
||
|
* }[]
|
||
|
*/
|
||
|
formList: {
|
||
|
type: Array,
|
||
|
default: () => []
|
||
|
},
|
||
|
labelWidth: {
|
||
|
type: String,
|
||
1 year ago
|
default: "auto"
|
||
|
},
|
||
|
rules: {
|
||
|
type: Object,
|
||
|
default: null
|
||
|
},
|
||
|
column: {
|
||
|
type: String,
|
||
|
default: "3"
|
||
1 year ago
|
}
|
||
|
},
|
||
|
computed: {
|
||
|
gridStyle() {
|
||
|
return (item, index) => ({
|
||
|
gridRow: `span ${item.gridRow || 1}`,
|
||
|
gridColumn: `span ${item.gridColumn || 1}`,
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
getStyle() {
|
||
|
return {
|
||
1 year ago
|
gridTemplateColumns: `repeat(${this.column}, 1fr)`,
|
||
1 year ago
|
}
|
||
1 year ago
|
},
|
||
|
getComponent(type) {
|
||
|
return `Form${type.replace(/^[a-z]/, word => word.toUpperCase())}`
|
||
1 year ago
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang='scss' scoped>
|
||
|
.FormConfig {
|
||
|
display: grid;
|
||
|
align-content: start;
|
||
|
width: 100%;
|
||
1 year ago
|
gap: 15px 15px;
|
||
1 year ago
|
|
||
1 year ago
|
.formItem {
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
}
|
||
|
|
||
1 year ago
|
|
||
|
::v-deep {
|
||
|
.el-form-item {
|
||
1 year ago
|
align-items: center;
|
||
|
margin: 0;
|
||
|
height: 100%;
|
||
|
|
||
|
.el-form-item__label-wrap {
|
||
|
width: fit-content;
|
||
|
|
||
|
.el-form-item__label {
|
||
|
height: 22px;
|
||
|
font-size: 16px;
|
||
|
// font-family: PingFang SC, PingFang SC;
|
||
|
font-weight: 400;
|
||
|
color: #3DE8FF;
|
||
|
line-height: 19px;
|
||
|
// -webkit-background-clip: text;
|
||
|
// -webkit-text-fill-color: transparent;
|
||
|
}
|
||
1 year ago
|
}
|
||
1 year ago
|
|
||
|
.el-form-item__content {
|
||
|
margin: 0 !important;
|
||
1 year ago
|
flex: 1;
|
||
|
|
||
|
.el-input__prefix {
|
||
|
color: #fff;
|
||
|
}
|
||
1 year ago
|
}
|
||
1 year ago
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|