Commit c47a7dea authored by kangzhenfei's avatar kangzhenfei

saas--数据源管理&主机管理

parent d0a35de7
...@@ -1000,6 +1000,7 @@ export default { ...@@ -1000,6 +1000,7 @@ export default {
}, },
data_source: { data_source: {
id: '', id: '',
hostName: '主机名称',
hostId: '数据源ID', hostId: '数据源ID',
port: '端口', port: '端口',
userName: '用户名', userName: '用户名',
......
...@@ -148,12 +148,36 @@ export default [ ...@@ -148,12 +148,36 @@ export default [
"app": "App", "app": "App",
"priority": 0, "priority": 0,
"id": 411, "id": 411,
"title": "数据源管理", "title": "主机管理",
"expand": true, "expand": true,
"upId": 410, "upId": 410,
"lay": 2, "lay": 2,
"path": "/system/host", "path": "/system/host",
"header": "home", "header": "home",
"meta": {
"auth": false,
"title": "主机管理",
"closable": true
}
},
{
"name": "system-datasource",
"type": 2,
"code": "",
"icon": "",
"url": "/system/datasource",
"status": 1,
"description": "",
"source": 0,
"app": "App",
"priority": 0,
"id": 413,
"title": "数据源管理",
"expand": true,
"upId": 410,
"lay": 2,
"path": "/system/datasource",
"header": "home",
"meta": { "meta": {
"auth": false, "auth": false,
"title": "数据源管理", "title": "数据源管理",
......
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row>
<Col :span="24">
<FormItem :label="l('hostName')" prop="hostName">
<Input v-model="entity.hostName"></Input>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('hostId')" prop="hostId">
<Dictionary v-model="entity.hostId"></Dictionary>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('port')" prop="port">
<InputNumber v-model="entity.port"></InputNumber>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('userName')" prop="userName">
<Input v-model="entity.userName"></Input>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('password')" prop="password">
<Input v-model="entity.password"></Input>
</FormItem>
</Col>
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Form>
</template>
<script>
import Api from "./api";
export default {
name: "Add",
data() {
return {
disabled: false,
entity: {},
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }]
}
};
},
props: {
v: Object
},
methods: {
handleSubmit() {
this.$refs.form.validate(v => {
if (v) {
this.disabled = true;
Api.create(this.entity)
.then(r => {
this.disabled = false;
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch(err => {
this.disabled = false;
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
l(key) {
key = "data_source" + "." + key;
return this.$t(key);
}
},
watch: {
v() {
this.entity = this.$u.clone(this.v);
}
}
};
</script>
\ No newline at end of file
import Api from '@/plugins/request'
export default {
index:`${systemNew}/datasource/paged`,
paged(params){
return Api.post(`${systemNew}/datasource/paged`,params);
},
get(params){
return Api.get(`${systemNew}/datasource/get`,params);
},
create(params){
return Api.post(`${systemNew}/datasource/create`,params);
},
update(params){
return Api.post(`${systemNew}/datasource/update`,params);
},
//删除:
delete(params) {
return Api.delete(`${systemNew}/datasource/delete`,{params:params});
},
}
\ No newline at end of file
<template>
<div class="detail">
<Row>
<Filed :span="24" :name="l('hostName')">{{entity.hostName}}</Filed>
<Filed :span="24" :name="l('port')">{{entity.port}}</Filed>
<Filed :span="24" :name="l('userName')">{{entity.userName}}</Filed>
<Filed :span="24" :name="l('password')">{{entity.password}}</Filed>
</Row>
</div>
</template>
<script>
import Api from './api'
export default {
name: 'Add',
data() {
return {
entity: {hostName:'', port: 0, userName: '', password: '' },
rules: {
name: [{ required: true, message: '必填', trigger: 'blur' }],
code: [{ required: true, message: '必填', trigger: 'blur' }]
}
}
},
props: {
eid: Number
},
methods: {
load(v) {
Api.get({ id: v }).then((r) => {
this.entity = r.result
this.$emit('on-load')
})
},
handleClose() {
this.$emit('on-close')
},
l(key) {
key = 'data_source' + '.' + key
return this.$t(key)
}
},
watch: {
eid(v) {
if (v != 0) {
this.load(v)
}
}
}
}
</script>
\ No newline at end of file
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row>
<Col :span="24">
<FormItem :label="l('hostName')" prop="hostName">
<Input v-model="entity.hostName"></Input>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('hostId')" prop="hostId">
<Dictionary v-model="entity.hostId"></Dictionary>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('port')" prop="port">
<InputNumber v-model="entity.port"></InputNumber>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('userName')" prop="userName">
<Input v-model="entity.userName"></Input>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('password')" prop="password">
<Input v-model="entity.password"></Input>
</FormItem>
</Col>
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Form>
</template>
<script>
import Api from "./api";
export default {
name: "Edit",
data() {
return {
disabled: false,
entity: {},
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }]
}
};
},
props: {
eid: Number
},
methods: {
load(v) {
Api.get({ id: v }).then(r => {
this.entity = r.result;
this.$emit("on-load");
});
},
handleSubmit() {
this.$refs.form.validate(v => {
if (v) {
this.disabled = true;
Api.update(this.entity)
.then(r => {
this.disabled = false;
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch(err => {
this.disabled = false;
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
l(key) {
key = "data_source" + "." + key;
return this.$t(key);
}
},
watch: {
eid(v) {
if (v != 0) {
this.load(v);
}
}
}
};
</script>
\ No newline at end of file
<template>
<div>
<DataGrid :columns="columns" ref="grid" :action="action">
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input placeholder="请输入关键字用户名" v-model="easySearch.keys.value" />
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<template slot="searchForm">
<Search />
</template>
<template slot="buttons">
<Button type="primary" @click="addModal=true">新增</Button>
</template>
</DataGrid>
<Modal v-model="addModal" title="新增" footer-hide>
<Add @on-close="cancel" @on-ok="addOk" />
</Modal>
<Modal v-model="editModal" title="编辑" footer-hide>
<Edit :eid="curId" @on-close="cancel" @on-ok="addOk" />
</Modal>
<Modal v-model="detailModal" title="详情">
<Detail :eid="curId" />
</Modal>
<Modal v-model="deletelModal" title="删除" @on-ok="removeOk" @on-cancel="cancel">
<p>确定删除?</p>
</Modal>
</div>
</template>
<script>
import Api from './api'
import Add from './add'
import Edit from './edit'
import Detail from './detail'
import Search from './search'
export default {
name: 'list',
components: {
Add,
Edit,
Detail,
Search
},
data() {
return {
action: Api.index,
easySearch: {
keys: { op: 'userName', value: null }
},
addModal: false,
editModal: false,
detailModal: false,
deletelModal: false,
curId: 0,
columns: [
{ key: 'id', title: this.l('id'), hide: true, align: 'left' },
{ key: 'hostName', title: this.l('hostName'), align: 'left', high: true },
{ key: 'hostId', title: this.l('hostId'), align: 'left', high: true },
{ key: 'port', title: this.l('port'), align: 'left', high: true },
{
key: 'userName',
title: this.l('userName'),
align: 'left',
easy: true,
high: true
},
{ key: 'password', title: this.l('password'), align: 'left' },
{
key: 'creationTime',
title: this.l('creationTime'),
hide: true,
align: 'left'
},
{
key: 'creatorUserId',
title: this.l('creatorUserId'),
hide: true,
align: 'left'
},
{
key: 'lastModificationTime',
title: this.l('lastModificationTime'),
hide: true,
align: 'left'
},
{
key: 'lastModifierUserId',
title: this.l('lastModifierUserId'),
hide: true,
align: 'left'
},
{
key: 'isDeleted',
title: this.l('isDeleted'),
hide: true,
align: 'left'
},
{
key: 'deletionTime',
title: this.l('deletionTime'),
hide: true,
align: 'left'
},
{
key: 'deleterUserId',
title: this.l('deleterUserId'),
hide: true,
align: 'left'
},
{
title: '操作',
key: 'id',
width: 140,
align: 'center',
render: (h, params) => {
return h('div', { class: 'action' }, [
h(
'op',
{
attrs: { oprate: 'detail' },
on: { click: () => this.detail(params.row.id) }
},
'查看'
),
h(
'op',
{
attrs: { oprate: 'edit' },
on: { click: () => this.edit(params.row.id) }
},
'编辑'
),
h(
'op',
{
attrs: { oprate: 'remove' },
on: { click: () => this.remove(params.row.id) }
},
'删除'
)
])
}
}
]
}
},
mounted() {
console.log(this)
},
async fetch({ store, params }) {
await store.dispatch('loadDictionary') // 加载数据字典
},
methods: {
addOk() {
this.$refs.grid.load()
this.addModal = false
this.detailModal = false
this.editModal = false
this.curId = 0
},
search() {
this.$refs.grid.reload(this.easySearch)
},
detail(id) {
this.detailModal = true
this.curId = id
},
edit(id) {
this.editModal = true
this.curId = id
},
remove(id) {
this.deletelModal = true
this.curId = id
},
removeOk() {
Api.delete({ id: this.curId }).then((r) => {
if (r.success) {
this.$refs.grid.load()
this.deletelModal = false
this.$Message.success('删除成功')
}
})
},
removeCancel() {
this.deletelModal = false
},
cancel() {
this.curId = 0
this.addModal = false
this.detailModal = false
this.editModal = false
this.deletedlModal = false
},
l(key) {
/*
data_source:{
id:'',
hostName:'主机名称',
hostId:'数据源ID',
port:'端口',
userName:'用户名',
password:'密码',
creationTime:'创建时间',
creatorUserId:'创建人',
lastModificationTime:'更新时间',
lastModifierUserId:'更新人',
isDeleted:'是否删除',
deletionTime:'删除时间',
deleterUserId:'删除人',
}
*/
let vkey = 'data_source' + '.' + key
return this.$t(vkey) || key
}
}
}
</script>
<style lang="less">
</style>
\ No newline at end of file
<template>
<Form ref="form" :model="condition" :label-width="90">
<Row>
<Col :span="12" :v-if="condition.id.show">
<FormItem :label="l('id')" prop="id">
<Input v-model="condition.id.value"></Input>
</FormItem>
</Col>
<Col :span="24" :v-if="condition.hostId.show">
<FormItem :label="l('hostId')" prop="hostId">
<Dictionary v-model="condition.hostId.value"></Dictionary>
</FormItem>
</Col>
<Col :span="24" :v-if="condition.port.show">
<FormItem :label="l('port')" prop="port">
<Input v-model="condition.port.value"></Input>
</FormItem>
</Col>
<Col :span="24" :v-if="condition.userName.show">
<FormItem :label="l('userName')" prop="userName">
<Input v-model="condition.userName.value"></Input>
</FormItem>
</Col>
<Col :span="24" :v-if="condition.password.show">
<FormItem :label="l('password')" prop="password">
<Input v-model="condition.password.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.creationTime.show">
<FormItem :label="l('creationTime')" prop="creationTime">
<DatePicker type="daterange" v-model="condition.creationTime.value"></DatePicker>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.creatorUserId.show">
<FormItem :label="l('creatorUserId')" prop="creatorUserId">
<Input v-model="condition.creatorUserId.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.lastModificationTime.show">
<FormItem :label="l('lastModificationTime')" prop="lastModificationTime">
<DatePicker type="daterange" v-model="condition.lastModificationTime.value"></DatePicker>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.lastModifierUserId.show">
<FormItem :label="l('lastModifierUserId')" prop="lastModifierUserId">
<Input v-model="condition.lastModifierUserId.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.isDeleted.show">
<FormItem :label="l('isDeleted')" prop="isDeleted">
<Input v-model="condition.isDeleted.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.deletionTime.show">
<FormItem :label="l('deletionTime')" prop="deletionTime">
<DatePicker type="daterange" v-model="condition.deletionTime.value"></DatePicker>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.deleterUserId.show">
<FormItem :label="l('deleterUserId')" prop="deleterUserId">
<Input v-model="condition.deleterUserId.value"></Input>
</FormItem>
</Col>
</Row>
</Form>
</template>
<script>
import Api from "./api";
export default {
name: "Add",
data() {
return {
condition: {
id: { op: "Equal", value: null, show: false },
hostId: { op: "Equal", value: null, show: true },
port: { op: "Equal", value: null, show: true },
userName: { op: "Equal", value: null, show: true },
password: { op: "Equal", value: null, show: false },
creationTime: { op: "Range", value: null, show: false },
creatorUserId: { op: "Equal", value: null, show: false },
lastModificationTime: { op: "Range", value: null, show: false },
lastModifierUserId: { op: "Equal", value: null, show: false },
isDeleted: { op: "Equal", value: null, show: false },
deletionTime: { op: "Range", value: null, show: false },
deleterUserId: { op: "Equal", value: null, show: false }
}
};
},
methods: {
handleClose() {
this.$emit("on-close");
},
l(key) {
key = "data_source" + "." + key;
return this.$t(key);
}
}
};
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment