Commit b31c1235 authored by Kerwin_Cui's avatar Kerwin_Cui

更新

parent 1d883036
......@@ -288,6 +288,7 @@ class Error_alarm(models.Model):
monitor_name = models.CharField(null=True, max_length=100, verbose_name="监控名称")
if_icube = models.CharField(null=True, max_length=100, verbose_name="是否来自一体化平台")
user = models.CharField(null=True, max_length=100, verbose_name="处理人")
cant_auto_info = models.TextField(null=True, verbose_name="不可自动化信息")
def toDic(self):
return dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]])
......
......@@ -2197,6 +2197,7 @@ def create_alarm(request):
if_auto = data['if_auto']
auto_sysname = data['auto_sysname']
auto_name = data['auto_name']
cant_auto_info = data['cantautoinfo']
other_autoname = data['other_autoname']
monitor_name = data['monitor_name']
if_icube = data['if_icube']
......@@ -2244,6 +2245,7 @@ def create_alarm(request):
other_autoname = other_autoname,
monitor_name = monitor_name,
if_icube = if_icube,
cant_auto_info = cant_auto_info,
user = login_person
)
error_alarm.save()
......@@ -2287,16 +2289,17 @@ def edit_alarm_display(request):
'alarm_time': alarm.alarm_happen_time.strftime('%Y-%m-%d %H:%M:%S') if alarm.alarm_happen_time else '',
'recover_time': alarm.alarm_recover_time.strftime('%Y-%m-%d %H:%M:%S') if alarm.alarm_recover_time else '',
'alarm_summary': alarm.alarm_summary if alarm.alarm_summary else '',
'if_interpose': alarm.if_interpose if alarm.if_interpose else '',
'if_interpose': int(alarm.if_interpose) if alarm.if_interpose else '',
'solve_process': alarm.solve_process if alarm.solve_process else '',
'if_workday': alarm.if_workday if alarm.if_workday else '',
'if_auto': alarm.if_auto if alarm.if_auto else '',
'if_workday': int(alarm.if_workday) if alarm.if_workday else '',
'if_auto': int(alarm.if_auto) if alarm.if_auto else '',
'auto_sysname': alarm.auto_sysname if alarm.auto_sysname else '',
'auto_name': alarm.auto_name if alarm.auto_name else '',
'other_autoname': alarm.other_autoname if alarm.other_autoname else '',
'monitor_name': alarm.monitor_name if alarm.monitor_name else '',
'if_icube': alarm.if_icube if alarm.if_icube else '',
'show_src': show_src
'if_icube': int(alarm.if_icube) if alarm.if_icube else '',
'show_src': show_src,
'cantautoinfo': alarm.cant_auto_info if alarm.cant_auto_info else ''
}
return render_json(
{
......@@ -2319,7 +2322,9 @@ def edit_alarm_display(request):
def edit_alarm(request):
try:
data = json.loads(request.body)
req = json.loads(request.body)
data = req['info']
alarm_number = req['number']
alarm_type = data['alarm_type']
alarm_system = data['alarm_system']
alarm_time = data['alarm_time']
......@@ -2335,13 +2340,37 @@ def edit_alarm(request):
monitor_name = data['monitor_name']
if_icube = data['if_icube']
alarm_time = alarm_time.replace('T', ' ')
alarm_time = alarm_time[0:-5]
# alarm_time = alarm_time[0:-5]
alarm_time = datetime.datetime.strptime(alarm_time, "%Y-%m-%d %H:%M:%S")
alarm_time = (alarm_time + datetime.timedelta(hours=8))
recover_time = recover_time.replace('T', ' ')
recover_time = recover_time[0:-5]
# recover_time = recover_time[0:-5]
recover_time = datetime.datetime.strptime(recover_time, "%Y-%m-%d %H:%M:%S")
recover_time = (recover_time + datetime.timedelta(hours=8))
alarm = Error_alarm.objects.get(alarm_number=alarm_number)
alarm.alarm_number = alarm_number
alarm.alarm_level = alarm_type
alarm.alarm_system = alarm_system
alarm.alarm_happen_time = alarm_time
alarm.alarm_recover_time = recover_time
alarm.alarm_summary = alarm_summary
alarm.if_interpose = if_interpose
alarm.solve_process = solve_process
alarm.if_workday = if_workday
alarm.if_auto = if_auto
alarm.auto_sysname = auto_sysname
alarm.auto_name = auto_name
alarm.other_autoname = other_autoname
alarm.monitor_name = monitor_name
alarm.if_icube = if_icube
alarm.save()
return render_json(
{"result": True,
"code": 0,
"message": u"编辑成功!",
"data": ''
})
except Exception as e:
return render_json(
{
......
......@@ -107,17 +107,16 @@
</el-form-item>
<el-form-item label="是否自动化处理:" class="normal" label-width="200px">
<el-radio-group style="margin-left: 5px;" @change="changeAuto"
v-model="formLine.if_auto">
<el-radio-group style="margin-left: 5px;" @change="changeAuto" v-model="formLine.if_auto">
<el-radio :label="5">已自动化</el-radio>
<el-radio :label="6">已自动化(非一体化平台)</el-radio>
<el-radio :label="7" style="margin-left: 47px">未自动化</el-radio>
<el-radio :label="10" style="margin-left: 47px">不可自动化</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="系统所属名称:" label-width="200px" class="normal"
style="display:inline-block" v-if="autochange">
<el-select v-model="formLine.auto_sysname" filterable clearable
style="width: 275px"
<el-select v-model="formLine.auto_sysname" filterable clearable style="width: 275px"
@change="project_team_autosys">
<el-option v-for="item in autosysOptions"
:key="item.value"
......@@ -127,8 +126,7 @@
</el-form-item>
<el-form-item label="自动化方案:" label-width="200px" class="normal"
style="display:inline-block" v-if="autochange">
<el-select style="width:275px;" v-model="formLine.auto_name"
filterable clearable>
<el-select style="width:275px;" v-model="formLine.auto_name" filterable clearable>
<el-option v-for="item in computedAutosysOptions"
:key="item.value"
:label="item.label"
......@@ -141,6 +139,16 @@
<el-input v-model="formLine.other_autoname" style="width:605px"
placeholder="请输入其他平台自动化名称"></el-input>
</el-form-item>
<el-form-item label="不可自动化原因" label-width="120px" class="normal" v-if="cantauto">
<el-input v-model="formLine.cantautoinfo"
placeholder="请输入该事件不可由自动化任务解决的原因"></el-input>
</el-form-item>
<el-form-item label="未自动化" label-width="120px" class="normal" v-if="notautoyet">
<el-input v-model="formLine.notautoyetinfo"
placeholder="请输入该事件纳入自动化计划"></el-input>
</el-form-item>
<el-form-item label="监控类别:" label-width="200px" class="normal">
<el-select v-model="formLine.monitor_name" clearable filterable style="width:200px;"
:disabled="editStatus">
......@@ -152,8 +160,7 @@
</el-select>
</el-form-item>
<el-form-item label="告警是否来自一体化平台:" class="normal" label-width="200px">
<el-radio-group style="margin-left: 5px;" @change="changeAuto"
v-model="formLine.if_icube" :disabled="true">
<el-radio-group style="margin-left: 5px;" v-model="formLine.if_icube" >
<el-radio :label="8"></el-radio>
<el-radio :label="9"></el-radio>
</el-radio-group>
......@@ -167,13 +174,9 @@
v-if="formLine.dealer==user || !formLine.dealer">提交
</el-button>
</el-col>
</el-row>
</div>
</div>
</div>
<script type="text/javascript">
......@@ -182,7 +185,7 @@
return array.filter(function (item, index, array) {
return obj.hasOwnProperty(item.bk_host_innerip) ? false : (obj[item.bk_host_innerip] = true)
})
}
};
var keyArray = {
alarmType: [
......@@ -190,20 +193,11 @@
{label: '指标告警', value: '1'},
{label: '日志和指标告警', value: '0'},
],
influenceLevel: [
{label: '', value: '1'},
{label: '', value: '2'},
{label: '', value: '3'}
],
//优先级
priority: [
{label: '1级', value: '1'},
{label: '2级', value: '2'},
{label: '3级', value: '3'},
{label: '4级', value: '4'},
{label: '5级', value: '5'}
],
//事件类型
eventType: [
{label: '严重', value: '1'},
......@@ -214,19 +208,19 @@
var formatToId = function (item, itemArray) {
for (let i of itemArray) {
if (item == i.label) {
return i.value
return i.value;
break;
}
}
}
};
var formatToText = function (item, itemArray) {
for (let i of itemArray) {
if (item == i.value) {
return i.label
return i.label;
break;
}
}
}
};
var vm = new Vue({
el: "#alarmEdit",
......@@ -303,6 +297,8 @@
auto_sysname:'',
auto_name:'',
other_autoname:'',
cantautoinfo: '',
notautoyetinfo: '',
monitor_name:'',
if_icube:'',
},
......@@ -319,9 +315,7 @@
mounted() {
let vm = this;
let data = JSON.parse(window.localStorage.getItem('alarm_info'));
console.log(data)
if (!!data) {
console.log(123)
this.type = "edit"
if (data.show_src == 1) {
this.showStatus = true
......@@ -333,7 +327,6 @@
//data.event_type = formatToId(data.event_type, keyArray.eventType)
this.formLine = data;
} else {
console.log(456);
this.type = "new";
//this.editStatus = false;
//this.showStatus = false;
......@@ -343,7 +336,28 @@
this.getAutoList();
this.getPrimaryList();
this.getSystem();
this.getAlarmTitle()
this.getAlarmTitle();
if (data.if_auto == '5') {
this.autochange = true;
this.notbkauto = false;
this.cantauto = false;
this.notautoyet = false
} else if (data.if_auto == '6') {
this.autochange = false;
this.notbkauto = true;
this.cantauto = false;
this.notautoyet = false
} else if (data.if_auto == '7') {
this.autochange = false;
this.notbkauto = false;
this.cantauto = false;
this.notautoyet = true
} else if (data.if_auto == '10') {
this.autochange = false;
this.notbkauto = false;
this.cantauto = true;
this.notautoyet = false
}
},
computed: {
......@@ -351,7 +365,7 @@
computedAutosysOptions() {
for (let i of this.autotaskOptions) {
if (i.value == this.formLine.urgency.auto_sys) {
if (i.value == this.formLine.auto_sysname) {
return i.label
break;
}
......@@ -414,27 +428,27 @@
// 自动化单选切换组件
changeAuto(value) {
this.formLine.urgency.notbkautoinfo = '';
this.formLine.urgency.cantautoinfo = '';
this.formLine.urgency.notautoyetinfo = '';
this.formLine.urgency.auto_sys = '';
this.formLine.urgency.script_name = '';
if (value == '4') {
this.formLine.other_autoname = '';
this.formLine.cantautoinfo = '';
this.formLine.notautoyetinfo = '';
this.formLine.auto_sysname = '';
this.formLine.auto_name = '';
if (value == '5') {
this.autochange = true
this.notbkauto = false
this.cantauto = false
this.notautoyet = false
} else if (value == '8') {
} else if (value == '6') {
this.autochange = false
this.notbkauto = true
this.cantauto = false
this.notautoyet = false
} else if (value == '5') {
} else if (value == '7') {
this.autochange = false
this.notbkauto = false
this.cantauto = true
this.notautoyet = false
} else if (value == '6') {
} else if (value == '10') {
this.autochange = false
this.notbkauto = false
this.cantauto = false
......@@ -499,8 +513,8 @@
},
project_team_autosys() {
if (this.formLine.urgency.script_name) {
this.formLine.urgency.script_name = ''
if (this.formLine.auto_name) {
this.formLine.auto_name = ''
}
},
......@@ -676,8 +690,7 @@
submit() {
if (this.type == "edit") {
console.log('编辑')
axios.post('${SITE_URL}edit_alarm/', this.formLine).then(res => {
axios.post('${SITE_URL}edit_alarm/', {'info':this.formLine,'number':window.localStorage.getItem("alarm_number")}).then(res => {
if(res.code==0){
this.$message({
type: 'success',
......
......@@ -460,6 +460,8 @@
}
},
createNewAlarm() {
window.localStorage.setItem("alarm_info", '');
window.localStorage.setItem("alarm_number", '');
window.location.href = "${SITE_URL}alarm_edit"
},
createNewTask() {
......@@ -534,6 +536,7 @@
//编辑模板
readRow(row) {
let data = {alarm_number: row.alarm_number};
window.localStorage.setItem("alarm_number", row.alarm_number);
axios.post("${SITE_URL}edit_alarm_display/", data).then(res => {
window.localStorage.setItem("alarm_info", JSON.stringify(res.results));
window.location.href = "${SITE_URL}alarm_edit"
......
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