alareCoreModule.vue
4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<template>
<!-- 查看详情弹框 -->
<el-dialog id="alareCoreModule" :close-on-click-modal="flag" @click="clickUser" :visible="detailFormVisible" @open="openDialog" @close="closeDialog" append-to-body width="800px">
<div class="dialog-header" slot="title">
<h2 class="header-title">警情处理</h2>
</div>
<el-form ref="form" :model="form" :rules="rules" size="medium" label-width="110px" >
<el-form-item label="警情描述">
<div class="detail" style="white-space:pre-line;" v-html="alarmDesc">
</div>
</el-form-item>
<el-form-item label="处理结果" prop="dealwith">
<el-input type="textarea" :rows="4" v-model="form.dealwith" :placeholder='tips' style='width: 400px'></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="sure('form')" size="small">提交</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button class="copy-btn" ref="copy" ata-clipboard-action="copy" @click="copyLink(form.dealwith,alarmDesc)" size="small">复制详情</el-button>
<el-button type="primary" @click="cancel('form')" size="small">关闭</el-button>
</div>
</el-dialog>
<!-- 查看详情弹框 /-->
</template>
<script>
import {services} from '../../api'
import Clipboard from 'clipboard'
const REPORT_SERVICE = services.report;
export default{
props: ['detailFormVisible', 'detailForm','vehileId','snList', 'alarmNumType', 'mode'],
watch: {
dataId: function(newValue) {
console.log(newValue); //可以看到数据已经拿到
}
},
data(){
return {
scrollToRef: '',
showBigImg:false,
num:0,
isDisabled:false,
tips:'',
editName:'',
alarmDesc:'',
form:{
dealwith:'',
},
vehileId:'',
rules :{
dealwith: [
{ required: true, message: '请填写处理结果', trigger: 'blur' },
{ min: 0, max: 200, message: '不可以超过200字', trigger: 'blur' }
],
}
}
},
computed: {
isEditMode:{
get(){
return this.dataId
}
}
},
methods: {
openDialog(){
let form = this.form;
if(this.detailForm.dealflag==1){
form.dealwith = this.detailForm.dealwith
}else{
form.dealwith = ''
}
this.alarmDesc = this.detailForm.alarmDesc;
this.$emit('onAlarmModuleChange', true)
},
closeDialog(){console.log(this.isOpen)
this.$emit('onAlarmModuleChange', false)
},
getParams(){
const form = this.form;
const params = {};
if(form.dealwith){
params.dealwith = form.dealwith;
}
return params;
},
sure(formName){
let _this = this
let params = _this.getParams();
params.alarmTime = this.detailForm.alarmTime;
params.sn = this.snList;
params.vehicleId = this.vehileId;
params.alarmNumType = this.alarmNumType;
this.$refs[formName].validate((valid) => {
if (valid) {
let postUrl = this.mode === 'mix'?REPORT_SERVICE.dealWithComplexAlarm:REPORT_SERVICE.dealWithAlarm
postUrl(params).then((response)=>{
if(response.returnCode==0){
_this.$message({
message: '提交成功!',
type: 'success'
});
}
});
this.$emit('onAlarmModuleChange', false)
this.$emit('getList')
} else {
return false;
}
});
},
cancel(){
this.$emit('onAlarmModuleChange', false)
},
copyLink(dealwith,alarmDesc) {
let _this = this;
var Url =dealwith?`${alarmDesc} 处理结果:${dealwith}`:`${alarmDesc}`;
let clipboard = new Clipboard('.copy-btn', {
text: function () {
return Url
}
})
clipboard.on('success', function() {
_this.$message({
message: '复制成功!',
type: 'success'
});
clipboard.destroy()
});
clipboard.on('error', function() {
_this.$message({
message: '复制失败,请手动选择复制!',
type: 'error'
});
clipboard.destroy()
});
}
},
components:{
}
}
</script>
<style scoped>
.detail{
width: 400px;
line-height: 30px;
}
</style>