Browse Source

疲劳唤醒

wangqin
zhoule 11 months ago
parent
commit
7da466bf29
  1. 360
      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

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

@ -2,13 +2,80 @@
<Dialog v-model="modelVisible" title="设备操作"> <Dialog v-model="modelVisible" title="设备操作">
<div class='DeviceControlDialog'> <div class='DeviceControlDialog'>
<ElTabs v-model="activeName" class="tabs"> <ElTabs v-model="activeName" class="tabs" @tab-click="tabClick">
<ElTabPane label="一般模式" name="first"> <ElTabPane label="一般模式" name="first">
<Form v-model="formData" class="form" ref="FormConfigRef" :formList="formList1" column="1" <Form v-model="formData" class="form" ref="FormConfigRef" :formList="formList1" column="1"
labelWidth="120px" /> labelWidth="120px" />
</ElTabPane> </ElTabPane>
<ElTabPane label="自定义模式" name="second"> <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> </ElTabPane>
</ElTabs> </ElTabs>
</div> </div>
@ -25,13 +92,11 @@
</template> </template>
<script> <script>
import Table from '@screen/components/Table.vue';
import Dialog from "@screen/components/Dialog/index.vue"; import Dialog from "@screen/components/Dialog/index.vue";
import Button from "@screen/components/Buttons/Button.vue" import Button from "@screen/components/Buttons/Button.vue"
import Form from '@screen/components/FormConfig'; import Form from '@screen/components/FormConfig';
import { delay } from "@screen/utils/common.js"
import request from "@/utils/request"; import request from "@/utils/request";
import { Message } from "element-ui"; import { Message } from "element-ui";
@ -40,7 +105,8 @@ export default {
components: { components: {
Dialog, Dialog,
Button, Button,
Form Form,
Table
}, },
model: { model: {
prop: 'visible', prop: 'visible',
@ -54,40 +120,77 @@ export default {
return { return {
submitting: false, submitting: false,
activeName: "first", activeName: "first",
onWorkStatus2: 0,
formData: {}, 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: [ formList1: [
{ {
label: "设备模式:", label: "工作模式:",
key: "controlType", key: "controlType",
type: "RadioGroup", type: "select",
default: "00", default: "1",
options: { options: {
type: 'circle',
options: [ options: [
{ {
key: "00", value: "0",
label: "常量", label: "激光关闭"
}, },
{ {
key: "01", value: "1",
label: "闪烁", 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", key: "onWorkStatus",
required: true, required: true,
type: "select", default: 0,
type: "inputNumber",
options: { options: {
placeholder: "请选择", min: 0,
max: 999
} }
}, },
], ],
formList2: [ formList2: [
{ {
label: "设备模式:", label: "工作模式:",
key: "controlType", key: "controlType",
type: "RadioGroup", type: "RadioGroup",
default: "00", default: "00",
@ -115,7 +218,7 @@ export default {
} }
}, },
{ {
label: "作时长:", label: "作时长:",
key: "onWorkStatus", key: "onWorkStatus",
required: true, required: true,
type: "select", type: "select",
@ -123,12 +226,21 @@ export default {
placeholder: "请选择", placeholder: "请选择",
} }
}, },
] ],
rules: {
onWorkStatus: [
{ required: true, message: '工作时长不能为空', trigger: 'blur' },
],
}
} }
}, },
computed: { computed: {
modelVisible: { modelVisible: {
get() { get() {
if (this.visible) {
this.deviceId = 'K82+285';
this.initData();
}
return this.visible return this.visible
}, },
set(val) { set(val) {
@ -136,138 +248,128 @@ export default {
} }
} }
}, },
watch: { // watch: {
modelVisible: { // modelVisible: {
immediate: true, // immediate: true,
handler(bool) { // handler(bool) {
if (!bool) return; // if (!bool) return;
// this.reDisplay(); // // this.requestURL();
} // }
// }
// },
methods: {
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';
} }
}, },
methods: { async requestURL(functionId, options = {}) {
requestURL(functionId, options = {}) { let result = await request({
return new Promise((resolve, reject) => { url: `/business/device/functions/${this.deviceId}/${functionId}`,
request.post(`business/device/functions/${this.deviceId}/${functionId}`, options) method: "post",
.then((result) => { data: options,
if (result.code != 200) return reject();
resolve(result.data[0]);
})
.catch((err) => {
reject();
});
}); });
if (result.code != 200) return Message.error(result?.msg);
//SETMDASKMDSETTMASKTMSETDFASKDF
console.log('aaaa', result);
return result;
}, },
reDisplay() { async tabClick() {
this.requestURL(52) if (this.activeName == 'second') {
.then(async (data) => { //
await delay(0); let result = await request({
url: `/business/device/properties/latest/${this.deviceId}`,
const formData = this.$refs.FormConfigRef?.formData; method: "get",
});
formData.controlType = data.mode; if (result.code != 200) return Message.error(result?.msg);
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') this.tableData = [];
formData.displayTime = [data.startDisplay, data.endDisplay]; let tData = [];
}) result.data.forEach(item => {
.catch(() => { }); if (item.property == 'TM') {
break; 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() { async handleSubmit() {
const result = {}, formData = this.$refs.FormConfigRef?.formData; if (this.activeName == 'first') {//
this.$refs.FormConfigRef.validate().then(async (formData) => {
result.mode = formData.controlType; console.log('formData', formData);
//
delete result.controlType; await this.requestURL('SETMD', { SET: formData.controlType })
//
if (result.mode === '01') { let res = await this.requestURL('SETTM', { SET: formData.onWorkStatus })
if (!formData.displayTime?.length) return Message.error(`时间不能为空!`); console.log('res', res)
if (res.code == 200) {
Message.success('设置成功!');
this.$emit('update:value', false)
} }
});
} else if (this.activeName == 'second') {//
let rData = [];
if (!formData.onWorkStatus || !formData.inWorkStatus) 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 (["01", "02"].includes(result.mode)) { //
if (["04", "00"].includes(formData.onWorkStatus)) return Message.error(`上行工作状态不能选择当前类型!`); await request({
if (["04", "00"].includes(formData.inWorkStatus)) return Message.error(`下行工作状态不能选择当前类型!`); 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)
} }
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> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
.DeviceControlDialog { .DeviceControlDialog {
width: 450px; width: 850px;
height: 210px; min-height: 410px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 15px; 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" /> <Video class="video-stream" :pileNum="dialogData.stakeMark" />
<ElTabs v-model="activeName" @tab-click="handleClickTabs" class="tabs"> <ElTabs v-model="activeName" @tab-click="handleClickTabs" class="tabs">
<ElTabPane label="基本信息" name="first"> <ElTabPane label="基本信息" name="first">
<Descriptions <Descriptions labelWidth="72px" :list="list" :data="data" style="gap: 18px" />
labelWidth="72px"
:list="list"
:data="data"
style="gap: 18px"
/>
</ElTabPane> </ElTabPane>
<ElTabPane label="设备参数" name="second">设备参数</ElTabPane> <ElTabPane label="设备参数" name="second">设备参数</ElTabPane>
<ElTabPane label="在线率统计" name="third"> <ElTabPane label="在线率统计" name="third">
<LineChart <LineChart v-if="activeName === 'third'" :productId="dialogData.id" style="height: 180px" />
v-if="activeName === 'third'"
:productId="dialogData.id"
style="height: 180px"
/>
</ElTabPane> </ElTabPane>
</ElTabs> </ElTabs>
</div> </div>
@ -25,11 +16,8 @@
<template #footer> <template #footer>
<Button @click.native="deviceControlVisible = true">设备操作</Button> <Button @click.native="deviceControlVisible = true">设备操作</Button>
</template> </template>
<!-- 设备操作弹窗 -->
<DeviceControlDialog <DeviceControlDialog v-model="deviceControlVisible" :deviceId="dialogData.iotDeviceId" />
v-model="deviceControlVisible"
:deviceId="dialogData.iotDeviceId"
/>
</Dialog> </Dialog>
</template> </template>
@ -114,7 +102,7 @@ export default {
if (roadInfo) this.$set(this.data, "roadName", roadInfo.roadName); if (roadInfo) this.$set(this.data, "roadName", roadInfo.roadName);
}, },
methods: { methods: {
handleClickTabs() {}, handleClickTabs() { },
}, },
}; };
</script> </script>
@ -155,7 +143,7 @@ export default {
align-items: center; align-items: center;
justify-content: end; justify-content: end;
> div { >div {
font-size: 16px; font-size: 16px;
padding: 6px 12px; padding: 6px 12px;
} }

Loading…
Cancel
Save