alareCoreModule.vue 4.11 KB
<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>