فهرست منبع

报警管理-报警确认

like 7 ماه پیش
والد
کامیت
23ab578ebb
2فایلهای تغییر یافته به همراه109 افزوده شده و 1 حذف شده
  1. 97 0
      snowy-admin-web/src/views/motoring/report/form.vue
  2. 12 1
      snowy-admin-web/src/views/motoring/report/list.vue

+ 97 - 0
snowy-admin-web/src/views/motoring/report/form.vue

@@ -0,0 +1,97 @@
+<template>
+	<xn-form-container
+		:title="formData.id ? '报警处理' : '报警确定'"
+		:width="550"
+		:visible="visible"
+		:destroy-on-close="true"
+		@close="onClose"
+	>
+		<a-form ref="formRef" :model="formData" :rules="formRules" layout="Inline" :label-col="labelCol">
+			<a-form-item label="发生时间" name="fssj">
+				<a-date-picker show-time placeholder="请选择发生时间" @change="onChange" style="width: 100%" />
+			</a-form-item>
+
+			<a-form-item label="设备" name="sb">
+				<a-input v-model:value="formData.sb" placeholder="请输入设备" allow-clear />
+			</a-form-item>
+			<a-form-item label="报警原因" name="bjyy">
+				<a-input v-model:value="formData.bjyy" placeholder="请输入报警原因" allow-clear />
+			</a-form-item>
+			<a-form-item label="故障类型:" name="gzlx">
+				<a-select ref="select" v-model:value="formData.gzlx" style="width: 100%">
+					<a-select-option value="1">超限报警</a-select-option>
+				</a-select>
+			</a-form-item>
+		</a-form>
+		<template #footer>
+			<a-button class="xn-mr8" @click="onClose">退出</a-button>
+			<a-button type="primary" @click="onSubmit">报警确定</a-button>
+		</template>
+		<Icon-selector ref="iconSelectorRef" @iconCallBack="iconCallBack" />
+	</xn-form-container>
+</template>
+
+<script setup>
+	import ColorPicker from '@/components/ColorPicker/index.vue'
+	import { required } from '@/utils/formRules'
+	import moduleApi from '@/api/sys/resource/moduleApi'
+	import IconSelector from '@/components/Selector/iconSelector.vue'
+	// 默认是关闭状态
+	const visible = ref(false)
+	const emit = defineEmits({ successful: null })
+	const formRef = ref()
+	const labelCol = { style: { width: '80px' } }
+	const treeData = ref([])
+	const iconSelectorRef = ref()
+	// 表单数据
+	const formData = ref({})
+
+	// 打开抽屉
+	const onOpen = (record) => {
+		visible.value = true
+
+		if (record) {
+			formData.value = Object.assign({}, record)
+		} else {
+			formData.value = {}
+		}
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		formRef.value.resetFields()
+		visible.value = false
+	}
+	// 报警时间
+	const onChange = (value, dateString) => {
+		formData.value.bjkssj = dateString
+		console.log('报警时间', dateString)
+	}
+
+	// 默认要校验的
+	const formRules = {
+		fssj: [required('请选择发生时间')],
+		sb: [required('请输入设备')],
+		bjyy: [required('请输入报警原因')],
+		gzlx: [required('请选择故障类型')]
+	}
+
+	// 验证并提交数据
+	const onSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				console.log(formData.value, '提交数据')
+
+				// moduleApi.submitForm(formData.value, formData.value.id).then(() => {
+				// 	onClose()
+				// 	emit('successful')
+				// })
+			})
+			.catch(() => {})
+	}
+
+	// 调用这个函数将子组件的一些数据和方法暴露出去
+	defineExpose({
+		onOpen
+	})
+</script>

+ 12 - 1
snowy-admin-web/src/views/motoring/report/list.vue

@@ -36,19 +36,30 @@
 			<template #bodyCell="{ column, record }">
 				<template v-if="column.dataIndex === 'clzt'">
 					<span>
-						<a-tag :color="record.clzt == '1' ? '#cd201f' : record.clzt == '2' ? '#2db7f5' : '#87d068'">
+						<a-tag
+							:color="record.clzt == '1' ? '#cd201f' : record.clzt == '2' ? '#2db7f5' : '#87d068'"
+							style="cursor: pointer"
+							@click="formRef.onOpen(record)"
+						>
+							<template #icon>
+								<form-outlined v-if="record.clzt == '1'" />
+							</template>
 							{{ record.clztValue }}
 						</a-tag>
 					</span>
 				</template>
 			</template>
 		</s-table>
+
+		<Form ref="formRef" @successful="tableRef.refresh(true)" />
 	</div>
 </template>
 
 <script setup>
 	import tool from '@/utils/tool'
 	import jobApi from '@/api/dev/jobApi'
+	import Form from './form.vue'
+	const formRef = ref()
 	const searchFormRef = ref()
 	const searchFormState = ref({})
 	const tableRef = ref()