Commit 3cd50e1b authored by Kerwin_Cui's avatar Kerwin_Cui

导出

parent 5db307fd
......@@ -41,4 +41,5 @@ urlpatterns = [
url(r'^alarm_count_info/$', alarm_count_info),
url(r'^monitor_excel/$', monitor_excel),
url(r'^system_cmdb/$', system_cmdb),
url(r'^download_monitor/$', download_monitor),
]
......@@ -2481,25 +2481,27 @@ def search_alarm(request):
try:
req = json.loads(request.body)
alarm_list = Error_alarm.objects.all().order_by('-alarm_happen_time')
if req['data']['alarm_system']:
alarm_list = alarm_list.filter(alarm_system__contains=req['data']['alarm_system'])
if req['data']['priority']:
alarm_list = alarm_list.filter(alarm_level=req['data']['priority'])
if req['dateoutinfo']:
hptime_choose = req['dateoutinfo']
if req['data']['dateoutinfo']:
hptime_choose = req['data']['dateoutinfo']
startTime = hptime_choose[0]
startTime = datetime.datetime.strptime(startTime, "%Y-%m-%d")
startTime = (startTime + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
# endTime = hptime_choose[1]
# endTime = datetime.datetime.strptime(endTime[0:10], "%Y-%m-%d")
# endTime = (endTime + datetime timedelta(days=1)).strftime("%Y-%m-%d")
# eventList = eventList.filter(event_happened_time__gte=startTime).filter(
# event_happened_time__lte=endTime)
# startTime = (startTime + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
endTime = hptime_choose[1]
endTime = datetime.datetime.strptime(endTime[0:10], "%Y-%m-%d")
# endTime = (endTime + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
alarm_list = alarm_list.filter(alarm_happen_time__gte=startTime).filter(
alarm_happen_time__lte=endTime)
if req['data']['alarm_number']:
alarm_list = alarm_list.filter(alarm_number__contains=req['data']['alarm_number'])
if req['data']['alarm_system']:
new_list = []
for i in alarm_list:
if req['data']['alarm_system'] in eval(i.alarm_system):
new_list.append(i)
alarm_list = new_list
if request.body == "":
current_page = 1
page_size = 10
......@@ -2543,7 +2545,17 @@ def alarm_count_info(request):
try:
req = json.loads(request.body)
sysList = req.get('syslist')
alarm_list = Error_alarm.objects.all()
alarm_list_all = Error_alarm.objects.all()
alarm_list = []
if sysList:
new_list = []
for sys in sysList:
for i in alarm_list_all:
if sys in eval(i.alarm_system):
new_list.append(i)
alarm_list = new_list
else:
alarm_list = alarm_list_all
result = {}
for alarm in alarm_list:
sys_list = eval(alarm.alarm_system)
......@@ -2667,6 +2679,14 @@ def monitor_excel(request):
)
def download_monitor(request):
file_name = u'统计报表.xls'
file = open(file_name, 'rb')
response = FileResponse(file)
response['Content-Type'] = 'application/octet-stream'
response['Content-Disposition'] = 'attachment;filename="统计报表.xls"'
return response
def system_cmdb(request):
try:
sys_data = requests.get('http://192.168.1.246:8001/webapi/moduleInstances/108?pageNum=1&pageSize=500')
......@@ -2695,6 +2715,7 @@ def system_cmdb(request):
}
)
# 同步事件
def sync(request):
now_time = int(time.time())
......
......@@ -10,7 +10,7 @@
<div class="panel-body">
<div class="king-wrapper clearfix">
选择用户组:
<el-select style="width:300px;margin-right: 100px" clearable
<el-select style="width:300px;margin-right: 100px" clearable filterable
v-model="Group">
<el-option v-for="item in GroupOp"
:key="item.value"
......@@ -18,14 +18,6 @@
:value="item.label">
</el-option>
</el-select>
查询时间:
<el-date-picker
v-model="time"
type="daterange"
style="width:250px;"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
<el-button size="medium" id="search" type="primary"
@click="searchList()"
style="float: right;margin-right:12px">查询
......@@ -92,15 +84,15 @@
methods: {
searchList() {
console.log(this.Group)
console.log(this.sysGroup)
console.log(this.sysGroup[this.Group])
let finallist = []
if(this.sysGroup && this.Group){
for (let temp of this.sysGroup) {
if (temp.group_name == this.Group) {
finallist = temp.group_system
}
}
}
let newdata = {
currentPage: this.currentPage,
pageSize: this.pageSize,
......
......@@ -49,7 +49,7 @@
style="display:inline-block;">
<el-select v-model="formLine.alarm_system" clearable multiple filterable style="width:200px;"
:disabled="editStatus">
<el-option v-for="item in systemList"
<el-option v-for="item in systemListCmdb"
:key="item.value"
:label="item.label"
:value="item.label">
......@@ -233,6 +233,7 @@
options: [],
tabelshowData: []
},
systemListCmdb:[],
errorMachine: [],
machineBiz: "",
machineListFlag: 1,
......@@ -335,8 +336,9 @@
this.getuser();
this.getAutoList();
this.getPrimaryList();
this.getSystem();
//this.getSystem();
this.getAlarmTitle();
this.system_cmdb()
if (data.if_auto == '5') {
this.autochange = true;
this.notbkauto = false;
......@@ -393,6 +395,12 @@
}
return result;
},
system_cmdb(){
axios.get('${SITE_URL}system_cmdb/').then(res => {
res = res.data;
this.systemListCmdb = res
})
},
dellabeldialog(e, label) {
e = e || window.event
e.stopPropagation()
......
......@@ -61,7 +61,7 @@
style="display:inline-block;width:100%;">
<el-select style="min-width:150px;width:80%;" clearable filterable
v-model="formLine.alarm_system">
<el-option v-for="item in systemList"
<el-option v-for="item in systemListCmdb"
:key="item.value"
:label="item.label"
:value="item.label"></el-option>
......@@ -330,7 +330,7 @@
data() {
return {
dateoutflag: false,
systemListCmdb:[],
user: '',
gridData: [],
priorityOp: keyArray.priority,
......@@ -382,7 +382,8 @@
mounted() {
this.setmainuser();
this.getAlarmList();
this.getSystem()
this.getSystem();
this.system_cmdb()
},
......@@ -393,6 +394,12 @@
this.systemList = res
})
},
system_cmdb(){
axios.get('${SITE_URL}system_cmdb/').then(res => {
res = res.data;
this.systemListCmdb = res
})
},
handleSelectionChange(selection) {
this.selectData =selection
......
......@@ -57,7 +57,7 @@
</el-col>
<el-col :span="20">
<el-form-item label="行政组" style="display:inline-block;" label-width="130px">
<el-select style="width:200px;" clearable v-model="formLine.xzz" >
<el-select style="width:200px;" clearable v-model="group" >
<el-option v-for="item in GroupOp"
:key="item.value"
:label="item.label"
......@@ -66,7 +66,7 @@
</el-select>
</el-form-item>
<el-button type="primary" size="medium" style="float:right"
@click="dateout()">导出
@click="monitorOut()">导出
</el-button>
</el-col>
</el-row>
......@@ -344,8 +344,10 @@
data() {
return {
labelList: [],
group:'',
dateoutflag: false,
dateoutinfo: "",
userGroup:{},
user: '',
sysGroup:{},
GroupOp:[],
......@@ -387,6 +389,9 @@
methods: {
async monitorOut(){
if ()
},
//查询
searchList() {
this.currentPage = 1;
......@@ -396,7 +401,7 @@
getUserGroup() {
axios.get('${SITE_URL}search_user_group/').then(res => {
this.GroupOp = res.data['group_list'];
this.sysGroup = res.data['group_system_list']
this.userGroup = res.data['group_user_list']
})
},
......
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