wujingjing
2025-01-02 3b6326a5f7be428657e2252560d10eb09e34eab9
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
<template>
    <yw-dialog v-model="isShow" :showFooter="false" width="500" :title="title">
        <el-form :label-width="labelWidth" v-if="item.config">
            <el-form-item label="用户名">
                <el-input v-model="item.config.user" readonly />
            </el-form-item>
            <el-form-item label="驱动">
                <el-input v-model="item.config.driver" readonly />
            </el-form-item>
            <el-form-item label="地址">
                <el-input v-model="item.config.url" readonly />
            </el-form-item>
        </el-form>
    </yw-dialog>
</template>
 
<script setup lang="ts" name="DataSourceConfigDlg">
import _ from 'lodash';
import { computed, ref, watch } from 'vue';
import ywDialog from '/@/components/dialog/yw-dialog.vue';
 
const props = defineProps(['item']);
const isShow = defineModel({
    type: Boolean,
});
 
const title = computed(() => props.item?.title + '——数据源配置');
 
// 计算最长的label宽度
const labelWidth = computed(() => {
    const labels = ['驱动', '地址', '用户名'];
    const maxLengthLabel = labels.reduce((prev, current) => {
        return prev.length > current.length ? prev : current;
    }, '');
    // 每个中文字符按16px计算,额外加20px留白
    return `${maxLengthLabel.length * 16 + 20}px`;
});
</script>
<style scoped lang="scss">
:deep(.el-card__body) {
    position: relative;
}
</style>