wujingjing
2024-12-30 c4004648da4014c8777e4f4bd887ca28cb7afd97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<template>
    <el-form :model="model" ref="formRef" :rules="rules" :label-width="labelWidth" :inline="inline">
        <el-form-item :label-width="item.labelWidth" v-for="item in formItems" :label="item.label" :prop="item.prop">
            <!-- 输入字符串 -->
            <el-input
                v-if="item.type === 'string'"
                :placeholder="item.placeholder"
                :style="{ width: `${item.width}px` }"
                :width="item.width"
                v-model="model[item.prop]"
                :clearable="item.clearable"
            ></el-input>
            <!-- 输入数字 -->
            <el-input-number
                class="w100"
                v-else-if="item.type === 'number'"
                :placeholder="item.placeholder"
                :style="{ width: `${item.width}px` }"
                v-model="model[item.prop]"
                :clearable="item.clearable"
            ></el-input-number>
        </el-form-item>
        <slot></slot>
    </el-form>
</template>
 
<script setup lang="ts">
import { ref } from 'vue';
import { YWFormProps } from '/@/components/form/yw-form';
import { FormInstance, ElInput, ElInputNumber } from 'element-plus';
 
const props = defineProps(YWFormProps);
 
const formRef = ref<FormInstance>(null);
 
defineExpose({
    formRef,
});
</script>
<style scoped lang="scss"></style>