Commit 04de1051 by 夏新然

可登录暂时版本

1 parent e056acf7
No preview for this file type
......@@ -6,10 +6,10 @@ import search from "./search";
import device from "./device"
import resource from "./resource"
import ops from "./ops"
let wsIP = "192.168.9.133:20080";
let wsIP = "vion-panda.51vip.biz:52510";
switch (process.env.NODE_ENV) {
case "development":
wsIP = "192.168.9.133:20080"; // 测试环境url
wsIP = "vion-panda.51vip.biz:52510"; // 测试环境url
// baseUrl = "http://192.168.9.61:8086";
break;
case "pre":
......
......@@ -17,7 +17,7 @@ service.interceptors.request.use(
}
if (config.method == 'get') {
config.params = {
_t: Date.parse(new Date()) / 1000,
// _t: Date.parse(new Date()) / 1000,
...config.params
}
}
......
......@@ -6,5 +6,6 @@ export default {
cates: baseUrl + "/api/v1/codes/traffic/cates",
codes: baseUrl + "/api/v1/codes/traffic/cates/",
customCode:baseUrl + "/api/v1/codes/custom/cates",
menus:baseUrl + "/api/v1/auth/menu_tree"
menus:baseUrl + "/api/v1/auth/apps/0d88c025fafc5ad1189670655597c183/menus"
// getApps:baseUrl + "/api/v1/auth/apps"
};
......@@ -5,7 +5,7 @@ export default {
pass:baseUrl+'/api/v1/datahandle/behavior/audit/',
delResult:baseUrl+'/api/v1/datahandle/behavior/events/',
delEvent:baseUrl+'/api/v1/datahandle/behavior/archive/',
eventTypeData:'http://192.168.9.133:20080'+'/api/v1/codes/event_types',
eventTypeData:baseUrl+'/api/v1/codes/event_types',
homeNum:baseUrl+'/api/v1/datahandle/statistics/type',
homeLine:baseUrl+'/api/v1/datahandle/statistics/hour',
homeCatch:baseUrl+'/api/v1/datahandle/statistics/handle',
......
import api from '../index'
import baseUrl from '../baseUrl'
export default {
getUserList(params){
return api.get(`${baseUrl}/api/v1/devconf_fx/users`, params)
getUserList(params,id){
return api.get(`${baseUrl}/api/v1/auth/users/${id}`, params)
},
getRoleList(params,id) {
return api.get(`${baseUrl}/api/v1/devconf_fx/roles`, params)
return api.get(`${baseUrl}/api/v1/auth/roles`, params)
},
addUser(params){
return api.post(`${baseUrl}/api/v1/devconf_fx/users`, params)
return api.post(`${baseUrl}/api/v1/auth/users`, params)
},
editUser(params,id) {
return api.post(`${baseUrl}/api/v1/devconf_fx/users/${id}`, params)
......@@ -23,9 +23,12 @@ export default {
return api.get(`${baseUrl}/api/v1/devconf_fx/menu/list`, params)
},
addRole(params){
return api.post(`${baseUrl}/api/v1/devconf_fx/roles`, params)
return api.post(`${baseUrl}/api/v1/auth/roles`, params)
},
logList(params){
return api.get(`${baseUrl}/api/v1/devconf_fx/logs`, params)
},
bindperms(params,id){
return api.post(`${baseUrl}/api/v1/auth/roles/${id}/perms`, params)
}
}
\ No newline at end of file
......@@ -47,6 +47,7 @@ export default {
uploadFile(params,id){
return api.post(`${baseUrl}/api/v1/devconf_fx/devs/${id}/vfile_vchans`, params,{'Content-Type': 'multipart/form-data'})
},
getResource(params,id){
return api.get(`${baseUrl}/api/v1/devconf_fx/devs/${id}/status`, params)
},
......@@ -56,6 +57,9 @@ export default {
getStoreConList(params){
return api.get(`${baseUrl}/api/v1/devconf_fx/store_confs`, params)
},
uploadStore(params){
return api.post(`${baseUrl}/api/v1/devconf_fx/store_confs`, params,{'Content-Type': 'multipart/form-data'})
},
getSubTask(params,id){
return api.get(`${baseUrl}/api/v1/devconf_fx/tasks/${id}/subtasks`, params)
},
......
......@@ -2,7 +2,7 @@ import api from "../index";
import baseUrl from "../baseUrl";
export default {
getEventType() {
return api.get(`http://192.168.9.133:20080/api/v1/codes/event_types`);
return api.get(`${baseUrl}/api/v1/codes/event_types`);
},
getTrafficType(params) {
//类型统计
......
......@@ -201,6 +201,13 @@ export const asyncRouterMap = [
},
component: resolve => require(["../views/ops/role_manage.vue"], resolve),
},{
path: "/ops/batch_upgrade",
name: "批量升级",
meta: {
icon: "el-icon-location"
},
component: resolve => require(["../views/ops/log_manage.vue"], resolve),
},{
path: "/ops/log_manage",
name: "日志管理",
meta: {
......
......@@ -36,10 +36,10 @@ function filterAsyncRouter(asyncRouterMap, roles) {
// return routers
asyncRouterMap.forEach((ele, index) => {
roles.map(m => {
if (ele.path == m.menu_api) {
if (ele.path == m.path) {
let obj = ele;
if (m.childs && m.childs.length > 0) {
obj.children = filterAsyncRouter(ele.children, m.childs);
if (m.children && m.children.length > 0) {
obj.children = filterAsyncRouter(ele.children, m.children);
} else {
obj.children = []
}
......@@ -72,6 +72,7 @@ const menu = {
commit("SET_ROUTERS", []);
return;
} else {
console.log('aaa',data)
let accessedRouters = filterAsyncRouter(asyncRouterMap, data);
commit("SET_ROUTERS", accessedRouters);
}
......
......@@ -46,7 +46,8 @@ import types from '../store/types.js'
login(){
this.$api.login.login({
"username":this.username,
"password":this.password
"password":this.password,
"user_type": "user"
}).then(res => {
if(!res.ecode){
this.$store.commit(types.ATOKEN,res.atoken);
......@@ -76,10 +77,10 @@ import types from '../store/types.js'
getMenu(id){
//获取菜单
this.$api.login.getMenus({
"app_unid":id
"shape":"tree"
}).then(res=>{
localStorage.setItem('menu', JSON.stringify(res.menu_tree))
this.$store.dispatch('GetMenuRole',res.menu_tree).then(res => {
localStorage.setItem('menu', JSON.stringify(res.menu_tree[0].children))
this.$store.dispatch('GetMenuRole',res.menu_tree[0].children).then(res => {
this.$router.push('/')
})
})
......
<template>
<div class="innnerBox">
<el-col :span="22">
<el-form ref="form" label-width="80px" inline>
<el-form-item label="运维设备">
<span class="selectBox">
<el-select placeholder="请选择" :popper-append-to-body=false v-model="devSeled">
<el-option :value="item.value" :label='item.label' v-for="item in devOpt"></el-option>
</el-select>
</span>
</el-form-item>
</el-form>
</el-col>
<el-col :span="2">
<div style="margin-bottom: 6px;padding-top: 3px;">
<el-button type="success" class="block" @click="batchUpdate">批量升级</el-button>
</div>
</el-col>
<div style="">
<el-table
:data="tableData"
height="574"
stripe
border
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
align="center"
width="55">
</el-table-column>
<el-table-column
prop="device_name"
align="center"
label="设备名称">
</el-table-column>
<el-table-column
prop="in_ip"
align="center"
label="内网IP">
</el-table-column>
<el-table-column
prop="out_ip"
align="center"
label="外网IP">
</el-table-column>
<el-table-column
prop="software_version"
align="center"
label="当前版本">
</el-table-column>
<el-table-column
prop="RefinedFeature_text"
align="center"
label="升级状态">
<template slot-scope="scope">
<span :style="{ color: scope.row.styleC }" :class="{ 'span-progress': scope.row.spanClass }">{{ scope.row.state }}</span>
<strong id="bar" :style="{ width: scope.row.styleW }">{{ scope.row.fileText }}</strong>
</template>
</el-table-column>
<el-table-column
align="center"
label="操作">
<template slot-scope="scope">
<el-tooltip content="详情" placement="bottom" effect="light" :visible-arrow=false>
<span class="iconfont icon-xiugai editIcon" @click="detailFun(scope.$index, scope.row)"></span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<div style="margin-top: 28px;">
<el-pagination
style="float: right;"
background
prev-text="上一页"
next-text="下一页"
:page-sizes="[30, 50, 100, 200]"
layout="prev, pager, next,sizes"
:current-page="page"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:total="total">
</el-pagination>
<div style="clear: both;"></div>
</div>
</div>
<el-dialog
title="批量上传"
:visible.sync="addVisible"
width="450px">
<div>
<el-form label-position="left" label-width="120px">
<el-form-item label="添加文件">
<el-upload
ref="upload"
action="uploadUrl"
:http-request="httpRequest"
:multiple=false
:limit="1"
:on-exceed="handleExceed"
name="file"
:auto-upload="false">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<!-- <div slot="tip" class="el-upload__tip">只能上传视频文件</div> -->
</el-upload>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="addVisible=false">取 消</el-button>
<el-button type="primary" @click="save">上 传</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
data(){
return{
uploadUrl:'',
file:[],
addVisible:false,
tableData:[],
total:0,
page:1,
pageSize:30,
selectcheck:[],
devOpt:[],
devSeled:'',
flag:true,
updating:false
}
},
components:{},
mounted(){
this.getDevs();
},
methods:{
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
// 自定义的上传函数
httpRequest(param) {
console.log(param)
if(param.filename) {
let modalFileExt = param.filename.slice(-7);
if(modalFileExt !== '.tar.gz') {
this.$message({
type: 'warning',
message: '仅支持"*.tar.gz"文件'
})
return false;
}
}else{
this.$message({
type: 'warning',
message: '请选择文件'
})
return false;
}
this.flag = true
for (let i = 0; i < this.selectcheck.length; i++) {
const upgradeSoftWare = this.selectcheck[i].upgradeSoftWare;
let isOk = false
for (let j = 0; j < upgradeSoftWare.length; j++) {
const ele = upgradeSoftWare[j];
let ary = param.filename.split('_')
console.log(ele.softWareName==ary[0])
console.log(ele.platType==ary[1])
if (ele.platType==ary[1]&&ele.softWareName==ary[0]) {
isOk = true
break;
}
}
console.log('isok'+isOk)
if (!isOk) {
this.flag = false
break
}
}
if(flag){
this.file=[];
// 一般情况下是在这里创建FormData对象,但我们需要上传多个文件,为避免发送多次请求,因此在这里只进行文件的获取,param可以拿到文件上传的所有信息
this.file.push(param.file)
}else{
this.$alert('该升级包不能应用于所有选中的节点,请重新选择', '提示', {
confirmButtonText: '确定',
});
return false
}
},
save(){
this.$refs.upload.submit(); // 这里是执行文件上传的函数,其实也就是获取我们要上传的文件
// 最重要的就是这段代码
if(this.flag){
// var upData = new FormData() // 首先创建FormData对象
// this.file.forEach(function (file) {
// upData.append('file', file); // 因为要上传多个文件,所以需要遍历一下才行
// upData.append('name', file.name);
// upData.append('vchan_type', 'vfile');
// upData.append('vchan_refid', new Date().getTime());
// })
// this.$api.resource.uploadFile(upData,this.devsId).then(res=>{
// console.log(res)
// })
console.log('上传')
}
},
handleSelectionChange(obj){
this.selectcheck = obj;
},
handleSizeChange(val) {
this.pageSize=val;
this.getData();
},
handleCurrentChange(val) {
this.page=val;
this.getData();
},
query(){
this.getData();
},
getDevs(){
this.$api.resource.devs({}).then(res=>{
if(res.length > 0) {
this.devOpt = res.map((v, i) => {
return {
value: v.dev_unid,
label: '运维设备' + (++i)
}
});
this.devSeled = this.devOpt[0].value;
this.getData();
} else {
// this.$message({
// message: '运维为空!',
// type: 'error'
// })
console.log('未发现运维!')
return false;
}
})
},
getData(){
this.tableData=[];
let offset = (this.page - 1) * this.pageSize;
let search_params = {
limit: this.pageSize,
offset: offset,
is_leaf:0
}
this.$api.resource.getDevsName(search_params,this.devSeled
).then((res)=>{
this.total=res.total_num;
this.tableData = res.list_data;
this.tableData.forEach(info => {
info.styleC = '#fff'; // 升级状态文字颜色
info.spanClass = false; // 升级状态文字class
info.state = '暂无'; // 升级状态文字
info.styleW = '0%'; // 升级状态进度条宽度
info.fileText = ''; // 升级状态进度条文字
info.unchangeCount = 90;
info.progressQueryErrorTime = {}; // 记录失败设备
})
}).catch((err)=>{
})
},
/* 开始升级 */
modalUpdateClick: function () {
//区别备注
if(this.updating) {
this.$message({
message: '程序正在升级中..',
type: 'warning'
});
return;
}
this.updating = true;
let localUpd = JSON.parse(window.localStorage.getItem('upgradeInfo'));
//获取选中id组
let localDevId = JSON.parse(window.localStorage.getItem('deviceArr'));
console.log('升级之前看有没有未完成升级的:', localUpd)
if(localUpd && localDevId) {
this.queryProgress(localUpd);
this.$message({
type: 'info',
message: '有设备正在升级中...请等待升级完成再进行下次升级!'
})
return;
}
// 筛选正在升级的...
// 保存一份升级设备ID
window.localStorage.setItem('deviceArr', JSON.stringify(this.checkedIndex));
let UpdateArr = JSON.parse(window.localStorage.getItem('deviceArr'));
console.log('本地UpdateArr:', UpdateArr)
this.updateEle = false;
// 初始化状态
for(var i = 0, len = UpdateArr.length; i < len; i++) {
this.modalUpdInfo.forEach(ele => {
if(ele.device_id === UpdateArr[i]) {
// console.log('筛选相同元素:', ele);
ele.spanClass = true;
ele.state = '暂无进度';
ele.styleW = '1%';
ele.styleC = '#fff'
}
})
}
this.updateEle = true;
// 上传文件
let modalFormData = new FormData();
let ele_files = document.getElementById('modalUpgradeFile');
modalFormData.append('list[0].file', ele_files.files[0]);
let fxChildIds = UpdateArr.toString();
let modalFormConfig = {
headers: {
'Content-Type': 'multipart/form-data',
'authorization': window.localStorage.getItem('atoken')
},
onUploadProgress: progressEvent => {
var complete = (progressEvent.loaded / progressEvent.total * 100 | 0) + '%';
// console.log('complete:', complete)
this.updateEle = false;
for(var i = 0, len = UpdateArr.length; i < len; i++) {
this.modalUpdInfo.forEach(ele => {
if(ele.device_id === UpdateArr[i]) {
// console.log('筛选相同元素:', ele);
ele.fileText = complete;
ele.styleW = complete;
}
})
}
this.updateEle = true;
}
};
modalFormData.append('list[0].fx_device_ids', fxChildIds);
let childUpdUrl = this.IP + '/api/v1/devconf_fx/devs/'+ this.dev_unid +'/fx_devs/upfile';
this.updateEle = false;
for(var i = 0, len = UpdateArr.length; i < len; i++) {
this.modalUpdInfo.forEach(ele => {
if(ele.device_id === UpdateArr[i]) {
ele.state = '文件上传中';
}
})
}
// 发送http请求
this.modalUpdHttp(childUpdUrl, modalFormData, modalFormConfig, fxChildIds);
this.updateEle = true;
},
/* 升级程序 */
modalUpdHttp: function (childUpdUrl, modalFormData, myFormConfig, fxChildIds) {
this.$http.post(childUpdUrl, modalFormData, myFormConfig, fxChildIds)
.then(res => {
let childUpdRes = res.data;
if(childUpdRes.ecode != 200) {
this.updateEle = false;
this.$message({
type: 'error',
message: '文件上传失败!'
});
for(var i = 0, len = fxChildIds.split(',').length; i < len; i++) {
this.updInfo.forEach(ele => {
if(ele.device_id === fxChildIds.split(',')[i]) {
ele.state = '文件上传失败!';
ele.spanClass = false;
ele.styleW = '0%';
ele.styleC = '#0f0'
ele.fileText = ''
}
})
}
console.log('文件上传失败!' + childUpdRes.enote);
this.updateEle = true;
} else {
this.updateEle = false;
for(var i = 0, len = fxChildIds.split(',').length; i < len; i++) {
this.updInfo.forEach(ele => {
if(ele.device_id === fxChildIds.split(',')[i]) {
ele.state = '文件上传成功!';
ele.spanClass = false;
ele.styleW = '0%';
ele.styleC = '#fff'
ele.fileText = '';
}
})
}
// 保存在本地
window.localStorage.setItem('upgradeInfo', JSON.stringify(fxChildIds));
this.updFlag = true;
this.queryProgress(fxChildIds);
this.updateEle = true;
}
})
},
/* 查询升级进度 */
queryProgress(dev_ids) {
console.log('升级的设备ID:', dev_ids);
if(dev_ids === '' || dev_ids == undefined) {
// let localUpdInfo = window.localStorage.getItem('upgradeInfo');
// if(localUpdInfo || localUpdInfo == undefined){
window.localStorage.removeItem('upgradeInfo');
// }
clearTimeout(this.updTimer);
this.updFlag = false;
console.log('暂无升级的设备');
return;
} else {
this.$http({
method: 'get',
url: this.IP + '/api/v1/devconf_fx/devs/' + this.dev_unid + '/fx_devs/upgrade/progress?s=' + new Date().getTime(),
headers: {
'authorization': window.localStorage.getItem('atoken')
},
params: {
fx_device_ids: dev_ids
}
}).then(res => {
let progressRes = res.data;
console.log('progressRes:', progressRes)
this.newIds = dev_ids;
this.updTab(this.newIds, progressRes);
this.updTimer = setTimeout(() => {
// console.log('查询进度开关: ' + this.updFlag)
if(this.updFlag) {
// console.log('更新查询进度的设备ID有:', this.newIds)
this.queryProgress(this.newIds);
}
},1000);
}).catch(err => {
console.log('查询升级进度异常:', err.message);
});
}
},
detailFun(index,row){
},
batchUpdate(){
if(this.selectcheck.length==0){
this.$message({
type: 'warning',
message: '请选择需要升级的行!'
})
return false
}
this.addVisible=true;
},
},
}
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
......@@ -266,8 +266,10 @@
this.addForm.menu_unids=this.$refs.addTree.getCheckedKeys().sort((a, b) => { return a - b; });
this.$refs[formName].validate((valid) => {
if (valid) {
this.$api.ops.addRole(this.addForm).then(res=>{
this.$api.ops.addRole({name:this.addForm.role_name}).then(res=>{
if(!res.ecode){
// this.$api.ops.bindperms({})
this.$message({
type: 'success',
message: '添加成功!'
......
......@@ -164,9 +164,10 @@
page:1,
pageSize:30,
addForm:{
norm_type:"login",
role_unid:'',
user_name:'',
user_password:''
username:'',
password:''
},
editForm:{
role_unid:'',
......@@ -211,11 +212,12 @@
},
getTableList(){
this.tableData=[];
console.log('aa',this.userId)
let offset = (this.page - 1) * this.pageSize;
this.$api.ops.getUserList({
limit: this.pageSize,
offset: offset,
}).then((res)=>{
},this.userId).then((res)=>{
this.total=res.total_num;
if(res.list_data==null){
......@@ -232,6 +234,7 @@
this.$api.ops.getRoleList({
limit: 9999,
offset: 0,
is_active:true
}).then((res)=>{
if(res.list_data==null){
this.roleList=[]
......
......@@ -71,6 +71,36 @@
</div>
</div>
<el-dialog
title="添加"
:visible.sync="addVisible"
width="450px">
<div>
<el-form label-position="left" label-width="120px">
<el-form-item label="配置名称">
<el-input v-model="names"></el-input>
</el-form-item>
<el-form-item label="添加文件">
<el-upload
ref="upload"
action="uploadUrl"
:http-request="httpRequest"
multiple
name="file"
:auto-upload="false">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<!-- <div slot="tip" class="el-upload__tip">只能上传视频文件</div> -->
</el-upload>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="addVisible=false">取 消</el-button>
<el-button type="primary" @click="save">上 传</el-button>
</span>
</el-dialog>
<el-dialog title="详情" :visible.sync="detailVisible" width="30%">
<div class="title">任务列表</div>
<div class="maxHeight">
......@@ -87,6 +117,10 @@
export default {
data(){
return{
addVisible:false,
uploadUrl: '',
names:'',
file:[],
props: {
label: 'name',
children: 'child',
......@@ -117,6 +151,26 @@
this.query();
},
methods:{
// 自定义的上传函数
httpRequest(param) {
this.file=[];
// 一般情况下是在这里创建FormData对象,但我们需要上传多个文件,为避免发送多次请求,因此在这里只进行文件的获取,param可以拿到文件上传的所有信息
this.file.push(param.file)
},
save(){
this.$refs.upload.submit(); // 这里是执行文件上传的函数,其实也就是获取我们要上传的文件
// 最重要的就是这段代码
var upData = new FormData() // 首先创建FormData对象
this.file.forEach((file)=>{
upData.append('file', file); // 因为要上传多个文件,所以需要遍历一下才行
upData.append('name', this.names);
upData.append("is_temp", 0);
})
this.$api.resource.uploadStore(upData).then(res=>{
this.query();
})
},
loadNode(node, resolve) {
if (node.level === 0) {
return resolve(this.curentSubList);
......@@ -164,7 +218,7 @@
})
},
add(){
this.addVisible=true;
},
taskFormatter(row, column, cellValue, index){
let columnText='';
......
......@@ -30,7 +30,6 @@
action="uploadUrl"
:http-request="httpRequest"
multiple
:data="uploadData"
name="file"
:auto-upload="false">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
......@@ -63,10 +62,6 @@
childs: []
}
],
uploadData:{
vchan_type:'vfile',
vchan_refid:new Date().getTime()
},
defaultProps:{
children: "childs",
disabled: "disabled",
......@@ -123,19 +118,8 @@
upData.append('file', file); // 因为要上传多个文件,所以需要遍历一下才行
upData.append('name', file.name);
upData.append('vchan_type', 'vfile');
upData.append('vchan_refid', '11111111');
upData.append('vchan_refid', new Date().getTime());
})
console.log(upData.getAll('file'))
// this.axios.post('http://192.168.9.133:20080/api/v1/devconf_fx/devs/'+this.devsId+'/vfile_vchans', upData, {
// headers: {
// 'Content-Type': 'multipart/form-data',
// },
// }).then(res => {
// console.log(res);
// }).catch(err => {
// console.log(err);
// });
this.$api.resource.uploadFile(upData,this.devsId).then(res=>{
console.log(res)
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!