|
|
@@ -5,8 +5,8 @@
|
|
|
<div class="card-header">
|
|
|
<span>传感器台账-新增</span>
|
|
|
<div>
|
|
|
- <el-button type="warning" @click="">复位</el-button>
|
|
|
- <el-button type="primary" @click="">保存</el-button>
|
|
|
+ <el-button type="warning" @click="initdata">复位</el-button>
|
|
|
+ <el-button type="primary" @click="savedata">保存</el-button>
|
|
|
<el-button type="primary" plain @click="router.back();">返回</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -23,7 +23,7 @@
|
|
|
|
|
|
</template>
|
|
|
<div class="content-w">
|
|
|
- <el-input placeholder="请输入传感器编码"/>
|
|
|
+ <el-input v-model="currentsensor.sn" placeholder="请输入传感器编码"/>
|
|
|
</div>
|
|
|
</el-descriptions-item>
|
|
|
<el-descriptions-item>
|
|
|
@@ -33,7 +33,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="content-w">
|
|
|
- <el-input placeholder="请输入传感器名称"/>
|
|
|
+ <el-input v-model="currentsensor.name" placeholder="请输入传感器名称"/>
|
|
|
</div>
|
|
|
</el-descriptions-item>
|
|
|
<el-descriptions-item>
|
|
|
@@ -43,11 +43,10 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="content-w">
|
|
|
- <el-select-v2
|
|
|
- v-model="value"
|
|
|
- :options="options"
|
|
|
- placeholder="请选择"
|
|
|
- />
|
|
|
+ <el-select v-model="currentsensor.sensorType" placeholder="请选择">
|
|
|
+ <el-option v-for="item in sensor_type" :key="item.value" :label="item.label" :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</div>
|
|
|
</el-descriptions-item>
|
|
|
<el-descriptions-item>
|
|
|
@@ -57,67 +56,125 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="content-w">
|
|
|
- <el-select-v2
|
|
|
- v-model="value"
|
|
|
- :options="options"
|
|
|
- placeholder="请选择"
|
|
|
- filterable
|
|
|
- remote
|
|
|
- />
|
|
|
+ <el-select @change="changeProtocalType" v-model="currentsensor.protocalType" placeholder="请选择">
|
|
|
+ <el-option v-for="item in protocal_type" :key="item.value" :label="item.label" :value="parseInt(item.value)">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-select v-if="currentsensor.protocalType!=3" v-model="currentsensor.protocalId" placeholder="请选择">
|
|
|
+ <el-option v-for="item in protocallist" :key="item.name" :value="item.id" :label="item.protocolName"></el-option>
|
|
|
+ </el-select>
|
|
|
</div>
|
|
|
</el-descriptions-item>
|
|
|
- <el-descriptions-item>
|
|
|
- <template #label>
|
|
|
- <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
- 配置信息
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div class="content-w">
|
|
|
- <el-select-v2
|
|
|
- v-model="value"
|
|
|
- :options="options"
|
|
|
- placeholder="请选择"
|
|
|
- filterable
|
|
|
- remote
|
|
|
- />
|
|
|
- </div>
|
|
|
- </el-descriptions-item>
|
|
|
- <el-descriptions-item>
|
|
|
- <template #label>
|
|
|
- <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
- 点表
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div class="content-w">
|
|
|
- <el-input placeholder="请输入"/>
|
|
|
- </div>
|
|
|
- </el-descriptions-item>
|
|
|
- <el-descriptions-item span="2">
|
|
|
+ <el-descriptions-item :span="4">
|
|
|
<template #label>
|
|
|
<div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
- <span style="color: red">*</span> 原表名
|
|
|
+ <span style="color: red">*</span> 关联设备
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="content-w">
|
|
|
- <el-input placeholder="请输入原表名"/>
|
|
|
- </div>
|
|
|
- </el-descriptions-item>
|
|
|
- <el-descriptions-item span="4">
|
|
|
- <template #label>
|
|
|
- <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
- <span style="color: red">*</span> 表字段类型
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div class="content-w">
|
|
|
- <el-select-v2
|
|
|
- v-model="value"
|
|
|
- :options="options"
|
|
|
- placeholder="请选择"
|
|
|
- filterable
|
|
|
- remote
|
|
|
- />
|
|
|
+ <el-popover placement="right" :width="800" trigger="click">
|
|
|
+ <template #reference>
|
|
|
+ <el-button plain>{{ `${ (alldevice.find(i=>(i.id+"")==currentsensor.deviceId) ?? {name:'未配置'}).name}` }}</el-button>
|
|
|
+ </template>
|
|
|
+ <div>
|
|
|
+ <div style="margin-bottom: 20px">
|
|
|
+ <div style="display: flex; flex-direction: row; justify-content: space-between">
|
|
|
+ <div style="display: flex; flex-direction: row;">
|
|
|
+ <div style="
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ align-items: center;
|
|
|
+ ">
|
|
|
+ <div style="font-size: 12px; width: 80px;">设备名称:</div>
|
|
|
+ <el-input v-model="searchform.name" placeholder="设备名称"></el-input>
|
|
|
+ </div>
|
|
|
+ <div style="
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ align-items: center;
|
|
|
+ ">
|
|
|
+ <div style="font-size: 12px; width: 80px;margin-left: 10px">设备编码:</div>
|
|
|
+ <el-input v-model="searchform.sn" placeholder="设备编码"></el-input>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" plain @click="initsearch">重置</el-button>
|
|
|
+ <el-button type="primary" @click="getalldata">搜索</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <el-table :data="alldevice" @cellClick="(row1)=>{currentsensor.deviceId=row1.id;}">
|
|
|
+ <el-table-column property="sn" label="设备编码" />
|
|
|
+ <el-table-column property="name" label="设备名称" />
|
|
|
+ <el-table-column property="deptName" label="上层位置" />
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <el-pagination style="float: right;margin-top: 20px"
|
|
|
+ small
|
|
|
+ background
|
|
|
+ layout="prev, pager, next"
|
|
|
+ :total="pagedata.total"
|
|
|
+ :page-size="pagedata.size"
|
|
|
+ :current-page="pagedata.current"
|
|
|
+ @current-change="onchangepage"
|
|
|
+ class="mt-4"
|
|
|
+ />
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </el-popover>
|
|
|
</div>
|
|
|
</el-descriptions-item>
|
|
|
+<!-- <el-descriptions-item>-->
|
|
|
+<!-- <template #label>-->
|
|
|
+<!-- <div style="display: inline-block;min-width: 100px;text-align: right">-->
|
|
|
+<!-- 配置信息-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- <div class="content-w">-->
|
|
|
+<!-- <el-input v-model="currentsensor.config" placeholder="请输入配置信息"/>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </el-descriptions-item>-->
|
|
|
+<!-- <el-descriptions-item>-->
|
|
|
+<!-- <template #label>-->
|
|
|
+<!-- <div style="display: inline-block;min-width: 100px;text-align: right">-->
|
|
|
+<!-- 点表-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- <div class="content-w">-->
|
|
|
+<!-- <el-input placeholder="请输入"/>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </el-descriptions-item>-->
|
|
|
+<!-- <el-descriptions-item span="2">-->
|
|
|
+<!-- <template #label>-->
|
|
|
+<!-- <div style="display: inline-block;min-width: 100px;text-align: right">-->
|
|
|
+<!-- <span style="color: red">*</span> 原表名-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- <div class="content-w">-->
|
|
|
+<!-- <el-input placeholder="请输入原表名"/>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </el-descriptions-item>-->
|
|
|
+<!-- <el-descriptions-item span="4">-->
|
|
|
+<!-- <template #label>-->
|
|
|
+<!-- <div style="display: inline-block;min-width: 100px;text-align: right">-->
|
|
|
+<!-- <span style="color: red">*</span> 表字段类型-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- <div class="content-w">-->
|
|
|
+<!-- <el-select-v2-->
|
|
|
+<!-- v-model="value"-->
|
|
|
+<!-- :options="options"-->
|
|
|
+<!-- placeholder="请选择"-->
|
|
|
+<!-- filterable-->
|
|
|
+<!-- remote-->
|
|
|
+<!-- />-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </el-descriptions-item>-->
|
|
|
|
|
|
<el-descriptions-item :span="2">
|
|
|
<template #label>
|
|
|
@@ -126,7 +183,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="content-w" style="min-width: 400px">
|
|
|
- <el-input type="textarea" :line-count="5" show-word-limit maxlength="200" placeholder="请输入描述"/>
|
|
|
+ <el-input type="textarea" v-model="currentsensor.sensorDesc" :line-count="5" show-word-limit maxlength="200" placeholder="请输入描述"/>
|
|
|
</div>
|
|
|
</el-descriptions-item>
|
|
|
<el-descriptions-item :span="2">
|
|
|
@@ -136,7 +193,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="content-w" style="min-width: 400px">
|
|
|
- <el-input type="textarea" :line-count="5" show-word-limit maxlength="200" placeholder="请输入备注"/>
|
|
|
+ <el-input type="textarea" v-model="currentsensor.remark" :line-count="5" show-word-limit maxlength="200" placeholder="请输入备注"/>
|
|
|
</div>
|
|
|
</el-descriptions-item>
|
|
|
|
|
|
@@ -151,9 +208,16 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts">
|
|
|
-import {ref} from "vue";
|
|
|
+<script setup >
|
|
|
+import {onMounted, ref} from "vue";
|
|
|
import {useRoute, useRouter} from "vue-router";
|
|
|
+import {addSensor,updateSensor} from "@/api/data/sensor"
|
|
|
+import {ElMessage} from "element-plus";
|
|
|
+import {listModbusTcp} from "@/api/data/modbusTcp";
|
|
|
+import {listModbusRtu} from "@/api/data/modbusRtu";
|
|
|
+import {listEquipmentSbook} from "@/api/data/equipmentSbook";
|
|
|
+const {proxy} = getCurrentInstance();
|
|
|
+const {protocal_type, sensor_type, sensor_status} = proxy.useDict("protocal_type", "sensor_type", "sensor_status");
|
|
|
|
|
|
|
|
|
|
|
|
@@ -168,6 +232,107 @@ const options = ref([
|
|
|
label: '黄金糕'
|
|
|
}]);
|
|
|
|
|
|
+const currentsensor = ref({
|
|
|
+ "name": "",
|
|
|
+ "sn": "",
|
|
|
+ "deviceId": null,
|
|
|
+ "sensorType": "",
|
|
|
+ "protocalType": null,
|
|
|
+ "sensorDesc": "",
|
|
|
+ "status": "",
|
|
|
+ "remark": "",
|
|
|
+ "protocalId": null,
|
|
|
+ "equipmentTreeId": null,
|
|
|
+ "equipmentName": null,
|
|
|
+ "configUuid": null});
|
|
|
+const initdata = ()=>{
|
|
|
+ currentsensor.value = {
|
|
|
+ "name": "",
|
|
|
+ "sn": "",
|
|
|
+ "deviceId": null,
|
|
|
+ "sensorType": "",
|
|
|
+ "protocalType": null,
|
|
|
+ "sensorDesc": "",
|
|
|
+ "status": "",
|
|
|
+ "remark": "",
|
|
|
+ "protocalId": null,
|
|
|
+ "equipmentTreeId": null,
|
|
|
+ "equipmentName": null,
|
|
|
+ "configUuid": null};
|
|
|
+}
|
|
|
+const savedata = ()=>{
|
|
|
+ if (route.query["type"] == 1) {
|
|
|
+ updateSensor(currentsensor.value).then(res => {
|
|
|
+ ElMessage.success("保存成功")
|
|
|
+ router.back();
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ addSensor(currentsensor.value).then(res => {
|
|
|
+ ElMessage.success("保存成功")
|
|
|
+ router.back();
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+const searchform = ref({
|
|
|
+ name:"",
|
|
|
+ sn:"",
|
|
|
+})
|
|
|
+
|
|
|
+onMounted(()=>{
|
|
|
+ if (route.query["type"] == 1) {
|
|
|
+ if (localStorage.getItem("currentsensor")) {
|
|
|
+ currentsensor.value = JSON.parse(localStorage.getItem("currentsensor"))
|
|
|
+ } else {
|
|
|
+ route.query["type"] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ getalldata();
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+const protocallist = ref([]);
|
|
|
+
|
|
|
+const changeProtocalType = (item) => {
|
|
|
+
|
|
|
+ if (item == 1) {
|
|
|
+ listModbusTcp({pageSize: 10000}).then(res => {
|
|
|
+ protocallist.value = res.rows;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (item == 2) {
|
|
|
+ listModbusRtu({pageSize: 10000}).then(res => {
|
|
|
+ protocallist.value = res.rows;
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const initsearch = ()=>{
|
|
|
+ searchform.value = {name:'',sn:''};
|
|
|
+ pagedata.value = { total:0,
|
|
|
+ size:10,
|
|
|
+ current:1}
|
|
|
+}
|
|
|
+
|
|
|
+const alldevice = ref([]);
|
|
|
+const onchangepage = (page) => {
|
|
|
+ pagedata.value.current = page;
|
|
|
+ getalldata();
|
|
|
+}
|
|
|
+const pagedata = ref({
|
|
|
+ total:0,
|
|
|
+ size:10,
|
|
|
+ current:1
|
|
|
+});
|
|
|
+const getalldata = () => {
|
|
|
+ listEquipmentSbook({ ...pagedata.value,params:{...searchform.value}
|
|
|
+ }).then(res => {
|
|
|
+ const {rows,total,page,size} = res;
|
|
|
+ alldevice.value = rows;
|
|
|
+ pagedata.value = {total:total,current:page, size:10};
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
</script>
|
|
|
|