cuiqian2004
2025-06-12 ade379c26e00929b7295b37d7c274ccbb0026b7d
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
    <view class="oi-form-item" :class="largeMode?'large-mode':''">
        <uni-forms-item v-show="!hiddenIds.includes(data.fieldId)"
            :label="data.labelWidth === 0 ? '' : data.label? data.label+':':''"
            :label-width="largeMode?'100%': data.labelWidth || data.labelWidth === 0 ? data.labelWidth : 100+'px'"
            :style="{ textAlign: data.setting.align }">
            <OIFormText v-if="viewMode && data.disabled" :data="data" :model="model">
            </OIFormText>
            <OIFormInput v-else-if="data.name == 'Input'" :viewMode="viewMode" :focus="focusId== data.fieldId"
                :data="data" :model="model" @on-change="onChange" @on-focus="onFocus" @on-click="onClick"
                @on-click-prefix="onClickPrefix" @on-click-suffix="onClickSuffix">
            </OIFormInput>
            <OIFormInputNumber v-else-if="data.name == 'InputNumber'" :focus="focusId== data.fieldId" :data="data"
                :model="model" @on-change="onChange" @on-focus="onFocus" @on-click="onClick">
            </OIFormInputNumber>
            <OIFormTextArea v-else-if="data.name == 'Textarea'" :focus="focusId== data.fieldId" :data="data"
                :model="model" @on-change="onChange" @on-focus="onFocus" @on-click="onClick">
            </OIFormTextArea>
            <OIFormSelect v-else-if="data.name == 'Select'" :data="data" :model="model" @on-change="onChange">
            </OIFormSelect>
            <OIFormSwitch v-else-if="data.name == 'Switch'" :data="data" :model="model" @on-change="onChange">
            </OIFormSwitch>
            <OIFormCheckbox v-else-if="data.name == 'Checkbox'" :data="data" :model="model" @on-change="onChange">
            </OIFormCheckbox>
            <OIFormRadio v-else-if="data.name == 'Radio'" :data="data" :model="model" @on-change="onChange">
            </OIFormRadio>
            <OIFormDatePicker v-else-if="data.name == 'DatePicker'" :data="data" :model="model" @on-change="onChange">
            </OIFormDatePicker>
            <OIFormTimePicker v-else-if="data.name == 'TimePicker'" :data="data" :model="model" @on-change="onChange">
            </OIFormTimePicker>
            <OIFormDatePickerRange v-else-if="data.name == 'DatePickerRange'" :data="data" :model="model"
                @on-change="onChange">
            </OIFormDatePickerRange>
            <OIFormText v-else-if="data.name == 'Text'" :data="data" :model="model">
            </OIFormText>
            <OIFormText v-else :data="data" :model="model">
            </OIFormText>
        </uni-forms-item>
    </view>
</template>
 
<script>
    import OIFormInput from './input/index.vue'
    import OIFormInputNumber from './input-number/index.vue'
    import OIFormText from './text/index.vue'
    import OIFormTextArea from './textarea/index.vue'
    import OIFormSelect from './select/index.vue'
    import OIFormSwitch from './switch/index.vue'
    import OIFormCheckbox from './checkbox/index.vue'
    import OIFormRadio from './radio/index.vue'
    import OIFormDatePicker from './date-picker/index.vue'
    import OIFormDatePickerRange from './date-picker-range/index.vue'
    import OIFormTimePicker from './time-picker/index.vue'
    export default {
        name: "OIFormItem",
        components: {
            OIFormInput,
            OIFormInputNumber,
            OIFormText,
            OIFormTextArea,
            OIFormSelect,
            OIFormSwitch,
            OIFormCheckbox,
            OIFormRadio,
            OIFormDatePicker,
            OIFormDatePickerRange,
            OIFormTimePicker
        },
        props: {
            data: {
                type: Object,
                required: true,
            },
            model: Object,
            viewMode: {
                type: Boolean,
                default: false
            },
            focusId: {
                type: String,
                default: ''
            },
            hiddenIds: {
                type: Array,
                default: () => [],
            },
        },
        data() {
            return {
                largeMode: getApp().globalData?.largeMode || false,
            }
        },
        methods: {
            onChange(e) {
                this.$emit("on-change", this.data)
            },
            onClick(e) {
                this.$emit("on-click", this.data)
            },
            onFocus(e) {
                this.$emit("on-focus", this.data)
            },
            onClickPrefix() {
                this.$emit("on-click-prefix", this.data)
            },
            onClickSuffix() {
                this.$emit("on-click-suffix", this.data)
            },
        },
    };
</script>
 
<style lang="less" scoped>
    .oi-form-item {
        .uni-forms-item {
            margin-bottom: 15rpx;
        }
    }
 
    .oi-form-item.large-mode {
        .uni-forms-item {
            margin-left: 10rpx;
            margin-right: 10rpx;
        }
    }
</style>