提交 | 用户 | 时间
|
759b1c
|
1 |
<template> |
H |
2 |
<div class="app-container"> |
|
3 |
<!-- 操作工具栏 --> |
|
4 |
<el-row :gutter="10" class="mb8"> |
|
5 |
<el-col :span="1.5"> |
|
6 |
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" |
|
7 |
v-hasPermi="['infra:data-source-config:create']">新增</el-button> |
|
8 |
</el-col> |
|
9 |
</el-row> |
|
10 |
|
|
11 |
<!-- 列表 --> |
|
12 |
<el-table v-loading="loading" :data="list"> |
|
13 |
<el-table-column label="主键编号" align="center" prop="id" /> |
|
14 |
<el-table-column label="数据源名称" align="center" prop="name" /> |
|
15 |
<el-table-column label="数据源连接" align="center" prop="url" /> |
|
16 |
<el-table-column label="用户名" align="center" prop="username" /> |
|
17 |
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
|
18 |
<template v-slot="scope"> |
|
19 |
<span>{{ parseTime(scope.row.createTime) }}</span> |
|
20 |
</template> |
|
21 |
</el-table-column> |
|
22 |
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
|
23 |
<template v-slot="scope"> |
|
24 |
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" |
|
25 |
v-hasPermi="['infra:data-source-config:update']">修改</el-button> |
|
26 |
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" |
|
27 |
v-hasPermi="['infra:data-source-config:delete']">删除</el-button> |
|
28 |
</template> |
|
29 |
</el-table-column> |
|
30 |
</el-table> |
|
31 |
|
|
32 |
<!-- 对话框(添加 / 修改) --> |
|
33 |
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
|
34 |
<el-form ref="form" :model="form" :rules="rules" label-width="100px"> |
|
35 |
<el-form-item label="数据源名称" prop="name"> |
|
36 |
<el-input v-model="form.name" placeholder="请输入参数名称" /> |
|
37 |
</el-form-item> |
|
38 |
<el-form-item label="数据源连接" prop="url"> |
|
39 |
<el-input v-model="form.url" placeholder="请输入数据源连接" /> |
|
40 |
</el-form-item> |
|
41 |
<el-form-item label="用户名" prop="username"> |
|
42 |
<el-input v-model="form.username" placeholder="请输入用户名" /> |
|
43 |
</el-form-item> |
|
44 |
<el-form-item label="密码" prop="password"> |
|
45 |
<el-input v-model="form.password" placeholder="请输入密码" /> |
|
46 |
</el-form-item> |
|
47 |
</el-form> |
|
48 |
<div slot="footer" class="dialog-footer"> |
|
49 |
<el-button type="primary" @click="submitForm">确 定</el-button> |
|
50 |
<el-button @click="cancel">取 消</el-button> |
|
51 |
</div> |
|
52 |
</el-dialog> |
|
53 |
</div> |
|
54 |
</template> |
|
55 |
|
|
56 |
<script> |
|
57 |
import { createDataSourceConfig, updateDataSourceConfig, deleteDataSourceConfig, getDataSourceConfig, getDataSourceConfigList } from "@/api/infra/dataSourceConfig"; |
|
58 |
|
|
59 |
export default { |
|
60 |
name: "InfraDataSourceConfig", |
|
61 |
components: { |
|
62 |
}, |
|
63 |
data() { |
|
64 |
return { |
|
65 |
// 遮罩层 |
|
66 |
loading: true, |
|
67 |
// 总条数 |
|
68 |
total: 0, |
|
69 |
// 数据源配置列表 |
|
70 |
list: [], |
|
71 |
// 弹出层标题 |
|
72 |
title: "", |
|
73 |
// 是否显示弹出层 |
|
74 |
open: false, |
|
75 |
// 表单参数 |
|
76 |
form: {}, |
|
77 |
// 表单校验 |
|
78 |
rules: { |
|
79 |
name: [{ required: true, message: "数据源名称不能为空", trigger: "blur" }], |
|
80 |
url: [{ required: true, message: "数据源连接不能为空", trigger: "blur" }], |
|
81 |
username: [{ required: true, message: "用户名不能为空", trigger: "blur" }], |
|
82 |
password: [{ required: true, message: "密码不能为空", trigger: "blur" }], |
|
83 |
} |
|
84 |
}; |
|
85 |
}, |
|
86 |
created() { |
|
87 |
this.getList(); |
|
88 |
}, |
|
89 |
methods: { |
|
90 |
/** 查询列表 */ |
|
91 |
getList() { |
|
92 |
this.loading = true; |
|
93 |
// 执行查询 |
|
94 |
getDataSourceConfigList().then(response => { |
|
95 |
this.list = response.data; |
|
96 |
this.loading = false; |
|
97 |
}); |
|
98 |
}, |
|
99 |
/** 取消按钮 */ |
|
100 |
cancel() { |
|
101 |
this.open = false; |
|
102 |
this.reset(); |
|
103 |
}, |
|
104 |
/** 表单重置 */ |
|
105 |
reset() { |
|
106 |
this.form = { |
|
107 |
id: undefined, |
|
108 |
name: undefined, |
|
109 |
url: undefined, |
|
110 |
username: undefined, |
|
111 |
password: undefined, |
|
112 |
}; |
|
113 |
this.resetForm("form"); |
|
114 |
}, |
|
115 |
/** 新增按钮操作 */ |
|
116 |
handleAdd() { |
|
117 |
this.reset(); |
|
118 |
this.open = true; |
|
119 |
this.title = "添加数据源配置"; |
|
120 |
}, |
|
121 |
/** 修改按钮操作 */ |
|
122 |
handleUpdate(row) { |
|
123 |
this.reset(); |
|
124 |
const id = row.id; |
|
125 |
getDataSourceConfig(id).then(response => { |
|
126 |
this.form = response.data; |
|
127 |
this.open = true; |
|
128 |
this.title = "修改数据源配置"; |
|
129 |
}); |
|
130 |
}, |
|
131 |
/** 提交按钮 */ |
|
132 |
submitForm() { |
|
133 |
this.$refs["form"].validate(valid => { |
|
134 |
if (!valid) { |
|
135 |
return; |
|
136 |
} |
|
137 |
// 修改的提交 |
|
138 |
if (this.form.id != null) { |
|
139 |
updateDataSourceConfig(this.form).then(response => { |
|
140 |
this.$modal.msgSuccess("修改成功"); |
|
141 |
this.open = false; |
|
142 |
this.getList(); |
|
143 |
}); |
|
144 |
return; |
|
145 |
} |
|
146 |
// 添加的提交 |
|
147 |
createDataSourceConfig(this.form).then(response => { |
|
148 |
this.$modal.msgSuccess("新增成功"); |
|
149 |
this.open = false; |
|
150 |
this.getList(); |
|
151 |
}); |
|
152 |
}); |
|
153 |
}, |
|
154 |
/** 删除按钮操作 */ |
|
155 |
handleDelete(row) { |
|
156 |
const id = row.id; |
|
157 |
this.$modal.confirm('是否确认删除数据源配置编号为"' + id + '"的数据项?').then(function() { |
|
158 |
return deleteDataSourceConfig(id); |
|
159 |
}).then(() => { |
|
160 |
this.getList(); |
|
161 |
this.$modal.msgSuccess("删除成功"); |
|
162 |
}).catch(() => {}); |
|
163 |
} |
|
164 |
} |
|
165 |
}; |
|
166 |
</script> |