feat: 增加部分后端交互

This commit is contained in:
chenjinsong
2019-12-09 19:23:20 +08:00
parent 493c4db1c9
commit 0f8707d9a5
5 changed files with 137 additions and 39 deletions

View File

@@ -202,15 +202,14 @@
</style> </style>
<template> <template>
<div class="account"> <div class="account">
<div class="content-left"> <div class="content-left">
<div class="sidebar-title"> <div class="sidebar-title">
<div>Config</div> <div>Config</div>
<div class="sidebar-info"> <div class="sidebar-info">
<div class="sidebar-info-footer" v-if="sidebarState"> <div class="sidebar-info-footer" v-if="sidebarState"></div>
</div>
</div> </div>
</div>
</div> </div>
</div>
<div class="account-list"> <div class="account-list">
<el-input <el-input
class="account-list-search" class="account-list-search"
@@ -442,7 +441,7 @@ export default {
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
pageSize: 20, pageSize: 20,
total:9 total:0
}, },
tableTitle: [ tableTitle: [
{ {

View File

@@ -246,7 +246,7 @@
</span> </span>
<span v-else-if="item.prop == 'status'"> <span v-else-if="item.prop == 'status'">
<el-switch <el-switch
v-model="scope.row[item.prop]" v-model="scope.row.status"
active-value="1" active-value="1"
inactive-value="0"> inactive-value="0">
</el-switch> </el-switch>
@@ -413,12 +413,12 @@ export default {
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
pageSize: 20, pageSize: 20,
total:13 total:0
}, },
tableTitle: [ tableTitle: [
{ {
label: 'ID', label: 'ID',
prop: 'id', prop: 'userId',
show: true, show: true,
width: 80 width: 80
}, { }, {
@@ -457,8 +457,9 @@ export default {
show: true, show: true,
} }
], ],
tableData: [{ tableData: [],
id: '1', /*tableData: [{
userId: '1',
username: '王小虎1', username: '王小虎1',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -472,7 +473,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '2', userId: '2',
username: '王小虎2', username: '王小虎2',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -486,7 +487,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '0' status: '0'
}, { }, {
id: '3', userId: '3',
username: '王小虎3', username: '王小虎3',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -500,7 +501,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '4', userId: '4',
username: '王小虎4', username: '王小虎4',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'zh', lang: 'zh',
@@ -514,7 +515,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '5', userId: '5',
username: '王小虎5', username: '王小虎5',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -528,7 +529,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '6', userId: '6',
username: '王小虎6', username: '王小虎6',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -542,7 +543,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '7', userId: '7',
username: '王小虎7', username: '王小虎7',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -556,7 +557,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '8', userId: '8',
username: '王小虎8', username: '王小虎8',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -574,7 +575,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '9', userId: '9',
username: '王小虎9', username: '王小虎9',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -588,7 +589,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '10', userId: '10',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -602,7 +603,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '222', userId: '222',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -616,7 +617,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '223', userId: '223',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -630,7 +631,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '224', userId: '224',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -644,7 +645,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '226', userId: '226',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -658,7 +659,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '225', userId: '225',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -672,7 +673,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '2', userId: '2',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -686,7 +687,7 @@ export default {
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}, { }, {
id: '2', userId: '2',
username: '王小虎', username: '王小虎',
email: 'c92c@qq.com', email: 'c92c@qq.com',
lang: 'en', lang: 'en',
@@ -702,7 +703,7 @@ export default {
}], }],
createTime: '2019-11-28 21:39:05', createTime: '2019-11-28 21:39:05',
status: '1' status: '1'
}], }],*/
receiverData: [{ receiverData: [{
id: '1', id: '1',
name: 'group1', name: 'group1',
@@ -745,6 +746,17 @@ export default {
this.rightBox.title = this.$t("config.account.account") + " ID" + u.userId; this.rightBox.title = this.$t("config.account.account") + " ID" + u.userId;
this.rightBox.show = true; this.rightBox.show = true;
}, },
getTableData: function() {
this.$get('sys/user/list', this.pageObj).then(response => {
if (response.code === 200) {
for (var i = 0; i < response.data.list.length; i++) {
response.data.list[i].status = response.data.list[i].status + "";
}
this.tableData = response.data.list;
this.pageObj.total = response.data.total
}
})
},
add: function() { add: function() {
this.cleanUser(); this.cleanUser();
this.rightBox.isEdit = true; this.rightBox.isEdit = true;
@@ -755,6 +767,8 @@ export default {
if (!this.rightBox.isEdit) { if (!this.rightBox.isEdit) {
this.rightBox.isEdit = true; this.rightBox.isEdit = true;
this.rightBox.title = this.$t("config.account.editAccount") + " ID" + this.user.userId; this.rightBox.title = this.$t("config.account.editAccount") + " ID" + this.user.userId;
} else {
} }
}, },
toEditReceiver: function(item) { toEditReceiver: function(item) {
@@ -786,7 +800,7 @@ export default {
}, },
toDelReceiver: function(item) { toDelReceiver: function(item) {
this.blurEditReceiver(); this.blurEditReceiver();
//TODO 请求后台,删除组 //TODO 请求后台,删除用户
}, },
initReceiverData: function() { initReceiverData: function() {
for (var i = 0; i < this.receiverData.length; i++) { for (var i = 0; i < this.receiverData.length; i++) {
@@ -818,9 +832,18 @@ export default {
receiver: [], receiver: [],
lang: 'en' lang: 'en'
} }
},
pageNo(val) {
this.pageObj.pageNo = val;
this.getTableData();
},
pageSize(val) {
this.pageObj.pageSize = val;
this.getTableData();
} }
}, },
mounted() { mounted() {
this.getTableData();
this.initReceiverData(); this.initReceiverData();
} }
} }

View File

@@ -357,7 +357,7 @@ export default {
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
pageSize: 20, pageSize: 20,
total:6 total:0
}, },
tableTitle: [ tableTitle: [
{ {
@@ -375,7 +375,8 @@ export default {
show: true, show: true,
} }
], ],
tableData: [ tableData: [],
/*tableData: [
{ {
id: '1', id: '1',
host: '192.168.40.241', host: '192.168.40.241',
@@ -406,8 +407,9 @@ export default {
host: '192.168.40.246', host: '192.168.40.246',
idc: {id: '9', name: 'idc151657', location: 'fj'} idc: {id: '9', name: 'idc151657', location: 'fj'}
}, },
], ],*/
idcData: [ idcData: []
/*idcData: [
{id: '1', name: 'idc151656', location: 'gd'}, {id: '1', name: 'idc151656', location: 'gd'},
{id: '2', name: 'idc151656', location: 'gd'}, {id: '2', name: 'idc151656', location: 'gd'},
{id: '3', name: 'aerareqarew', location: 'zhaertaewr'}, {id: '3', name: 'aerareqarew', location: 'zhaertaewr'},
@@ -417,7 +419,7 @@ export default {
{id: '7', name: 'idc151656', location: 'gd'}, {id: '7', name: 'idc151656', location: 'gd'},
{id: '8', name: 'idc151656', location: 'gd'}, {id: '8', name: 'idc151656', location: 'gd'},
{id: '9', name: 'idc151657', location: 'fj'}, {id: '9', name: 'idc151657', location: 'fj'},
] ]*/
} }
}, },
methods: { methods: {
@@ -429,6 +431,14 @@ export default {
}, },
del: function(u) { del: function(u) {
}, },
getTableData: function() {
this.$get('promServer', this.pageObj).then(response => {
if (response.code === 200) {
this.tableData = response.data.list;
this.pageObj.total = response.data.total
}
})
},
detail: function(u) { detail: function(u) {
this.promServer = Object.assign({}, u); this.promServer = Object.assign({}, u);
this.rightBox.isEdit = false; this.rightBox.isEdit = false;
@@ -445,6 +455,14 @@ export default {
if (!this.rightBox.isEdit) { if (!this.rightBox.isEdit) {
this.rightBox.isEdit = true; this.rightBox.isEdit = true;
this.rightBox.title = this.$t("config.promServer.editProm") + " ID" + this.promServer.id; this.rightBox.title = this.$t("config.promServer.editProm") + " ID" + this.promServer.id;
} else {
this.$put('promServer', this.promServer).then(response => {
if (response.code === 200) {
this.getTableData();
this.rightBox.isEdit = false;
}
})
} }
}, },
toEditIdc: function(item) { toEditIdc: function(item) {
@@ -478,7 +496,12 @@ export default {
this.blurEditIdc(); this.blurEditIdc();
//TODO 请求后台,删除 //TODO 请求后台,删除
}, },
initIdcData: function() { getIdcData: function() {
this.$get('idc', this.pageObj).then(response => {
if (response.code === 200) {
this.idcData = response.data.list;
}
})
for (var i = 0; i < this.idcData.length; i++) { for (var i = 0; i < this.idcData.length; i++) {
this.$set(this.idcData[i], 'oldName', this.idcData[i].name); this.$set(this.idcData[i], 'oldName', this.idcData[i].name);
this.$set(this.idcData[i], 'isEdit', false); this.$set(this.idcData[i], 'isEdit', false);
@@ -489,6 +512,23 @@ export default {
}, },
stopFun: function() { stopFun: function() {
},
getTableData: function() {
this.$get('promServer', this.pageObj).then(response => {
if (response.code === 200) {
console.info(this.idcData)
for (var i = 0; i < response.data.list.length; i++) {
for (var j = 0; j < this.idcData.length; j++) {
if (response.data.list[i].idcId == this.idcData[j].id) {
response.data.list[i].idc = this.idcData[j];
break;
}
}
}
this.tableData = response.data.list;
this.pageObj.total = response.data.total
}
})
}, },
updateIdcName: function(item) { updateIdcName: function(item) {
//TODO 请求接口改名 //TODO 请求接口改名
@@ -502,12 +542,22 @@ export default {
this.promServer = { this.promServer = {
id: '', id: '',
host: '', host: '',
idcId: '',
idc: {id: '', name: '', location: ''} idc: {id: '', name: '', location: ''}
} }
},
pageNo(val) {
this.pageObj.pageNo = val;
this.getTableData();
},
pageSize(val) {
this.pageObj.pageSize = val;
this.getTableData();
} }
}, },
mounted() { mounted() {
this.initIdcData(); this.getIdcData();
this.getTableData();
} }
} }
</script> </script>

View File

@@ -36,3 +36,27 @@ export function post(url, params) {
}) })
}) })
} }
export function put(url, params) {
return new Promise((resolve, reject) => {
//params = qs.stringify(Object.assign(params));
//console.info(params);
axios.put(url, params).then(response => {
resolve(response.data)
}).catch(err => {
console.info(err)
reject(err.response.data)
})
})
}
export function del(url, params) {
return new Promise((resolve, reject) => {
axios.delete(url, params).then(response => {
resolve(response.data)
}).catch(err => {
console.info(err)
reject(err.response.data)
})
})
}

View File

@@ -12,7 +12,7 @@ import router from './router'
import axios from 'axios'; import axios from 'axios';
import {post, get} from './http.js' import {post, get, put, del} from './http.js'
import Pagination from "./components/common/pagination"; //引入全局分页组件 import Pagination from "./components/common/pagination"; //引入全局分页组件
Vue.component("Pagination", Pagination); Vue.component("Pagination", Pagination);
@@ -20,6 +20,8 @@ Vue.component("Pagination", Pagination);
Vue.prototype.$axios = axios Vue.prototype.$axios = axios
Vue.prototype.$post = post; Vue.prototype.$post = post;
Vue.prototype.$get = get; Vue.prototype.$get = get;
Vue.prototype.$put = put;
Vue.prototype.$delete = del;
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(ElementUI) Vue.use(ElementUI)