feat:天平连接
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, nextTick, onBeforeUnmount, reactive, ref } from 'vue'
|
||||
import sysApi from '@/nx/api/sys'
|
||||
import nx from '@/nx'
|
||||
import { aesEncrypt } from './utils/aes'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -196,7 +196,7 @@ function resetState() {
|
||||
async function loadCaptcha() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await sysApi.getCaptchaCode({ captchaType: props.captchaType })
|
||||
const res = await nx.$api.sys.getCaptchaCode({ captchaType: props.captchaType })
|
||||
if (res && (res.repCode === '0000' || res.code === 0)) {
|
||||
const data = res.repData || res.data || {}
|
||||
captchaState.originalImageBase64 = data.originalImageBase64 || ''
|
||||
@@ -292,7 +292,7 @@ async function submitVerification() {
|
||||
? aesEncrypt(JSON.stringify(point), captchaState.secretKey)
|
||||
: JSON.stringify(point)
|
||||
|
||||
const res = await sysApi.verifyCaptcha({
|
||||
const res = await nx.$api.sys.verifyCaptcha({
|
||||
captchaType: props.captchaType,
|
||||
token: captchaState.token,
|
||||
pointJson: payload
|
||||
|
||||
@@ -7,23 +7,15 @@
|
||||
<u-grid-item v-for="(auncel, index) in auncelList" :index="index" :key="index">
|
||||
<view class="auncel-item">
|
||||
<view class="auncel-name">
|
||||
{{ auncel.code }}
|
||||
{{ auncel.deviceCode }}
|
||||
<view style="text-align: center">{{ auncel.controlRealName }}</view>
|
||||
</view>
|
||||
|
||||
<view class="weight">
|
||||
<view
|
||||
:class="
|
||||
auncel.weightStable === 0
|
||||
? 'weight-data-yellow'
|
||||
: auncel.weightStable === 1
|
||||
? 'weight-data'
|
||||
: 'weight-data-warning'
|
||||
"
|
||||
>
|
||||
{{ auncel.weightData }}
|
||||
<view :class="getWeightClass(auncel)" :style="getWeightStyle(auncel)">
|
||||
{{ getWeightText(auncel) }}
|
||||
</view>
|
||||
<view class="weight-unit">{{ auncel.weightUnit }}</view>
|
||||
<view v-if="auncel.isConnected === 1" class="weight-unit">{{ auncel.weightUnit }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-grid-item>
|
||||
@@ -72,30 +64,19 @@ const close = () => {
|
||||
const getPageData = () => {
|
||||
nx.$api.laboratory
|
||||
.getDeviceLaboratoryListBy({
|
||||
deviceType: 'auncel',
|
||||
pageNo: 0,
|
||||
pageSize: -1,
|
||||
status: '1',
|
||||
pageNo: 1,
|
||||
pageSize: 999,
|
||||
collectDeviceType: 'balance',
|
||||
deviceStatus: '0',
|
||||
isEnable: '1'
|
||||
})
|
||||
.then(res => {
|
||||
const dataList = res.records.map(item => ({
|
||||
...item,
|
||||
weightData: '',
|
||||
weightUnit: '',
|
||||
isConnected: 0,
|
||||
weightStable: 0,
|
||||
temperature: 0,
|
||||
humidity: 0,
|
||||
controlRealName: ''
|
||||
}))
|
||||
auncelList.value = dataList
|
||||
auncelList.value = res.list
|
||||
})
|
||||
}
|
||||
|
||||
const doSelect = index => {
|
||||
const currentAuncel = auncelList.value[index]
|
||||
|
||||
if (currentAuncel.isConnected !== 1) {
|
||||
uni.showToast({ title: '天平设备尚未连接!', icon: 'none' })
|
||||
return
|
||||
@@ -121,8 +102,8 @@ const doSelect = index => {
|
||||
clientType: 'caaClient',
|
||||
data: {
|
||||
deviceId: currentAuncel.id,
|
||||
deviceCode: currentAuncel.code,
|
||||
deviceName: currentAuncel.name,
|
||||
deviceCode: currentAuncel.deviceCode,
|
||||
deviceName: currentAuncel.productName,
|
||||
isControl: true,
|
||||
controlRealName: userInfo.value.nickname
|
||||
}
|
||||
@@ -164,23 +145,25 @@ const listenDeviceData = () => {
|
||||
}
|
||||
|
||||
const handleDeviceData = res => {
|
||||
if (res.deviceType !== 'auncel') return
|
||||
if (res.deviceType === 'balance') {
|
||||
auncelList.value.forEach(item => {
|
||||
if (item.id === res.deviceId) {
|
||||
item.weightData = res.weightData ?? ''
|
||||
item.weightUnit = res.weightUnit ?? ''
|
||||
item.weightStable = res.weightStable ?? 0
|
||||
item.weightData = res.weightData
|
||||
item.weightUnit = res.weightUnit
|
||||
item.weightStable = res.weightStable
|
||||
item.isConnected = 1
|
||||
item.controlRealName = res.controlRealName ?? ''
|
||||
item.controlRealName = res.controlRealName
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handleDeviceStatus = res => {
|
||||
if (res.deviceType === 'balance') {
|
||||
auncelList.value.forEach(item => {
|
||||
if (item.id === res.deviceId) {
|
||||
item.isConnected = res.connected ?? 0
|
||||
if (res.connected === 0) {
|
||||
item.isConnected = res.connected
|
||||
if (res.connected == 0) {
|
||||
item.weightData = '天平断开'
|
||||
item.weightUnit = ''
|
||||
item.weightStable = 0
|
||||
@@ -188,6 +171,7 @@ const handleDeviceStatus = res => {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handleConnClose = () => {
|
||||
auncelList.value.forEach(item => {
|
||||
@@ -213,6 +197,32 @@ onMounted(() => {
|
||||
onUnmounted(() => {
|
||||
closeDeviceListener()
|
||||
})
|
||||
function getWeightText(auncel) {
|
||||
if (auncel.isConnected !== 1) {
|
||||
return '天平断开'
|
||||
}
|
||||
return auncel.weightData || ''
|
||||
}
|
||||
|
||||
function getWeightClass(auncel) {
|
||||
if (auncel.weightStable === 0) return 'weight-data-yellow'
|
||||
if (auncel.weightStable === 1) return 'weight-data'
|
||||
if (auncel.weightStable === 2) return 'weight-data-warning'
|
||||
return 'weight-data-yellow'
|
||||
}
|
||||
|
||||
function getWeightStyle(auncel) {
|
||||
if (auncel.isConnected !== 1) {
|
||||
return {
|
||||
textAlign: 'center',
|
||||
fontSize: '28px'
|
||||
}
|
||||
}
|
||||
return {
|
||||
textAlign: 'right',
|
||||
fontSize: '32px'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -236,33 +246,34 @@ onUnmounted(() => {
|
||||
}
|
||||
.weight {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
font-size: 32px;
|
||||
letter-spacing: 2px;
|
||||
font-size: 28px;
|
||||
padding-top: 10px;
|
||||
padding: 10px 30px 0 30px;
|
||||
position: relative;
|
||||
}
|
||||
.weight-data,
|
||||
.weight-data-yellow,
|
||||
.weight-data-warning {
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
|
||||
.weight-data {
|
||||
flex: 1;
|
||||
color: #4cd964;
|
||||
text-align: right;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
|
||||
.weight-data-yellow {
|
||||
flex: 1;
|
||||
color: #ffff00;
|
||||
text-align: center;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
|
||||
.weight-data-warning {
|
||||
color: #ff3333;
|
||||
text-align: right;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
.weight-unit {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
color: #ffffff;
|
||||
font-size: 24px;
|
||||
padding: 0 10px;
|
||||
font-size: 20px;
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
.auncel-item {
|
||||
|
||||
@@ -64,6 +64,7 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:showPopup'])
|
||||
// Data
|
||||
const curSample = ref({})
|
||||
const curParameterKey = ref('')
|
||||
@@ -79,7 +80,7 @@ const getAllIndexes = arr => {
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
uni.$emit('sample-detail-popup_close')
|
||||
emit('update:showPopup', false)
|
||||
}
|
||||
|
||||
const getSampleData = () => {
|
||||
|
||||
@@ -30,5 +30,6 @@ export function getUpgradeBaseUrl() {
|
||||
return uni.getStorageSync('upgradeBaseUrl')
|
||||
}
|
||||
export function getWebSocketUrl() {
|
||||
return uni.getStorageSync('base_url').replace('/api', '') + '/ws'
|
||||
// return uni.getStorageSync('base_url').replace('/api', '') + '/ws'
|
||||
return 'ws://localhost:8330'
|
||||
}
|
||||
|
||||
112
nx/api/auncel.js
112
nx/api/auncel.js
@@ -1,105 +1,11 @@
|
||||
import request from '@/nx/request'
|
||||
const taskPrefix = '/qms/bus/qmsBusAssayTask'
|
||||
const taskDetailPrefix = '/qms/bus/qmsBusAssayTaskDetail'
|
||||
|
||||
// 获取任务
|
||||
const getAssayTaskList = params => {
|
||||
return request({
|
||||
url: taskPrefix + '/listTaskForPAD',
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 天平称重
|
||||
const auncelWeigh = params => {
|
||||
return request({
|
||||
url: taskDetailPrefix + '/saveWeight',
|
||||
method: 'POST',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
//撤销称重
|
||||
const auncelWeighRevoke = id => {
|
||||
return request({
|
||||
url: taskDetailPrefix + '/revokeWeight',
|
||||
method: 'POST',
|
||||
params: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 批量称重提交
|
||||
const weighBatchSubmitByTaskNo = taskNo => {
|
||||
return request({
|
||||
url: taskDetailPrefix + '/submitWeightTaskByTaskNo',
|
||||
method: 'POST',
|
||||
params: {
|
||||
taskNo
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 批量称重提交
|
||||
const weighBatchSubmitByIds = ids => {
|
||||
return request({
|
||||
url: taskDetailPrefix + '/submitWeightTaskByIds',
|
||||
method: 'POST',
|
||||
params: {
|
||||
ids
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 任务单复核
|
||||
const assayTaskReview = id => {
|
||||
return request({
|
||||
url: taskPrefix + '/review',
|
||||
method: 'POST',
|
||||
params: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 任务单及样品复核
|
||||
const reviewWeightTaskByTaskIdAndSampleIds = (taskId, sampleIds) => {
|
||||
return request({
|
||||
url: taskDetailPrefix + '/reviewWeightTaskByTaskIdAndSampleIds',
|
||||
method: 'POST',
|
||||
params: {
|
||||
taskId,
|
||||
sampleIds
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 复核
|
||||
const assayTaskDetailReview = id => {
|
||||
return request({
|
||||
url: taskDetailPrefix + '/review',
|
||||
method: 'POST',
|
||||
params: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 恢复
|
||||
const assayTaskDetailRecovery = id => {
|
||||
return request({
|
||||
url: taskDetailPrefix + '/recovery',
|
||||
method: 'POST',
|
||||
params: {
|
||||
id
|
||||
},
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -109,9 +15,6 @@ export const getConAssayTaskWithReportTemplateContent = id => {
|
||||
method: 'get',
|
||||
params: {
|
||||
id
|
||||
},
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -119,23 +22,12 @@ export const queryTaskDetailListByAssayTaskId = params => {
|
||||
return request({
|
||||
url: taskPrefix + '/getAssayTaskDataWithDetailData',
|
||||
method: 'get',
|
||||
params: params,
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
auncelWeigh,
|
||||
auncelWeighRevoke,
|
||||
getAssayTaskList,
|
||||
weighBatchSubmitByTaskNo,
|
||||
weighBatchSubmitByIds,
|
||||
assayTaskReview,
|
||||
reviewWeightTaskByTaskIdAndSampleIds,
|
||||
assayTaskDetailReview,
|
||||
assayTaskDetailRecovery,
|
||||
getConAssayTaskWithReportTemplateContent,
|
||||
queryTaskDetailListByAssayTaskId
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import request from '@/nx/request'
|
||||
//获取实验室设备
|
||||
const getDeviceLaboratoryListBy = params => {
|
||||
return request({
|
||||
url: '/qms/lims/deviceLaboratory/list',
|
||||
url: '/qms/resource/device-infomation/page',
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
import request from '@/nx/request'
|
||||
|
||||
// 根据用户id获取计量点
|
||||
const getMeasurePointByUserId = params => {
|
||||
return request({
|
||||
url: '/mas-iot/user-measure-point/listByUserId',
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params
|
||||
},
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 根据用户id及计量点id获取计量点
|
||||
const getMeasurePointByUserIdAndMeasurePointId = params => {
|
||||
return request({
|
||||
url: '/mas-iot/user-measure-point/findByUserIdAndMeasurePointId',
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params
|
||||
},
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取物料信息
|
||||
const getGoodsListBy = params => {
|
||||
return request({
|
||||
url: '/mas-lims/bas-goods/oldGoodsListBy',
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params
|
||||
},
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取发货方
|
||||
const getSellerListBy = params => {
|
||||
return request({
|
||||
url: '/mas-lims/bas-businesses/oldSellerListBy',
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params
|
||||
},
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取收货方
|
||||
const getBuyerListBy = params => {
|
||||
return request({
|
||||
url: '/mas-lims/bas-businesses/oldBuyerListBy',
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params
|
||||
},
|
||||
custom: {
|
||||
isApiEncryption: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
getGoodsListBy,
|
||||
getSellerListBy,
|
||||
getBuyerListBy,
|
||||
getMeasurePointByUserId,
|
||||
getMeasurePointByUserIdAndMeasurePointId
|
||||
}
|
||||
@@ -130,6 +130,8 @@ http.interceptors.response.use(
|
||||
// $store('user').setToken(response.header.authorization || response.header.Authorization)
|
||||
// }
|
||||
|
||||
const userStore = $store('user')
|
||||
const isLogin = userStore.isLogin
|
||||
response.config.custom.showLoading && closeLoading()
|
||||
|
||||
console.log('response', JSON.parse(JSON.stringify(response.data)))
|
||||
@@ -193,6 +195,9 @@ http.interceptors.response.use(
|
||||
title: msg || response.config.custom.errorMsg,
|
||||
icon: 'none'
|
||||
})
|
||||
if (code === 401) {
|
||||
userStore.logout(true)
|
||||
}
|
||||
}
|
||||
|
||||
if ((code === 0 || code === 200) && response.config.custom.showSuccess) {
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
<template>
|
||||
<view>
|
||||
<navbar-back title="选择天平"></navbar-back>
|
||||
|
||||
<u-grid :col="3" @click="click">
|
||||
<u-grid-item v-for="(auncel, index) in auncelList" :index="index" :key="index">
|
||||
<view
|
||||
style="
|
||||
height: 180px;
|
||||
width: 180px;
|
||||
background-image: url(../../static/images/auncel.png);
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100%;
|
||||
"
|
||||
>
|
||||
<view style="height: 100px">
|
||||
<view style="padding-top: 20px; text-align: center; font-size: 20rpx"
|
||||
><text>{{ auncel.code }}</text></view
|
||||
>
|
||||
<view style="padding-top: 5px; text-align: center"
|
||||
><text>{{ auncel.controlRealName }}</text></view
|
||||
>
|
||||
</view>
|
||||
<view class="weight">
|
||||
<view
|
||||
:class="
|
||||
auncel.weightStable == 0
|
||||
? 'weight-data-yellow'
|
||||
: auncel.weightStable == 1
|
||||
? 'weight-data'
|
||||
: 'weight-data-warning'
|
||||
"
|
||||
>
|
||||
{{ auncel.weightData }}
|
||||
</view>
|
||||
<view class="weight-unit">{{ auncel.weightUnit }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-grid-item>
|
||||
</u-grid>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
auncelList: [],
|
||||
currentAuncel: '',
|
||||
currentTaskNo: '',
|
||||
currentTaskType: ''
|
||||
}
|
||||
},
|
||||
onLoad(param) {
|
||||
this.currentTaskNo = param.currentTaskNo
|
||||
this.currentTaskType = param.currentTaskType
|
||||
//获取数据
|
||||
this.getPageData()
|
||||
console.log('onLoad')
|
||||
},
|
||||
onShow() {
|
||||
console.log('onShow')
|
||||
// #ifdef H5
|
||||
//注册websocket
|
||||
let regData = {
|
||||
msgId: this.$helper.uuid(),
|
||||
cmd: 'register',
|
||||
clientType: 'caaClient',
|
||||
data: {
|
||||
userId: this.userInfo.user_id,
|
||||
tenantId: this.userInfo.tenant_id,
|
||||
userRealName: this.userInfo.real_name
|
||||
}
|
||||
}
|
||||
this.$measure.setRegData(JSON.stringify(regData))
|
||||
this.$measure.reOpen()
|
||||
// #endif
|
||||
//监听websocket返回来的数据
|
||||
//设备数据
|
||||
uni.$on('deviceData', res => {
|
||||
switch (res.deviceType) {
|
||||
case 'auncel':
|
||||
this.auncelList.forEach((item, index) => {
|
||||
if (item.id === res.deviceId) {
|
||||
item.weightData = res.weightData
|
||||
item.weightUnit = res.weightUnit
|
||||
item.weightStable = res.weightStable
|
||||
item.isConnected = 1
|
||||
item.controlRealName = res.controlRealName
|
||||
}
|
||||
})
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
})
|
||||
//设备状态
|
||||
uni.$on('deviceStatus', res => {
|
||||
this.auncelList.forEach((item, index) => {
|
||||
if (item.id === res.deviceId) {
|
||||
item.isConnected = res.connected
|
||||
if (res.connected == 0) {
|
||||
item.weightData = '天平断开'
|
||||
item.weightUnit = ''
|
||||
item.weightStable = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
//连接断开
|
||||
uni.$on('connClose', res => {
|
||||
//重置
|
||||
this.auncelList.forEach(i => {
|
||||
i.weightData = ''
|
||||
i.weightUnit = ''
|
||||
i.weightStable = 0
|
||||
i.controlRealName = ''
|
||||
i.isConnected = 0
|
||||
})
|
||||
})
|
||||
},
|
||||
onHide() {
|
||||
console.log('onHide')
|
||||
//移除监听websocket返回来的数据
|
||||
uni.$off('deviceData')
|
||||
uni.$off('deviceStatus')
|
||||
uni.$off('connClose')
|
||||
},
|
||||
methods: {
|
||||
getPageData() {
|
||||
//显示loading
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
//获取计量点数量
|
||||
this.$u.api
|
||||
.getDeviceLaboratoryListBy({
|
||||
deviceType: 'auncel',
|
||||
pageNo: 0,
|
||||
pageSize: -1,
|
||||
status: '1',
|
||||
isEnable: '1'
|
||||
})
|
||||
.then(res => {
|
||||
let dataList = res.result.records
|
||||
dataList.forEach(i => {
|
||||
i.weightData = ''
|
||||
i.weightUnit = ''
|
||||
i.isConnected = 0
|
||||
i.weightStable = 0
|
||||
i.temperature = 0
|
||||
i.humidity = 0
|
||||
i.controlRealName = ''
|
||||
})
|
||||
this.auncelList = dataList
|
||||
uni.hideLoading()
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
click(index) {
|
||||
// this.$refs.uToast.show({
|
||||
// title: `点击了第${index + 1}宫格`,
|
||||
// type: 'warning'
|
||||
// });
|
||||
console.log(this.auncelList[index])
|
||||
this.currentAuncel = this.auncelList[index]
|
||||
if (this.currentAuncel.isConnected != 1) {
|
||||
this.$helper.showToast({
|
||||
title: '天平设备尚未连接!'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.currentAuncel.controlRealName && this.currentAuncel.controlRealName != this.userInfo.real_name) {
|
||||
this.$helper.showToast({
|
||||
title: '当前天平正被“' + this.currentAuncel.controlRealName + '”使用,请选择其他天平!'
|
||||
})
|
||||
return
|
||||
}
|
||||
//发送控制请求
|
||||
let controlDevice = {
|
||||
msgId: this.currentAuncel.id,
|
||||
cmd: 'controlDevice',
|
||||
clientType: 'caaClient',
|
||||
data: {
|
||||
deviceId: this.currentAuncel.id,
|
||||
isControl: true,
|
||||
controlRealName: this.userInfo.real_name
|
||||
}
|
||||
}
|
||||
//发送控制数据
|
||||
this.$measure.send(JSON.stringify(controlDevice))
|
||||
uni.redirectTo({
|
||||
url:
|
||||
'/pages/auncel/auncel-weigh?currentTaskNo=' +
|
||||
this.currentTaskNo +
|
||||
'¤tTaskType=' +
|
||||
this.currentTaskType +
|
||||
'¤tAuncelId=' +
|
||||
this.currentAuncel.id +
|
||||
'¤tAuncelName=' +
|
||||
this.currentAuncel.name +
|
||||
'¤tAuncelCode=' +
|
||||
this.currentAuncel.code
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.weight {
|
||||
width: 180px;
|
||||
height: 40px;
|
||||
padding: 0 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.weight-data {
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
color: #4cd964;
|
||||
text-align: right;
|
||||
line-height: 40px;
|
||||
letter-spacing: 2px;
|
||||
font-size: 32px;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
.weight-data-yellow {
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
color: #ffff00;
|
||||
text-align: right;
|
||||
line-height: 40px;
|
||||
letter-spacing: 2px;
|
||||
font-size: 32px;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
.weight-data-warning {
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
color: #ff3333;
|
||||
text-align: right;
|
||||
line-height: 40px;
|
||||
font-size: 32px;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
.weight-unit {
|
||||
color: #ffffff;
|
||||
font-size: 24px;
|
||||
line-height: 40px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -3,27 +3,16 @@
|
||||
<navbar-back title="天平状态"></navbar-back>
|
||||
<up-grid border :col="3">
|
||||
<up-grid-item v-for="(auncel, index) in auncelList" :index="index" :key="index">
|
||||
<view
|
||||
class="auncel-item"
|
||||
:style="{
|
||||
backgroundImage: `url(${require('@/static/images/auncel.png')})`
|
||||
}"
|
||||
>
|
||||
<view class="auncel-item" :style="{ backgroundImage: `url(${balanceBackground})` }">
|
||||
<view class="auncel-header">
|
||||
<view class="auncel-code">{{ auncel.code }}</view>
|
||||
<view class="auncel-code">{{ auncel.deviceCode }}</view>
|
||||
<view class="auncel-name">{{ auncel.controlRealName }}</view>
|
||||
</view>
|
||||
<view class="weight">
|
||||
<view
|
||||
:class="{
|
||||
'weight-data-yellow': auncel.weightStable === 0,
|
||||
'weight-data': auncel.weightStable === 1,
|
||||
'weight-data-warning': auncel.weightStable === 2
|
||||
}"
|
||||
>
|
||||
{{ auncel.weightData || '' }}
|
||||
<view :class="getWeightClass(auncel)" :style="getWeightStyle(auncel)">
|
||||
{{ getWeightText(auncel) }}
|
||||
</view>
|
||||
<view class="weight-unit">{{ auncel.weightUnit }}</view>
|
||||
<view v-if="auncel.isConnected === 1" class="weight-unit">{{ auncel.weightUnit }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-grid-item>
|
||||
@@ -36,6 +25,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { onUnload, onHide } from '@dcloudio/uni-app'
|
||||
import { getTenantId } from '@/defaultBaseUrl'
|
||||
import nx from '@/nx'
|
||||
const balanceBackground = new URL('/static/images/auncel.png', import.meta.url).href
|
||||
|
||||
// refs
|
||||
const auncelList = ref([])
|
||||
@@ -45,7 +35,7 @@ const userInfo = computed(() => nx.$store('user').userInfo)
|
||||
|
||||
// 页面加载
|
||||
onMounted(() => {
|
||||
// getPageData()
|
||||
getPageData()
|
||||
// #ifdef H5
|
||||
const regData = {
|
||||
msgId: nx.$helper.uuid(),
|
||||
@@ -87,24 +77,14 @@ function cleanup() {
|
||||
function getPageData() {
|
||||
nx.$api.laboratory
|
||||
.getDeviceLaboratoryListBy({
|
||||
deviceType: 'auncel',
|
||||
status: '1',
|
||||
isEnable: '1',
|
||||
pageNo: 0,
|
||||
pageSize: -1
|
||||
pageNo: 1,
|
||||
pageSize: 999,
|
||||
collectDeviceType: 'balance',
|
||||
deviceStatus: '0',
|
||||
isEnable: '1'
|
||||
})
|
||||
.then(res => {
|
||||
const dataList = res.records || []
|
||||
dataList.forEach(i => {
|
||||
i.weightData = ''
|
||||
i.weightUnit = ''
|
||||
i.isConnected = 0
|
||||
i.weightStable = 0
|
||||
i.temperature = 0
|
||||
i.humidity = 0
|
||||
i.controlRealName = ''
|
||||
})
|
||||
auncelList.value = dataList
|
||||
auncelList.value = res.list
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('获取天平列表失败', err)
|
||||
@@ -113,46 +93,71 @@ function getPageData() {
|
||||
|
||||
// WebSocket 事件处理器
|
||||
function handleDeviceData(res) {
|
||||
if (res.deviceType !== 'auncel') return
|
||||
auncelList.value = auncelList.value.map(item => {
|
||||
if (res.deviceType === 'balance') {
|
||||
auncelList.value.forEach(item => {
|
||||
if (item.id === res.deviceId) {
|
||||
return {
|
||||
...item,
|
||||
weightData: res.weightData,
|
||||
weightUnit: res.weightUnit,
|
||||
weightStable: res.weightStable,
|
||||
isConnected: 1,
|
||||
controlRealName: res.controlRealName
|
||||
item.weightData = res.weightData
|
||||
item.weightUnit = res.weightUnit
|
||||
item.weightStable = res.weightStable
|
||||
item.isConnected = 1
|
||||
item.controlRealName = res.controlRealName
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handleDeviceStatus(res) {
|
||||
auncelList.value = auncelList.value.map(item => {
|
||||
if (res.deviceType === 'balance') {
|
||||
auncelList.value.forEach(item => {
|
||||
if (item.id === res.deviceId) {
|
||||
const updated = { ...item, isConnected: res.connected }
|
||||
if (res.connected === 0) {
|
||||
updated.weightData = '天平断开'
|
||||
updated.weightUnit = ''
|
||||
updated.weightStable = 0
|
||||
item.isConnected = res.connected
|
||||
if (res.connected == 0) {
|
||||
item.weightData = '天平断开'
|
||||
item.weightUnit = ''
|
||||
item.weightStable = 0
|
||||
}
|
||||
return updated
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handleConnClose() {
|
||||
auncelList.value = auncelList.value.map(i => ({
|
||||
...i,
|
||||
weightData: '',
|
||||
weightUnit: '',
|
||||
weightStable: 0,
|
||||
controlRealName: '',
|
||||
isConnected: 0
|
||||
}))
|
||||
auncelList.value.forEach(item => {
|
||||
item.weightData = ''
|
||||
item.weightUnit = ''
|
||||
item.weightStable = 0
|
||||
item.controlRealName = ''
|
||||
item.isConnected = 0
|
||||
})
|
||||
}
|
||||
|
||||
function getWeightText(auncel) {
|
||||
if (auncel.isConnected !== 1) {
|
||||
return '天平断开'
|
||||
}
|
||||
return auncel.weightData || ''
|
||||
}
|
||||
|
||||
function getWeightClass(auncel) {
|
||||
if (auncel.weightStable === 0) return 'weight-data-yellow'
|
||||
if (auncel.weightStable === 1) return 'weight-data'
|
||||
if (auncel.weightStable === 2) return 'weight-data-warning'
|
||||
return 'weight-data-yellow'
|
||||
}
|
||||
|
||||
function getWeightStyle(auncel) {
|
||||
if (auncel.isConnected !== 1) {
|
||||
return {
|
||||
textAlign: 'center',
|
||||
paddingTop: '0',
|
||||
fontSize: '28px'
|
||||
}
|
||||
}
|
||||
return {
|
||||
textAlign: 'right',
|
||||
paddingTop: '10px',
|
||||
fontSize: '32px'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -170,7 +175,6 @@ function handleConnClose() {
|
||||
}
|
||||
|
||||
.auncel-header {
|
||||
height: 100px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
@@ -184,27 +188,18 @@ function handleConnClose() {
|
||||
|
||||
.auncel-name {
|
||||
margin-top: 5px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.weight {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 60px;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.weight-data,
|
||||
.weight-data-yellow,
|
||||
.weight-data-warning {
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
text-align: right;
|
||||
line-height: 40px;
|
||||
letter-spacing: 2px;
|
||||
font-size: 32px;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
|
||||
@@ -221,9 +216,10 @@ function handleConnClose() {
|
||||
}
|
||||
|
||||
.weight-unit {
|
||||
position: absolute;
|
||||
right: 3px;
|
||||
top: 8px;
|
||||
color: #ffffff;
|
||||
font-size: 24px;
|
||||
line-height: 40px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
<!-- 样品详情 -->
|
||||
<sample-detail-popup
|
||||
ref="sampleDetailPopup"
|
||||
:showPopup="showDetailPopup"
|
||||
v-model:showPopup="showDetailPopup"
|
||||
:detailPopupParam="detailPopupParam"
|
||||
></sample-detail-popup>
|
||||
</view>
|
||||
@@ -324,11 +324,6 @@ const printTask = () => {
|
||||
onMounted(() => {
|
||||
getDicSampleProcessCodeList()
|
||||
getAssayTask()
|
||||
|
||||
// 监听 popup 关闭
|
||||
uni.$on('sample-detail-popup_close', () => {
|
||||
showDetailPopup.value = false
|
||||
})
|
||||
})
|
||||
|
||||
onBackPress(() => {
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
<view class="auncel-weight">
|
||||
<view class="weight">
|
||||
<view
|
||||
:style="{ textAlign: currentAuncel.isConnected != 1 ? 'center' : 'right' }"
|
||||
:class="
|
||||
currentAuncel.weightStable === 0
|
||||
? 'weight-data-yellow'
|
||||
@@ -89,7 +90,7 @@
|
||||
|
||||
<u-button
|
||||
class="btn-operation"
|
||||
v-if="currentAuncel.code === ''"
|
||||
v-if="currentAuncel.code !== ''"
|
||||
type="success"
|
||||
:disabled="confirmWeightDisabled"
|
||||
shape="circle"
|
||||
@@ -200,6 +201,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, nextTick, onMounted } from 'vue'
|
||||
import { onLoad, onBackPress, onShow, onHide, onUnload } from '@dcloudio/uni-app'
|
||||
import request from '@/nx/request'
|
||||
import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue'
|
||||
import { number } from 'mathjs'
|
||||
@@ -207,6 +209,7 @@ import AuncelSelectPopup from '@/components/sample/auncel-select-popup.vue'
|
||||
import { getTenantId } from '@/defaultBaseUrl'
|
||||
import { useScreenOrientation } from '@/nx/hooks/useScreenOrientation'
|
||||
import nx from '@/nx'
|
||||
import text from '@/uview-plus/components/u-text/text'
|
||||
|
||||
// 响应式数据定义
|
||||
const elId = nx.$helper.uuid()
|
||||
@@ -944,7 +947,7 @@ const listenDeviceData = () => {
|
||||
//设备数据
|
||||
uni.$on('deviceData', res => {
|
||||
switch (res.deviceType) {
|
||||
case 'auncel':
|
||||
case 'balance':
|
||||
if (currentAuncel.id === res.deviceId) {
|
||||
currentAuncel.weightData = res.weightData
|
||||
currentAuncel.weightUnit = res.weightUnit
|
||||
@@ -1233,7 +1236,7 @@ onBackPress(() => {
|
||||
}
|
||||
|
||||
.auncel {
|
||||
width: 100%;
|
||||
width: 90%;
|
||||
height: 55vh;
|
||||
background-image: url(/static/images/auncel.png);
|
||||
background-repeat: no-repeat;
|
||||
@@ -1263,31 +1266,29 @@ onBackPress(() => {
|
||||
.weight {
|
||||
font-size: 42px;
|
||||
width: 100%;
|
||||
padding-right: 10px;
|
||||
padding: 0 60px;
|
||||
}
|
||||
|
||||
.weight-data {
|
||||
color: #4cd964;
|
||||
text-align: right;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
|
||||
.weight-data-yellow {
|
||||
color: #ffff00;
|
||||
text-align: center;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
|
||||
.weight-data-warning {
|
||||
color: #ff3333;
|
||||
text-align: right;
|
||||
font-family: zzjc-lcd;
|
||||
}
|
||||
|
||||
.weight-unit {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
color: #ffffff;
|
||||
font-size: 32px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
.auncel {
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import request from '@/nx/request'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue'
|
||||
import nx from '@/nx'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
|
||||
@@ -198,17 +198,9 @@ const applyRollbackSample = () => {
|
||||
taskId: currentTask.value.id,
|
||||
detailIds: detailIdList.join(',')
|
||||
}
|
||||
|
||||
uni.showLoading({ title: '正在发起申请...' })
|
||||
nx.$api.assayTask
|
||||
.createRollbackApply(data)
|
||||
.then(() => {
|
||||
nx.$api.assayTask.createRollbackApply(data).then(() => {
|
||||
getAssayTaskDetail(currentTaskNo.value)
|
||||
})
|
||||
.catch(console.error)
|
||||
.finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import { reactive, ref, computed, onMounted } from 'vue'
|
||||
import nx from '@/nx'
|
||||
import { useGridCol } from '@/nx/hooks/useGridCol'
|
||||
let list = reactive([
|
||||
{ url: '/pages/lims/index/index', name: '设备管理系统', icon: 'dailyCheck' },
|
||||
{ url: '/pages/analysis/index/index', name: '化学分析系统', icon: 'maintain' }
|
||||
{ url: '/pages/lims/index/index', name: '设备管理系统', icon: 'device' },
|
||||
{ url: '/pages/analysis/index/index', name: '化学分析系统', icon: 'analyse' }
|
||||
])
|
||||
|
||||
// const sysMenus = computed(() => nx.$store('user').sysMenus)
|
||||
|
||||
@@ -24,7 +24,7 @@ import { reactive } from 'vue'
|
||||
let state = reactive({
|
||||
pageHeight: 0,
|
||||
appVersion: '1.1.0',
|
||||
appName: '凉山矿业设备管理系统',
|
||||
appName: '管理系统',
|
||||
copyrightYear: '2019',
|
||||
aboutMe:
|
||||
'<div style="text-align:left;font-size:20px;padding:18px"><p style="text-indent:2em;line-height:32px"></p></div>'
|
||||
|
||||
Reference in New Issue
Block a user