-
- ×
+
@@ -65,7 +65,7 @@
-
@@ -135,33 +135,34 @@
}
}
- .close {
- width: 150px;
- height: 70px;
+ .close1 {
+ width: 40px;
+ height: 40px;
z-index: 99;
position: fixed;
- top: 0;
- right: 0;
+ top: 0px;
+ right: 10px;
+ // background: rgb(145 144 144 / 60%);
+ // border-radius: 50%;
/* background-color: antiquewhite; */
- &:hover {
- .icon {
- display: block;
- }
- }
+ // &:hover {
+ // .icon {
+ // display: block;
+ // }
+ // }
- .icon {
- display: none;
- width: 50px;
- height: 50px;
- background: rgb(145 144 144 / 60%);
- border-radius: 50%;
- line-height: 50px;
+ .icon1 {
+ background: url("@/assets/icons/icon-home1.svg") no-repeat center center / cover;
+ display: block;
+ width: 36px;
+ height: 36px;
+ // line-height: 50px;
text-align: center;
- font-size: 18px;
- font-weight: 700;
+ // font-size: 18px;
+ // font-weight: 700;
color: #ccc;
- margin: 10px auto;
+ // margin: 10px auto;
&:hover {
cursor: pointer;
diff --git a/src/views/home/device/instruction/components/editDialog.vue b/src/views/home/device/instruction/components/editDialog.vue
index cb9b144..ab03661 100644
--- a/src/views/home/device/instruction/components/editDialog.vue
+++ b/src/views/home/device/instruction/components/editDialog.vue
@@ -8,13 +8,14 @@
import type { FormRules } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getDictByCode } from '@/api/system/dict'
-import { addInstruction, removeInstruction } from '@/api/home/device/instruction'
+import { addInstruction, addInstructionOther, removeInstruction } from '@/api/home/device/instruction'
import { getDeviceTypeListPage } from '@/api/home/device/type'
import { getProductListPage } from '@/api/home/device/product'
import { getDeviceListPage } from '@/api/home/device/device'
import useUserStore from '@/store/modules/user'
import indexDB from '@/utils/indexDB'
import { indexDBHandler } from '@/utils/sessionData'
+import { instructionProductList } from './instruction'
const emits = defineEmits(['refresh'])
const $route = useRoute()
const $router = useRouter()
@@ -42,6 +43,46 @@
framecontentDesc: '',
writetime: '',
devCodeList: [],
+
+
+ // 北分麦哈克-管网哨兵
+ 'mhk01': '', // 浓度低报值
+ 'mhk02': 50, // 浓度高报值 不可修改 50(国标要求)
+ 'mhk03': '', // 设备采样周期 1- 30 分钟
+ 'mhk04': '', // 上传采样周期 1- 1440 分钟
+ 'mhk05': '', // GPS告警距离 1 - 65535 米
+ 'mhk06': '1', // 确定设备安装位置 value = 1 生效
+ 'mhk07': '1', // 清除安装位置 value = 1 生效
+ 'mhk08': '1', // 重启设备 value = 1 生效
+
+ // 诺成新-燃气智能警示桩
+ 'ncx01': '', // 第一次上报时间 值,时分(整数)
+ 'ncx02': '', // 第二次上报时间 值,时分(整数)
+ 'ncx03': '', // 左侧线长度 值,单位米
+ 'ncx04': '', // 右侧线长度 值,单位米
+ 'ncx05': '1', // 倾斜报警
+ 'ncx06': '1', // 破坏报警
+ 'ncx07': '1', // 甲烷泄漏报警
+ 'ncx08': '1', // 左侧断线报警
+ 'ncx09': '1', // 右侧断线报警
+ 'ncx10': '1', // 左侧振动报警
+ 'ncx11': '1', // 右侧振动报警
+ 'ncx12': '1', // 语音报警
+ // 'ncx13': '1', // 备用
+
+ // 百瑞生-管网哨兵
+ 'brs4': '', // 浓度报警低阈值 值,%LEL
+ 'brs5': '', // 浓度报警高阈值 值,%LEL
+ 'brs7': '', // 低温阈值
+ 'brs8': '', // 高温阈值
+ 'brs11': '', // 传感器采集间隔 值,单位秒
+ 'brs12': '', // 采样深度
+ 'brs15': '', // 预热时间 值,单位秒
+ 'brs19': '1', // 防盗使能 1开启,0禁用
+ 'brs20': '1', // 振动监测 1开启,0禁用
+ 'brs28': '1', // 振动采样使能 1开启,0禁用
+ 'brs29': '', // 振动阈值1
+ 'brs30': '', // 振动阈值2
}) // 表单
const textMap: { [key: string]: string } = {
edit: '编辑',
@@ -49,14 +90,91 @@
addOther: '新增',
detail: '详情',
} // 表头显示标题
+
+const validatemhk01 = (rule: any, value: any, callback: any) => {
+ if (value === '') {
+ callback(new Error('浓度低报值不能为空'))
+ }
+ else {
+ if (Number(value) >= 5 && Number(value) <= 25) {
+ callback()
+ }
+ else {
+ callback(new Error('浓度低报值需在5-25之间'))
+ }
+ }
+}
+const validatemhk03 = (rule: any, value: any, callback: any) => {
+ if (value === '') {
+ callback(new Error('设备采样周期不能为空'))
+ }
+ else {
+ if (Number(value) >= 1 && Number(value) <= 30) {
+ callback()
+ }
+ else {
+ callback(new Error('设备采样周期需在1-30之间'))
+ }
+ }
+}
+const validatemhk04 = (rule: any, value: any, callback: any) => {
+ if (value === '') {
+ callback(new Error('上传采样周期不能为空'))
+ }
+ else {
+ if (Number(value) >= 1 && Number(value) <= 1440) {
+ callback()
+ }
+ else {
+ callback(new Error('上传采样周期需在1-1440之间'))
+ }
+ }
+}
+const validatemhk05 = (rule: any, value: any, callback: any) => {
+ if (value === '') {
+ callback()
+ }
+ else {
+ if (Number(value) >= 1 && Number(value) <= 65535) {
+ callback()
+ }
+ else {
+ callback(new Error('GPS告警距离需在1-1440之间'))
+ }
+ }
+}
const rules: FormRules = {
productId: [{ required: true, message: '产品必选', trigger: ['blur', 'change'] }],
- devCodeList: [{ required: true, message: '设备必选', trigger: ['blur', 'change'] }],
+ devCodeList: [{ required: true, message: '设备编号必选', trigger: ['blur', 'change'] }],
collectInterval: [{ required: true, message: '采集间隔不能为空', trigger: ['blur', 'change'] }],
reloadInterval: [{ required: true, message: '重传次数不能为空', trigger: ['blur', 'change'] }],
uploadPeriod: [{ required: true, message: '上传周期不能为空', trigger: ['blur', 'change'] }],
-} // 前端校验规则
+ // 北分麦哈克-管网哨兵
+ mhk01: [{ required: true, validator: validatemhk01, trigger: ['blur', 'change'] }], // 浓度低报值
+ mhk03: [{ required: true, validator: validatemhk03, trigger: ['blur', 'change'] }], // 设备采样周期
+ mhk04: [{ required: true, validator: validatemhk04, trigger: ['blur', 'change'] }], // 上传采样周期
+ mhk05: [{ required: false, validator: validatemhk05, trigger: ['blur', 'change'] }], // GPS告警距离
+
+ // 诺成新-燃气智能警示桩
+ ncx01: [{ required: true, message: '第一次上报时间不能为空', trigger: ['blur', 'change'] }],
+ ncx02: [{ required: true, message: '第二次上报时间不能为空', trigger: ['blur', 'change'] }],
+ ncx03: [{ required: true, message: '左侧线长度不能为空', trigger: ['blur', 'change'] }],
+ ncx04: [{ required: true, message: '右侧线长度不能为空', trigger: ['blur', 'change'] }],
+
+ // 百瑞生-管网哨兵
+ brs4: [{ required: true, message: '报警低阈值不能为空', trigger: ['blur', 'change'] }],
+ brs5: [{ required: true, message: '报警高阈值不能为空', trigger: ['blur', 'change'] }],
+} // 前端校验规则
+// 当前指令类型
+const instruction = ref<{ [key: string]: boolean }>({
+ bjwxd: false, // 北京无线电
+ brsGwsb: false, // 百瑞生-管网哨兵
+ bfmhkGwsb: false, // 北分麦哈克-管网哨兵
+ ncxRqznjsz: false // 诺成新-燃气智能警示桩
+})
+// 当前支持下发配置的产品
+const productConfig = ref(instructionProductList)
// 重置表单
const resetForm = () => {
dataForm.value = {
@@ -75,15 +193,57 @@
framecontentDesc: '',
writetime: '',
devCodeList: [],
+
+ // 北分麦哈克-管网哨兵
+ 'mhk01': '', // 浓度低报值
+ 'mhk02': 50, // 浓度高报值 不可修改 50(国标要求)
+ 'mhk03': '', // 设备采样周期 1- 30 分钟
+ 'mhk04': '', // 上传采样周期 1- 1440 分钟
+ 'mhk05': '', // GPS告警距离 1 - 65535 米
+ 'mhk06': '1', // 确定设备安装位置 value = 1 生效
+ 'mhk07': '1', // 清除安装位置 value = 1 生效
+ 'mhk08': '1', // 重启设备 value = 1 生效
+
+ // 诺成新-燃气智能警示桩
+ 'ncx01': '', // 第一次上报时间 值,时分(整数)
+ 'ncx02': '', // 第二次上报时间 值,时分(整数)
+ 'ncx03': '', // 左侧线长度 值,单位米
+ 'ncx04': '', // 右侧线长度 值,单位米
+ 'ncx05': '1', // 倾斜报警
+ 'ncx06': '1', // 破坏报警
+ 'ncx07': '1', // 甲烷泄漏报警
+ 'ncx08': '1', // 左侧断线报警
+ 'ncx09': '1', // 右侧断线报警
+ 'ncx10': '1', // 左侧振动报警
+ 'ncx11': '1', // 右侧振动报警
+ 'ncx12': '1', // 语音报警
+
+ // 百瑞生-管网哨兵
+ 'brs4': '', // 浓度报警低阈值 值,%LEL
+ 'brs5': '', // 浓度报警高阈值 值,%LEL
+ 'brs7': '', // 低温阈值
+ 'brs8': '', // 高温阈值
+ 'brs11': '', // 传感器采集间隔 值,单位秒
+ 'brs12': '', // 采样深度
+ 'brs15': '', // 预热时间 值,单位秒
+ 'brs19': '1', // 防盗使能 1开启,0禁用
+ 'brs20': '1', // 振动监测 1开启,0禁用
+ 'brs28': '1', // 振动采样使能 1开启,0禁用
+ 'brs29': '', // 振动阈值1
+ 'brs30': '', // 振动阈值2
}
}
const disabledBtn = ref(false)
// 初始化对话框
const isFirst = ref(true)
const initDialog = (dialogStatusValue: string, row: any) => {
+ disabledInstruction.value = false
dialogStatus.value = dialogStatusValue
dialogFormVisible.value = true
disabledBtn.value = false
+ for (const i in instruction.value) {
+ instruction.value[i] = false
+ }
if (dialogStatus.value === 'add') { // 如果是新增,清除验证
resetForm()
dataFormRef.value?.resetFields()
@@ -91,10 +251,15 @@
dataForm.value.operatorName = user.name
}
else if (dialogStatus.value === 'addOther') {
+ isFirst.value = false
resetForm()
dataFormRef.value?.resetFields()
const data = JSON.parse($route.query.row as string)
dataForm.value = data
+ console.log([data.devcode])
+ setTimeout(() => {
+ dataForm.value.devCodeList = [dataForm.value.devcode]
+ }, 100)
// dataForm.value.devcode = data.devcode
// dataForm.value.deviceType = data.deviceType
dataForm.value.operator = user.id
@@ -104,6 +269,70 @@
dataForm.value = {
...JSON.parse(JSON.stringify(row)),
}
+ dataForm.value.devCodeList = [dataForm.value.devcode]
+ deviceList.value = deviceAllList.value.filter((item: any) => item.productId === dataForm.value.productId)
+ // 北京无线电
+ if (dataForm.value.instructionTypeCustrom === 'bjwxd') {
+ instruction.value.bjwxd = true
+ // 解析指令回显
+ if (dataForm.value.framecontent) {
+ const framecontent = dataForm.value.framecontent.split(';').map((item: string) => ({ name: item.split(':')[0], value: item.split(':')[1] }))
+ framecontent.forEach((item: { name: string, value: string }) => {
+ dataForm.value[item.name] = item.value
+ })
+ }
+ }
+
+ // 北分麦哈克-管网哨兵
+ else if (dataForm.value.instructionTypeCustrom === 'bfmhkGwsb') {
+ instruction.value.bfmhkGwsb = true
+ if (dataForm.value.framecontent) {
+ const framecontent = JSON.parse(dataForm.value.framecontent)
+ framecontent.forEach((item: { command: string, value: string }) => {
+ dataForm.value[`mhk${item.command}`] = item.value
+ })
+ }
+ }
+ // 百瑞生-管网哨兵
+ else if (dataForm.value.instructionTypeCustrom === 'brsGwsb') {
+ instruction.value.brsGwsb = true
+ if (dataForm.value.framecontent) {
+ const framecontent = JSON.parse(dataForm.value.framecontent)
+ framecontent.forEach((item: { command: string, value: string }) => {
+ dataForm.value[`brs${item.command}`] = item.value
+ })
+ }
+ }
+ // 诺成新-燃气智能警示桩
+ else if (dataForm.value.instructionTypeCustrom === 'ncxRqznjsz') {
+ instruction.value.ncxRqznjsz = true
+ if (dataForm.value.framecontent) {
+ const framecontent = JSON.parse(dataForm.value.framecontent)
+ framecontent.forEach((item: { command: string, value: string }) => {
+ if (item.command === 'time') {
+ const value = item.value.split(',')
+ value.forEach((item: string, index: number) => {
+ dataForm.value[`ncx0${index + 1}`] = `${item.substring(0, 2)}:00`
+ })
+ }
+ else if (item.command === 'length') {
+ const value = item.value.split(',')
+ value.forEach((item: string, index: number) => {
+ dataForm.value[`ncx0${index + 3}`] = item
+ })
+ }
+ else if (item.command === 'switch') {
+ let result = []
+ for (let i = 0; i < item.value.length; i++) {
+ result.push(item.value[i])
+ }
+ result.forEach((item: string, index: number) => {
+ dataForm.value[`ncx${index + 5 >= 10 ? '' : '0'}${index + 5}`] = item
+ })
+ }
+ })
+ }
+ }
}
setTimeout(() => {
isFirst.value = false
@@ -117,10 +346,81 @@
const createData = () => {
dataFormRef.value.validate((valid: any) => {
if (valid) {
- dataForm.value.framecontent = `reloadInterval:${dataForm.value.reloadInterval};collectInterval:${dataForm.value.collectInterval};uploadPeriod:${dataForm.value.uploadPeriod}`
- dataForm.value.framecontentDesc = `重传次数:${dataForm.value.reloadInterval}次;采集间隔:${dataForm.value.collectInterval}分;上传周期:${dataForm.value.uploadPeriod}分`
- disabledBtn.value = true
- addInstruction(dataForm.value).then((response) => {
+ let otherData = {} as { [key: string]: any }
+ // 北京无线电-燃气终端
+ if (instruction.value.bjwxd) {
+ dataForm.value.framecontent = `reloadInterval:${dataForm.value.reloadInterval};collectInterval:${dataForm.value.collectInterval};uploadPeriod:${dataForm.value.uploadPeriod}`
+ dataForm.value.framecontentDesc = `重传次数:${dataForm.value.reloadInterval}次;采集间隔:${dataForm.value.collectInterval}分;上传周期:${dataForm.value.uploadPeriod}分`
+ otherData = JSON.parse(JSON.stringify(dataForm.value))
+ for (const i in otherData) {
+ // 清除其余字段
+ if (i.includes('mhk') || i.includes('ncx') || i.includes('brs')) {
+ otherData[i] = undefined
+ }
+ }
+ }
+ else {
+ otherData.typeId = dataForm.value.deviceType
+ otherData.productId = dataForm.value.productId
+ otherData.devCodeList = dataForm.value.devCodeList
+ // 整理不同产品的指令
+ // 北分麦哈克-管网哨兵
+ if (instruction.value.bfmhkGwsb) {
+ const instructionMHK = []
+ for (const i in dataForm.value) {
+ if (i.includes('mhk') && String(dataForm.value[i])) {
+ instructionMHK.push({
+ command: i.replace('mhk', ''),
+ value: dataForm.value[i]
+ })
+ }
+ }
+ otherData.commandConfigList = instructionMHK
+ }
+ // .诺成新-燃气智能警示桩
+ else if (instruction.value.ncxRqznjsz) {
+ const instructionNCX = []
+ for (const i in dataForm.value) {
+ if (i.includes('ncx')) {
+ instructionNCX.push({
+ command: i.replace('ncx', ''),
+ value: dataForm.value[i]
+ })
+ }
+ }
+ const instructionNCXresult = []
+ // 上报时间指令
+ const instructionTime = ['01', '02']
+ const time = instructionNCX.filter(item => instructionTime.includes(item.command)).map(item => item.value)
+ instructionNCXresult.push({ command: 'time', value: time.map((item: string) => item.replace(':', '')).join() })
+ // 侧线长度
+ const instructionLength = ['03', '04']
+ const length = instructionNCX.filter(item => instructionLength.includes(item.command)).map(item => item.value)
+ instructionNCXresult.push({ command: 'length', value: length.join() })
+ // 报警等
+ const instructionSwitch = ['05', '06', '07', '08', '09', '10', '11', '12']
+ const alarm = instructionNCX.filter(item => instructionSwitch.includes(item.command)).map(item => item.value)
+ alarm.push('1')
+ instructionNCXresult.push({ command: 'switch', value: alarm.join(',').replaceAll(',', '') })
+ otherData.commandConfigList = instructionNCXresult
+ }
+ // 百瑞生-管网哨兵
+ else if (instruction.value.brsGwsb) {
+ const instructionBRS = []
+ for (const i in dataForm.value) {
+ if (i.includes('brs') && String(dataForm.value[i])) {
+ instructionBRS.push({
+ command: i.replace('brs', ''),
+ value: dataForm.value[i]
+ })
+ }
+ }
+ otherData.commandConfigList = instructionBRS
+ }
+ }
+ // console.log(otherData, 'otherData')
+ disabledBtn.value = true;
+ (instruction.value.bjwxd ? addInstruction(otherData) : addInstructionOther(otherData)).then((response) => {
if (response.code === 200) {
ElMessage({
message: '添加成功',
@@ -185,7 +485,7 @@
}))
// 产品
getProductListPage({ offset: 1, limit: 99999 }).then((res) => {
- productList.value = res.data.rows.map((item: any) => ({
+ productList.value = res.data.rows.filter((item: any) => productConfig.value.some((citem: any) => item.manufacturerName.includes(citem.manufacturerName) && item.deviceTypeName.includes(citem.deviceName))).map((item: any) => ({
...item,
name: `${item.productName}-${item.deviceModel}/${item.manufacturerName}`,
id: item.id,
@@ -217,16 +517,36 @@
})
}
fetchDict()
-
+// 禁用指令
+const disabledInstruction = ref(false)
+// 当前选中的产品
+const currentProduct = ref
({})
watch(() => dataForm.value.productId, (newVal) => {
if (dialogStatus.value === 'detail' || isFirst.value) { return }
if (newVal) {
- // dataForm.value.devcode = ''
- dataForm.value.deviceType = productList.value.filter((item: any) => item.id === newVal)[0].deviceType
+ dataForm.value.deviceType = productList.value.filter((item: any) => item.id === newVal)[0]?.deviceType || ''
+ if (!dataForm.value.deviceType) {
+ disabledInstruction.value = true
+ ElMessage.warning('该设备不支持指令下发')
+ return
+ }
+ disabledInstruction.value = false
dataForm.value.deviceTypeName = productList.value.filter((item: any) => item.id === newVal)[0].deviceTypeName
deviceList.value = deviceAllList.value.filter((item: any) => item.productId === newVal)
- // console.log(dataForm.value, 'dataForm.value')
dataForm.value.devCodeList = []
+ currentProduct.value = productList.value.filter((item: any) => item.id === newVal)[0]
+ for (const i in instruction.value) {
+ instruction.value[i] = false
+ }
+ const currentProductConfig = productConfig.value.filter((item: any) => currentProduct.value.deviceTypeName.includes(item.deviceName) && currentProduct.value.manufacturerName.includes(item.manufacturerName))
+ if (currentProductConfig.length) {
+ instruction.value[currentProductConfig[0].value] = true
+ }
+ }
+ else {
+ for (const i in instruction.value) {
+ instruction.value[i] = false
+ }
}
}, {
deep: true,
@@ -243,22 +563,24 @@
const computeOptions = (val: any[]) => {
return val.map((item: any) => ({ label: `${item.name}-${item.value}`, value: item.value }))
}
+
+
-
-
+
-
+
+ style="width: 100%;" clearable filterable :disabled="disabledInstruction || dialogStatus === 'addOther'">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+