2024-08-26 14:21:46 +08:00
|
|
|
<template>
|
2024-11-06 13:25:42 +08:00
|
|
|
<TableHeader ref="refheader" :showSearch="false">
|
|
|
|
|
<template #select>
|
2024-09-26 10:01:41 +08:00
|
|
|
<el-form-item label="日期">
|
|
|
|
|
<DatePicker ref="datePickerRef"></DatePicker>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-checkbox-group style="width: 150px" v-model="checkList">
|
2024-09-30 14:45:31 +08:00
|
|
|
<el-checkbox label="稳态" :value="0" />
|
|
|
|
|
<el-checkbox label="暂态" :value="1" />
|
2024-09-26 10:01:41 +08:00
|
|
|
</el-checkbox-group>
|
|
|
|
|
</el-form-item>
|
2024-11-06 13:25:42 +08:00
|
|
|
</template>
|
|
|
|
|
<template #operation>
|
2024-11-13 09:21:26 +08:00
|
|
|
<el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
|
2024-11-06 13:25:42 +08:00
|
|
|
<el-button type="primary" :icon="Setting" @click="handleUpDevice">补召</el-button>
|
|
|
|
|
<el-button :icon="Back" @click="go(-1)">返回</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
</TableHeader>
|
|
|
|
|
<!-- 设备补召 -->
|
|
|
|
|
<div class="default-main current_device" v-loading="loading">
|
|
|
|
|
|
2024-09-26 10:01:41 +08:00
|
|
|
<div class="current_body" ref="tbodyRef">
|
2024-11-06 13:25:42 +08:00
|
|
|
<vxe-table border ref="tableRef" :data="dirList" align="center" height="auto"
|
|
|
|
|
:style="{ height: tableHeight }" @radio-change="radioChangeEvent">
|
|
|
|
|
<vxe-column type="radio" width="60">
|
|
|
|
|
<template #header>
|
|
|
|
|
<vxe-button mode="text" @click="clearRadioRowEvent" :disabled="!selectRow">取消</vxe-button>
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
|
|
|
|
<!-- <vxe-column type="checkbox" width="60"></vxe-column> -->
|
|
|
|
|
<vxe-column field="name" title="名称"></vxe-column>
|
|
|
|
|
<vxe-column field="status" title="补召进度">
|
2024-10-09 15:11:56 +08:00
|
|
|
<template #default="{ row }">
|
2024-11-19 10:39:46 +08:00
|
|
|
<div class="finish" v-if="row.status == 100">
|
|
|
|
|
<SuccessFilled style="width: 16px;" /><span class="ml5">补召完成</span>
|
|
|
|
|
</div>
|
|
|
|
|
<el-progress v-model="row.status" v-else :class="row.status == 100 ? 'progress' : ''"
|
|
|
|
|
:format="format" :stroke-width="10" striped :percentage="row.status" :duration="30"
|
|
|
|
|
striped-flow />
|
|
|
|
|
|
2024-11-06 13:25:42 +08:00
|
|
|
|
2024-10-09 15:11:56 +08:00
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
2024-11-06 13:25:42 +08:00
|
|
|
<vxe-column field="startTime" title="起始时间"></vxe-column>
|
|
|
|
|
<vxe-column field="endTime" title="结束时间"></vxe-column>
|
2024-09-26 10:01:41 +08:00
|
|
|
</vxe-table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-08-26 14:21:46 +08:00
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
2024-10-30 15:02:25 +08:00
|
|
|
import { ref, onMounted, defineExpose, onBeforeUnmount, inject } from 'vue'
|
2024-09-30 14:45:31 +08:00
|
|
|
import { getMakeUpData, getAskDirOrFile, offlineDataUploadMakeUp } from '@/api/cs-harmonic-boot/recruitment.ts'
|
2024-09-26 10:01:41 +08:00
|
|
|
import DatePicker from '@/components/form/datePicker/index.vue'
|
2024-11-06 13:25:42 +08:00
|
|
|
import TableHeader from '@/components/table/header/index.vue'
|
2024-09-30 14:45:31 +08:00
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
2024-10-09 15:11:56 +08:00
|
|
|
import { mainHeight } from '@/utils/layout'
|
2024-11-06 13:25:42 +08:00
|
|
|
import { VxeUI, VxeTableInstance, VxeTableEvents } from 'vxe-table'
|
2024-11-19 10:39:46 +08:00
|
|
|
import { SuccessFilled } from '@element-plus/icons-vue'
|
2024-09-26 10:01:41 +08:00
|
|
|
import {
|
|
|
|
|
Back,
|
2024-11-13 09:21:26 +08:00
|
|
|
Setting, Search
|
2024-11-06 13:25:42 +08:00
|
|
|
} from '@element-plus/icons-vue'
|
2024-09-30 14:45:31 +08:00
|
|
|
import { ElMessage } from 'element-plus'
|
2024-10-09 15:11:56 +08:00
|
|
|
import mqtt from 'mqtt'
|
2024-11-13 09:21:26 +08:00
|
|
|
defineOptions({
|
|
|
|
|
name: 'supplementaryRecruitment'
|
|
|
|
|
})
|
2024-09-30 13:47:32 +08:00
|
|
|
const checkList: any = ref([])
|
2024-08-26 14:21:46 +08:00
|
|
|
// const props = defineProps(['lineId'])
|
2024-10-30 15:02:25 +08:00
|
|
|
const { go } = useRouter() // 路由
|
2024-11-06 13:25:42 +08:00
|
|
|
const selectRow: any = ref(null)
|
2024-08-26 14:21:46 +08:00
|
|
|
const loading = ref(false)
|
|
|
|
|
const dirList = ref([])
|
|
|
|
|
const route: any = ref({})
|
2024-09-26 10:01:41 +08:00
|
|
|
const datePickerRef = ref()
|
2024-11-06 13:25:42 +08:00
|
|
|
const format = (percentage) => (percentage === 100 ? '完成' : `${percentage}%`)
|
2024-08-26 14:21:46 +08:00
|
|
|
const getMakeUpDataList = (row: any) => {
|
|
|
|
|
route.value = row
|
|
|
|
|
loading.value = true
|
|
|
|
|
getMakeUpData(row.id).then(res => {
|
2024-09-26 10:01:41 +08:00
|
|
|
res.data.map((item: any) => {
|
2024-09-30 13:47:32 +08:00
|
|
|
item.name = item.prjName
|
|
|
|
|
? item.prjDataPath.replace('/bd0/cmn/', item.prjName + '-')
|
|
|
|
|
: item.prjDataPath.replace('/bd0/cmn/', '')
|
2024-09-26 10:01:41 +08:00
|
|
|
item.startTime = item.startTime ? item.startTime : '/'
|
|
|
|
|
item.endTime = item.endTime ? item.endTime : '/'
|
2024-10-21 10:33:45 +08:00
|
|
|
item.status = 0
|
2024-09-26 10:01:41 +08:00
|
|
|
})
|
2024-08-26 14:21:46 +08:00
|
|
|
dirList.value = res.data
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 进入文件夹
|
|
|
|
|
const dirCheckedList: any = ref([])
|
2024-09-26 10:01:41 +08:00
|
|
|
const tbodyRef = ref()
|
2024-11-06 13:25:42 +08:00
|
|
|
const tableHeight = mainHeight(105).height
|
2024-09-30 14:45:31 +08:00
|
|
|
const routes = useRoute()
|
|
|
|
|
const tableRef = ref()
|
2024-11-06 13:25:42 +08:00
|
|
|
const selectRowCopy: any = ref(null)
|
2024-09-30 14:45:31 +08:00
|
|
|
const handleUpDevice = () => {
|
|
|
|
|
let proList = tableRef.value.getCheckboxRecords().map((item: any) => {
|
|
|
|
|
return item.prjDataPath
|
|
|
|
|
})
|
|
|
|
|
if (checkList.value.length == 0) {
|
|
|
|
|
return ElMessage.warning('请选择暂态稳态')
|
|
|
|
|
}
|
2024-11-06 13:25:42 +08:00
|
|
|
if (selectRow.value == null) {
|
2024-09-30 14:45:31 +08:00
|
|
|
return ElMessage.warning('请选择工程')
|
|
|
|
|
}
|
2024-11-06 13:25:42 +08:00
|
|
|
selectRowCopy.value = JSON.parse(JSON.stringify(selectRow.value))
|
2024-09-30 14:45:31 +08:00
|
|
|
let form = {
|
|
|
|
|
dataTypeList: checkList.value,
|
|
|
|
|
startTime: datePickerRef.value && datePickerRef.value.timeValue[0],
|
|
|
|
|
endTime: datePickerRef.value && datePickerRef.value.timeValue[1],
|
|
|
|
|
lineId: routes.query.id,
|
|
|
|
|
ndid: routes.query.ndid,
|
2024-11-06 13:25:42 +08:00
|
|
|
proList: [selectRow.value?.prjDataPath]
|
2024-09-30 14:45:31 +08:00
|
|
|
}
|
2024-11-06 13:25:42 +08:00
|
|
|
ElMessage.warning('补召中, 请稍等...')
|
2024-09-30 14:45:31 +08:00
|
|
|
offlineDataUploadMakeUp(form)
|
|
|
|
|
.then((res: any) => {
|
|
|
|
|
if (res.code == 'A0000') {
|
2024-11-19 10:39:46 +08:00
|
|
|
// ElMessage.success(res.data)
|
2024-11-06 13:25:42 +08:00
|
|
|
dirList.value.map((item: any) => {
|
|
|
|
|
// checkedList.map((vv: any) => {
|
|
|
|
|
if (item.name == selectRowCopy.value?.name) {
|
|
|
|
|
item.status = 5
|
|
|
|
|
}
|
|
|
|
|
// })
|
|
|
|
|
})
|
2024-10-21 19:00:52 +08:00
|
|
|
// loading.value = false
|
2024-09-30 14:45:31 +08:00
|
|
|
}
|
|
|
|
|
})
|
2024-10-30 15:02:25 +08:00
|
|
|
.catch(() => {
|
2024-10-21 19:00:52 +08:00
|
|
|
// loading.value = false
|
2024-09-30 14:45:31 +08:00
|
|
|
})
|
|
|
|
|
}
|
2024-10-09 15:11:56 +08:00
|
|
|
|
2024-11-06 13:25:42 +08:00
|
|
|
const radioChangeEvent: VxeTableEvents.RadioChange = ({ row }) => {
|
|
|
|
|
selectRow.value = row
|
|
|
|
|
console.log('单选事件')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const clearRadioRowEvent = () => {
|
|
|
|
|
const $table = tableRef.value
|
|
|
|
|
if ($table) {
|
|
|
|
|
selectRow.value = null
|
|
|
|
|
$table.clearRadioRow()
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-09 15:11:56 +08:00
|
|
|
const mqttRef = ref()
|
2024-10-15 15:30:01 +08:00
|
|
|
const url: any = inject('MQTTURL')
|
2024-10-09 15:11:56 +08:00
|
|
|
const connectMqtt = () => {
|
|
|
|
|
if (mqttRef.value) {
|
|
|
|
|
if (mqttRef.value.connected) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const options = {
|
|
|
|
|
protocolId: 'MQTT',
|
|
|
|
|
qos: 2,
|
|
|
|
|
clean: true,
|
|
|
|
|
connectTimeout: 30 * 1000,
|
|
|
|
|
clientId: 'mqttjs' + Math.random(),
|
|
|
|
|
username: 't_user',
|
|
|
|
|
password: 'njcnpqs'
|
|
|
|
|
}
|
|
|
|
|
mqttRef.value = mqtt.connect(url, options)
|
|
|
|
|
}
|
2024-11-13 09:21:26 +08:00
|
|
|
const handleSearch = () => {
|
|
|
|
|
getMakeUpDataList(route.value)
|
|
|
|
|
}
|
2024-10-09 15:11:56 +08:00
|
|
|
connectMqtt()
|
2024-10-30 15:02:25 +08:00
|
|
|
mqttRef.value.on('connect', () => {
|
2024-10-09 15:11:56 +08:00
|
|
|
// ElMessage.success('连接mqtt服务器成功!')
|
|
|
|
|
console.log('mqtt客户端已连接....')
|
|
|
|
|
// mqttRef.value.subscribe('/Web/Progress')
|
|
|
|
|
// mqttRef.value.subscribe('/Web/Progress/+')
|
|
|
|
|
mqttRef.value.subscribe('/dataOnlineRecruitment/Progress/' + route.value.id)
|
|
|
|
|
})
|
|
|
|
|
const mqttMessage = ref<any>({})
|
|
|
|
|
mqttRef.value.on('message', (topic: any, message: any) => {
|
|
|
|
|
console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))))
|
2024-10-21 19:00:52 +08:00
|
|
|
loading.value = false
|
2024-10-09 15:11:56 +08:00
|
|
|
let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
|
|
|
|
|
let regex1 = /allStep:(.*?),nowStep/
|
|
|
|
|
let regex2 = /nowStep:(.*?)}/
|
|
|
|
|
mqttMessage.value = {
|
|
|
|
|
allStep: str.match(regex1)[1],
|
|
|
|
|
nowStep: str.match(regex2)[1]
|
|
|
|
|
}
|
2024-10-30 15:02:25 +08:00
|
|
|
console.log(mqttMessage.value)
|
2024-10-21 10:33:45 +08:00
|
|
|
let checkedList = tableRef.value.getCheckboxRecords().map((item: any) => {
|
|
|
|
|
return item.name
|
|
|
|
|
})
|
|
|
|
|
dirList.value.map((item: any) => {
|
2024-11-06 13:25:42 +08:00
|
|
|
// checkedList.map((vv: any) => {
|
|
|
|
|
if (item.name == selectRowCopy.value?.name) {
|
|
|
|
|
let percentage = parseInt(Number((mqttMessage.value.nowStep / mqttMessage.value.allStep) * 100)) || 0
|
|
|
|
|
if (percentage > 5) {
|
|
|
|
|
item.status = percentage
|
|
|
|
|
|
2024-10-21 10:33:45 +08:00
|
|
|
}
|
2024-11-06 13:25:42 +08:00
|
|
|
}
|
|
|
|
|
// })
|
2024-10-21 10:33:45 +08:00
|
|
|
})
|
2024-10-09 15:11:56 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
mqttRef.value.on('error', (error: any) => {
|
|
|
|
|
console.log('mqtt连接失败...', error)
|
|
|
|
|
mqttRef.value.end()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
mqttRef.value.on('close', function () {
|
|
|
|
|
console.log('mqtt客户端已断开连接.....')
|
|
|
|
|
})
|
2024-08-26 14:21:46 +08:00
|
|
|
onMounted(() => {
|
|
|
|
|
})
|
2024-10-09 15:11:56 +08:00
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
if (mqttRef.value) {
|
|
|
|
|
mqttRef.value.end()
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-08-26 14:21:46 +08:00
|
|
|
defineExpose({ getMakeUpDataList })
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
2024-11-06 13:25:42 +08:00
|
|
|
// .current_device {
|
|
|
|
|
// width: 100%;
|
|
|
|
|
|
|
|
|
|
// display: flex;
|
|
|
|
|
// flex-direction: column;
|
|
|
|
|
|
|
|
|
|
// .current_header {
|
|
|
|
|
// width: 100%;
|
|
|
|
|
// height: 60px;
|
|
|
|
|
// padding: 15px;
|
|
|
|
|
// display: flex;
|
|
|
|
|
// align-items: center;
|
|
|
|
|
// box-sizing: border-box;
|
|
|
|
|
|
|
|
|
|
// .el-form-item {
|
|
|
|
|
// display: flex;
|
|
|
|
|
// align-items: center;
|
|
|
|
|
// margin-bottom: 0;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// .current_body {
|
|
|
|
|
// flex: 1;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
:deep(.el-progress-bar__inner--striped) {
|
|
|
|
|
background-image: linear-gradient(45deg, rgba(255, 255, 255, .3) 25%, transparent 0, transparent 50%, rgba(255, 255, 255, .3) 0, rgba(255, 255, 255, .3) 75%, transparent 0, transparent);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.progress) {
|
|
|
|
|
.el-progress__text {
|
|
|
|
|
color: green;
|
|
|
|
|
|
2024-08-26 14:21:46 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-19 10:39:46 +08:00
|
|
|
|
|
|
|
|
.finish {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
font-weight: 550;
|
|
|
|
|
color: #009688
|
|
|
|
|
}
|
2024-08-26 14:21:46 +08:00
|
|
|
</style>
|