Compare commits

...

2 Commits

  1. 27
      ruoyi-ui/src/views/JiHeExpressway/components/Descriptions.vue
  2. 11
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/Broadcast/components/BroadcastParamMulti.vue
  3. 139
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/SmartDevice/components/DeviceParams.vue
  4. 208
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/SmartDevice/components/DeviceParamsMulti.vue
  5. 6
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/HomeFrameControl/index.vue
  6. 19
      ruoyi-ui/src/views/JiHeExpressway/utils/common.js

27
ruoyi-ui/src/views/JiHeExpressway/components/Descriptions.vue

@ -1,16 +1,8 @@
<template> <template>
<div class="Descriptions keep-ratio" origin="left" :style="getStyle()"> <div class="Descriptions keep-ratio" origin="left" :style="getStyle()">
<div <div class="item" v-for="(item, index) in getResolveList" :key="`${item.key || item.label}${index}`"
class="item" :style="[gridStyle(item, index), transformStyle(itemStyle)]" v-if="item.visible != false">
v-for="(item, index) in getResolveList" <div v-if="!item.labelHidden" class="text title" :style="{ ...transformStyle(titleStyle), width: labelWidth }">
:key="`${item.key || item.label}${index}`"
:style="[gridStyle(item, index), transformStyle(itemStyle)]"
v-if="item.visible != false"
>
<div
class="text title"
:style="{ ...transformStyle(titleStyle), width: labelWidth }"
>
<p> <p>
<slot :name="`title-${item.key || item.label}`" :data="item"> <slot :name="`title-${item.key || item.label}`" :data="item">
{{ item.label || "-" }} {{ item.label || "-" }}
@ -18,18 +10,9 @@
</p> </p>
: :
</div> </div>
<ContentText <ContentText :style="transformStyle(titleStyle)" class="content text" :data="data" :_config="item">
:style="transformStyle(titleStyle)"
class="content text"
:data="data"
:_config="item"
>
<template #default="{ value }"> <template #default="{ value }">
<slot <slot :name="`content-${item.key || item.label}`" :value="value" :data="item">
:name="`content-${item.key || item.label}`"
:value="value"
:data="item"
>
{{ value }} {{ value }}
</slot> </slot>
</template> </template>

11
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/Broadcast/components/BroadcastParamMulti.vue

@ -30,6 +30,7 @@ import CheckboxGroup from "@screen/components/FormConfig/components/ElCheckboxGr
import request from "@/utils/request"; import request from "@/utils/request";
import { batchFunctions } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js"; import { batchFunctions } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js";
import { multiResultShow } from "@screen/utils/common";
import { Message } from "element-ui"; import { Message } from "element-ui";
@ -89,7 +90,6 @@ export default {
}, },
handleSubmit() { handleSubmit() {
const selectItems = this.selectItems.map(item => JSON.parse(item)); const selectItems = this.selectItems.map(item => JSON.parse(item));
console.log(this.selectItems, selectItems, "selectItems");
const checkList = selectItems.map(item => JSON.parse(item.otherConfig)); const checkList = selectItems.map(item => JSON.parse(item.otherConfig));
if (!this.releaseMessage?.trim()) if (!this.releaseMessage?.trim())
return Message.error("发布内容不能为空!"); return Message.error("发布内容不能为空!");
@ -118,14 +118,7 @@ export default {
] ]
}) })
.then((data) => { .then((data) => {
const allItems = data.data; multiResultShow(data.data, item => item.result.retCode == 0, "广播设置");
const successItems = allItems.filter(item => item.result.retCode == 0);
console.log("xxxxxxx111")
if (successItems.length == allItems.length) {
Message.success("广播设置成功!");
} else {
Message.error(`广播设置失败, 失败${allItems.length - successItems.length}个!`);
}
}) })
.finally(() => { .finally(() => {
this.submitting = false; this.submitting = false;

139
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/SmartDevice/components/DeviceParams.vue

@ -4,9 +4,11 @@
<Descriptions :list="devicesList" style="gap: 18px;" column="5"> <Descriptions :list="devicesList" style="gap: 18px;" column="5">
<template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }"> <template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }">
<span>{{ data.text }}</span> <span>{{ data.text }}</span>
<Switcher v-if="!disabled" class="switcher" :activeOption="activeOption" :value="data.state" <Switcher v-if="!disabled" class="switcher" :activeOption="activeOption" :value="data.state"
@change="(value) => handleSwitcherChange(value, data)" /> @change="(value) => handleSwitcherChange(value, data)" />
<ElTag style="margin-left: 20px;" v-else effect="dark" :type="data.state?'':'info'">{{ data.state?'开':'关' }}</ElTag> <ElTag style="margin-left: 20px;" v-else effect="dark" :type="data.state ? '' : 'info'">{{ data.state ? '开' :
'关' }}
</ElTag>
</template> </template>
</Descriptions> </Descriptions>
</div> </div>
@ -49,93 +51,93 @@ export default {
}, },
created() { created() {
Promise.all([this.getAc(), this.getDc()]).then(res=>{ Promise.all([this.getAc(), this.getDc()]).then(res => {
// if (result.code != 200) return; // if (result.code != 200) return;
let ac = res[0].data; let ac = res[0].data;
let dc = res[1].data; let dc = res[1].data;
let deviceInfo = _.merge({}, ac, dc); let deviceInfo = _.merge({}, ac, dc);
const typeMap = { const typeMap = {
ac: '220v', ac: '220v',
dc: '12v', dc: '12v',
} }
for (const key in deviceInfo.formatValue) { for (const key in deviceInfo.formatValue) {
// electricity // electricity
// voltage // voltage
if (key.includes('electricity')) { if (key.includes('electricity')) {
const args = key.match(/[a-z]+|[0-9]+$/g); const args = key.match(/[a-z]+|[0-9]+$/g);
const type = args[0], num = args.slice(-1)[0], prefix = args.slice(0, 2).join('_'); const type = args[0], num = args.slice(-1)[0], prefix = args.slice(0, 2).join('_');
// console.log(type , num , prefix , "+++=========="); //dc 2 dc_out // console.log(type , num , prefix , "+++=========="); //dc 2 dc_out
this.devicesList.push( this.devicesList.push(
{ {
label: `支路${num}${typeMap[type]}) 电压`, label: `支路${num}${typeMap[type]}) 电压`,
key: `${prefix}_voltage_${num}`, key: `${prefix}_voltage_${num}`,
text: deviceInfo.formatValue[`${prefix}_voltage_${num}`], text: deviceInfo.formatValue[`${prefix}_voltage_${num}`],
gridColumn: 3 gridColumn: 3
}, },
{ {
label: '电流', label: '电流',
key: `${prefix}_electricity_${num}`, key: `${prefix}_electricity_${num}`,
text: deviceInfo.formatValue[key], text: deviceInfo.formatValue[key],
gridColumn: 2, gridColumn: 2,
state: deviceInfo.value[key] > 0 state: deviceInfo.value[key] > 0
} }
); );
}
} }
this.devicesList.push( }
{ this.devicesList.push(
label: '风扇', {
key: `fan_status`, label: '风扇',
// key: `aa_electricity_1`, key: `fan_status`,
text: { 0: '正常', 1: '开' }[deviceInfo.formatValue['fan_status']] || '-', // key: `aa_electricity_1`,
gridColumn: 2, text: { 0: '正常', 1: '开' }[deviceInfo.formatValue['fan_status']] || '-',
state: (deviceInfo.formatValue['fan_status']==='0') gridColumn: 2,
}, state: (deviceInfo.formatValue['fan_status'] === '0')
},
{
label: '温度', {
key: `temperature`, label: '温度',
text: deviceInfo.formatValue['temperature'] ? `${deviceInfo.formatValue['temperature']} °C` : '-', key: `temperature`,
gridColumn: 2 text: deviceInfo.formatValue['temperature'] ? `${deviceInfo.formatValue['temperature']} °C` : '-',
}, gridColumn: 2
{ },
{
label: '箱门', label: '箱门',
key: `door_status`, key: `door_status`,
text: { 0: '关闭', 1: '打开' }[deviceInfo.formatValue['door_status']] || '-', text: { 0: '关闭', 1: '打开' }[deviceInfo.formatValue['door_status']] || '-',
gridColumn: 1 gridColumn: 1
}, },
{ {
label: '湿度', label: '湿度',
key: `humidity`, key: `humidity`,
text: deviceInfo.formatValue['humidity'] ? `${deviceInfo.formatValue['humidity']} %` : '-', text: deviceInfo.formatValue['humidity'] ? `${deviceInfo.formatValue['humidity']} %` : '-',
gridColumn: 2 gridColumn: 2
}, },
{ {
label: '市电掉电', label: '市电掉电',
key: `power_status`, key: `power_status`,
text: { 0: '正常', 1: '掉电' }[deviceInfo.formatValue['power_status']] || '-', text: { 0: '正常', 1: '掉电' }[deviceInfo.formatValue['power_status']] || '-',
gridColumn: 2 gridColumn: 2
}, },
) )
// this.data = result.rows; // this.data = result.rows;
// this.total = result.total; // this.total = result.total;
}) })
.finally(() => { .finally(() => {
this.secondLoading = false this.secondLoading = false
}) })
}, },
methods: { methods: {
getAc(){ getAc() {
return request({ return request({
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1ac`, url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1ac`,
method: "get", method: "get",
params: {} params: {}
}) })
}, },
getDc(){ getDc() {
return request({ return request({
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1dc`, url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1dc`,
method: "get", method: "get",
@ -145,17 +147,16 @@ export default {
async handleSwitcherChange(value, data) { async handleSwitcherChange(value, data) {
let str = data.state ? "关闭" : "开启"; let str = data.state ? "关闭" : "开启";
let deviceName = ""; let deviceName = "";
if(data.key.includes("fan")){ if (data.key.includes("fan")) {
str += "风扇?"; str += "风扇?";
deviceName = "fan_out_en"; deviceName = "fan_out_en";
}else{ } else {
str += "该支路?" str += "该支路?"
deviceName = data.key.match(/^[a-z]+_out|[0-9]+/g).join("_") + "_en"; //dc_out_2_en ac_out_2_en; deviceName = data.key.match(/^[a-z]+_out|[0-9]+/g).join("_") + "_en"; //dc_out_2_en ac_out_2_en;
} }
data.state = value; data.state = value;
const isContinue = await confirm({ message: `${str}` }) const isContinue = await confirm({ message: `${str}` })
.catch(() => { .catch(() => {
console.log(data.state,value,333)
data.state = !value; data.state = !value;
}); });

208
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/Dialogs/SmartDevice/components/DeviceParamsMulti.vue

@ -2,8 +2,8 @@
<div class='DeviceParams'> <div class='DeviceParams'>
<div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div> <div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div>
<Descriptions :list="devicesList" style="gap: 18px;" column="5"> <Descriptions :list="devicesList" style="gap: 18px;" column="5">
<template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }"> <template v-for="item in devicesList" #[`content-${item.key}`]="{ data }">
<span>{{ data.text }}</span> <span style="font-size: 15px;font-weight: 400;color: #3de8ff;">{{ data.text }}</span>
<Switcher v-if="!disabled" class="switcher" :activeOption="activeOption" :value="data.state" <Switcher v-if="!disabled" class="switcher" :activeOption="activeOption" :value="data.state"
@change="(value) => handleSwitcherChange(value, data)" /> @change="(value) => handleSwitcherChange(value, data)" />
<ElTag style="margin-left: 20px;" v-else effect="dark" :type="data.state ? '' : 'info'">{{ data.state ? '开' : <ElTag style="margin-left: 20px;" v-else effect="dark" :type="data.state ? '' : 'info'">{{ data.state ? '开' :
@ -17,10 +17,12 @@
<script> <script>
import Descriptions from '@screen/components/Descriptions.vue'; import Descriptions from '@screen/components/Descriptions.vue';
import Switcher from '@screen/pages/service/PublishingChannelManagement/components/Switcher.vue'; import Switcher from '@screen/pages/service/PublishingChannelManagement/components/Switcher.vue';
import { cloneDeep } from 'lodash';
import request from "@/utils/request"; import request from "@/utils/request";
import { Message } from 'element-ui'; import { Message } from 'element-ui';
import { confirm } from "@screen/utils/common"; import { confirm } from "@screen/utils/common";
import { batchFunctions } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js";
import { multiResultShow } from "@screen/utils/common";
export default { export default {
name: 'DeviceParams', name: 'DeviceParams',
@ -34,12 +36,57 @@ export default {
default: () => ({}) default: () => ({})
}, },
disabled: Boolean, disabled: Boolean,
isMultiControl: Boolean isMultiControl: Boolean,
selectItems: {
type: Array,
default: () => []
}
}, },
data() { data() {
return { return {
secondLoading: true, secondLoading: true,
devicesList: [], devicesList: [
{
labelHidden: true,
text: `支路1 (220v): `,
key: `ac_out_1_en`,
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`],
gridColumn: 1,
state: 0
},
{
labelHidden: true,
text: `支路2 (220v): `,
key: `ac_out_2_en`,
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`],
gridColumn: 1,
state: 0
},
{
labelHidden: true,
text: `支路1 (12v): `,
key: `dc_out_1_en`,
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`],
gridColumn: 1,
state: 0
},
{
labelHidden: true,
text: `支路2 (12v): `,
key: `dc_out_2_en`,
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`],
gridColumn: 1,
state: 0
},
{
labelHidden: true,
text: '风扇:',
key: `fan_out_en`,
// text: { 0: '', 1: '' }[deviceInfo.formatValue['fan_status']] || '-',
gridColumn: 1,
state: 0
},
],
activeOption: { activeOption: {
active: { active: {
text: "开" text: "开"
@ -52,135 +99,51 @@ export default {
}, },
created() { created() {
Promise.all([this.getAc(), this.getDc()]).then(res => {
// if (result.code != 200) return;
let ac = res[0].data;
let dc = res[1].data;
let deviceInfo = _.merge({}, ac, dc);
console.log(deviceInfo, "deviceInfo11")
const typeMap = {
ac: '220v',
dc: '12v',
}
for (const key in deviceInfo.formatValue) {
// electricity
// voltage
if (key.includes('electricity')) {
const args = key.match(/[a-z]+|[0-9]+$/g);
const type = args[0], num = args.slice(-1)[0], prefix = args.slice(0, 2).join('_');
// console.log(type , num , prefix , "+++=========="); //dc 2 dc_out
this.devicesList.push(
{
label: `支路${num}${typeMap[type]}) 电压`,
key: `${prefix}_voltage_${num}`,
text: deviceInfo.formatValue[`${prefix}_voltage_${num}`],
gridColumn: 3
},
{
label: '电流',
key: `${prefix}_electricity_${num}`,
text: deviceInfo.formatValue[key],
gridColumn: 2,
state: deviceInfo.value[key] > 0
}
);
}
}
this.devicesList.push(
{
label: '风扇',
key: `fan_status`,
// key: `aa_electricity_1`,
text: { 0: '正常', 1: '开' }[deviceInfo.formatValue['fan_status']] || '-',
gridColumn: 2,
state: (deviceInfo.formatValue['fan_status'] === '0')
},
{
label: '温度',
key: `temperature`,
text: deviceInfo.formatValue['temperature'] ? `${deviceInfo.formatValue['temperature']} °C` : '-',
gridColumn: 2
},
{
label: '箱门',
key: `door_status`,
text: { 0: '关闭', 1: '打开' }[deviceInfo.formatValue['door_status']] || '-',
gridColumn: 1
},
{
label: '湿度',
key: `humidity`,
text: deviceInfo.formatValue['humidity'] ? `${deviceInfo.formatValue['humidity']} %` : '-',
gridColumn: 2
},
{
label: '市电掉电',
key: `power_status`,
text: { 0: '正常', 1: '掉电' }[deviceInfo.formatValue['power_status']] || '-',
gridColumn: 2
},
)
// this.data = result.rows;
// this.total = result.total;
})
.finally(() => {
this.secondLoading = false
})
}, },
methods: { methods: {
getAc() {
return request({
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1ac`,
method: "get",
params: {}
})
},
getDc() {
return request({
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1dc`,
method: "get",
params: {}
})
},
async handleSwitcherChange(value, data) { async handleSwitcherChange(value, data) {
let str = data.state ? "关闭" : "开启"; let str = data.state ? "关闭" : "开启";
let deviceName = ""; let deviceName = data.key;
if (data.key.includes("fan")) { str += `${data.text.replace(":", "")}?`;
str += "风扇?"; // if (data.key.includes("fan")) {
deviceName = "fan_out_en"; // str += "?";
} else { // deviceName = "fan_out_en";
str += "该支路?" // } else {
deviceName = data.key.match(/^[a-z]+_out|[0-9]+/g).join("_") + "_en"; //dc_out_2_en ac_out_2_en; // str += "?"
} // deviceName = data.key.match(/^[a-z]+_out|[0-9]+/g).join("_") + "_en"; //dc_out_2_en ac_out_2_en;
// }
data.state = value; data.state = value;
if (!this.selectItems.length) {
setTimeout(() => { data.state = !value; }, 10);
Message.error("请至少选择一个广播设备!")
return;
}
const selectItems = this.selectItems.map(item => JSON.parse(item));
const isContinue = await confirm({ message: `${str}` }) const isContinue = await confirm({ message: `${str}` })
.catch(() => { .catch(() => {
console.log(data.state, value, 333)
data.state = !value; data.state = !value;
}); });
if (!isContinue) return; if (!isContinue) return;
// https://www.yuque.com/dayuanzhong-ovjwn/gkht0m/ww776d5kzs72ilzh?singleDoc= batchFunctions(
request({ {
url: `/business/device/functions/${this.dialogData.iotDeviceId}/${102}`, "devices": selectItems,
method: "POST", "functions": [
data: { {
deviceName, "functionId": "102",
// 1=0= "params": {
value: value ? 1 : 0 deviceName,
} // 1=0=
}) value: value ? 1 : 0
}
}
]
})
.then(result => { .then(result => {
if (result.code != 200) { multiResultShow(result.data, item => item.result.code == 200, "操作");
Message.error("操作失败");
data.state = !value;
return;
};
Message.success("操作成功");
}) })
.catch(() => { .catch(() => {
data.state = !value; data.state = !value;
@ -197,5 +160,8 @@ export default {
<style lang='scss' scoped> <style lang='scss' scoped>
.DeviceParams { .DeviceParams {
height: 100%; height: 100%;
padding-right: 9px;
padding-left: 14px;
margin-top: 15px;
} }
</style> </style>

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

@ -37,12 +37,12 @@ import { ChildTypes } from "@screen/utils/enum.js"
import { getDeviceList } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js"; import { getDeviceList } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js";
import { delay } from "@screen/utils/common"; import { delay } from "@screen/utils/common";
import { initSearch } from "@screen/utils/enum/common.js" import { initSearch } from "@screen/utils/enum/common.js"
import DeviceParams from "@screen/pages/Home/components/Dialogs/SmartDevice/components/DeviceParams.vue"; import DeviceParams 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 { DeviceForMap } from "@screen/pages/Home/components/RoadAndEvents/utils/buttonEvent"; import { DeviceForMap } from "@screen/pages/Home/components/RoadAndEvents/utils/buttonEvent";
const componentMap = { "语音广播": "BroadcastParam" } //DeviceTopics[deviceType] const componentMap = { "设备箱": "DeviceParams", "语音广播": "BroadcastParam" } //DeviceTopics[deviceType]
//"": undefined, "": undefined, "": undefined, "": undefined,"": "DeviceParams", //"": undefined, "": undefined, "": undefined, "": undefined,
const controlMulti = Object.keys(componentMap);//6 const controlMulti = Object.keys(componentMap);//6
const DeviceTopics = {};//6 {key:label} const DeviceTopics = {};//6 {key:label}

19
ruoyi-ui/src/views/JiHeExpressway/utils/common.js

@ -1,6 +1,25 @@
import request from "@/utils/request"; import request from "@/utils/request";
import { Message, MessageBox } from "element-ui"; import { Message, MessageBox } from "element-ui";
/**
*
* @param {*} result 结果数组
* @param {*} predicate 断言函数
* @param {*} operationName 操作名称
*/
export const multiResultShow = (allItems, predicate, operationName) => {
const successItems = allItems.filter(predicate);
if (successItems.length == allItems.length) {
Message.success(`${operationName}成功!`);
} else {
Message.error(
`${operationName}成功${successItems.length}个, 失败${
allItems.length - successItems.length
}!`
);
}
};
export function delay(ms = 240) { export function delay(ms = 240) {
return new Promise((resolve) => setTimeout(() => resolve(void 0), ms)); return new Promise((resolve) => setTimeout(() => resolve(void 0), ms));
} }

Loading…
Cancel
Save