Browse Source

疲劳唤醒

wangqin
zhoule 11 months ago
parent
commit
7da466bf29
  1. 366
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/components/DeviceControlDialog.vue
  2. 24
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/index.vue

366
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/components/DeviceControlDialog.vue

@ -2,13 +2,80 @@
<Dialog v-model="modelVisible" title="设备操作">
<div class='DeviceControlDialog'>
<ElTabs v-model="activeName" class="tabs">
<ElTabs v-model="activeName" class="tabs" @tab-click="tabClick">
<ElTabPane label="一般模式" name="first">
<Form v-model="formData" class="form" ref="FormConfigRef" :formList="formList1" column="1"
labelWidth="120px" />
</ElTabPane>
<ElTabPane label="自定义模式" name="second">
<Form class="form" ref="FormConfigRef" :formList="formList2" column="1" labelWidth="120px" />
<div style="display: flex; margin: 20px 0;">
<p style="width: 115px;">工作时长():</p>
<el-input-number v-model="onWorkStatus2" :min="0" :max="999" label="工作时长(s分):"></el-input-number>
</div>
<Table :data="tableData">
<ElTableColumn prop="ds" label="段数"></ElTableColumn>
<ElTableColumn prop="time" width="120" label="时间">
<template slot-scope="scope">
<div style="display: flex;">
<el-input-number style="width: 80px;" v-model="scope.row.time" :min="0" :max="999"></el-input-number>
<p></p>
</div>
</template>
</ElTableColumn>
<ElTableColumn prop="A" label="线路A">
<template slot-scope="scope">
<el-switch v-model="scope.row.A" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
<ElTableColumn prop="B" label="线路B">
<template slot-scope="scope">
<el-switch v-model="scope.row.B" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
<ElTableColumn prop="C" label="线路C">
<template slot-scope="scope">
<el-switch v-model="scope.row.C" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
<ElTableColumn prop="D" label="线路D">
<template slot-scope="scope">
<el-switch v-model="scope.row.D" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
<ElTableColumn prop="E" label="线路E">
<template slot-scope="scope">
<el-switch v-model="scope.row.E" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
<ElTableColumn prop="F" label="线路F">
<template slot-scope="scope">
<el-switch v-model="scope.row.F" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
<ElTableColumn prop="G" label="线路G">
<template slot-scope="scope">
<el-switch v-model="scope.row.G" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
<ElTableColumn prop="H" label="线路H">
<template slot-scope="scope">
<el-switch v-model="scope.row.H" active-color="#13ce66" inactive-color="#C9C9C9">
</el-switch>
</template>
</ElTableColumn>
</Table>
</ElTabPane>
</ElTabs>
</div>
@ -25,13 +92,11 @@
</template>
<script>
import Table from '@screen/components/Table.vue';
import Dialog from "@screen/components/Dialog/index.vue";
import Button from "@screen/components/Buttons/Button.vue"
import Form from '@screen/components/FormConfig';
import { delay } from "@screen/utils/common.js"
import request from "@/utils/request";
import { Message } from "element-ui";
@ -40,7 +105,8 @@ export default {
components: {
Dialog,
Button,
Form
Form,
Table
},
model: {
prop: 'visible',
@ -54,40 +120,77 @@ export default {
return {
submitting: false,
activeName: "first",
onWorkStatus2: 0,
formData: {},
duan: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T'],
tableData: [
// {
// ds: 'A',
// time: 0,
// A: false,
// B: false,
// C: false,
// D: false,
// E: false,
// F: false,
// G: false,
// H: false,
// }
],
formList1: [
{
label: "设备模式:",
label: "工作模式:",
key: "controlType",
type: "RadioGroup",
default: "00",
type: "select",
default: "1",
options: {
type: 'circle',
options: [
{
key: "00",
label: "常量",
value: "0",
label: "激光关闭"
},
{
key: "01",
label: "闪烁",
}
value: "1",
label: "常亮模式"
},
{
value: "2",
label: "间隔100ms闪烁模式"
},
{
value: "3",
label: "间隔200ms闪烁模式",
},
{
value: "4",
label: "间隔500ms闪烁模式",
},
{
value: "5",
label: "2次闪烁模式"
},
{
value: "6",
label: "SOS模式"
},
],
},
},
{
label: "操作时长:",
label: "工作时长(分):",
key: "onWorkStatus",
required: true,
type: "select",
default: 0,
type: "inputNumber",
options: {
placeholder: "请选择",
min: 0,
max: 999
}
},
],
formList2: [
{
label: "设备模式:",
label: "工作模式:",
key: "controlType",
type: "RadioGroup",
default: "00",
@ -115,7 +218,7 @@ export default {
}
},
{
label: "作时长:",
label: "作时长:",
key: "onWorkStatus",
required: true,
type: "select",
@ -123,12 +226,21 @@ export default {
placeholder: "请选择",
}
},
]
],
rules: {
onWorkStatus: [
{ required: true, message: '工作时长不能为空', trigger: 'blur' },
],
}
}
},
computed: {
modelVisible: {
get() {
if (this.visible) {
this.deviceId = 'K82+285';
this.initData();
}
return this.visible
},
set(val) {
@ -136,138 +248,128 @@ export default {
}
}
},
watch: {
modelVisible: {
immediate: true,
handler(bool) {
if (!bool) return;
// watch: {
// modelVisible: {
// immediate: true,
// handler(bool) {
// if (!bool) return;
// this.reDisplay();
}
}
},
// // this.requestURL();
// }
// }
// },
methods: {
requestURL(functionId, options = {}) {
return new Promise((resolve, reject) => {
request.post(`business/device/functions/${this.deviceId}/${functionId}`, options)
.then((result) => {
if (result.code != 200) return reject();
resolve(result.data[0]);
})
.catch((err) => {
reject();
});
async initData() {
//
let result = await this.requestURL('ASKMD');
if (result.data == 7) {
this.activeName = 'second';
this.tabClick();
} else {
this.formData.controlType = result.data + "" || '1';
//
let resultTime = await this.requestURL('ASKTM');
this.formData.onWorkStatus = resultTime.data || 0;
this.activeName = 'first';
}
},
async requestURL(functionId, options = {}) {
let result = await request({
url: `/business/device/functions/${this.deviceId}/${functionId}`,
method: "post",
data: options,
});
if (result.code != 200) return Message.error(result?.msg);
//SETMDASKMDSETTMASKTMSETDFASKDF
console.log('aaaa', result);
return result;
},
reDisplay() {
this.requestURL(52)
.then(async (data) => {
await delay(0);
const formData = this.$refs.FormConfigRef?.formData;
async tabClick() {
if (this.activeName == 'second') {
//
let result = await request({
url: `/business/device/properties/latest/${this.deviceId}`,
method: "get",
});
if (result.code != 200) return Message.error(result?.msg);
formData.controlType = data.mode;
switch (data.mode) {
case "00":
formData.onWorkStatus = data.onWorkStatus;
formData.inWorkStatus = data.inWorkStatus;
break;
case "01":
case "02":
await this.requestURL("3C")
.then((data2) => {
formData.onWorkStatus = data2.onWorkStatus;
formData.inWorkStatus = data2.inWorkStatus;
if (data.mode === '01')
formData.displayTime = [data.startDisplay, data.endDisplay];
})
.catch(() => { });
break;
this.tableData = [];
let tData = [];
result.data.forEach(item => {
if (item.property == 'TM') {
this.onWorkStatus2 = item.value;
} else if (item.property == 'MD') {
} else {
let data = JSON.parse(item.value || {});
tData.push({ ...data, ds: item.property })
}
this.oldFormData = { ...formData };
})
this.tableData = tData;
}
},
handleSubmit() {
const result = {}, formData = this.$refs.FormConfigRef?.formData;
result.mode = formData.controlType;
delete result.controlType;
async handleSubmit() {
if (this.activeName == 'first') {//
this.$refs.FormConfigRef.validate().then(async (formData) => {
console.log('formData', formData);
//
await this.requestURL('SETMD', { SET: formData.controlType })
//
let res = await this.requestURL('SETTM', { SET: formData.onWorkStatus })
console.log('res', res)
if (res.code == 200) {
Message.success('设置成功!');
this.$emit('update:value', false)
}
});
} else if (this.activeName == 'second') {//
let rData = [];
if (result.mode === '01') {
if (!formData.displayTime?.length) return Message.error(`时间不能为空!`);
}
this.tableData.forEach((it, index) => {
rData.push({
order: 7,
time: it.time,
numberOfSegments: this.duan[index],
A: Number(it.A),
B: Number(it.B),
C: Number(it.C),
D: Number(it.D),
E: Number(it.E),
F: Number(it.F),
G: Number(it.G),
H: Number(it.H),
})
})
if (!formData.onWorkStatus || !formData.inWorkStatus) return Message.error(`工作状态不能为空!`);
//
await request({
url: `/business/device/batchLaserFatigueInvokedFunction`,
method: "post",
data: {
deviceId: this.deviceId,
functionId: 'SETDF',
params: rData
}
});
//
let res = await this.requestURL('SETTM', { SET: this.onWorkStatus2 });
if (res.code == 200) {
Message.success('设置成功!')
this.$emit('update:value', false)
}
if (["01", "02"].includes(result.mode)) {
if (["04", "00"].includes(formData.onWorkStatus)) return Message.error(`上行工作状态不能选择当前类型!`);
if (["04", "00"].includes(formData.inWorkStatus)) return Message.error(`下行工作状态不能选择当前类型!`);
}
result.onWorkStatus = formData.onWorkStatus;
result.inWorkStatus = formData.inWorkStatus;
this.submitting = true;
// this.submitting = false;
// return;
/**
* 接口 地址
*
* https://www.showdoc.com.cn/2450725213006196/10877717880262686
*/
let promise = [];
switch (result.mode) {
case "00":
promise.push(this.requestURL("51", result))
break;
case "01":
case "02":
const options = { mode: result.mode };
if (result.mode === '01') {
options.startDisplayTime = formData.displayTime[0];
options.endDisplayTime = formData.displayTime[1];
}
promise.push(
this.requestURL("30", {
onWorkStatus: result.onWorkStatus,
inWorkStatus: result.inWorkStatus,
}),
this.requestURL("51", options),
)
break;
}
Promise.all(promise)
.then(() => {
this.modelVisible = false;
})
.catch((err) => {
console.log("%c [ err ]-110-「DeviceControlDialog.vue」", "font-size:15px; background:#547bf2; color:#98bfff;", err);
Message.error(`设备操作失败!`);
})
.finally(() => {
this.submitting = false;
})
}
},
}
</script>
<style lang='scss' scoped>
.DeviceControlDialog {
width: 450px;
height: 210px;
width: 850px;
min-height: 410px;
display: flex;
flex-direction: column;
gap: 15px;

24
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/index.vue

@ -4,20 +4,11 @@
<Video class="video-stream" :pileNum="dialogData.stakeMark" />
<ElTabs v-model="activeName" @tab-click="handleClickTabs" class="tabs">
<ElTabPane label="基本信息" name="first">
<Descriptions
labelWidth="72px"
:list="list"
:data="data"
style="gap: 18px"
/>
<Descriptions labelWidth="72px" :list="list" :data="data" style="gap: 18px" />
</ElTabPane>
<ElTabPane label="设备参数" name="second">设备参数</ElTabPane>
<ElTabPane label="在线率统计" name="third">
<LineChart
v-if="activeName === 'third'"
:productId="dialogData.id"
style="height: 180px"
/>
<LineChart v-if="activeName === 'third'" :productId="dialogData.id" style="height: 180px" />
</ElTabPane>
</ElTabs>
</div>
@ -25,11 +16,8 @@
<template #footer>
<Button @click.native="deviceControlVisible = true">设备操作</Button>
</template>
<DeviceControlDialog
v-model="deviceControlVisible"
:deviceId="dialogData.iotDeviceId"
/>
<!-- 设备操作弹窗 -->
<DeviceControlDialog v-model="deviceControlVisible" :deviceId="dialogData.iotDeviceId" />
</Dialog>
</template>
@ -114,7 +102,7 @@ export default {
if (roadInfo) this.$set(this.data, "roadName", roadInfo.roadName);
},
methods: {
handleClickTabs() {},
handleClickTabs() { },
},
};
</script>
@ -155,7 +143,7 @@ export default {
align-items: center;
justify-content: end;
> div {
>div {
font-size: 16px;
padding: 6px 12px;
}

Loading…
Cancel
Save