conf.vue 4.7 KB
<template>
    <Tabs size="small">
        <TabPane label="基础配置">
            <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="120">
                <FormItem label="活动规则" required>
                    <Input type="textarea" :autosize="{minRows: 2,maxRows: 30}"
                           placeholder="请输入活动规则" :maxlength="2000"></Input>
                </FormItem>
                <FormItem label="分享链接" required>
                    <Input type="text"
                           placeholder="活动分享链接"></Input>
                </FormItem>
                <FormItem label="提示文案(上)" required>
                    <Input type="text"
                           placeholder="提示文案(上)"></Input>
                </FormItem>
                <FormItem label="提示文案(下)" required>
                    <Input type="text"
                           placeholder="提示文案(下)"></Input>
                </FormItem>
                <FormItem label="跳转链接(左)" required>
                    <Input type="text"
                           placeholder="活动底部链接(左)"></Input>
                </FormItem>
                <FormItem label="跳转链接(右)" required>
                    <Input type="text"
                           placeholder="活动底部链接(右)"></Input>
                </FormItem>
                <FormItem label="活动最大参与次数" required>
                    <Input type="text"
                           placeholder="活动最大参与次数"></Input>
                </FormItem>
                <FormItem label="每天最大抽奖次数" required>
                    <Input type="text"
                           placeholder="每天最大抽奖次数"></Input>
                </FormItem>
                <FormItem>
                    <Button type="primary" @click="handleSubmit('formValidate')">保存</Button>
                    <Button type="warning" @click="handleSubmit('formValidate')">预览</Button>
                </FormItem>
            </Form>
        </TabPane>
        <TabPane label="奖品配置">标签二的内容</TabPane>
    </Tabs>
</template>
<script>
    export default {
        data () {
            return {
                formValidate: {
                    name: '',
                    mail: '',
                    city: '',
                    gender: '',
                    interest: [],
                    date: '',
                    time: '',
                    desc: ''
                },
                ruleValidate: {
                    name: [
                        { required: true, message: 'The name cannot be empty', trigger: 'blur' }
                    ],
                    mail: [
                        { required: true, message: 'Mailbox cannot be empty', trigger: 'blur' },
                        { type: 'email', message: 'Incorrect email format', trigger: 'blur' }
                    ],
                    city: [
                        { required: true, message: 'Please select the city', trigger: 'change' }
                    ],
                    gender: [
                        { required: true, message: 'Please select gender', trigger: 'change' }
                    ],
                    interest: [
                        { required: true, type: 'array', min: 1, message: 'Choose at least one hobby', trigger: 'change' },
                        { type: 'array', max: 2, message: 'Choose two hobbies at best', trigger: 'change' }
                    ],
                    date: [
                        { required: true, type: 'date', message: 'Please select the date', trigger: 'change' }
                    ],
                    time: [
                        { required: true, type: 'string', message: 'Please select time', trigger: 'change' }
                    ],
                    desc: [
                        { required: true, message: 'Please enter a personal introduction', trigger: 'blur' },
                        { type: 'string', min: 20, message: 'Introduce no less than 20 words', trigger: 'blur' }
                    ]
                }
            }
        },
        methods: {
            handleSubmit (name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.$Message.success('Success!');
                    } else {
                        this.$Message.error('Fail!');
                    }
                })
            },
            handleReset (name) {
                this.$refs[name].resetFields();
            }
        }
    }
</script>
<style lang="scss">
    .ivu-form-item {
        margin-bottom: 10px;
    }

</style>