Selaa lähdekoodia

报警接收人管理

like 6 kuukautta sitten
vanhempi
commit
e8153db3df

+ 28 - 0
snowy-admin-web/src/api/coldchain/alarmUserApi.js

@@ -0,0 +1,28 @@
+import { baseRequest } from '@/utils/request'
+
+const request = (url, ...arg) => baseRequest(`/coldchain/alarmuser/` + url, ...arg)
+
+/**
+ * 报警接收人Api接口管理器
+ *
+ * @author 黄渊昊
+ * @date  2024/12/02 15:41
+ **/
+export default {
+	// 获取报警接收人分页
+	alarmUserPage(data) {
+		return request('page', data, 'get')
+	},
+	// 提交报警接收人表单 edit为true时为编辑,默认为新增
+	alarmUserSubmitForm(data, edit = false) {
+		return request(edit ? 'edit' : 'add', data)
+	},
+	// 删除报警接收人
+	alarmUserDelete(data) {
+		return request('delete', data)
+	},
+	// 获取报警接收人详情
+	alarmUserDetail(data) {
+		return request('detail', data, 'get')
+	}
+}

+ 73 - 0
snowy-admin-web/src/views/biz/alarmuser/form.vue

@@ -0,0 +1,73 @@
+<template>
+	<xn-form-container
+		:title="formData.id ? '编辑报警接收人' : '增加报警接收人'"
+		:width="700"
+		v-model:open="open"
+		:destroy-on-close="true"
+		@close="onClose"
+	>
+		<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
+			<a-form-item label="系统用户id:" name="userId">
+				<a-input v-model:value="formData.userId" placeholder="请输入系统用户id" allow-clear />
+			</a-form-item>
+		</a-form>
+		<template #footer>
+			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
+			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
+		</template>
+	</xn-form-container>
+</template>
+
+<script setup name="alarmUserForm">
+	import { cloneDeep } from 'lodash-es'
+	import { required } from '@/utils/formRules'
+	import alarmUserApi from '@/api/coldchain/alarmUserApi'
+	// 抽屉状态
+	const open = ref(false)
+	const emit = defineEmits({ successful: null })
+	const formRef = ref()
+	// 表单数据
+	const formData = ref({})
+	const submitLoading = ref(false)
+
+	// 打开抽屉
+	const onOpen = (record) => {
+		open.value = true
+		if (record) {
+			let recordData = cloneDeep(record)
+			formData.value = Object.assign({}, recordData)
+		}
+	}
+	// 关闭抽屉
+	const onClose = () => {
+		formRef.value.resetFields()
+		formData.value = {}
+		open.value = false
+	}
+	// 默认要校验的
+	const formRules = {
+	}
+	// 验证并提交数据
+	const onSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				submitLoading.value = true
+				const formDataParam = cloneDeep(formData.value)
+				alarmUserApi
+					.alarmUserSubmitForm(formDataParam, formDataParam.id)
+					.then(() => {
+						onClose()
+						emit('successful')
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			})
+			.catch(() => {})
+	}
+	// 抛出函数
+	defineExpose({
+		onOpen
+	})
+</script>

+ 173 - 0
snowy-admin-web/src/views/biz/alarmuser/index.vue

@@ -0,0 +1,173 @@
+<template>
+	<a-card :bordered="false">
+		<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
+			<a-row :gutter="24">
+				<a-col :span="6">
+					<a-form-item label="微信昵称" name="nickname">
+						<a-input v-model:value="searchFormState.nickname" placeholder="请输入微信昵称" />
+					</a-form-item>
+				</a-col>
+				<a-col :span="6">
+					<a-button type="primary" @click="tableRef.refresh()">查询</a-button>
+					<a-button style="margin: 0 8px" @click="reset">重置</a-button>
+				</a-col>
+			</a-row>
+		</a-form>
+		<s-table
+			ref="tableRef"
+			:columns="columns"
+			:data="loadData"
+			:alert="options.alert.show"
+			bordered
+			:row-key="(record) => record.id"
+			:tool-config="toolConfig"
+			:row-selection="options.rowSelection"
+		>
+			<template #operator>
+				<a-space>
+					<a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('alarmUserAdd')">
+						<template #icon><plus-outlined /></template>
+						新增
+					</a-button>
+					<xn-batch-button
+						v-if="hasPerm('alarmUserBatchDelete')"
+						buttonName="批量删除"
+						icon="DeleteOutlined"
+						:selectedRowKeys="selectedRowKeys"
+						@batchCallBack="deleteBatchAlarmUser"
+					/>
+				</a-space>
+			</template>
+			<template #bodyCell="{ column, record }">
+				<template v-if="column.dataIndex === 'action'">
+					<a-space>
+						<a @click="formRef.onOpen(record)" v-if="hasPerm('alarmUserEdit')">编辑</a>
+						<a-divider type="vertical" v-if="hasPerm(['alarmUserEdit', 'alarmUserDelete'], 'and')" />
+						<a-popconfirm title="确定要删除吗?" @confirm="deleteAlarmUser(record)">
+							<a-button type="link" danger size="small" v-if="hasPerm('alarmUserDelete')">删除</a-button>
+						</a-popconfirm>
+					</a-space>
+				</template>
+			</template>
+		</s-table>
+	</a-card>
+	<Form ref="formRef" @successful="tableRef.refresh()" />
+</template>
+
+<script setup name="alarmuser">
+	import { cloneDeep } from 'lodash-es'
+	import Form from './form.vue'
+	import alarmUserApi from '@/api/coldchain/alarmUserApi'
+	const searchFormState = ref({})
+	const searchFormRef = ref()
+	const tableRef = ref()
+	const formRef = ref()
+	const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
+	const columns = [
+		{
+			title: '系统用户id',
+			dataIndex: 'userId'
+		},
+		{
+			title: '用户唯一标识',
+			dataIndex: 'openid'
+		},
+		{
+			title: 'AccessToken',
+			dataIndex: 'accessToken'
+		},
+		{
+			title: 'RefreshToken',
+			dataIndex: 'refreshToken'
+		},
+		{
+			title: '微信昵称',
+			dataIndex: 'nickname'
+		},
+		{
+			title: '性别',
+			dataIndex: 'sex'
+		},
+		{
+			title: '省份',
+			dataIndex: 'province'
+		},
+		{
+			title: '用户城市',
+			dataIndex: 'city'
+		},
+		{
+			title: '国家',
+			dataIndex: 'country'
+		},
+		{
+			title: '用户头像',
+			dataIndex: 'avatar'
+		},
+		{
+			title: '特权信息',
+			dataIndex: 'privilege'
+		},
+		{
+			title: 'unionid',
+			dataIndex: 'unionid'
+		},
+		{
+			title: '扩展信息',
+			dataIndex: 'extJson'
+		}
+	]
+	// 操作栏通过权限判断是否显示
+	if (hasPerm(['alarmUserEdit', 'alarmUserDelete'])) {
+		columns.push({
+			title: '操作',
+			dataIndex: 'action',
+			align: 'center',
+			width: 150
+		})
+	}
+	const selectedRowKeys = ref([])
+	// 列表选择配置
+	const options = {
+		// columns数字类型字段加入 needTotal: true 可以勾选自动算账
+		alert: {
+			show: true,
+			clear: () => {
+				selectedRowKeys.value = ref([])
+			}
+		},
+		rowSelection: {
+			onChange: (selectedRowKey, selectedRows) => {
+				selectedRowKeys.value = selectedRowKey
+			}
+		}
+	}
+	const loadData = (parameter) => {
+		const searchFormParam = cloneDeep(searchFormState.value)
+		return alarmUserApi.alarmUserPage(Object.assign(parameter, searchFormParam)).then((data) => {
+			return data
+		})
+	}
+	// 重置
+	const reset = () => {
+		searchFormRef.value.resetFields()
+		tableRef.value.refresh(true)
+	}
+	// 删除
+	const deleteAlarmUser = (record) => {
+		let params = [
+			{
+				id: record.id
+			}
+		]
+		alarmUserApi.alarmUserDelete(params).then(() => {
+			tableRef.value.refresh(true)
+		})
+	}
+	// 批量删除
+	const deleteBatchAlarmUser = (params) => {
+		alarmUserApi.alarmUserDelete(params).then(() => {
+			tableRef.value.clearRefreshSelected()
+		})
+	}
+</script>

+ 1 - 0
snowy-admin-web/src/views/biz/monitor/mem/form.vue

@@ -33,6 +33,7 @@
 							allow-clear
 							:maxlength="10"
 							@change="deviceCodeChange(formData.deviceCode)"
+							:disabled="formData.id"
 						/>
 					</a-form-item>
 				</a-col>

+ 89 - 73
snowy-admin-web/src/views/biz/monitor/object/index.vue

@@ -5,7 +5,6 @@
 			:columns="columns"
 			:data="loadData"
 			:row-key="(record) => record.id"
-			bordered
 			@resizeColumn="handleResizeColumn"
 		>
 			<template #operator>
@@ -51,6 +50,7 @@
 					</div> -->
 				</div>
 			</template>
+
 			<template #bodyCell="{ column, record, index }">
 				<!-- 序号 -->
 				<template v-if="column.dataIndex === 'index'">{{ index + 1 }} </template>
@@ -72,73 +72,72 @@
 					<a-button type="link" size="small" @click="leaveFor('/biz/monitor/point', record)">监测点配置</a-button>
 				</template>
 			</template>
-			<!-- <template #expandedRowRender="{ record }">
-				<a-tabs v-model:activeKey="record.activeKey" size="small" type="card">
-					<a-tab-pane key="1" tab="基本信息">
-						<div class="list">
-							<a-descriptions bordered size="small">
-								<a-descriptions-item label="对象名称" :span="2">{{ record.name }}</a-descriptions-item>
-								<a-descriptions-item label="对象编号" :span="2">{{ record.dxcode }}</a-descriptions-item>
-								<a-descriptions-item label="品牌">{{ record.pp }}</a-descriptions-item>
-								<a-descriptions-item label="型号">{{ record.xh }}</a-descriptions-item>
-								<a-descriptions-item label="类型">{{ record.type }}</a-descriptions-item>
-								<a-descriptions-item label="使用状态">{{ record.syzt }}</a-descriptions-item>
-								<a-descriptions-item label="报警状态">{{ record.bjzt }}</a-descriptions-item>
-								<a-descriptions-item label="位置">{{ record.wz }}</a-descriptions-item>
-							</a-descriptions>
-						</div>
-					</a-tab-pane>
-					<a-tab-pane key="2" tab="冷链设备">
-						<div class="list">
-							<a-descriptions bordered size="small">
-								<a-descriptions-item label="冷链编号" :span="2">{{ record.llcode }}</a-descriptions-item>
-								<a-descriptions-item label="对应路数" :span="2">{{ record.dyls }}</a-descriptions-item>
-								<a-descriptions-item label="所属中继" :span="2">{{ record.sszj }}</a-descriptions-item>
-							</a-descriptions>
-						</div>
-					</a-tab-pane>
-					<a-tab-pane key="3" tab="温湿度设定">
-						<div class="list">
-							<a-descriptions title="报警上下限" bordered size="small">
-								<a-descriptions-item label="温度上限(℃)" :span="2">{{ record.wdsx }}</a-descriptions-item>
-								<a-descriptions-item label="温度下限(℃)" :span="2">{{ record.wdxx }}</a-descriptions-item>
-								<a-descriptions-item label="湿度上限(%)" :span="2">{{ record.sdsx }}</a-descriptions-item>
-								<a-descriptions-item label="湿度下限(%)" :span="2">{{ record.sdxx }}</a-descriptions-item>
-							</a-descriptions>
 
-							<a-descriptions title="温湿度修正" bordered size="small">
-								<a-descriptions-item label="温度(-10~10)(℃)" :span="2">{{ record.wdxz }}</a-descriptions-item>
-								<a-descriptions-item label="湿度(-20~20)(%)" :span="2">{{ record.sdxz }}</a-descriptions-item>
-							</a-descriptions>
-						</div>
-					</a-tab-pane>
-					<a-tab-pane key="4" tab="报警信息">
-						<div class="list">
-							<a-descriptions title="对象信息" bordered size="small">
-								<a-descriptions-item label="对象名称" :span="2">{{ record.name }}</a-descriptions-item>
-								<a-descriptions-item label="监控点名称" :span="2">{{ record.jkd }}</a-descriptions-item>
-								<a-descriptions-item label="报警级别" :span="2">{{ '1' }}</a-descriptions-item>
-								<a-descriptions-item label="延时时间" :span="2">{{ '0' }}</a-descriptions-item>
-								<a-descriptions-item label="报警频率" :span="2">{{ '1' }}</a-descriptions-item>
-
-								<a-descriptions-item label="执行间隔" :span="2">{{ '10' }}</a-descriptions-item>
-								<a-descriptions-item label="是否逐级报警" :span="2">{{ '否' }}</a-descriptions-item>
-								<a-descriptions-item label="逐级报警时间间隔" :span="2">{{ '0' }}</a-descriptions-item>
-								<a-descriptions-item label="允许报警开始时间" :span="2"></a-descriptions-item>
-								<a-descriptions-item label="允许报警结束时间" :span="2"></a-descriptions-item>
-							</a-descriptions>
-
-							<a-descriptions title="短信报警" bordered size="small">
-								<a-descriptions-item label="提醒人姓名" :span="2">{{ '欧阳天添' }}</a-descriptions-item>
-								<a-descriptions-item label="接收电话" :span="2">{{ '13476548750' }}</a-descriptions-item>
+			<template #expandColumnTitle>
+				<span>更多</span>
+			</template>
+			<template #expandedRowRender="{ record }">
+				<a-tabs
+					v-model:activeKey="record.activeKey"
+					size="small"
+					type="card"
+					v-if="record.monitorTargetRegionList.length"
+				>
+					<a-tab-pane key="1" tab="监测设备">
+						<div class="list" v-for="(item, index) in record.monitorTargetRegionList" :key="index">
+							<a-descriptions bordered size="small">
+								<a-descriptions-item label="点位名称" :span="2">{{ item.name }}</a-descriptions-item>
+								<a-descriptions-item label="传感器类型" :span="2">{{
+									$TOOL.dictTypeData('SENSORTYPE', item.sensorType)
+								}}</a-descriptions-item>
+								<a-descriptions-item label="监控设备" :span="2">{{ item.deviceName }}</a-descriptions-item>
+								<a-descriptions-item label="传感器编号" :span="2">{{ item.sensorCode }}</a-descriptions-item>
+								<a-descriptions-item label="传感器路数" :span="2">{{ item.sensorRoute + '路' }}</a-descriptions-item>
+								<a-descriptions-item label="报警接收人">
+									<span v-for="(e, i) in item.alarmUsers" :key="i">{{ e.userName + ',' }} </span>
+								</a-descriptions-item>
+								<a-descriptions-item
+									v-if="item.sensorType == 'W' || item.sensorType == 'WS' || item.sensorType == 'WSC'"
+									label="温度上限"
+									:span="2"
+									>{{ item.temperatureUp }}</a-descriptions-item
+								>
+								<a-descriptions-item
+									v-if="item.sensorType == 'W' || item.sensorType == 'WS' || item.sensorType == 'WSC'"
+									label="温度下限"
+									:span="2"
+									>{{ item.temperatureDown }}</a-descriptions-item
+								>
+								<a-descriptions-item
+									v-if="item.sensorType == 'WS' || item.sensorType == 'WSC'"
+									label="湿度上限"
+									:span="2"
+									>{{ item.humidityUp }}</a-descriptions-item
+								>
+								<a-descriptions-item
+									v-if="item.sensorType == 'WS' || item.sensorType == 'WSC'"
+									label="湿度下限"
+									:span="2"
+									>{{ item.humidityDown }}</a-descriptions-item
+								>
+								<a-descriptions-item v-if="item.sensorType == 'WSC'" label="CO2上限" :span="2">{{
+									item.co2Up
+								}}</a-descriptions-item>
+								<a-descriptions-item v-if="item.sensorType == 'WSC'" label="CO2下限" :span="2">{{
+									item.co2Down
+								}}</a-descriptions-item>
 							</a-descriptions>
 						</div>
 					</a-tab-pane>
-					<a-tab-pane key="5" tab="温度记录">
-						<div class="list">温度记录</div>
-					</a-tab-pane>
 				</a-tabs>
-			</template> -->
+				<div v-else>
+					<a-empty>
+						<template #description>
+							<span> 暂无监测设备,快去添加吧 </span>
+						</template>
+					</a-empty>
+				</div>
+			</template>
 		</s-table>
 		<Form ref="formRef" @successful="tableRef.refresh(true)" />
 	</div>
@@ -181,6 +180,20 @@
 			ellipsis: true,
 			resizable: true
 		},
+		{
+			title: '创建人',
+			dataIndex: 'createUserName',
+			align: 'center',
+			ellipsis: true,
+			resizable: true
+		},
+		{
+			title: '创建时间',
+			dataIndex: 'createTime',
+			align: 'center',
+			ellipsis: true,
+			resizable: true
+		},
 		{
 			title: '操作',
 			dataIndex: 'action',
@@ -230,25 +243,28 @@
 <style lang="less" scoped>
 	.table_item {
 		padding: 15px 20px;
-
+		background-color: #ffffff;
 		:deep(.ant-table-pagination-right) {
 			justify-content: center !important;
 		}
 	}
 	.list {
 		width: 60%;
-		padding: 10px 20px;
+		padding: 20px 20px;
 		border-radius: 10px;
-		background-color: #ffffff;
 
 		:deep(.ant-descriptions) {
-			margin-bottom: 10px;
-		}
-		:deep(.ant-descriptions-header) {
-			margin: 0;
-			padding: 10px;
-			border: 1px solid #f0f0f0;
-			border-bottom: none;
+			width: 100%;
+			.ant-descriptions-row {
+				width: 100%;
+			}
+
+			.ant-descriptions-item-label {
+				width: 120px;
+			}
+			.ant-descriptions-item-content {
+				width: calc(100% - 120px);
+			}
 		}
 	}
 </style>