<template>
    <BaseModal title="配置JDBC数据源">
        <Form :label-width="100" :model="data" :rules="rules">
            <FormItem label="数据源名称" prop="name">
                <Input v-model="data.name" />
            </FormItem>
            <FormItem label="驱动名称" prop="driver">
                <Select v-model="data.driver" @on-change="changeDriver">
                    <Option
                        value="oracle.jdbc.OracleDriver"
                        key="oracle"
                    >Oracle-(oracle.jdbc.OracleDriver)</Option>
                </Select>
            </FormItem>
            <FormItem label="连接URL" prop="url">
                <Input v-model="data.url" />
            </FormItem>
            <FormItem label="用户名" prop="username">
                <Input v-model="data.username" />
            </FormItem>
            <FormItem label="密码" prop="password">
                <Input v-model="data.password" />
            </FormItem>
            <FormItem label="过滤器使用">
                <i-Switch v-model="data.forfilter"></i-Switch>
            </FormItem>
        </Form>
    </BaseModal>
</template>
<script>
import ApiDesigner from '@/api/designer'

export default {
    name: 'JdbcDatasourceDialog',
    data() {
        return {
            rules: {
                name: [{ required: true }],
                driver: [{ required: true }],
                url: [{ required: true }],
                username: [{ required: true }],
                password: [{ required: true }],
            },
        }
    },
    components: {},
    methods: {
        changeDriver() {
            if (!this.data.url) {
                this.data.url = 'jdbc:oracle:thin:@IP:Port:SID'
            }
        }
    }
}
</script>