Browse Source

feat 批量控制 行车诱导完成

wangqin
qingzhengli 7 months ago
parent
commit
96a41957ef
  1. 222
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/DrivingGuidance/components/DeviceControlDialog.vue
  2. 307
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/DrivingGuidance/components/DeviceParam.vue
  3. 19
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/DrivingGuidance/index.vue
  4. 6
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/components/DeviceControlDialog.vue
  5. 3
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/components/DeviceParam.vue
  6. 24
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/index.vue
  7. 10
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/HomeFrameControl/index.vue

222
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/DrivingGuidance/components/DeviceControlDialog.vue

@ -1,28 +1,12 @@
<template> <template>
<Dialog v-model="modelVisible" title="设备操作" width="600px"> <Dialog v-model="modelVisible" title="设备操作" width="600px">
<div class="DeviceControlDialog"> <DeviceParam v-model="modelVisible" ref="DeviceParam" :deviceId="deviceId" :id="id" :deviceType="deviceType"
<Form @update:submitting="(val) => { submitting = val }">
v-model="formData" </DeviceParam>
class="form"
ref="FormConfigRef"
:formList="formList"
column="1"
labelWidth="120px"
/>
<div class="tips" v-if="formData.controlType === '01'">
说明: 定时控制模式下,诱导灯在开始时间自动打开,结束时间自动关闭
</div>
<div class="tips" v-if="formData.controlType === '02'">
说明: 万年历自动模式下,诱导灯在白天会自动关闭,夜晚会自动打开
</div>
</div>
<template #footer> <template #footer>
<Button <Button style="background-color: rgba(0, 179, 204, 0.3)"
style="background-color: rgba(0, 179, 204, 0.3)" @click.native="(modelVisible = false), (submitting = false)">
@click.native="(modelVisible = false), (submitting = false)"
>
取消 取消
</Button> </Button>
<Button @click.native="handleSubmit" :loading="submitting"> 确定 </Button> <Button @click.native="handleSubmit" :loading="submitting"> 确定 </Button>
@ -35,14 +19,10 @@ 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 { cloneDeep } from "lodash";
import { delay } from "@screen/utils/common.js";
import request from "@/utils/request";
import { Message } from "element-ui"; import { Message } from "element-ui";
// import { axiosIns } from "@screen/utils/axios/auth.js"; // import { axiosIns } from "@screen/utils/axios/auth.js";
import { handle3CResult } from "@screen/utils/deviceControl.js"; import { handle3CResult } from "@screen/utils/deviceControl.js";
import DeviceParam from "./DeviceParam.vue";
const workStatus = [ const workStatus = [
{ {
key: "00", key: "00",
@ -74,6 +54,7 @@ export default {
Dialog, Dialog,
Button, Button,
Form, Form,
DeviceParam,
}, },
model: { model: {
prop: "visible", prop: "visible",
@ -82,99 +63,12 @@ export default {
props: { props: {
visible: Boolean, visible: Boolean,
deviceId: String, deviceId: String,
id: String,
deviceType: String,
}, },
inject: ["requestURL"],
data() { data() {
return { return {
submitting: false, submitting: false,
formData: {},
formList: [
{
label: "类型:",
key: "controlType",
type: "RadioGroup",
default: "00",
ons: {
input: (value, { data }) => {
const oldFormData = this.oldFormData;
if (!oldFormData) return;
this.formList[1].options.options.splice(-1, 1, {
...workStatus.slice(-1)[0],
disabled: value != "00",
});
this.formList[1].options.options.splice(0, 1, {
...workStatus[0],
disabled: value != "00",
});
switch (value) {
case "01":
if (["04", "00"].includes(data.onWorkStatus))
data.onWorkStatus = null;
if (["04", "00"].includes(data.inWorkStatus))
data.inWorkStatus = null;
Array.isArray(oldFormData.displayTime) &&
(data.displayTime = [...oldFormData.displayTime]);
break;
}
},
},
options: {
type: "circle",
options: [
{
key: "00",
label: "手动控制",
},
{
key: "01",
label: "自动控制",
},
{
key: "02",
label: "万年历",
},
],
},
},
{
label: "上行工作状态:",
key: "onWorkStatus",
required: true,
type: "select",
options: {
placeholder: "请选择",
options: workStatus,
},
},
{
label: "下行工作状态:",
key: "inWorkStatus",
required: true,
type: "select",
options: {
placeholder: "请选择",
options: workStatus,
},
},
{
label: "选择时间:",
key: "displayTime",
type: "timePicker",
required: true,
visible: (data) => data.controlType == "01",
options: {
isRange: true,
rangeSeparator: "至",
valueFormat: "HH:mm",
startPlaceholder: "开始时间",
endPlaceholder: "结束时间",
},
},
],
}; };
}, },
computed: { computed: {
@ -187,105 +81,9 @@ export default {
}, },
}, },
}, },
watch: {
modelVisible: {
immediate: true,
handler(bool) {
if (!bool) return;
this.reDisplay();
},
},
},
methods: { methods: {
reDisplay() {
this.requestURL().then(async (data) => {
await delay(0);
const formData = this.$refs.FormConfigRef?.formData;
formData.controlType = data.mode;
await handle3CResult(data, formData, this.requestURL);
this.oldFormData = { ...formData };
});
},
handleSubmit() { handleSubmit() {
const result = {}, this.$refs.DeviceParam.handleSubmit();
formData = this.$refs.FormConfigRef?.formData;
result.mode = formData.controlType;
delete result.controlType;
if (result.mode === "01") {
if (!formData.displayTime?.length)
return Message.error(`时间不能为空!`);
}
if (!formData.onWorkStatus || !formData.inWorkStatus)
return Message.error(`工作状态不能为空!`);
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;
});
}, },
}, },
}; };

307
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/DrivingGuidance/components/DeviceParam.vue

@ -0,0 +1,307 @@
<template>
<div class="DeviceControlDialog" :style="{
'margin-top': isMultiControl ? '15px' : undefined,
'width': isMultiControl ? '100%' : undefined,
}">
<Form v-model="formData" class="form" ref="FormConfigRef" :formList="formList" column="1" labelWidth="120px" />
<div class="tips" v-if="formData.controlType === '01'">
说明: 定时控制模式下,诱导灯在开始时间自动打开,结束时间自动关闭
</div>
<div class="tips" v-if="formData.controlType === '02'">
说明: 万年历自动模式下,诱导灯在白天会自动关闭,夜晚会自动打开
</div>
</div>
</template>
<script>
import Dialog from "@screen/components/Dialog/index.vue";
import Button from "@screen/components/Buttons/Button.vue";
import Form from "@screen/components/FormConfig";
import { cloneDeep } from "lodash";
import { delay } from "@screen/utils/common.js";
import request from "@/utils/request";
import { Message } from "element-ui";
// import { axiosIns } from "@screen/utils/axios/auth.js";
import { handle3CResult } from "@screen/utils/deviceControl.js";
import { batchFunctions } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js";
import { multiResultShow } from "@screen/utils/common";
const workStatus = [
{
key: "00",
label: "不更新状态",
disabled: false,
},
{
key: "01",
label: "常亮",
},
{
key: "02",
label: "流水",
},
{
key: "03",
label: "闪烁",
},
{
key: "04",
label: "关闭",
disabled: false,
},
];
export default {
name: "DeviceControlDialog",
components: {
Dialog,
Button,
Form,
},
model: {
prop: "visible",
event: "update:value",
},
props: {
visible: Boolean,
deviceId: String,
id: String,
deviceType: String,
isMultiControl: Boolean,
selectItems: {
type: Array,
default: () => []
}
},
inject: ["requestURL"],
data() {
return {
formData: {},
formList: [
{
label: "类型:",
key: "controlType",
type: "RadioGroup",
default: "00",
ons: {
input: (value, { data }) => {
const oldFormData = this.oldFormData;
if (!oldFormData) return;
this.formList[1].options.options.splice(-1, 1, {
...workStatus.slice(-1)[0],
disabled: value != "00",
});
this.formList[1].options.options.splice(0, 1, {
...workStatus[0],
disabled: value != "00",
});
switch (value) {
case "01":
if (["04", "00"].includes(data.onWorkStatus))
data.onWorkStatus = null;
if (["04", "00"].includes(data.inWorkStatus))
data.inWorkStatus = null;
Array.isArray(oldFormData.displayTime) &&
(data.displayTime = [...oldFormData.displayTime]);
break;
}
},
},
options: {
type: "circle",
options: [
{
key: "00",
label: "手动控制",
},
{
key: "01",
label: "自动控制",
},
{
key: "02",
label: "万年历",
},
],
},
},
{
label: "上行工作状态:",
key: "onWorkStatus",
required: true,
type: "select",
options: {
placeholder: "请选择",
options: workStatus,
},
},
{
label: "下行工作状态:",
key: "inWorkStatus",
required: true,
type: "select",
options: {
placeholder: "请选择",
options: workStatus,
},
},
{
label: "选择时间:",
key: "displayTime",
type: "timePicker",
required: true,
visible: (data) => data.controlType == "01",
options: {
isRange: true,
rangeSeparator: "至",
valueFormat: "HH:mm",
startPlaceholder: "开始时间",
endPlaceholder: "结束时间",
},
},
],
};
},
mounted() {
this.$emit("update:submitting", false);
if (!this.isMultiControl)
this.reDisplay();
},
methods: {
reDisplay() {
console.log(this.requestURL)
this.requestURL().then(async (data) => {
await delay(0);
const formData = this.$refs.FormConfigRef?.formData;
formData.controlType = data.mode;
await handle3CResult(data, formData, this.requestURL);
this.oldFormData = { ...formData };
});
},
handleSubmit() {
const result = {},
formData = this.$refs.FormConfigRef?.formData;
result.mode = formData.controlType;
delete result.controlType;
if (result.mode === "01") {
if (!formData.displayTime?.length)
return Message.error(`时间不能为空!`);
}
if (!formData.onWorkStatus || !formData.inWorkStatus)
return Message.error(`工作状态不能为空!`);
if (["01", "02"].includes(result.mode)) {
if (["04", "00"].includes(formData.onWorkStatus))
return Message.error(`上行工作状态不能选择当前类型!`);
if (["04", "00"].includes(formData.inWorkStatus))
return Message.error(`下行工作状态不能选择当前类型!`);
}
if (this.isMultiControl && !this.selectItems.length) {
return Message.error("请至少选择一个设备!");
}
const selectItems = this.selectItems.map(item => JSON.parse(item));
result.onWorkStatus = formData.onWorkStatus;
result.inWorkStatus = formData.inWorkStatus;
this.$emit("update:submitting", true);
let devices;
if (this.isMultiControl) devices = selectItems;
else devices = [{
iotDeviceId: this.deviceId,
id: this.id,
deviceType: this.deviceType
}]
const functions = [];
/**
* 接口 地址
*
* https://www.showdoc.com.cn/2450725213006196/10877717880262686
*/
let promise = [];
switch (result.mode) {
case "00":
// promise.push(this.requestURL("51", result));
functions.push({ "functionId": "51", "params": 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];
}
functions.push({
"functionId": "30", "params": {
onWorkStatus: result.onWorkStatus,
inWorkStatus: result.inWorkStatus,
}
},
{ "functionId": "51", "params": options })
// promise.push(
// this.requestURL("30", {
// onWorkStatus: result.onWorkStatus,
// inWorkStatus: result.inWorkStatus,
// }),
// this.requestURL("51", options)
// );
break;
}
batchFunctions({
devices: devices,
functions: functions
})
// Promise.all(promise)
.then(() => {
this.$emit("update:value", false); // this.modelVisible = false;
Message.success(`操作成功`);
})
.catch((err) => {
console.log(
"%c [ err ]-110-「DeviceControlDialog.vue」",
"font-size:15px; background:#547bf2; color:#98bfff;",
err
);
Message.error(`设备操作失败!`);
})
.finally(() => {
this.$emit("update:submitting", false);
});
},
},
};
</script>
<style lang="scss" scoped>
.DeviceControlDialog {
width: 450px;
height: 210px;
display: flex;
flex-direction: column;
gap: 15px;
.tips {
font-size: 12px;
}
}
</style>

19
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/DrivingGuidance/index.vue

@ -9,11 +9,7 @@
</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>
@ -21,12 +17,9 @@
<Button @click.native="deviceControlVisible = true">设备操作</Button> <Button @click.native="deviceControlVisible = true">设备操作</Button>
</div> </div>
</div> </div>
<!-- <DeviceControlDialog v-model="deviceControlVisible" :deviceId="dialogData.iotDeviceId || '8697-1'" /> --> <!-- <DeviceControlDialog v-model="deviceControlVisible" :deviceId="dialogData.iotDeviceId || '8697-1'" /> -->
<DeviceControlDialog <DeviceControlDialog v-model="deviceControlVisible" :deviceId="dialogData.iotDeviceId" :id="dialogData.id"
v-model="deviceControlVisible" :deviceType="dialogData.deviceType" />
:deviceId="dialogData.iotDeviceId"
/>
</Dialog> </Dialog>
</template> </template>
@ -127,7 +120,7 @@ export default {
.then((data) => { .then((data) => {
this.dialogData.brand = data.brand; this.dialogData.brand = data.brand;
}) })
.catch((err) => {}); .catch((err) => { });
// this.requestURL(52) // this.requestURL(52)
// .then((result) => { // .then((result) => {
@ -164,7 +157,7 @@ export default {
if (roadInfo) this.data.roadName = roadInfo.roadName; if (roadInfo) this.data.roadName = roadInfo.roadName;
}, },
methods: { methods: {
handleClickTabs() {}, handleClickTabs() { },
requestURL(functionId = 52, options = {}) { requestURL(functionId = 52, options = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request request
@ -219,7 +212,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;
} }

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

@ -1,7 +1,8 @@
<template> <template>
<Dialog v-model="modelVisible" title="设备操作" width="910px"> <Dialog v-model="modelVisible" title="设备操作" width="910px">
<div class="DeviceControlDialog"> <div class="DeviceControlDialog">
<DeviceParam v-model="modelVisible" ref="DeviceParam" :deviceId="this.deviceId" :productId="this.productId"> <DeviceParam v-model="modelVisible" ref="DeviceParam" :deviceId="this.deviceId" :productId="this.productId"
:deviceType="deviceType">
</DeviceParam> </DeviceParam>
</div> </div>
@ -39,7 +40,8 @@ export default {
props: { props: {
visible: Boolean, visible: Boolean,
deviceId: String, deviceId: String,
productId: String productId: String,
deviceType: String
}, },
data() { data() {
return { return {

3
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/FatigueWakesUp/components/DeviceParam.vue

@ -110,6 +110,7 @@ export default {
visible: Boolean, visible: Boolean,
deviceId: String, deviceId: String,
productId: String, productId: String,
deviceType: String,
isMultiControl: Boolean, isMultiControl: Boolean,
selectItems: { selectItems: {
type: Array, type: Array,
@ -347,7 +348,7 @@ export default {
else devices = [{ else devices = [{
iotDeviceId: this.deviceId, iotDeviceId: this.deviceId,
id: this.productId, id: this.productId,
deviceType: 10 deviceType: this.deviceType
}] }]
if (this.activeName == "first") { if (this.activeName == "first") {
// //

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>
@ -26,11 +17,8 @@
<Button @click.native="deviceControlVisible = true">设备操作</Button> <Button @click.native="deviceControlVisible = true">设备操作</Button>
</template> </template>
<!-- 设备操作弹窗 --> <!-- 设备操作弹窗 -->
<DeviceControlDialog <DeviceControlDialog v-model="deviceControlVisible" :deviceId="dialogData.iotDeviceId" :productId="dialogData.id"
v-model="deviceControlVisible" :deviceType="dialogData.deviceType" />
:deviceId="dialogData.iotDeviceId"
:productId="dialogData.id"
/>
</Dialog> </Dialog>
</template> </template>
@ -115,7 +103,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>
@ -156,7 +144,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;
} }

10
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/HomeFrameControl/index.vue

@ -41,11 +41,16 @@ import { initSearch } from "@screen/utils/enum/common.js"
import SmartDeviceParams from "@screen/pages/Home/components/Dialogs/SmartDevice/components/DeviceParamsMulti.vue"; import SmartDeviceParams from "@screen/pages/Home/components/Dialogs/SmartDevice/components/DeviceParamsMulti.vue";
import BroadcastParam from "@screen/pages/Home/components/Dialogs/Broadcast/components/BroadcastParamMulti.vue"; import BroadcastParam from "@screen/pages/Home/components/Dialogs/Broadcast/components/BroadcastParamMulti.vue";
import FatigueWakesUpParam from "@screen/pages/Home/components/Dialogs/FatigueWakesUp/components/DeviceParam.vue"; import FatigueWakesUpParam from "@screen/pages/Home/components/Dialogs/FatigueWakesUp/components/DeviceParam.vue";
import DrivingGuidanceParam from "@screen/pages/Home/components/Dialogs/DrivingGuidance/components/DeviceParam.vue";
import { DeviceForMap } from "@screen/pages/Home/components/RoadAndEvents/utils/buttonEvent"; import { DeviceForMap } from "@screen/pages/Home/components/RoadAndEvents/utils/buttonEvent";
const componentMap = { "设备箱": "SmartDeviceParams", "语音广播": "BroadcastParam", "疲劳唤醒": "FatigueWakesUpParam" } //DeviceTopics[deviceType] const componentMap = {
//"": undefined, "": undefined, , "": undefined, "设备箱": "SmartDeviceParams", "语音广播": "BroadcastParam", "疲劳唤醒": "FatigueWakesUpParam",
"行车诱导": "DrivingGuidanceParam"
} //DeviceTopics[deviceType]
//"": undefined, , , "": undefined,
const hiddenDevices = ["SmartDeviceParams"]; const hiddenDevices = ["SmartDeviceParams"];
const controlMulti = Object.keys(componentMap);//6 const controlMulti = Object.keys(componentMap);//6
const DeviceTopics = {};//6 {key:label} const DeviceTopics = {};//6 {key:label}
@ -79,6 +84,7 @@ export default {
SmartDeviceParams, SmartDeviceParams,
BroadcastParam, BroadcastParam,
FatigueWakesUpParam, FatigueWakesUpParam,
DrivingGuidanceParam,
}, },
data() { data() {
return { return {

Loading…
Cancel
Save