WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2022-07-25 c6d0e88d664f4427fab388bef83af93784bda221
forms/datePicker/CDatePicker.vue
@@ -23,9 +23,14 @@
                :placeholder="placeholder"
            >
                <view
                    v-show="!readOnly"
                    v-show="!readOnly && !showClear"
                    class="at-icon at-icon-chevron-right"
                />
                <view
                    v-show="showClear"
                    class="at-icon at-icon-close"
                    @tap.stop="evt => handleClear()"
                ></view>
            </AtInput>
        </CDateRangeAction>
        <CDateTimeAction
@@ -43,9 +48,14 @@
                :placeholder="placeholder"
            >
                <view
                    v-show="!readOnly"
                    v-show="!readOnly && !showClear"
                    class="at-icon at-icon-chevron-right"
                />
                <view
                    v-show="showClear"
                    class="at-icon at-icon-close"
                    @tap.stop="evt => handleClear()"
                ></view>
            </AtInput>
        </CDateTimeAction>
        <view v-else-if="mode==='date'">
@@ -65,9 +75,14 @@
                    :placeholder="placeholder"
                >
                    <view
                        v-show="!readOnly"
                        v-show="!readOnly && !showClear"
                        class="at-icon at-icon-chevron-right"
                    />
                    <view
                        v-show="showClear"
                        class="at-icon at-icon-close"
                        @tap.stop="evt => handleClear()"
                    ></view>
                </AtInput>
            </picker>
        </view>
@@ -108,6 +123,11 @@
            type: Boolean,
            default: false,
        },
        // 允许清除
        allowClear: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        const year = new Date().getFullYear();
@@ -116,11 +136,21 @@
            pickerEnd: year + 30 + '-12-31',
        };
    },
    computed: {},
    computed: {
        showClear() {
            if (!this.allowClear) {
                return false;
            }
            return !!this.itemRes.formData[this.itemRes.name];
        },
    },
    methods: {
        handleChange(val) {
            this.itemRes.onChange(val);
        },
        handleClear() {
            this.itemRes.onChange('');
        },
    },
    mounted() {},
};