feat:天平连接

This commit is contained in:
houjunxiang
2025-10-10 18:16:14 +08:00
parent 2b50debcd3
commit c8b2d8683e
16 changed files with 182 additions and 622 deletions

View File

@@ -59,7 +59,7 @@
<script setup> <script setup>
import { computed, nextTick, onBeforeUnmount, reactive, ref } from 'vue' import { computed, nextTick, onBeforeUnmount, reactive, ref } from 'vue'
import sysApi from '@/nx/api/sys' import nx from '@/nx'
import { aesEncrypt } from './utils/aes' import { aesEncrypt } from './utils/aes'
const props = defineProps({ const props = defineProps({
@@ -196,7 +196,7 @@ function resetState() {
async function loadCaptcha() { async function loadCaptcha() {
loading.value = true loading.value = true
try { 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)) { if (res && (res.repCode === '0000' || res.code === 0)) {
const data = res.repData || res.data || {} const data = res.repData || res.data || {}
captchaState.originalImageBase64 = data.originalImageBase64 || '' captchaState.originalImageBase64 = data.originalImageBase64 || ''
@@ -292,7 +292,7 @@ async function submitVerification() {
? aesEncrypt(JSON.stringify(point), captchaState.secretKey) ? aesEncrypt(JSON.stringify(point), captchaState.secretKey)
: JSON.stringify(point) : JSON.stringify(point)
const res = await sysApi.verifyCaptcha({ const res = await nx.$api.sys.verifyCaptcha({
captchaType: props.captchaType, captchaType: props.captchaType,
token: captchaState.token, token: captchaState.token,
pointJson: payload pointJson: payload

View File

@@ -7,23 +7,15 @@
<u-grid-item v-for="(auncel, index) in auncelList" :index="index" :key="index"> <u-grid-item v-for="(auncel, index) in auncelList" :index="index" :key="index">
<view class="auncel-item"> <view class="auncel-item">
<view class="auncel-name"> <view class="auncel-name">
{{ auncel.code }} {{ auncel.deviceCode }}
<view style="text-align: center">{{ auncel.controlRealName }}</view> <view style="text-align: center">{{ auncel.controlRealName }}</view>
</view> </view>
<view class="weight"> <view class="weight">
<view <view :class="getWeightClass(auncel)" :style="getWeightStyle(auncel)">
:class=" {{ getWeightText(auncel) }}
auncel.weightStable === 0
? 'weight-data-yellow'
: auncel.weightStable === 1
? 'weight-data'
: 'weight-data-warning'
"
>
{{ auncel.weightData }}
</view> </view>
<view class="weight-unit">{{ auncel.weightUnit }}</view> <view v-if="auncel.isConnected === 1" class="weight-unit">{{ auncel.weightUnit }}</view>
</view> </view>
</view> </view>
</u-grid-item> </u-grid-item>
@@ -72,30 +64,19 @@ const close = () => {
const getPageData = () => { const getPageData = () => {
nx.$api.laboratory nx.$api.laboratory
.getDeviceLaboratoryListBy({ .getDeviceLaboratoryListBy({
deviceType: 'auncel', pageNo: 1,
pageNo: 0, pageSize: 999,
pageSize: -1, collectDeviceType: 'balance',
status: '1', deviceStatus: '0',
isEnable: '1' isEnable: '1'
}) })
.then(res => { .then(res => {
const dataList = res.records.map(item => ({ auncelList.value = res.list
...item,
weightData: '',
weightUnit: '',
isConnected: 0,
weightStable: 0,
temperature: 0,
humidity: 0,
controlRealName: ''
}))
auncelList.value = dataList
}) })
} }
const doSelect = index => { const doSelect = index => {
const currentAuncel = auncelList.value[index] const currentAuncel = auncelList.value[index]
if (currentAuncel.isConnected !== 1) { if (currentAuncel.isConnected !== 1) {
uni.showToast({ title: '天平设备尚未连接!', icon: 'none' }) uni.showToast({ title: '天平设备尚未连接!', icon: 'none' })
return return
@@ -121,8 +102,8 @@ const doSelect = index => {
clientType: 'caaClient', clientType: 'caaClient',
data: { data: {
deviceId: currentAuncel.id, deviceId: currentAuncel.id,
deviceCode: currentAuncel.code, deviceCode: currentAuncel.deviceCode,
deviceName: currentAuncel.name, deviceName: currentAuncel.productName,
isControl: true, isControl: true,
controlRealName: userInfo.value.nickname controlRealName: userInfo.value.nickname
} }
@@ -164,29 +145,32 @@ const listenDeviceData = () => {
} }
const handleDeviceData = res => { const handleDeviceData = res => {
if (res.deviceType !== 'auncel') return if (res.deviceType === 'balance') {
auncelList.value.forEach(item => { auncelList.value.forEach(item => {
if (item.id === res.deviceId) { if (item.id === res.deviceId) {
item.weightData = res.weightData ?? '' item.weightData = res.weightData
item.weightUnit = res.weightUnit ?? '' item.weightUnit = res.weightUnit
item.weightStable = res.weightStable ?? 0 item.weightStable = res.weightStable
item.isConnected = 1 item.isConnected = 1
item.controlRealName = res.controlRealName ?? '' item.controlRealName = res.controlRealName
} }
}) })
}
} }
const handleDeviceStatus = res => { const handleDeviceStatus = res => {
auncelList.value.forEach(item => { if (res.deviceType === 'balance') {
if (item.id === res.deviceId) { auncelList.value.forEach(item => {
item.isConnected = res.connected ?? 0 if (item.id === res.deviceId) {
if (res.connected === 0) { item.isConnected = res.connected
item.weightData = '天平断开' if (res.connected == 0) {
item.weightUnit = '' item.weightData = '天平断开'
item.weightStable = 0 item.weightUnit = ''
item.weightStable = 0
}
} }
} })
}) }
} }
const handleConnClose = () => { const handleConnClose = () => {
@@ -213,6 +197,32 @@ onMounted(() => {
onUnmounted(() => { onUnmounted(() => {
closeDeviceListener() 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> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -236,33 +246,34 @@ onUnmounted(() => {
} }
.weight { .weight {
flex: 1; flex: 1;
display: flex; font-size: 28px;
flex-direction: row;
font-size: 32px;
letter-spacing: 2px;
padding-top: 10px; padding-top: 10px;
padding: 10px 30px 0 30px;
position: relative;
} }
.weight-data,
.weight-data-yellow,
.weight-data-warning {
font-family: zzjc-lcd;
}
.weight-data { .weight-data {
flex: 1;
color: #4cd964; color: #4cd964;
text-align: right;
font-family: zzjc-lcd;
} }
.weight-data-yellow { .weight-data-yellow {
flex: 1;
color: #ffff00; color: #ffff00;
text-align: center;
font-family: zzjc-lcd;
} }
.weight-data-warning { .weight-data-warning {
color: #ff3333; color: #ff3333;
text-align: right;
font-family: zzjc-lcd;
} }
.weight-unit { .weight-unit {
position: absolute;
right: 10px;
top: 10px;
color: #ffffff; color: #ffffff;
font-size: 24px; font-size: 20px;
padding: 0 10px;
} }
@media (max-width: 700px) { @media (max-width: 700px) {
.auncel-item { .auncel-item {

View File

@@ -64,6 +64,7 @@ const props = defineProps({
} }
}) })
const emit = defineEmits(['update:showPopup'])
// Data // Data
const curSample = ref({}) const curSample = ref({})
const curParameterKey = ref('') const curParameterKey = ref('')
@@ -79,7 +80,7 @@ const getAllIndexes = arr => {
} }
const close = () => { const close = () => {
uni.$emit('sample-detail-popup_close') emit('update:showPopup', false)
} }
const getSampleData = () => { const getSampleData = () => {

View File

@@ -30,5 +30,6 @@ export function getUpgradeBaseUrl() {
return uni.getStorageSync('upgradeBaseUrl') return uni.getStorageSync('upgradeBaseUrl')
} }
export function getWebSocketUrl() { export function getWebSocketUrl() {
return uni.getStorageSync('base_url').replace('/api', '') + '/ws' // return uni.getStorageSync('base_url').replace('/api', '') + '/ws'
return 'ws://localhost:8330'
} }

View File

@@ -1,105 +1,11 @@
import request from '@/nx/request' import request from '@/nx/request'
const taskPrefix = '/qms/bus/qmsBusAssayTask' const taskPrefix = '/qms/bus/qmsBusAssayTask'
const taskDetailPrefix = '/qms/bus/qmsBusAssayTaskDetail'
// 获取任务 // 获取任务
const getAssayTaskList = params => { const getAssayTaskList = params => {
return request({ return request({
url: taskPrefix + '/listTaskForPAD', url: taskPrefix + '/listTaskForPAD',
method: 'GET', method: 'GET',
params: { 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
}
}) })
} }
@@ -109,9 +15,6 @@ export const getConAssayTaskWithReportTemplateContent = id => {
method: 'get', method: 'get',
params: { params: {
id id
},
custom: {
isApiEncryption: false
} }
}) })
} }
@@ -119,23 +22,12 @@ export const queryTaskDetailListByAssayTaskId = params => {
return request({ return request({
url: taskPrefix + '/getAssayTaskDataWithDetailData', url: taskPrefix + '/getAssayTaskDataWithDetailData',
method: 'get', method: 'get',
params: params, params: params
custom: {
isApiEncryption: false
}
}) })
} }
export default { export default {
auncelWeigh,
auncelWeighRevoke,
getAssayTaskList, getAssayTaskList,
weighBatchSubmitByTaskNo,
weighBatchSubmitByIds,
assayTaskReview,
reviewWeightTaskByTaskIdAndSampleIds,
assayTaskDetailReview,
assayTaskDetailRecovery,
getConAssayTaskWithReportTemplateContent, getConAssayTaskWithReportTemplateContent,
queryTaskDetailListByAssayTaskId queryTaskDetailListByAssayTaskId
} }

View File

@@ -3,7 +3,7 @@ import request from '@/nx/request'
//获取实验室设备 //获取实验室设备
const getDeviceLaboratoryListBy = params => { const getDeviceLaboratoryListBy = params => {
return request({ return request({
url: '/qms/lims/deviceLaboratory/list', url: '/qms/resource/device-infomation/page',
method: 'GET', method: 'GET',
params: { params: {
...params ...params

View File

@@ -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
}

View File

@@ -130,6 +130,8 @@ http.interceptors.response.use(
// $store('user').setToken(response.header.authorization || response.header.Authorization) // $store('user').setToken(response.header.authorization || response.header.Authorization)
// } // }
const userStore = $store('user')
const isLogin = userStore.isLogin
response.config.custom.showLoading && closeLoading() response.config.custom.showLoading && closeLoading()
console.log('response', JSON.parse(JSON.stringify(response.data))) console.log('response', JSON.parse(JSON.stringify(response.data)))
@@ -193,6 +195,9 @@ http.interceptors.response.use(
title: msg || response.config.custom.errorMsg, title: msg || response.config.custom.errorMsg,
icon: 'none' icon: 'none'
}) })
if (code === 401) {
userStore.logout(true)
}
} }
if ((code === 0 || code === 200) && response.config.custom.showSuccess) { if ((code === 0 || code === 200) && response.config.custom.showSuccess) {

View File

@@ -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 +
'&currentTaskType=' +
this.currentTaskType +
'&currentAuncelId=' +
this.currentAuncel.id +
'&currentAuncelName=' +
this.currentAuncel.name +
'&currentAuncelCode=' +
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>

View File

@@ -3,27 +3,16 @@
<navbar-back title="天平状态"></navbar-back> <navbar-back title="天平状态"></navbar-back>
<up-grid border :col="3"> <up-grid border :col="3">
<up-grid-item v-for="(auncel, index) in auncelList" :index="index" :key="index"> <up-grid-item v-for="(auncel, index) in auncelList" :index="index" :key="index">
<view <view class="auncel-item" :style="{ backgroundImage: `url(${balanceBackground})` }">
class="auncel-item"
:style="{
backgroundImage: `url(${require('@/static/images/auncel.png')})`
}"
>
<view class="auncel-header"> <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 class="auncel-name">{{ auncel.controlRealName }}</view>
</view> </view>
<view class="weight"> <view class="weight">
<view <view :class="getWeightClass(auncel)" :style="getWeightStyle(auncel)">
:class="{ {{ getWeightText(auncel) }}
'weight-data-yellow': auncel.weightStable === 0,
'weight-data': auncel.weightStable === 1,
'weight-data-warning': auncel.weightStable === 2
}"
>
{{ auncel.weightData || '' }}
</view> </view>
<view class="weight-unit">{{ auncel.weightUnit }}</view> <view v-if="auncel.isConnected === 1" class="weight-unit">{{ auncel.weightUnit }}</view>
</view> </view>
</view> </view>
</up-grid-item> </up-grid-item>
@@ -36,6 +25,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue'
import { onUnload, onHide } from '@dcloudio/uni-app' import { onUnload, onHide } from '@dcloudio/uni-app'
import { getTenantId } from '@/defaultBaseUrl' import { getTenantId } from '@/defaultBaseUrl'
import nx from '@/nx' import nx from '@/nx'
const balanceBackground = new URL('/static/images/auncel.png', import.meta.url).href
// refs // refs
const auncelList = ref([]) const auncelList = ref([])
@@ -45,7 +35,7 @@ const userInfo = computed(() => nx.$store('user').userInfo)
// 页面加载 // 页面加载
onMounted(() => { onMounted(() => {
// getPageData() getPageData()
// #ifdef H5 // #ifdef H5
const regData = { const regData = {
msgId: nx.$helper.uuid(), msgId: nx.$helper.uuid(),
@@ -87,24 +77,14 @@ function cleanup() {
function getPageData() { function getPageData() {
nx.$api.laboratory nx.$api.laboratory
.getDeviceLaboratoryListBy({ .getDeviceLaboratoryListBy({
deviceType: 'auncel', pageNo: 1,
status: '1', pageSize: 999,
isEnable: '1', collectDeviceType: 'balance',
pageNo: 0, deviceStatus: '0',
pageSize: -1 isEnable: '1'
}) })
.then(res => { .then(res => {
const dataList = res.records || [] auncelList.value = res.list
dataList.forEach(i => {
i.weightData = ''
i.weightUnit = ''
i.isConnected = 0
i.weightStable = 0
i.temperature = 0
i.humidity = 0
i.controlRealName = ''
})
auncelList.value = dataList
}) })
.catch(err => { .catch(err => {
console.error('获取天平列表失败', err) console.error('获取天平列表失败', err)
@@ -113,46 +93,71 @@ function getPageData() {
// WebSocket 事件处理器 // WebSocket 事件处理器
function handleDeviceData(res) { function handleDeviceData(res) {
if (res.deviceType !== 'auncel') return if (res.deviceType === 'balance') {
auncelList.value = auncelList.value.map(item => { auncelList.value.forEach(item => {
if (item.id === res.deviceId) { if (item.id === res.deviceId) {
return { item.weightData = res.weightData
...item, item.weightUnit = res.weightUnit
weightData: res.weightData, item.weightStable = res.weightStable
weightUnit: res.weightUnit, item.isConnected = 1
weightStable: res.weightStable, item.controlRealName = res.controlRealName
isConnected: 1,
controlRealName: res.controlRealName
} }
} })
return item }
})
} }
function handleDeviceStatus(res) { function handleDeviceStatus(res) {
auncelList.value = auncelList.value.map(item => { if (res.deviceType === 'balance') {
if (item.id === res.deviceId) { auncelList.value.forEach(item => {
const updated = { ...item, isConnected: res.connected } if (item.id === res.deviceId) {
if (res.connected === 0) { item.isConnected = res.connected
updated.weightData = '天平断开' if (res.connected == 0) {
updated.weightUnit = '' item.weightData = '天平断开'
updated.weightStable = 0 item.weightUnit = ''
item.weightStable = 0
}
} }
return updated })
} }
return item
})
} }
function handleConnClose() { function handleConnClose() {
auncelList.value = auncelList.value.map(i => ({ auncelList.value.forEach(item => {
...i, item.weightData = ''
weightData: '', item.weightUnit = ''
weightUnit: '', item.weightStable = 0
weightStable: 0, item.controlRealName = ''
controlRealName: '', item.isConnected = 0
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> </script>
@@ -170,7 +175,6 @@ function handleConnClose() {
} }
.auncel-header { .auncel-header {
height: 100px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
@@ -184,27 +188,18 @@ function handleConnClose() {
.auncel-name { .auncel-name {
margin-top: 5px; margin-top: 5px;
font-size: 14px;
color: #666;
} }
.weight { .weight {
width: 100%; width: 100%;
height: 40px; height: 60px;
display: flex; position: relative;
flex-direction: row;
box-sizing: border-box; box-sizing: border-box;
padding: 0 20px;
} }
.weight-data, .weight-data,
.weight-data-yellow, .weight-data-yellow,
.weight-data-warning { .weight-data-warning {
flex-grow: 1;
height: 100%;
text-align: right;
line-height: 40px;
letter-spacing: 2px;
font-size: 32px;
font-family: zzjc-lcd; font-family: zzjc-lcd;
} }
@@ -221,9 +216,10 @@ function handleConnClose() {
} }
.weight-unit { .weight-unit {
position: absolute;
right: 3px;
top: 8px;
color: #ffffff; color: #ffffff;
font-size: 24px; font-size: 24px;
line-height: 40px;
padding-left: 10px;
} }
</style> </style>

View File

@@ -117,7 +117,7 @@
<!-- 样品详情 --> <!-- 样品详情 -->
<sample-detail-popup <sample-detail-popup
ref="sampleDetailPopup" ref="sampleDetailPopup"
:showPopup="showDetailPopup" v-model:showPopup="showDetailPopup"
:detailPopupParam="detailPopupParam" :detailPopupParam="detailPopupParam"
></sample-detail-popup> ></sample-detail-popup>
</view> </view>
@@ -324,11 +324,6 @@ const printTask = () => {
onMounted(() => { onMounted(() => {
getDicSampleProcessCodeList() getDicSampleProcessCodeList()
getAssayTask() getAssayTask()
// 监听 popup 关闭
uni.$on('sample-detail-popup_close', () => {
showDetailPopup.value = false
})
}) })
onBackPress(() => { onBackPress(() => {

View File

@@ -72,6 +72,7 @@
<view class="auncel-weight"> <view class="auncel-weight">
<view class="weight"> <view class="weight">
<view <view
:style="{ textAlign: currentAuncel.isConnected != 1 ? 'center' : 'right' }"
:class=" :class="
currentAuncel.weightStable === 0 currentAuncel.weightStable === 0
? 'weight-data-yellow' ? 'weight-data-yellow'
@@ -89,7 +90,7 @@
<u-button <u-button
class="btn-operation" class="btn-operation"
v-if="currentAuncel.code === ''" v-if="currentAuncel.code !== ''"
type="success" type="success"
:disabled="confirmWeightDisabled" :disabled="confirmWeightDisabled"
shape="circle" shape="circle"
@@ -200,6 +201,7 @@
<script setup> <script setup>
import { ref, reactive, computed, nextTick, onMounted } from 'vue' import { ref, reactive, computed, nextTick, onMounted } from 'vue'
import { onLoad, onBackPress, onShow, onHide, onUnload } from '@dcloudio/uni-app'
import request from '@/nx/request' import request from '@/nx/request'
import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue' import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue'
import { number } from 'mathjs' import { number } from 'mathjs'
@@ -207,6 +209,7 @@ import AuncelSelectPopup from '@/components/sample/auncel-select-popup.vue'
import { getTenantId } from '@/defaultBaseUrl' import { getTenantId } from '@/defaultBaseUrl'
import { useScreenOrientation } from '@/nx/hooks/useScreenOrientation' import { useScreenOrientation } from '@/nx/hooks/useScreenOrientation'
import nx from '@/nx' import nx from '@/nx'
import text from '@/uview-plus/components/u-text/text'
// 响应式数据定义 // 响应式数据定义
const elId = nx.$helper.uuid() const elId = nx.$helper.uuid()
@@ -944,7 +947,7 @@ const listenDeviceData = () => {
//设备数据 //设备数据
uni.$on('deviceData', res => { uni.$on('deviceData', res => {
switch (res.deviceType) { switch (res.deviceType) {
case 'auncel': case 'balance':
if (currentAuncel.id === res.deviceId) { if (currentAuncel.id === res.deviceId) {
currentAuncel.weightData = res.weightData currentAuncel.weightData = res.weightData
currentAuncel.weightUnit = res.weightUnit currentAuncel.weightUnit = res.weightUnit
@@ -1233,7 +1236,7 @@ onBackPress(() => {
} }
.auncel { .auncel {
width: 100%; width: 90%;
height: 55vh; height: 55vh;
background-image: url(/static/images/auncel.png); background-image: url(/static/images/auncel.png);
background-repeat: no-repeat; background-repeat: no-repeat;
@@ -1263,31 +1266,29 @@ onBackPress(() => {
.weight { .weight {
font-size: 42px; font-size: 42px;
width: 100%; width: 100%;
padding-right: 10px; padding: 0 60px;
} }
.weight-data { .weight-data {
color: #4cd964; color: #4cd964;
text-align: right;
font-family: zzjc-lcd; font-family: zzjc-lcd;
} }
.weight-data-yellow { .weight-data-yellow {
color: #ffff00; color: #ffff00;
text-align: center;
font-family: zzjc-lcd; font-family: zzjc-lcd;
} }
.weight-data-warning { .weight-data-warning {
color: #ff3333; color: #ff3333;
text-align: right;
font-family: zzjc-lcd; font-family: zzjc-lcd;
} }
.weight-unit { .weight-unit {
position: absolute;
right: 30px;
color: #ffffff; color: #ffffff;
font-size: 32px; font-size: 32px;
padding-right: 30px;
} }
@media (max-width: 700px) { @media (max-width: 700px) {
.auncel { .auncel {

View File

@@ -80,7 +80,7 @@
<script setup> <script setup>
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import request from '@/nx/request' import request from '@/nx/request'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash'
import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue' import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue'
import nx from '@/nx' import nx from '@/nx'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'

View File

@@ -198,17 +198,9 @@ const applyRollbackSample = () => {
taskId: currentTask.value.id, taskId: currentTask.value.id,
detailIds: detailIdList.join(',') detailIds: detailIdList.join(',')
} }
nx.$api.assayTask.createRollbackApply(data).then(() => {
uni.showLoading({ title: '正在发起申请...' }) getAssayTaskDetail(currentTaskNo.value)
nx.$api.assayTask })
.createRollbackApply(data)
.then(() => {
getAssayTaskDetail(currentTaskNo.value)
})
.catch(console.error)
.finally(() => {
uni.hideLoading()
})
} }
}) })
} }

View File

@@ -13,8 +13,8 @@ import { reactive, ref, computed, onMounted } from 'vue'
import nx from '@/nx' import nx from '@/nx'
import { useGridCol } from '@/nx/hooks/useGridCol' import { useGridCol } from '@/nx/hooks/useGridCol'
let list = reactive([ let list = reactive([
{ url: '/pages/lims/index/index', name: '设备管理系统', icon: 'dailyCheck' }, { url: '/pages/lims/index/index', name: '设备管理系统', icon: 'device' },
{ url: '/pages/analysis/index/index', name: '化学分析系统', icon: 'maintain' } { url: '/pages/analysis/index/index', name: '化学分析系统', icon: 'analyse' }
]) ])
// const sysMenus = computed(() => nx.$store('user').sysMenus) // const sysMenus = computed(() => nx.$store('user').sysMenus)

View File

@@ -24,7 +24,7 @@ import { reactive } from 'vue'
let state = reactive({ let state = reactive({
pageHeight: 0, pageHeight: 0,
appVersion: '1.1.0', appVersion: '1.1.0',
appName: '凉山矿业设备管理系统', appName: '管理系统',
copyrightYear: '2019', copyrightYear: '2019',
aboutMe: aboutMe:
'<div style="text-align:left;font-size:20px;padding:18px"><p style="text-indent:2em;line-height:32px"></p></div>' '<div style="text-align:left;font-size:20px;padding:18px"><p style="text-indent:2em;line-height:32px"></p></div>'