feat:分析值保留两位有效数字计算

This commit is contained in:
houjunxiang
2026-02-05 11:10:44 +08:00
parent e10c70e819
commit da01e1efcd
8 changed files with 123 additions and 80 deletions

View File

@@ -7,7 +7,7 @@
<span>{{ title }}</span> <span>{{ title }}</span>
</view> </view>
<view class="x-c"> <view class="x-c">
<u-icon size="150" color="#0055A2" name="scan"></u-icon> <u-icon size="150" color="#0055A2" name="scan" @click="handleScan"></u-icon>
</view> </view>
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<up-search <up-search
@@ -47,6 +47,14 @@ function iconMap(key) {
return customIconsMap.get(key) return customIconsMap.get(key)
} }
function handleScan() {
uni.scanCode({
onlyFromCamera: true,
success: function (res) {
emits('scanResult', res.result)
}
})
}
function handleInputSearch(e) { function handleInputSearch(e) {
emits('deviceId', e) emits('deviceId', e)
} }

View File

@@ -2,26 +2,26 @@ import request from '@/nx/request'
export default { export default {
queryById: id => queryById: id =>
request({ request({
url: '/lims/bus/deviceBusMaintain/getMaintainDetail', url: '/qms/resource/device-maintain/getMaintainDetail',
method: 'GET', method: 'GET',
params: { id } params: { id }
}), }),
list: params => list: params =>
request({ request({
url: '/lims/bus/deviceBusMaintain/list', url: '/qms/resource/device-maintain/page',
method: 'GET', method: 'GET',
params params
}), }),
// 根据设备id或者维护和点检记录 // 根据设备id或者维护和点检记录
getCheckRecord: data => getCheckRecord: data =>
request({ request({
url: '/lims/bus/deviceBusMaintain/createOrGet', url: '/qms/resource/device-maintain/createOrGet',
method: 'POST', method: 'POST',
data data
}), }),
submit: data => submit: data =>
request({ request({
url: '/lims/bus/deviceBusMaintain/saveMaintainVo', url: '/qms/resource/device-maintain/saveMaintainVo',
method: 'POST', method: 'POST',
data, data,
custom: { custom: {
@@ -30,13 +30,13 @@ export default {
}), }),
getLastDailyCheckOfToday: params => getLastDailyCheckOfToday: params =>
request({ request({
url: '/lims/bus/deviceBusMaintain/getLastDailyCheckOfToday', url: '/qms/resource/device-maintain/getLastDailyCheckOfToday',
method: 'GET', method: 'GET',
params, params,
}), }),
createDailyCheck: data => createDailyCheck: data =>
request({ request({
url: '/lims/bus/deviceBusMaintain/create', url: '/qms/resource/device-maintain/create',
method: 'POST', method: 'POST',
data data
}) })

File diff suppressed because it is too large Load Diff

View File

@@ -674,7 +674,7 @@ const saveDetail = async () => {
if (item.calcMethod === 'calculateAverageValue') { if (item.calcMethod === 'calculateAverageValue') {
item.value = calcAverageValue(sourceKey, currentAssayType.value.tableData) item.value = calcAverageValue(sourceKey, currentAssayType.value.tableData)
} else { } else {
item.value = handleRoundFiveNumber(row[sourceKey].value, row.decimalPosition) item.value = handleRoundFiveNumber(row[sourceKey].value, row.decimalPosition, row.type === 'project')
} }
// 如果处理后的值不为空,重新赋值该字段到其他样品类型下的样品上,并触发每一个样品的计算 // 如果处理后的值不为空,重新赋值该字段到其他样品类型下的样品上,并触发每一个样品的计算
for (const col of currentAssayType.value.columns) { for (const col of currentAssayType.value.columns) {
@@ -707,9 +707,10 @@ const saveDetail = async () => {
function calcAverageValue(fieldIndex, tableData) { function calcAverageValue(fieldIndex, tableData) {
const rows = tableData.map(row => row[fieldIndex]) const rows = tableData.map(row => row[fieldIndex])
const decimalPosition = rows[0].decimalPosition const decimalPosition = rows[0].decimalPosition
const isProject = rows[0].type === 'project'
const values = rows.map(row => Number(row.value)) const values = rows.map(row => Number(row.value))
if (values.some(item => item == null)) return null if (values.some(item => item == null)) return null
return handleRoundFiveNumber(math.mean(values), decimalPosition) return handleRoundFiveNumber(math.mean(values), decimalPosition, isProject)
} }
// 表格数据更新后重新计算 // 表格数据更新后重新计算
@@ -1109,12 +1110,13 @@ const listenNumKeyboard = () => {
} }
//自动补全小数位数 //自动补全小数位数
const decimalPosition = selectedField.value.decimalPosition const decimalPosition = selectedField.value.decimalPosition
const isProject = selectedField.value.type === 'project'
let val = res.val let val = res.val
const symbol = res.symbol const symbol = res.symbol
if (decimalPosition == null) { if (decimalPosition == null) {
selectedField.value.value = val selectedField.value.value = val
} else { } else {
selectedField.value.value = handleRoundFiveNumber(val, decimalPosition) selectedField.value.value = handleRoundFiveNumber(val, decimalPosition, isProject)
} }
if (symbol) { if (symbol) {
selectedField.value.symbol = symbol selectedField.value.symbol = symbol

File diff suppressed because it is too large Load Diff

View File

@@ -156,7 +156,7 @@ function getLastDailyCheckOfToday(id) {
}) })
}, 100) }, 100)
pageLoading.value = false pageLoading.value = false
nx.$router.go('/pages/deviceBusDailyCheck/index', { deviceId: id }) nx.$router.go('/pages/device/deviceBusDailyCheck/index', { deviceId: id })
} else { } else {
getDeviceInfo(id) getDeviceInfo(id)
await getUseIngRecord(id) await getUseIngRecord(id)

View File

@@ -3,38 +3,37 @@
<navbar-back title="实验室管理系统【设备管理】" :autoBack="false" leftIcon="" leftText=""> <navbar-back title="实验室管理系统【设备管理】" :autoBack="false" leftIcon="" leftText="">
<u-icon @click="popupShow = true" size="28" color="#FFF" name="setting-fill" /> <u-icon @click="popupShow = true" size="28" color="#FFF" name="setting-fill" />
</navbar-back> </navbar-back>
<up-grid :border="false" :col="gridCol"> <up-grid :col="gridCol" :border="false">
<up-grid-item <up-grid-item class="mb20 mt20" v-for="item in menuItemList" :key="item.id" @click="goTo(item.component)">
class="mb20 mt20" <u-icon :name="`/static/images/menus/${item.path}.png`" color="#0055A2" size="80" />
v-for="(item, listIndex) in list" <view class="grid-text">{{ item.name }}</view>
:key="listIndex"
@click="nx.$router.go(item.url)"
>
<image style="width: 80px; height: 80px" :src="`/static/images/menus/${item.icon}.png`"></image>
<text class="grid-text">{{ item.name }}</text>
</up-grid-item> </up-grid-item>
</up-grid> </up-grid>
<mePopup v-model:show="popupShow" /> <mePopup v-model:show="popupShow" />
</view> </view>
</template> </template>
<script setup> <script setup>
import { reactive, ref, computed } from 'vue' import { 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'
import mePopup from '@/pages/index/me-popup.vue' import mePopup from '@/pages/index/me-popup.vue'
const { gridCol } = useGridCol([400, 600], [2, 3, 4]) const { gridCol } = useGridCol([400, 600], [2, 3, 4])
let popupShow = ref(false) let popupShow = ref(false)
let list = reactive([ const menuItemList = computed(() => {
{ url: '/pages/device/deviceBusDailyCheck/index', name: '点检', icon: 'dailyCheck' }, let roleMenus = nx.$store('user').roleMenus
{ url: '/pages/device/deviceBusMaintain/index', name: '维护保养', icon: 'maintain' }, const result = roleMenus.find(item => item.path === 'device')
{ url: '/pages/device/deviceBusUseRecord/index', name: '使用', icon: 'useRecord' }, if (result) {
{ url: '/pages/device/deviceBusInfo/index', name: '设备查询', icon: 'baseInfo' }, return result.children
{ url: '/pages/device/knowledge/index', name: '知识库查询', icon: 'knowledge' } } else {
]) return []
}
})
const roleMenus = computed(() => nx.$store('user').roleMenus) // 方法
const userInfo = computed(() => nx.$store('user').userInfo) const goTo = url => {
nx.$router.go(url)
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB