feat:样品分析
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
<u-dropdown-item
|
||||
v-model="curParameterClassify"
|
||||
:title="curParameterTitle"
|
||||
height="340px"
|
||||
height="70vh"
|
||||
:options="optionParameterClassify"
|
||||
@change="parameterClassifyChange"
|
||||
></u-dropdown-item>
|
||||
@@ -44,12 +44,12 @@
|
||||
v-for="(sample, index) in leftList"
|
||||
:key="index"
|
||||
class="u-tab-item"
|
||||
:class="[current.value === index ? 'u-tab-item-active' : '']"
|
||||
:class="currentSampleIndex === index ? 'u-tab-item-active' : ''"
|
||||
:data-current="index"
|
||||
@tap.stop="switchSample(index, false)"
|
||||
>
|
||||
<view class="pr5"> 【{{ sample.sort }}】 </view>
|
||||
<view>
|
||||
<u-badge type="warning" :value="index + 1"></u-badge>
|
||||
<view class="ml20">
|
||||
<view>
|
||||
{{ sample.sampleCode }}
|
||||
</view>
|
||||
@@ -60,19 +60,19 @@
|
||||
<u-button class="btn-operation" type="primary" @click="submitTask()">提交指派单</u-button>
|
||||
</u-col>
|
||||
<u-col span="6">
|
||||
<view class="field-name" v-html="selectedField.value.name" />
|
||||
<view class="field-name" v-html="selectedField.title" />
|
||||
<zzjc-num-keyboard
|
||||
ref="myKeyboard"
|
||||
v-show="selectedField.value.fillingWay === '1' && selectedField.value.type !== 'select'"
|
||||
v-show="selectedField.fillingWay == '1' && selectedField.type != 'select'"
|
||||
:numKeyboardParam="numKeyboardParam"
|
||||
></zzjc-num-keyboard>
|
||||
<view v-if="selectedField.value.fillingWay === '2'" class="y-f">
|
||||
<view v-if="selectedField.fillingWay == '2'" class="y-f">
|
||||
<view class="auncel" @click="selectAuncel">
|
||||
<view class="auncel-title"> {{ currentAuncel.code }}</view>
|
||||
<view class="auncel-weight">
|
||||
<view class="weight">
|
||||
<view
|
||||
:style="{ textAlign: currentAuncel.isConnected != 1 ? 'center' : 'right' }"
|
||||
:style="{ textAlign: !currentAuncel.isConnected ? 'center' : 'right' }"
|
||||
:class="
|
||||
currentAuncel.weightStable === 0
|
||||
? 'weight-data-yellow'
|
||||
@@ -90,7 +90,6 @@
|
||||
|
||||
<u-button
|
||||
class="btn-operation"
|
||||
v-if="currentAuncel.code !== ''"
|
||||
type="success"
|
||||
:disabled="confirmWeightDisabled"
|
||||
shape="circle"
|
||||
@@ -106,7 +105,7 @@
|
||||
<view>
|
||||
<u-form :model="curSample" ref="uForm" label-width="140">
|
||||
<template v-for="(fields, groupIndex) in fieldGroup" :key="'group_' + groupIndex">
|
||||
<view v-if="curParameterKey.value === '' || curParameterKey.value === fields.title">
|
||||
<view>
|
||||
<!-- 组名 -->
|
||||
<view class="my-collapse" @click="fields.open = !fields.open">
|
||||
<text class="title">{{ fields.title }}</text>
|
||||
@@ -122,35 +121,31 @@
|
||||
v-for="(field, fieldIndex) in fields.fields"
|
||||
@click="fieldClick(field, groupIndex + '-' + fieldIndex)"
|
||||
:key="groupIndex + '-' + fieldIndex"
|
||||
v-show="field.hidden !== 1 && field.hidden !== '1'"
|
||||
:class="{ 'selected-field': selectedFieldIndex.value === groupIndex + '-' + fieldIndex }"
|
||||
v-show="field.hidden != 1"
|
||||
:class="{
|
||||
'selected-field': groupFieldIndex === groupIndex + '-' + fieldIndex,
|
||||
'disabled-field': !field.isEdit
|
||||
}"
|
||||
>
|
||||
<view
|
||||
:class="[
|
||||
'label-my',
|
||||
{ 'label-high-light': field.highlight === 1 || field.highlight === '1' }
|
||||
]"
|
||||
v-html="
|
||||
field.name +
|
||||
(typeof field.unit !== 'undefined' && field.unit !== null && field.unit !== ''
|
||||
? '(' + field.unit + ')'
|
||||
: '')
|
||||
"
|
||||
:class="['label-my', { 'label-high-light': field.highlight == 1 }]"
|
||||
v-html="field.title"
|
||||
></view>
|
||||
<view class="content-my">
|
||||
<!--
|
||||
如果是select,渲染2个组件:1个input、1个picker.
|
||||
field.valueText用于显示picker选中的文本
|
||||
1,键盘输入,2、天平,3、自动计算,4、文本输入
|
||||
-->
|
||||
<u-input
|
||||
border="bottom"
|
||||
style="width: 120px"
|
||||
v-if="field.fillingWay === 4"
|
||||
v-if="field.fillingWay == 4"
|
||||
v-model="field.value"
|
||||
:placeholder="field.placeholder"
|
||||
type="text"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
|
||||
<view v-if="field.type === 'select'" class="x-bc select-my" @click="field.showPicker = true">
|
||||
<!-- <view v-if="field.type === 'select'" class="x-bc select-my" @click="field.showPicker = true">
|
||||
<text v-if="field.valueText">{{ field.valueText }}</text>
|
||||
<text v-else>请选择</text>
|
||||
<u-icon name="arrow-down" size="20"></u-icon>
|
||||
@@ -162,18 +157,15 @@
|
||||
keyName="dictValue"
|
||||
@cancel="field.showPicker = false"
|
||||
@confirm="event => dicPickerConfirm(event, field)"
|
||||
/>
|
||||
/> -->
|
||||
<!--普通输入框 使用文本显示-->
|
||||
<view class="content-my-text" v-if="field.type !== 'select' && field.fillingWay !== 4">
|
||||
<text v-if="!field.value || field.value === ''" class="content-my-text-placeholder">{{
|
||||
field.placeholder
|
||||
<view class="content-my-text" v-if="field.dataType != 'select' && field.fillingWay != 4">
|
||||
<text v-if="!field.value" class="content-my-text-placeholder">{{
|
||||
!field.fillingWay || field.fillingWay == 3 ? '计算值' : '请输入'
|
||||
}}</text>
|
||||
<text
|
||||
v-else
|
||||
:class="[
|
||||
'content-my-text-value',
|
||||
{ 'field-high-light': field.highlight === 1 || field.highlight === '1' }
|
||||
]"
|
||||
:class="['content-my-text-value', { 'field-high-light': field.highlight == 1 }]"
|
||||
>{{ field.value }}</text
|
||||
>
|
||||
</view>
|
||||
@@ -200,7 +192,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, nextTick, onMounted } from 'vue'
|
||||
import { ref, reactive, computed, nextTick, getCurrentInstance } from 'vue'
|
||||
import { onLoad, onBackPress, onShow, onHide, onUnload } from '@dcloudio/uni-app'
|
||||
import request from '@/nx/request'
|
||||
import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue'
|
||||
@@ -209,26 +201,26 @@ 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'
|
||||
import { getDataSourceTypeShow } from '../common'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
// 响应式数据定义
|
||||
const taskId = ref('')
|
||||
const elId = nx.$helper.uuid()
|
||||
const scrollTop = ref(0) //tab标题的滚动条位置
|
||||
const current = ref(0) // 预设当前项的值
|
||||
const menuHeight = ref(0) // 左边菜单的高度
|
||||
const menuItemHeight = ref(0) // 左边菜单item的高度
|
||||
const orderGenBH = ref(true) //顺序生成杯号
|
||||
const weightDataIsToZero = ref(false) //重量数据是否归零
|
||||
const currentSample = ref({}) //当前样品
|
||||
const currentTaskNo = ref('') //当前任务指派单号
|
||||
const currentTaskId = ref('') //当前任务指派单id
|
||||
const currentTaskType = ref('') //当前任务类型
|
||||
const currentSampleIndex = ref(0) // 预设当前项的值
|
||||
let sampleDataList = []
|
||||
const title = ref('')
|
||||
const numKeyboardParam = reactive({
|
||||
decimal: '-1' //数字键盘小数位数,-1为不限制
|
||||
})
|
||||
const showAuncelSelector = ref(false) //显示天平选择框
|
||||
const currentAuncel = reactive({
|
||||
const currentAuncel = ref({
|
||||
id: '',
|
||||
name: '',
|
||||
code: '',
|
||||
@@ -236,48 +228,60 @@ const currentAuncel = reactive({
|
||||
weightData: '请选天平',
|
||||
weightUnit: ''
|
||||
})
|
||||
const selectedField = ref({})
|
||||
const selectedFieldIndex = ref('')
|
||||
let selectedField = ref({})
|
||||
const groupFieldIndex = ref('') //分组的索引
|
||||
const leftList = ref([])
|
||||
const curSample = ref({})
|
||||
const showDicPicker = ref(false)
|
||||
const curParameterTitle = ref('选择字段分类')
|
||||
const curParameterKey = ref('')
|
||||
const curParameterClassify = ref('')
|
||||
const conAssayTaskId = ref('')
|
||||
const busSubCSampleId = ref('')
|
||||
const optionParameterClassify = ref([])
|
||||
const paramFieldApiRet = ref([])
|
||||
const fieldGroup = ref([])
|
||||
let fieldGroup = ref([])
|
||||
const collaHeights = ref([])
|
||||
const cupNumKey = '杯号'
|
||||
|
||||
// refs
|
||||
const myKeyboard = ref(null)
|
||||
const auncelSelector = ref(null)
|
||||
|
||||
// 计算属性
|
||||
const confirmWeightDisabled = computed(() => {
|
||||
if (currentSample.value.sampleCode && currentAuncel.weightStable === 1 && Number(currentAuncel.weightData) > 0) {
|
||||
if (
|
||||
currentSample.value.sampleCode &&
|
||||
currentAuncel.value.weightStable === 1 &&
|
||||
Number(currentAuncel.value.weightData) > 0
|
||||
) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
const checkCupNumReadonly = computed(() => {
|
||||
if (!currentAuncel.value || currentAuncel.value.id === '') return true
|
||||
return false
|
||||
// 当前样品数据索引
|
||||
const currentSampleDataIndex = computed(() => {
|
||||
if (sampleDataList.length > 0) {
|
||||
return sampleDataList.findIndex(item => item.businessAssayTaskDataId === currentSample.value.id)
|
||||
}
|
||||
return -1
|
||||
})
|
||||
// 当前操作字段索引
|
||||
const currentFieldKey = computed(() => {
|
||||
return selectedField.value.fieldIndex
|
||||
})
|
||||
|
||||
const userInfo = computed(() => nx.$store('user').userInfo)
|
||||
|
||||
// 方法定义
|
||||
const getDomHeight = () => {
|
||||
const getDomHeight = async () => {
|
||||
await nextTick() // 等待 DOM 更新完成
|
||||
collaHeights.value = []
|
||||
nextTick(() => {
|
||||
if (fieldGroup.value.length) {
|
||||
fieldGroup.value.forEach((item, index) => {
|
||||
nx.getRect('#elId' + index).then(res => {
|
||||
collaHeights.value.push(res.height)
|
||||
})
|
||||
if (fieldGroup.value.length) {
|
||||
fieldGroup.value.forEach((item, index) => {
|
||||
proxy.$u.getRect('#elId' + index).then(res => {
|
||||
collaHeights.value.push(res.height)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//返回上一页
|
||||
@@ -289,7 +293,7 @@ const customBack = () => {
|
||||
|
||||
const navRightClick = () => {
|
||||
let url = '/pages/analysis/sample/sample-work-edit-task'
|
||||
url += '?currentTaskNo=' + currentTaskNo.value
|
||||
url += '?currentTaskId=' + taskId.value
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
})
|
||||
@@ -307,24 +311,20 @@ const parameterClassifyChange = (v, a) => {
|
||||
if (v === '') groupIndex.value = 0
|
||||
if (groupIndex.value > 0) groupIndex.value--
|
||||
//自动选中字段
|
||||
selectedFieldIndex.value = groupIndex.value + '-'
|
||||
groupFieldIndex.value = groupIndex.value + '-'
|
||||
autoNextField()
|
||||
}
|
||||
|
||||
const fieldClick = (field, key) => {
|
||||
try {
|
||||
myKeyboard.value.clearNum()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
if (field.fillingWay === 4) return
|
||||
myKeyboard.value.clearNum()
|
||||
if (field.fillingWay == 4 || !field.fillingWay || field.fillingWay == 3) return
|
||||
selectedField.value = field
|
||||
selectedFieldIndex.value = key
|
||||
groupFieldIndex.value = key
|
||||
//判断小数位数
|
||||
let dataType = field.dataType
|
||||
if (dataType == null || dataType < -1) dataType = -1
|
||||
numKeyboardParam.decimal = dataType
|
||||
if (field.fillingWay === 2) {
|
||||
let decimalPosition = field.decimalPosition
|
||||
if (decimalPosition == null || decimalPosition < -1) decimalPosition = -1
|
||||
numKeyboardParam.decimal = decimalPosition
|
||||
if (field.fillingWay == 2) {
|
||||
listenDeviceData()
|
||||
} else {
|
||||
closeDeviceListener()
|
||||
@@ -333,20 +333,15 @@ const fieldClick = (field, key) => {
|
||||
|
||||
//自动切换到下一个字段
|
||||
const autoNextField = () => {
|
||||
//selectedFieldIndex是groupIndex-fieldIndex
|
||||
let groupIndex = 0
|
||||
let fieldIndex = 0
|
||||
if (typeof selectedFieldIndex.value === 'undefined' || selectedFieldIndex.value === '')
|
||||
selectedFieldIndex.value = '0-'
|
||||
const indexV = selectedFieldIndex.value.split('-')
|
||||
if (typeof groupFieldIndex.value === 'undefined' || groupFieldIndex.value === '') groupFieldIndex.value = '0-'
|
||||
const indexV = groupFieldIndex.value.split('-')
|
||||
groupIndex = number(indexV[0])
|
||||
fieldIndex = indexV[1] === '' ? -1 : number(indexV[1])
|
||||
const group = fieldGroup.value[groupIndex]
|
||||
const fields = group.fields
|
||||
if (fields.length > fieldIndex + 1) {
|
||||
//如果下一个字段是计算,不自动切换
|
||||
const fillingWay = fields[fieldIndex + 1].fillingWay || ''
|
||||
if (fillingWay === '3') return
|
||||
//切换到下一个字段
|
||||
const key = groupIndex + '-' + (fieldIndex + 1)
|
||||
fieldClick(fields[fieldIndex + 1], key)
|
||||
@@ -355,11 +350,10 @@ const autoNextField = () => {
|
||||
|
||||
//自动切换到下一个样品
|
||||
const autoNextSample = () => {
|
||||
//仅在顺序称重时自动切换
|
||||
// if (!orderWeighChecked.value)
|
||||
// return;
|
||||
if (leftList.value.length <= current.value + 1) return
|
||||
const index = current.value + 1
|
||||
if (leftList.value.length <= currentSampleIndex.value + 1) return
|
||||
const index = currentSampleIndex.value + 1
|
||||
groupFieldIndex.value = ''
|
||||
selectedField.value = {}
|
||||
switchSample(index, true)
|
||||
}
|
||||
|
||||
@@ -367,44 +361,53 @@ const autoNextSample = () => {
|
||||
const switchSample = async (index, autoFlag) => {
|
||||
//重置天平归0
|
||||
weightDataIsToZero.value = false
|
||||
//清空数字键盘数据
|
||||
myKeyboard.value.clearNum()
|
||||
if (index === current.value) return
|
||||
// if (orderWeighChecked.value && !autoFlag) return;//顺序称重不允许选中
|
||||
current.value = index
|
||||
if (index === currentSampleIndex.value) return
|
||||
setValueToSample()
|
||||
currentSampleIndex.value = index
|
||||
// 如果为0,意味着尚未初始化
|
||||
if (menuHeight.value === 0 || menuItemHeight.value === 0) {
|
||||
// await getElRect('menu-scroll-view', 'menuHeight');
|
||||
await getElRect('u-tab-item', 'menuItemHeight')
|
||||
const rect = await getElRect('u-tab-item')
|
||||
menuItemHeight.value = rect.height
|
||||
}
|
||||
// 将菜单菜单活动item垂直居中
|
||||
scrollTop.value = index * menuItemHeight.value + menuItemHeight.value / 2 - menuHeight.value / 2 - 50
|
||||
//修改当前选中的selectedFieldIndex
|
||||
if (typeof selectedFieldIndex.value !== 'undefined' && selectedFieldIndex.value.indexOf('-') > 0) {
|
||||
selectedFieldIndex.value = selectedFieldIndex.value.split('-')[0] + '-'
|
||||
}
|
||||
//修改当前选中的groupFieldIndex
|
||||
// if (typeof groupFieldIndex.value !== 'undefined' && groupFieldIndex.value.indexOf('-') > 0) {
|
||||
// groupFieldIndex.value = groupFieldIndex.value.split('-')[0] + '-'
|
||||
// }
|
||||
uni.showLoading({ title: '加载中...' })
|
||||
currentSample.value = leftList.value[index]
|
||||
//读取样品明细字段
|
||||
getDetailFieldsAndStatus(true)
|
||||
setValueToField()
|
||||
autoGenerateCupNum()
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 获取一个目标元素的高度
|
||||
const getElRect = (elClass, dataVal) => {
|
||||
const getElRect = (elClass, maxRetry = 50) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const query = uni.createSelectorQuery().in(this)
|
||||
query
|
||||
.select('.' + elClass)
|
||||
.fields({ size: true }, res => {
|
||||
// 如果节点尚未生成,res值为null,循环调用执行
|
||||
if (!res) {
|
||||
setTimeout(() => {
|
||||
getElRect(elClass)
|
||||
}, 10)
|
||||
return
|
||||
}
|
||||
this[dataVal] = res.height
|
||||
})
|
||||
.exec()
|
||||
let retryCount = 0
|
||||
const execQuery = () => {
|
||||
uni
|
||||
.createSelectorQuery()
|
||||
.in(proxy)
|
||||
.select('.' + elClass)
|
||||
.fields({ size: true, rect: true })
|
||||
.exec(res => {
|
||||
const result = res[0] // exec 返回数组,取第一个
|
||||
if (result) {
|
||||
resolve(result)
|
||||
} else if (retryCount < maxRetry) {
|
||||
retryCount++
|
||||
setTimeout(execQuery, 10)
|
||||
} else {
|
||||
reject(new Error(`无法获取元素 .${elClass} 的尺寸,已重试 ${maxRetry} 次`))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
execQuery()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -413,55 +416,13 @@ const getDetailFieldsAndStatus = autoSelectNextField => {
|
||||
const taskDetailId = currentSample.value.id
|
||||
//读取回收率配置
|
||||
loadConRecoveryList()
|
||||
//查询字段
|
||||
nx.$api.assayTask.queryFieldsByTaskDetail({ taskDetailId: taskDetailId }).then(res => {
|
||||
fieldGroup.value = []
|
||||
if (!res.success) {
|
||||
nx.$helper.showToast({
|
||||
title: res.message
|
||||
})
|
||||
return
|
||||
}
|
||||
//处理“填写&计算”字段:如果后台存了值,则不自动计算
|
||||
const groupList = res.result
|
||||
for (const g of groupList) {
|
||||
g.open = true
|
||||
for (const f of g.fields) {
|
||||
if (f.fillingWay === '1' && f.value != null && f.value !== '') {
|
||||
f.valueTypeManual = '1'
|
||||
}
|
||||
}
|
||||
}
|
||||
fieldGroup.value = groupList
|
||||
const arr = [
|
||||
{
|
||||
label: '全部',
|
||||
value: ''
|
||||
}
|
||||
]
|
||||
for (const g of fieldGroup.value) {
|
||||
const title = g.title
|
||||
const o = {
|
||||
label: title,
|
||||
value: title
|
||||
}
|
||||
arr.push(o)
|
||||
}
|
||||
// 计算样品详情高度
|
||||
getDomHeight()
|
||||
optionParameterClassify.value = arr //字段分类
|
||||
conAssayTaskId.value = res.additionalProperties.conAssayTaskId
|
||||
busSubCSampleId.value = res.additionalProperties.busSubCSampleId
|
||||
const detail = res.additionalProperties.taskDetail
|
||||
//处理硫值、硫量:未保存过的数据,读取接口返回的硫值、硫量
|
||||
loadSValue(detail)
|
||||
//自动生成杯号
|
||||
autoGenerateCupNum()
|
||||
//自动选择下一个字段
|
||||
if (autoSelectNextField) autoNextField()
|
||||
//按公式计算值,并检查原数据与计算后的数据是否一致
|
||||
calAndCheck()
|
||||
})
|
||||
optionParameterClassify.value = arr //字段分类
|
||||
conAssayTaskId.value = res.additionalProperties.conAssayTaskId
|
||||
busSubCSampleId.value = res.additionalProperties.busSubCSampleId
|
||||
const detail = res.additionalProperties.taskDetail
|
||||
//处理硫值、硫量:未保存过的数据,读取接口返回的硫值、硫量
|
||||
loadSValue(detail)
|
||||
calAndCheck()
|
||||
}
|
||||
|
||||
const checkLoadSValue = () => {
|
||||
@@ -568,7 +529,6 @@ const clearFieldVal = () => {
|
||||
return
|
||||
}
|
||||
selectedField.value.value = ''
|
||||
selectedField.value.valueTypeManual = '0'
|
||||
//重新计算
|
||||
calcAnalysisValue(fieldGroup.value)
|
||||
}
|
||||
@@ -593,7 +553,7 @@ const checkBh = () => {
|
||||
let hasHb = true
|
||||
for (const g of fieldGroup.value) {
|
||||
for (const f of g.fields) {
|
||||
if (f.dicKey && f.dicKey.indexOf('bh_') >= 0) {
|
||||
if (f.title && f.title.indexOf(cupNumKey) >= 0) {
|
||||
if (typeof f.value === 'undefined' || f.value === null || f.value === '') hasHb = false
|
||||
}
|
||||
}
|
||||
@@ -608,8 +568,6 @@ const checkBh = () => {
|
||||
}
|
||||
|
||||
const saveAuncelData = () => {
|
||||
//检查杯号
|
||||
if (!checkBh()) return
|
||||
//保存数据
|
||||
if (!weightDataIsToZero.value) {
|
||||
nx.$helper.showToast({
|
||||
@@ -618,10 +576,10 @@ const saveAuncelData = () => {
|
||||
return
|
||||
}
|
||||
//获取当前重量
|
||||
let weight = currentAuncel.weightData
|
||||
let weight = currentAuncel.value.weightData
|
||||
|
||||
selectedField.value.value = weight
|
||||
const curFieldDicKey = selectedField.value.dicKey
|
||||
const curFieldDicKey = selectedField.dicKey
|
||||
let upDownFlag = ''
|
||||
if (curFieldDicKey && curFieldDicKey !== '' && curFieldDicKey.indexOf('_') > 0) {
|
||||
upDownFlag = curFieldDicKey.substring(curFieldDicKey.lastIndexOf('_') + 1)
|
||||
@@ -640,15 +598,15 @@ const saveAuncelData = () => {
|
||||
}
|
||||
const auncelNoField = getFieldByKey(auncelNoFieldKey)
|
||||
if (auncelNoField !== null) {
|
||||
auncelNoField.value = currentAuncel.code
|
||||
auncelNoField.value = currentAuncel.value.code
|
||||
}
|
||||
const measureTimeField = getFieldByKey(measureTimeFieldKey)
|
||||
if (measureTimeField !== null) {
|
||||
measureTimeField.value = nx.$dayjs.format('yyyy-MM-dd hh:mm:ss')
|
||||
measureTimeField.value = nx.$dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
}
|
||||
//指派单明细上的称重时间
|
||||
curSample.value.measureTime = nx.$dayjs.format('yyyy-MM-dd hh:mm:ss')
|
||||
curSample.value.measureTime = nx.$dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
//计算
|
||||
try {
|
||||
calcAnalysisValue(fieldGroup.value)
|
||||
@@ -662,92 +620,36 @@ const saveAuncelData = () => {
|
||||
}, 100)
|
||||
}
|
||||
|
||||
const checkSubmit = () => {
|
||||
//检查必填字段
|
||||
let fieldNames = ''
|
||||
for (const g of fieldGroup.value) {
|
||||
for (const f of g.fields) {
|
||||
let name = f.shortName
|
||||
if (name === null || name === '') name = f.name
|
||||
if (f.allowNull === 1 || f.allowNull === '1') continue
|
||||
if (f.value === null || f.value === '') {
|
||||
fieldNames += name + ','
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fieldNames !== '') {
|
||||
nx.$helper.showToast({
|
||||
title: '请填写必填字段:' + fieldNames
|
||||
})
|
||||
return false
|
||||
}
|
||||
//检查不能为0的字段
|
||||
fieldNames = ''
|
||||
for (const g of fieldGroup.value) {
|
||||
for (const f of g.fields) {
|
||||
let name = f.shortName
|
||||
if (name === null || name === '') name = f.name
|
||||
//检查不可为0的数据
|
||||
if (f.notZero === 1 || f.notZero === '1') {
|
||||
if (f.value === null || f.value === '' || number(f.value) === 0) {
|
||||
fieldNames += name + ','
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fieldNames !== '') {
|
||||
nx.$helper.showToast({
|
||||
title: '这几个值不能为0,请检查:' + fieldNames
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const saveDetail = () => {
|
||||
const saveDetail = async () => {
|
||||
//检查杯号
|
||||
if (!checkBh()) return
|
||||
const valueList = []
|
||||
let cupNum = 0
|
||||
let detailId = currentSample.value.id
|
||||
for (const g of fieldGroup.value) {
|
||||
for (const f of g.fields) {
|
||||
if (f.dicKey === 'bh' || f.dicKey === 'bh_up') cupNum = f.value
|
||||
valueList.push({
|
||||
id: f.detailId,
|
||||
type: f.pOrE,
|
||||
value: f.value,
|
||||
name: f.name,
|
||||
dataType: f.dataType
|
||||
})
|
||||
let params = {
|
||||
businessAssayTaskId: taskId.value,
|
||||
datas: sampleDataList
|
||||
}
|
||||
setValueToSample()
|
||||
await nx.$api.assayTask.saveDetailValue(params)
|
||||
|
||||
autoNextSample()
|
||||
}
|
||||
// 把字段值保存回样品数据中
|
||||
function setValueToSample() {
|
||||
let fields = fieldGroup.value.flatMap(item => item.fields)
|
||||
fields.forEach(item => {
|
||||
if (sampleDataList[currentSampleDataIndex.value].hasOwnProperty(item.fieldIndex)) {
|
||||
sampleDataList[currentSampleDataIndex.value][item.fieldIndex].value = item.value
|
||||
}
|
||||
// 初始化的时候保存杯号到样品中后续自动生成杯号用
|
||||
if (item.title === cupNumKey && currentSampleIndex.value == 0) {
|
||||
leftList.value[currentSampleIndex.value].cupNum = item.value
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
busSubCSampleId: busSubCSampleId.value,
|
||||
conAssayTaskId: conAssayTaskId.value,
|
||||
measureTime: curSample.value.measureTime,
|
||||
elementParamValueList: valueList,
|
||||
busAssayTaskDetailId: detailId
|
||||
}
|
||||
if (typeof cupNum !== 'undefined' && cupNum !== null && cupNum !== '' && cupNum !== 0 && cupNum !== '0') {
|
||||
//提交杯号,保存到后台
|
||||
data.cupNum = cupNum
|
||||
//标记当前杯号
|
||||
markCurCupNum(cupNum)
|
||||
}
|
||||
nx.$api.assayTask.saveDetailValue(data).then(res => {
|
||||
//如果仅保存,在这里触发切换
|
||||
setTimeout(() => {
|
||||
autoNextSample()
|
||||
}, 1000)
|
||||
})
|
||||
}
|
||||
|
||||
//提交任务指派单
|
||||
const submitTask = () => {
|
||||
const data = {
|
||||
taskNo: currentTaskNo.value
|
||||
const params = {
|
||||
businessAssayTaskId: taskId.value
|
||||
}
|
||||
const msg = '请确认所有样品数据都已保存,然后再提交指派单!是否继续?'
|
||||
uni.showModal({
|
||||
@@ -758,7 +660,7 @@ const submitTask = () => {
|
||||
success: res => {
|
||||
if (res.cancel) return
|
||||
|
||||
nx.$api.assayTask.submitTask(data).then(res => {
|
||||
nx.$api.assayTask.submitTask(params).then(res => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/analysis/sample/sample-report'
|
||||
})
|
||||
@@ -769,37 +671,24 @@ const submitTask = () => {
|
||||
|
||||
//自动生成杯号(仅顺序称重):第一杯:手填,后续杯 = 上一杯 + 1
|
||||
const autoGenerateCupNum = () => {
|
||||
if (!orderGenBH.value) return
|
||||
let cupNum = 0
|
||||
|
||||
let current = current.value
|
||||
if (typeof current === 'undefined' || current === null) current = 0
|
||||
let current = currentSampleIndex.value
|
||||
//第一杯
|
||||
if (current === 0) {
|
||||
cupNum = 1
|
||||
putCupNum(cupNum)
|
||||
return
|
||||
}
|
||||
if (current === 0) return
|
||||
//取上一个样品的杯号
|
||||
const sample = leftList.value[current - 1]
|
||||
cupNum = sample.cupNum
|
||||
if (typeof cupNum === 'undefined' || cupNum === null || cupNum === '') return
|
||||
//杯号赋值到当前样品
|
||||
putCupNum(Number(cupNum) + 1, current, Number(cupNum))
|
||||
}
|
||||
|
||||
const markCurCupNum = cupNum => {
|
||||
currentSample.value.cupNum = cupNum
|
||||
}
|
||||
|
||||
const putCupNum = (cupNum, sampleIndex, lastCupNum) => {
|
||||
if (typeof sampleIndex === 'undefined' || sampleIndex === null) sampleIndex = 0
|
||||
const cupNumKey = 'bh'
|
||||
leftList.value[sampleIndex].cupNum = cupNum
|
||||
for (const fields of fieldGroup.value) {
|
||||
if (typeof fields === 'undefined') continue
|
||||
//杯号
|
||||
for (const field of fields.fields) {
|
||||
if (field.dicKey === cupNumKey) {
|
||||
if (field.title === cupNumKey) {
|
||||
if (typeof field.value === 'undefined' || field.value === null || field.value === '') {
|
||||
field.value = cupNum
|
||||
return true
|
||||
@@ -865,27 +754,48 @@ const loadConRecoveryList = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const getAssayTaskDetail = taskNo => {
|
||||
const getAssayTaskSampleList = businessAssayTaskId => {
|
||||
leftList.value = []
|
||||
nx.$api.assayTask
|
||||
.getAssayTaskDetailListByTaskNo({ taskNo: taskNo })
|
||||
.getAssayTaskDataList({ businessAssayTaskId })
|
||||
.then(res => {
|
||||
let dataList = res.result
|
||||
dataList.forEach((item, index) => {
|
||||
leftList.value.push(item)
|
||||
})
|
||||
if (leftList.value.length === 0) {
|
||||
return
|
||||
}
|
||||
current.value = 0
|
||||
leftList.value = res
|
||||
currentSampleIndex.value = 0
|
||||
currentSample.value = leftList.value[0]
|
||||
getDetailFieldsAndStatus(true)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
})
|
||||
}
|
||||
|
||||
async function getSampleAnalysisByTaskId(businessAssayTaskId) {
|
||||
const data = await nx.$api.assayTask.getSampleAnalysisByTaskId(businessAssayTaskId)
|
||||
sampleDataList = data.datas
|
||||
let columns = data.columns.filter(item => item.paramNo)
|
||||
fieldGroup.value = [{ open: true, fields: columns, title: '样品分析' }]
|
||||
setValueToField()
|
||||
title.value = '样品分析-任务指派单:' + data.businessAssayTasNo
|
||||
getDomHeight()
|
||||
autoNextField()
|
||||
}
|
||||
// 设置字段值
|
||||
function setValueToField() {
|
||||
for (const group of fieldGroup.value) {
|
||||
group.fields.forEach(field => {
|
||||
let value = getFieldValue(field)
|
||||
field.value = value
|
||||
})
|
||||
}
|
||||
}
|
||||
function getFieldValue(field) {
|
||||
const fieldValue = sampleDataList[currentSampleDataIndex.value][field.fieldIndex].value
|
||||
if (fieldValue) {
|
||||
return fieldValue
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
const apiRequest = async url => {
|
||||
return request({
|
||||
url: url,
|
||||
@@ -948,11 +858,11 @@ const listenDeviceData = () => {
|
||||
uni.$on('deviceData', res => {
|
||||
switch (res.deviceType) {
|
||||
case 'balance':
|
||||
if (currentAuncel.id === res.deviceId) {
|
||||
currentAuncel.weightData = res.weightData
|
||||
currentAuncel.weightUnit = res.weightUnit
|
||||
currentAuncel.weightStable = res.weightStable
|
||||
currentAuncel.isConnected = 1
|
||||
if (currentAuncel.value.id === res.deviceId) {
|
||||
currentAuncel.value.weightData = res.weightData
|
||||
currentAuncel.value.weightUnit = res.weightUnit
|
||||
currentAuncel.value.weightStable = res.weightStable
|
||||
currentAuncel.value.isConnected = true
|
||||
if (Number(res.weightData) === 0) {
|
||||
weightDataIsToZero.value = true
|
||||
}
|
||||
@@ -964,34 +874,34 @@ const listenDeviceData = () => {
|
||||
})
|
||||
//设备状态
|
||||
uni.$on('deviceStatus', res => {
|
||||
if (currentAuncel.id === res.deviceId) {
|
||||
if (currentAuncel.value.id === res.deviceId) {
|
||||
if (res.connected === 0) {
|
||||
currentAuncel.weightStable = 0
|
||||
currentAuncel.weightData = '天平断开'
|
||||
currentAuncel.weightUnit = ''
|
||||
currentAuncel.value.weightStable = 0
|
||||
currentAuncel.value.weightData = '天平断开'
|
||||
currentAuncel.value.weightUnit = ''
|
||||
}
|
||||
}
|
||||
currentAuncel.isConnected = res.connected
|
||||
currentAuncel.value.isConnected = res.connected
|
||||
})
|
||||
//控制设备状态
|
||||
uni.$on('controlDevice', res => {
|
||||
if (currentAuncel.id === res.deviceId) {
|
||||
currentAuncel.id = ''
|
||||
currentAuncel.name = ''
|
||||
currentAuncel.code = ''
|
||||
currentAuncel.weightStable = 0
|
||||
currentAuncel.weightData = '请选天平'
|
||||
currentAuncel.weightUnit = ''
|
||||
if (currentAuncel.value.id === res.deviceId) {
|
||||
currentAuncel.value.id = ''
|
||||
currentAuncel.value.name = ''
|
||||
currentAuncel.value.code = ''
|
||||
currentAuncel.value.weightStable = 0
|
||||
currentAuncel.value.weightData = '请选天平'
|
||||
currentAuncel.value.weightUnit = ''
|
||||
}
|
||||
})
|
||||
//连接断开
|
||||
uni.$on('connClose', res => {
|
||||
//重置
|
||||
currentAuncel.weightData = ''
|
||||
currentAuncel.weightUnit = ''
|
||||
currentAuncel.weightStable = 0
|
||||
currentAuncel.controlUserName = ''
|
||||
currentAuncel.isConnected = 0
|
||||
currentAuncel.value.weightData = ''
|
||||
currentAuncel.value.weightUnit = ''
|
||||
currentAuncel.value.weightStable = 0
|
||||
currentAuncel.value.controlUserName = ''
|
||||
currentAuncel.value.isConnected = false
|
||||
})
|
||||
}
|
||||
const closeDeviceListener = () => {
|
||||
@@ -1025,22 +935,21 @@ const listenNumKeyboard = () => {
|
||||
return
|
||||
}
|
||||
//自动补全小数位数
|
||||
const dataType = selectedField.value.dataType || 0
|
||||
const decimalPosition = selectedField.value.decimalPosition || 0
|
||||
let val = res.val
|
||||
//判断val小数位,如果小于设定位数,则补全
|
||||
if (dataType > 0) {
|
||||
if (decimalPosition > 0) {
|
||||
if (val === '') val = '0'
|
||||
if (typeof val === 'number') val += ''
|
||||
let dotLen = 0
|
||||
if (val.indexOf('.') > 0) dotLen = val.length - val.indexOf('.') - 1
|
||||
else val += '.'
|
||||
while (dotLen < dataType) {
|
||||
while (dotLen < decimalPosition) {
|
||||
dotLen++
|
||||
val += '0'
|
||||
}
|
||||
}
|
||||
selectedField.value.value = val
|
||||
selectedField.value.valueTypeManual = '1' //标记为手动值,不参与计算
|
||||
const dicKey = selectedField.value.dicKey
|
||||
if (dicKey && dicKey === 'bh_down') {
|
||||
autoFillBhUp(val)
|
||||
@@ -1057,7 +966,7 @@ const closeNumKeyBoardListener = () => {
|
||||
}
|
||||
|
||||
const closeDeviceLink = () => {
|
||||
const deviceId = currentAuncel.id
|
||||
const deviceId = currentAuncel.value.id
|
||||
releaseDeviceControl(deviceId)
|
||||
}
|
||||
|
||||
@@ -1078,11 +987,6 @@ const releaseDeviceControl = deviceId => {
|
||||
nx.$measure.send(JSON.stringify(controlDevice))
|
||||
}
|
||||
|
||||
const getDataSourceTypeShow = val => {
|
||||
if (val === 2) return '【筛上】'
|
||||
if (val === 3) return '【筛下】'
|
||||
return ''
|
||||
}
|
||||
// 天平选择
|
||||
const selectAuncel = () => {
|
||||
showAuncelSelector.value = true
|
||||
@@ -1091,26 +995,22 @@ const selectAuncel = () => {
|
||||
const auncelDoSelect = res => {
|
||||
const data = res.data
|
||||
if (data) {
|
||||
currentAuncel.id = data.deviceId
|
||||
currentAuncel.name = data.deviceName
|
||||
currentAuncel.code = data.deviceCode
|
||||
currentAuncel.value.id = data.deviceId
|
||||
currentAuncel.value.name = data.deviceName
|
||||
currentAuncel.value.code = data.deviceCode
|
||||
}
|
||||
}
|
||||
// refs
|
||||
const myKeyboard = ref(null)
|
||||
const auncelSelector = ref(null)
|
||||
|
||||
// 生命周期
|
||||
const { lockOrientation } = useScreenOrientation()
|
||||
|
||||
onLoad(param => {
|
||||
lockOrientation('landscape')
|
||||
if (param.currentTaskNo) {
|
||||
currentTaskNo.value = param.currentTaskNo
|
||||
currentTaskType.value = param.currentTaskType
|
||||
if (param.currentTaskId) {
|
||||
taskId.value = param.currentTaskId
|
||||
getAssayTaskSampleList(taskId.value)
|
||||
getSampleAnalysisByTaskId(taskId.value)
|
||||
}
|
||||
title.value = '样品分析-任务指派单:' + param.currentTaskNo
|
||||
getAssayTaskDetail(currentTaskNo.value)
|
||||
loadFieldApiData(fieldGroup.value)
|
||||
listenNumKeyboard()
|
||||
})
|
||||
@@ -1163,10 +1063,14 @@ onBackPress(() => {
|
||||
margin-bottom: 10px;
|
||||
height: 35px;
|
||||
font-size: 13px;
|
||||
border-bottom: 1px solid #dcdcdc;
|
||||
}
|
||||
.selected-field {
|
||||
background-color: #bada55;
|
||||
}
|
||||
.disabled-field {
|
||||
background-color: #eee;
|
||||
}
|
||||
.label-my {
|
||||
flex: 5;
|
||||
}
|
||||
@@ -1191,6 +1095,7 @@ onBackPress(() => {
|
||||
.content-my {
|
||||
flex: 2;
|
||||
text-align: right;
|
||||
padding-right: 4px;
|
||||
.select-my {
|
||||
color: #303133;
|
||||
font-size: 15px;
|
||||
@@ -1216,11 +1121,10 @@ onBackPress(() => {
|
||||
.u-tab-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
font-size: 16px;
|
||||
color: #444;
|
||||
font-weight: 400;
|
||||
padding: 4px 0;
|
||||
padding: 4px 8px;
|
||||
box-sizing: border-box;
|
||||
border-bottom: 2px dotted #444;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user