|
|
@@ -0,0 +1,323 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
+ <el-form-item label="仓库名称" prop="houseName">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.houseName"
|
|
|
+ placeholder="请输入仓库名称"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="仓库编码" prop="houseCode">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.houseCode"
|
|
|
+ placeholder="请输入仓库编码"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="传感器名称" prop="sensorName">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.sensorName"
|
|
|
+ placeholder="请输入传感器名称"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="Plus"
|
|
|
+ @click="handleAdd"
|
|
|
+ v-hasPermi="['biz:sensorConfig:add']"
|
|
|
+ >新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ plain
|
|
|
+ icon="Edit"
|
|
|
+ :disabled="single"
|
|
|
+ @click="handleUpdate"
|
|
|
+ v-hasPermi="['biz:sensorConfig:edit']"
|
|
|
+ >修改</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ plain
|
|
|
+ icon="Delete"
|
|
|
+ :disabled="multiple"
|
|
|
+ @click="handleDelete"
|
|
|
+ v-hasPermi="['biz:sensorConfig:remove']"
|
|
|
+ >删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ icon="Download"
|
|
|
+ @click="handleExport"
|
|
|
+ v-hasPermi="['biz:sensorConfig:export']"
|
|
|
+ >导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="sensorConfigList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="传感器ID" align="center" prop="sensorId" />
|
|
|
+ <el-table-column label="仓库ID" align="center" prop="houseId" />
|
|
|
+ <el-table-column label="仓库名称" align="center" prop="houseName" />
|
|
|
+ <el-table-column label="仓库编码" align="center" prop="houseCode" />
|
|
|
+ <el-table-column label="传感器名称" align="center" prop="sensorName" />
|
|
|
+ <el-table-column label="订阅地址" align="center" prop="subscribAddr" />
|
|
|
+ <el-table-column label="订阅主题" align="center" prop="topic" />
|
|
|
+ <el-table-column label="烟雾阈值" align="center" prop="smokeThreshold" />
|
|
|
+ <el-table-column label="温度阈值" align="center" prop="tmpThreshold" />
|
|
|
+ <el-table-column label="温度阈值" align="center" prop="rhThreshold" />
|
|
|
+ <el-table-column label="发布流程间隔时间" align="center" prop="alarmTime" />
|
|
|
+ <el-table-column label="上次发布流程时间" align="center" prop="lastTime" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.lastTime, '{y}-{m}-{d}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['biz:sensorConfig:edit']">修改</el-button>
|
|
|
+ <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['biz:sensorConfig:remove']">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total>0"
|
|
|
+ :total="total"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 添加或修改传感器网关配置对话框 -->
|
|
|
+ <el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
|
|
+ <el-form ref="sensorConfigRef" :model="form" :rules="rules" label-width="80px">
|
|
|
+ <el-form-item label="仓库名称" prop="houseName">
|
|
|
+ <el-input v-model="form.houseName" placeholder="请输入仓库名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="仓库编码" prop="houseCode">
|
|
|
+ <el-input v-model="form.houseCode" placeholder="请输入仓库编码" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="传感器名称" prop="sensorName">
|
|
|
+ <el-input v-model="form.sensorName" placeholder="请输入传感器名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="订阅地址" prop="subscribAddr">
|
|
|
+ <el-input v-model="form.subscribAddr" placeholder="请输入订阅地址" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="订阅主题" prop="topic">
|
|
|
+ <el-input v-model="form.topic" placeholder="请输入订阅主题" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="烟雾阈值" prop="smokeThreshold">
|
|
|
+ <el-input v-model="form.smokeThreshold" placeholder="请输入烟雾阈值" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="温度阈值" prop="tmpThreshold">
|
|
|
+ <el-input v-model="form.tmpThreshold" placeholder="请输入温度阈值" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="温度阈值" prop="rhThreshold">
|
|
|
+ <el-input v-model="form.rhThreshold" placeholder="请输入温度阈值" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="发布流程间隔时间" prop="alarmTime">
|
|
|
+ <el-input v-model="form.alarmTime" placeholder="请输入发布流程间隔时间" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="SensorConfig">
|
|
|
+import { listSensorConfig, getSensorConfig, delSensorConfig, addSensorConfig, updateSensorConfig } from "@/api/biz/sensorConfig";
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+
|
|
|
+const sensorConfigList = ref([]);
|
|
|
+const open = ref(false);
|
|
|
+const loading = ref(true);
|
|
|
+const showSearch = ref(true);
|
|
|
+const ids = ref([]);
|
|
|
+const single = ref(true);
|
|
|
+const multiple = ref(true);
|
|
|
+const total = ref(0);
|
|
|
+const title = ref("");
|
|
|
+
|
|
|
+const data = reactive({
|
|
|
+ form: {},
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ houseName: null,
|
|
|
+ houseCode: null,
|
|
|
+ sensorName: null,
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ sensorName: [
|
|
|
+ { required: true, message: "传感器名称不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ subscribAddr: [
|
|
|
+ { required: true, message: "订阅地址不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ topic: [
|
|
|
+ { required: true, message: "订阅主题不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ smokeThreshold: [
|
|
|
+ { required: true, message: "烟雾阈值不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ tmpThreshold: [
|
|
|
+ { required: true, message: "温度阈值不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ rhThreshold: [
|
|
|
+ { required: true, message: "温度阈值不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ alarmTime: [
|
|
|
+ { required: true, message: "发布流程间隔时间不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ lastTime: [
|
|
|
+ { required: true, message: "上次发布流程时间不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const { queryParams, form, rules } = toRefs(data);
|
|
|
+
|
|
|
+/** 查询传感器网关配置列表 */
|
|
|
+function getList() {
|
|
|
+ loading.value = true;
|
|
|
+ listSensorConfig(queryParams.value).then(response => {
|
|
|
+ sensorConfigList.value = response.rows;
|
|
|
+ total.value = response.total;
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 取消按钮
|
|
|
+function cancel() {
|
|
|
+ open.value = false;
|
|
|
+ reset();
|
|
|
+}
|
|
|
+
|
|
|
+// 表单重置
|
|
|
+function reset() {
|
|
|
+ form.value = {
|
|
|
+ sensorId: null,
|
|
|
+ houseId: null,
|
|
|
+ houseName: null,
|
|
|
+ houseNum: null,
|
|
|
+ houseCode: null,
|
|
|
+ sensorName: null,
|
|
|
+ subscribAddr: null,
|
|
|
+ topic: null,
|
|
|
+ smokeThreshold: null,
|
|
|
+ tmpThreshold: null,
|
|
|
+ rhThreshold: null,
|
|
|
+ alarmTime: null,
|
|
|
+ lastTime: null,
|
|
|
+ createBy: null,
|
|
|
+ createTime: null,
|
|
|
+ updateBy: null,
|
|
|
+ updateTime: null,
|
|
|
+ remark: null
|
|
|
+ };
|
|
|
+ proxy.resetForm("sensorConfigRef");
|
|
|
+}
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+function handleQuery() {
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
+ getList();
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+function resetQuery() {
|
|
|
+ proxy.resetForm("queryRef");
|
|
|
+ handleQuery();
|
|
|
+}
|
|
|
+
|
|
|
+// 多选框选中数据
|
|
|
+function handleSelectionChange(selection) {
|
|
|
+ ids.value = selection.map(item => item.sensorId);
|
|
|
+ single.value = selection.length != 1;
|
|
|
+ multiple.value = !selection.length;
|
|
|
+}
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+function handleAdd() {
|
|
|
+ reset();
|
|
|
+ open.value = true;
|
|
|
+ title.value = "添加传感器网关配置";
|
|
|
+}
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+function handleUpdate(row) {
|
|
|
+ reset();
|
|
|
+ const _sensorId = row.sensorId || ids.value
|
|
|
+ getSensorConfig(_sensorId).then(response => {
|
|
|
+ form.value = response.data;
|
|
|
+ open.value = true;
|
|
|
+ title.value = "修改传感器网关配置";
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+function submitForm() {
|
|
|
+ proxy.$refs["sensorConfigRef"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (form.value.sensorId != null) {
|
|
|
+ updateSensorConfig(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("修改成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addSensorConfig(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("新增成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+function handleDelete(row) {
|
|
|
+ const _sensorIds = row.sensorId || ids.value;
|
|
|
+ proxy.$modal.confirm('是否确认删除传感器网关配置编号为"' + _sensorIds + '"的数据项?').then(function() {
|
|
|
+ return delSensorConfig(_sensorIds);
|
|
|
+ }).then(() => {
|
|
|
+ getList();
|
|
|
+ proxy.$modal.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+}
|
|
|
+
|
|
|
+/** 导出按钮操作 */
|
|
|
+function handleExport() {
|
|
|
+ proxy.download('biz/sensorConfig/export', {
|
|
|
+ ...queryParams.value
|
|
|
+ }, `sensorConfig_${new Date().getTime()}.xlsx`)
|
|
|
+}
|
|
|
+
|
|
|
+getList();
|
|
|
+</script>
|