Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 08b82f02e3 | |||
|
|
da01e1efcd | ||
|
|
e10c70e819 |
@@ -7,7 +7,7 @@
|
||||
<span>{{ title }}</span>
|
||||
</view>
|
||||
<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>
|
||||
<!-- #ifdef H5 -->
|
||||
<up-search
|
||||
@@ -47,6 +47,14 @@ function iconMap(key) {
|
||||
return customIconsMap.get(key)
|
||||
}
|
||||
|
||||
function handleScan() {
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
success: function (res) {
|
||||
emits('scanResult', res.result)
|
||||
}
|
||||
})
|
||||
}
|
||||
function handleInputSearch(e) {
|
||||
emits('deviceId', e)
|
||||
}
|
||||
|
||||
@@ -2,26 +2,26 @@ import request from '@/nx/request'
|
||||
export default {
|
||||
queryById: id =>
|
||||
request({
|
||||
url: '/lims/bus/deviceBusMaintain/getMaintainDetail',
|
||||
url: '/qms/resource/device-maintain/getMaintainDetail',
|
||||
method: 'GET',
|
||||
params: { id }
|
||||
}),
|
||||
list: params =>
|
||||
request({
|
||||
url: '/lims/bus/deviceBusMaintain/list',
|
||||
url: '/qms/resource/device-maintain/page',
|
||||
method: 'GET',
|
||||
params
|
||||
}),
|
||||
// 根据设备id或者维护和点检记录
|
||||
getCheckRecord: data =>
|
||||
request({
|
||||
url: '/lims/bus/deviceBusMaintain/createOrGet',
|
||||
url: '/qms/resource/device-maintain/createOrGet',
|
||||
method: 'POST',
|
||||
data
|
||||
}),
|
||||
submit: data =>
|
||||
request({
|
||||
url: '/lims/bus/deviceBusMaintain/saveMaintainVo',
|
||||
url: '/qms/resource/device-maintain/saveMaintainVo',
|
||||
method: 'POST',
|
||||
data,
|
||||
custom: {
|
||||
@@ -30,13 +30,13 @@ export default {
|
||||
}),
|
||||
getLastDailyCheckOfToday: params =>
|
||||
request({
|
||||
url: '/lims/bus/deviceBusMaintain/getLastDailyCheckOfToday',
|
||||
url: '/qms/resource/device-maintain/getLastDailyCheckOfToday',
|
||||
method: 'GET',
|
||||
params,
|
||||
}),
|
||||
createDailyCheck: data =>
|
||||
request({
|
||||
url: '/lims/bus/deviceBusMaintain/create',
|
||||
url: '/qms/resource/device-maintain/create',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
|
||||
@@ -60,14 +60,17 @@ const Get_C_KNO3_bySValue = function (sValue, weight, operator) {
|
||||
|
||||
return ''
|
||||
}
|
||||
const Get_C_KNO3 = function (sValue, weight, operator) {
|
||||
const Get_C_KNO3 = function (weight, sValue, operator) {
|
||||
//判断sValue是数字
|
||||
const S = number(sValue)
|
||||
const W = number(weight)
|
||||
console.log(S, W)
|
||||
|
||||
if (sValue === 0 || weight === 0) {
|
||||
//如果样重为0就不计算
|
||||
if (W === 0) {
|
||||
console.log('结束')
|
||||
return ''
|
||||
}
|
||||
let S = number(sValue)
|
||||
const W = number(weight)
|
||||
if (W === 0) return ''
|
||||
const V = ((W * S) / 100) * 22 - 75
|
||||
if (operator === '<' && V < 0) {
|
||||
|
||||
511
nx/helper/calcAnalysisValue.js.bak
Normal file
511
nx/helper/calcAnalysisValue.js.bak
Normal file
@@ -0,0 +1,511 @@
|
||||
import { create, all, number, pow } from 'mathjs'
|
||||
import parseSafeArgs from './parseSafeArgs'
|
||||
const math = create(all)
|
||||
math.config({
|
||||
number: 'BigNumber',
|
||||
precision: 64
|
||||
})
|
||||
export { math }
|
||||
|
||||
const GetRecoveryRate = function (elementFormulaCode, value) {
|
||||
// //读取conRecoveryRateList
|
||||
const conRecoveryRateList = uni.getStorageSync('ConRecoveryRateList')
|
||||
if (!conRecoveryRateList) return
|
||||
let o = conRecoveryRateList.find(i => {
|
||||
//console.log("取得的" + i + "回收率:" + i);
|
||||
if (value === 0) {
|
||||
return i.elementFormulaCode === elementFormulaCode && i.minValue === value
|
||||
}
|
||||
return i.elementFormulaCode === elementFormulaCode && i.minValue < value && value <= i.maxValue
|
||||
})
|
||||
// console.log(o);
|
||||
const rate = o ? o.rate : 100
|
||||
// console.log("取得的" + elementFormulaCode + "回收率:" + rate);
|
||||
return rate
|
||||
// console.log("执行方法:GetRecoveryRate");
|
||||
// return 100;
|
||||
}
|
||||
/*
|
||||
* 根据硫值计算:支持碳、硝酸钾(滇中)
|
||||
* 当S%<22%时,需加入淀粉的量=(75-S%*22*M)/12
|
||||
* 当 S%>22%时,需加入硝酸钾的量=(S%*22*M-75)/4
|
||||
* 当 S%==22%时,硝酸钾为0,淀粉为空
|
||||
* sValueKey:硫值对应的dicKey
|
||||
* weightKey:重量对应的dicKey
|
||||
* percent:计算参数
|
||||
*
|
||||
* 举例:Get_C_KNO3_bySValue|(|p14|, |p2|, |>|)
|
||||
* */
|
||||
const Get_C_KNO3_bySValue = function (sValue, weight, operator) {
|
||||
//判断sValue是数字
|
||||
if (isNaN(sValue) || isNaN(weight)) {
|
||||
return ''
|
||||
}
|
||||
let v = number(sValue)
|
||||
const w = number(weight)
|
||||
if (w === 0) return ''
|
||||
v = v * 0.01
|
||||
//当S%<22%时,需加入淀粉的量=(75-S%*22*M)/12
|
||||
if (operator === '<' && v < 0.22) {
|
||||
// return ( 75 - v * 22 * w )/12;
|
||||
return accDiv(accSub(75, accMul(accMul(v, 22), w)), 12)
|
||||
}
|
||||
//S%>22%时,需加入硝酸钾的量=(S%*22*M-75)/4
|
||||
if (operator === '>=' && v >= 0.22) {
|
||||
//S%==22%时,硝酸钾为0,淀粉为空
|
||||
if (v === 22) return 0
|
||||
// return ( v * 22 * w - 75 ) + 44;
|
||||
return accDiv(accSub(accMul(v, accMul(22, w)), 75), 4)
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
const Get_C_KNO3 = function (weight, sValue, operator) {
|
||||
//判断sValue是数字
|
||||
const S = number(sValue)
|
||||
const W = number(weight)
|
||||
//如果样重为0就不计算
|
||||
if (W === 0) {
|
||||
return ''
|
||||
}
|
||||
if (W === 0) return ''
|
||||
const V = ((W * S) / 100) * 22 - 75
|
||||
if (operator === '<' && V < 0) {
|
||||
return math.abs(V / 12)
|
||||
}
|
||||
if (operator === '>=' && V >= 0) {
|
||||
return V / 4
|
||||
}
|
||||
return ''
|
||||
}
|
||||
const FORMULA_FUNCTIONS = {
|
||||
GetRecoveryRate,
|
||||
Get_C_KNO3_bySValue,
|
||||
Get_C_KNO3
|
||||
}
|
||||
/*
|
||||
* 计算当前样品分析值*/
|
||||
export function calcAnalysisValue(group, externalFormData, taskIngredientsWay) {
|
||||
const MAX_ITERATIONS = 5 // 防止无限循环
|
||||
let iterations = 0
|
||||
let changed = true
|
||||
while (changed && iterations < MAX_ITERATIONS) {
|
||||
changed = false
|
||||
iterations++
|
||||
try {
|
||||
for (const g of group) {
|
||||
for (const ele of g.fields) {
|
||||
if (!ele.formula || ele.formula == '' || ele.formula.startsWith('From')) continue
|
||||
let formula = ele.formula
|
||||
let formulas = formula.split('|')
|
||||
let formulaVal = ''
|
||||
formulas.forEach(f => {
|
||||
let value = ''
|
||||
if (f.charAt(0) === 'p') {
|
||||
let o = findFieldInGroup(f, group, 'p')
|
||||
value = o.value || 0
|
||||
} else if (f.charAt(0) === 'e') {
|
||||
let o = findFieldInGroup(f, group, 'e')
|
||||
value = o.value || 0
|
||||
} else if (f.charAt(0) === '<' || f.charAt(0) === '>') {
|
||||
value = "'" + f + "'"
|
||||
} else {
|
||||
value = f
|
||||
}
|
||||
|
||||
formulaVal += value
|
||||
})
|
||||
|
||||
let v = ''
|
||||
if (formulaVal.startsWith('Get_')) {
|
||||
//计算公式为Get开头的,都是执行方法,只有人工配料才执行
|
||||
if (taskIngredientsWay !== 'manual') continue
|
||||
v = eval(formulaVal)
|
||||
} else if (formulaVal.startsWith('GetFrom')) {
|
||||
v = evaluateGetFromFormula(formulaVal, false, externalFormData)
|
||||
} else {
|
||||
v = math.evaluate(formulaVal).toString()
|
||||
v = isFinite(v) ? v.toString() : 0
|
||||
}
|
||||
ele.value = handleRoundFiveNumber(v, ele.decimalPosition, ele.type === 'project')
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// parse: 是否解析公式
|
||||
export function evaluateGetFromFormula(formula, parse, externalFormData, currentColumn, row, dynamicsColumns) {
|
||||
let formulaVal = formula
|
||||
if (parse) {
|
||||
formulaVal = parseFormula(formulaVal, row, dynamicsColumns)
|
||||
}
|
||||
let relFormulaVal = formulaVal.split(':')[1]
|
||||
for (const [key, value] of Object.entries(externalFormData)) {
|
||||
if (relFormulaVal.includes(key)) {
|
||||
relFormulaVal = relFormulaVal.replace(key, value || 0)
|
||||
}
|
||||
}
|
||||
try {
|
||||
let v = math.evaluate(relFormulaVal).toString()
|
||||
v = isFinite(v) ? v : 0
|
||||
if (parse) {
|
||||
return handleRoundFiveNumber(v, currentColumn.decimalPosition, currentColumn.type === 'project')
|
||||
}
|
||||
return v
|
||||
} catch (e) {
|
||||
console.warn('GetFrom formula evaluate error:', relFormulaVal, e)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
// 解析公式
|
||||
function parseFormula(formula, row, dynamicsColumns) {
|
||||
let formulas = formula.split('|')
|
||||
let formulaVal = ''
|
||||
formulas.forEach(f => {
|
||||
if (f.charAt(0) === 'p') {
|
||||
let o = dynamicsColumns.find(i => 'p' + i.paramNo === f && i.type !== 'project')
|
||||
const currentColumnData = row[o.fieldIndex]
|
||||
formulaVal += currentColumnData.value ? currentColumnData.value : 0
|
||||
} else if (f.charAt(0) === 'e') {
|
||||
let o = dynamicsColumns.find(i => 'e' + i.paramNo === f)
|
||||
formulaVal += row[o.fieldIndex]?.value ? row[o.fieldIndex].value : 0
|
||||
} else {
|
||||
formulaVal += f
|
||||
}
|
||||
})
|
||||
return formulaVal
|
||||
}
|
||||
// 根据样品和配置列计算分析值
|
||||
export function calcRowAnalysisValue(row, columnObj, dynamicsColumns, externalFormData, taskIngredientsWay) {
|
||||
if (!columnObj.paramNo || !row[columnObj.fieldIndex]) return
|
||||
|
||||
for (let i = 0; i < dynamicsColumns.length; i++) {
|
||||
let curItem = dynamicsColumns[i]
|
||||
if (curItem.fieldIndex === columnObj.fieldIndex) continue
|
||||
|
||||
let param = columnObj.fieldIndex.charAt(0) === 'p' ? 'p' + columnObj.paramNo : 'e' + columnObj.paramNo
|
||||
if (curItem.formula && curItem.formula.includes(param)) {
|
||||
let formula = curItem.formula
|
||||
let formulaVal = parseFormula(formula, row, dynamicsColumns)
|
||||
let v
|
||||
if (formulaVal.startsWith('Get_')) {
|
||||
if (taskIngredientsWay !== 'manual') continue
|
||||
const match = formulaVal.match(/^([a-zA-Z_]\w*)\((.*)\)$/)
|
||||
const funcName = match[1]
|
||||
const argsStr = match[2].trim()
|
||||
const func = FORMULA_FUNCTIONS[funcName]
|
||||
// 安全解析参数(支持数字、字符串)
|
||||
const args = parseSafeArgs(argsStr)
|
||||
v = func(...args)
|
||||
} else if (formulaVal.startsWith('GetFrom')) {
|
||||
v = evaluateGetFromFormula(formulaVal, false, externalFormData)
|
||||
} else {
|
||||
v = math.evaluate(formulaVal).toString()
|
||||
v = isFinite(v) ? v : 0
|
||||
}
|
||||
let rowObj = row[curItem.fieldIndex]
|
||||
rowObj.value = handleRoundFiveNumber(Number(v), rowObj.decimalPosition, rowObj.type === 'project')
|
||||
calcRowAnalysisValue(row, curItem, dynamicsColumns, externalFormData)
|
||||
}
|
||||
}
|
||||
}
|
||||
const findFieldInGroup = function (paramNo, group, p) {
|
||||
for (const g of group) {
|
||||
for (const f of g.fields) {
|
||||
if (p === 'p' && f.type == 'project') continue
|
||||
if (p + f.paramNo === paramNo) {
|
||||
return f
|
||||
}
|
||||
}
|
||||
}
|
||||
return { value: null }
|
||||
}
|
||||
|
||||
/** 处理数值数据:四舍六入奇进偶不进
|
||||
* 1,如果取小数的最后一位为5,5前为奇数进位,为偶不进,五后非零就进一,五后皆零看奇偶,五前为偶应舍去,五前为奇要进一
|
||||
* 2.5后不为0时就入,为0时看5前,奇进偶不进
|
||||
* 3.四舍,六入
|
||||
* 传入数值和保留位数
|
||||
*/
|
||||
export function handleRoundFiveNumber(number, fixed = 0, useTwoSignificantDigits = false) {
|
||||
if (number == null || number === '' || isNaN(number)) return number
|
||||
if (fixed === -1) return number
|
||||
number = String(number)
|
||||
//可以考虑清掉末尾的0,暂时限制了不会有,因为传入数值,末尾0是去掉的
|
||||
// 保留2位有效数字:小数点后面大于0的才叫有效数字,从小数点后面查找两位有效数字 ,如果末尾的有效数字的位数大于所设置的精度 以及 如果查找的有效数字没有两位的 ,就按照所设置的精度逻辑来计算,两位有效数字的最后 一位是在第几位,就用这个位数充当精度来按照原来精度的逻辑计算,
|
||||
// ===== 新增:按小数点后前两个非零数字确定精度 =====
|
||||
let actualFixed = fixed
|
||||
if (useTwoSignificantDigits) {
|
||||
const numStr = String(number)
|
||||
const dotIndex = numStr.indexOf('.')
|
||||
|
||||
if (dotIndex !== -1) {
|
||||
const decimalPart = numStr.slice(dotIndex + 1)
|
||||
let nonZeroCount = 0
|
||||
let secondNonZeroPos = -1
|
||||
|
||||
for (let i = 0; i < decimalPart.length; i++) {
|
||||
if (decimalPart[i] !== '0') {
|
||||
nonZeroCount++
|
||||
if (nonZeroCount === 2) {
|
||||
secondNonZeroPos = i + 1 // 小数点后第几位(从1开始)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 只有同时满足:
|
||||
// 1. 找到两个非零数字
|
||||
// 2. 第二个的位置 <= 用户指定的 fixed
|
||||
// 才使用该位置作为精度
|
||||
if (secondNonZeroPos !== -1 && secondNonZeroPos <= fixed) {
|
||||
actualFixed = secondNonZeroPos
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(actualFixed)
|
||||
const index = number.indexOf('.')
|
||||
if (index == -1) {
|
||||
if (actualFixed > 0) {
|
||||
number += '.'
|
||||
}
|
||||
for (let i = 0; i < actualFixed; i++) {
|
||||
number += '0'
|
||||
}
|
||||
//补0返回
|
||||
return number
|
||||
}
|
||||
//取到保留小数位的下一位,5.5555取保留俩位,那就是小数点后第三位
|
||||
const indexFixed = index + actualFixed + 1
|
||||
if (indexFixed >= number.length) {
|
||||
//如果小数位数不够, 补0直接返回
|
||||
const zerolen = indexFixed - number.length
|
||||
for (let i = 0; i < zerolen; i++) {
|
||||
number += '0'
|
||||
}
|
||||
return number
|
||||
}
|
||||
//取保留位数的后一位做判断,以下是有5的判断
|
||||
const endNumber = number.substr(indexFixed, 1)
|
||||
if (endNumber != '5') {
|
||||
//如果做判断的数不是五,就按正常的四舍五入,即忽略了5,后面补0的那些由于是数字传进来,0已经去掉,此处不做处理
|
||||
return Number(number).toFixed(actualFixed)
|
||||
}
|
||||
if (indexFixed != number.length - 1) {
|
||||
//由于当前判断位不是最后一位,而又去除了0,那么后面后的位数应该直接入位,五后不为0时入,由于会有小于五的,四舍五入肯定不行,那么只能截取到当前保留位数,然后转成数字加上10的负fixed的次方即可
|
||||
number = number.substring(0, indexFixed)
|
||||
if (number.indexOf('-') != -1) {
|
||||
//需要考虑到负数的情况
|
||||
return (Number(number) - Number(Math.pow(10, -actualFixed))).toFixed(actualFixed)
|
||||
}
|
||||
return (Number(number) + Number(Math.pow(10, -actualFixed))).toFixed(actualFixed)
|
||||
//return this.accAdd(number,Math.pow(10,-fixed))
|
||||
}
|
||||
//接下来就时五后没有值也就是0的需要看前面的奇入偶不入了,取当前位的上一位
|
||||
let twoNumber = number.substr(indexFixed - 1, 1)
|
||||
if (twoNumber == '.') {
|
||||
//取到小数点,再取一次,要取到小数点左边第一位
|
||||
twoNumber = number.substr(indexFixed - 2, 1)
|
||||
}
|
||||
if ('13579'.indexOf(twoNumber) != -1) {
|
||||
//奇进
|
||||
number = number.substring(0, indexFixed)
|
||||
if (number.indexOf('-') != -1) {
|
||||
//需要考虑到负数的情况
|
||||
return (Number(number) - Math.pow(10, -actualFixed)).toFixed(actualFixed)
|
||||
}
|
||||
return (Number(number) + Math.pow(10, -actualFixed)).toFixed(actualFixed)
|
||||
}
|
||||
//偶不进,将取值的当前位数,直接截取字符即可
|
||||
return number.substr(0, indexFixed)
|
||||
}
|
||||
|
||||
/**
|
||||
** 除法函数,用来得到精确的除法结果
|
||||
** 说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
|
||||
** 调用:accDiv(arg1,arg2)
|
||||
** 返回值:arg1除以arg2的精确结果
|
||||
**/
|
||||
function accDiv(arg1, arg2) {
|
||||
var t1 = 0,
|
||||
t2 = 0,
|
||||
r1,
|
||||
r2
|
||||
try {
|
||||
t1 = arg1.toString().split('.')[1].length
|
||||
} catch (e) {}
|
||||
try {
|
||||
t2 = arg2.toString().split('.')[1].length
|
||||
} catch (e) {}
|
||||
r1 = Number(arg1.toString().replace('.', ''))
|
||||
r2 = Number(arg2.toString().replace('.', ''))
|
||||
return (r1 / r2) * pow(10, t2 - t1)
|
||||
}
|
||||
|
||||
/**
|
||||
** 乘法函数,用来得到精确的乘法结果
|
||||
** 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
|
||||
** 调用:accMul(arg1,arg2)
|
||||
** 返回值:arg1乘以 arg2的精确结果
|
||||
**/
|
||||
function accMul(arg1, arg2) {
|
||||
var m = 0,
|
||||
s1 = arg1.toString(),
|
||||
s2 = arg2.toString()
|
||||
try {
|
||||
m += s1.split('.')[1].length
|
||||
} catch (e) {}
|
||||
try {
|
||||
m += s2.split('.')[1].length
|
||||
} catch (e) {}
|
||||
return (Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / Math.pow(10, m)
|
||||
}
|
||||
|
||||
/**
|
||||
** 减法函数,用来得到精确的减法结果
|
||||
** 说明:javascript的减法结果会有误差,在两个浮点数相减的时候会比较明显。这个函数返回较为精确的减法结果。
|
||||
** 调用:accSub(arg1,arg2)
|
||||
** 返回值:arg1加上arg2的精确结果
|
||||
**/
|
||||
function accSub(arg1, arg2) {
|
||||
var r1, r2, m, n
|
||||
try {
|
||||
r1 = arg1.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r1 = 0
|
||||
}
|
||||
try {
|
||||
r2 = arg2.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r2 = 0
|
||||
}
|
||||
m = Math.pow(10, Math.max(r1, r2)) //last modify by deeka //动态控制精度长度
|
||||
n = r1 >= r2 ? r1 : r2
|
||||
return ((arg1 * m - arg2 * m) / m).toFixed(n)
|
||||
}
|
||||
|
||||
/**
|
||||
** 加法函数,用来得到精确的加法结果
|
||||
** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
|
||||
** 调用:accAdd(arg1,arg2)
|
||||
** 返回值:arg1加上arg2的精确结果
|
||||
**/
|
||||
function accAdd(arg1, arg2) {
|
||||
var r1, r2, m, c
|
||||
try {
|
||||
r1 = arg1.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r1 = 0
|
||||
}
|
||||
try {
|
||||
r2 = arg2.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r2 = 0
|
||||
}
|
||||
c = Math.abs(r1 - r2)
|
||||
m = Math.pow(10, Math.max(r1, r2))
|
||||
if (c > 0) {
|
||||
var cm = Math.pow(10, c)
|
||||
if (r1 > r2) {
|
||||
arg1 = Number(arg1.toString().replace('.', ''))
|
||||
arg2 = Number(arg2.toString().replace('.', '')) * cm
|
||||
} else {
|
||||
arg1 = Number(arg1.toString().replace('.', '')) * cm
|
||||
arg2 = Number(arg2.toString().replace('.', ''))
|
||||
}
|
||||
} else {
|
||||
arg1 = Number(arg1.toString().replace('.', ''))
|
||||
arg2 = Number(arg2.toString().replace('.', ''))
|
||||
}
|
||||
return (arg1 + arg2) / m
|
||||
}
|
||||
|
||||
// 通过配置项分组
|
||||
export function groupByField(list, cupNumFieldIndex, groupKey = 'groupDictionaryBusinessKey') {
|
||||
const groupMap = new Map()
|
||||
|
||||
// 插入“全部”项
|
||||
list.unshift({ groupDictionaryBusinessKey: 'all', groupDictionaryBusinessName: '全部' })
|
||||
|
||||
for (const item of list) {
|
||||
// 赋值杯号 fieldIndex
|
||||
if (item.title === '杯号') {
|
||||
cupNumFieldIndex.value = item.fieldIndex
|
||||
}
|
||||
|
||||
let key = item[groupKey]
|
||||
|
||||
// 如果没有有效 key,统一归入自定义分组
|
||||
if (!key) {
|
||||
key = 'customParameter' // 使用固定字符串作为无 key 项的分组标识
|
||||
}
|
||||
|
||||
// 如果该分组不存在,初始化
|
||||
if (!groupMap.has(key)) {
|
||||
groupMap.set(key, {
|
||||
value: key,
|
||||
label: key === 'customParameter' ? '分析项目' : item.groupDictionaryBusinessName || '未知分组',
|
||||
fields: []
|
||||
})
|
||||
}
|
||||
|
||||
// 将当前项加入对应分组
|
||||
groupMap.get(key).fields.push(item)
|
||||
}
|
||||
|
||||
return Array.from(groupMap.values())
|
||||
}
|
||||
|
||||
export function validateElementRange(fieldIndex, row, conRangeElementAnalysisList) {
|
||||
if (!conRangeElementAnalysisList?.length) return null
|
||||
const rangeElementAnalysis = conRangeElementAnalysisList.find(
|
||||
ele => ele.dictionaryProjectId === row[fieldIndex]?.dicId && row[fieldIndex]['type'] === 'project'
|
||||
)
|
||||
|
||||
if (!rangeElementAnalysis) return null
|
||||
|
||||
const val = row[fieldIndex]?.value
|
||||
|
||||
if (val == '' || val == null) return null
|
||||
const value = Number(val)
|
||||
|
||||
let result = { promptType: '', promptMsg: '' }
|
||||
|
||||
switch (Number(rangeElementAnalysis.rangeType)) {
|
||||
case 1:
|
||||
//如果值小于最小警告值或者大于最大警告值,则校验不通过
|
||||
if (value < rangeElementAnalysis.minimumWarningValue || value > rangeElementAnalysis.maximumWarningValue) {
|
||||
result.promptType = 'warning'
|
||||
result.promptMsg = `警告:值超出范围(${rangeElementAnalysis.minimumWarningValue} ~ ${rangeElementAnalysis.maximumWarningValue})`
|
||||
}
|
||||
break
|
||||
case 2:
|
||||
//如果值小于最小限制值或者大于最大限制值,则校验不通过
|
||||
if (value < rangeElementAnalysis.minimumValue || value > rangeElementAnalysis.maximumValue) {
|
||||
result.promptType = 'error'
|
||||
result.promptMsg = `错误:值超出范围(${rangeElementAnalysis.minimumValue} ~ ${rangeElementAnalysis.maximumValue})`
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
//如果值小于最小限制值或者大于最大限制值,则校验不通过
|
||||
if (value < rangeElementAnalysis.minimumValue || value > rangeElementAnalysis.maximumValue) {
|
||||
result.promptType = 'error'
|
||||
result.promptMsg = `错误:值超出范围(${rangeElementAnalysis.minimumValue} ~ ${rangeElementAnalysis.maximumValue})`
|
||||
} else if (
|
||||
(rangeElementAnalysis.minimumValue < value && value < rangeElementAnalysis.minimumWarningValue) ||
|
||||
(rangeElementAnalysis.maximumWarningValue < value && value <= rangeElementAnalysis.maximumValue)
|
||||
) {
|
||||
result.promptType = 'warning'
|
||||
result.promptMsg = `警告:值超出范围(${rangeElementAnalysis.minimumWarningValue} ~ ${rangeElementAnalysis.maximumWarningValue})`
|
||||
}
|
||||
break
|
||||
default:
|
||||
return null
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -54,9 +54,8 @@
|
||||
class="u-tab-item"
|
||||
:class="[currentSampleIndex === index ? 'u-tab-item-active' : '']"
|
||||
:data-current="index"
|
||||
@tap.stop="switchSample(index, false)"
|
||||
@tap.stop="switchSample(index)"
|
||||
>
|
||||
<!-- sample.rollbackStatus === 'in_progress' ? 'u-tab-item-disabled' : '' 退回disabled暂不显示 -->
|
||||
<u-badge type="warning" :value="index + 1"></u-badge>
|
||||
<view class="ml20">
|
||||
<view>
|
||||
@@ -151,18 +150,6 @@
|
||||
<view class="pt10">
|
||||
<scroll-view class="content-right-scroll" scroll-y scroll-with-animation :scroll-top="scrollFieldTop">
|
||||
<view>
|
||||
<!-- <template v-for="(fields, groupIndex) in fieldGroup" :key="'group_' + groupIndex"> -->
|
||||
<!-- <view> -->
|
||||
<!-- 组名 -->
|
||||
<!-- <view class="my-collapse" @click="fields.open = !fields.open">
|
||||
<text class="title">{{ fields.title }}</text>
|
||||
<u-icon :name="fields.open ? 'arrow-up' : 'arrow-down'"></u-icon>
|
||||
</view>
|
||||
<view
|
||||
class="content"
|
||||
:id="'elId' + groupIndex"
|
||||
:style="{ height: fields.open ? collaHeights[groupIndex] + 'px' : '0' }"
|
||||
> -->
|
||||
<up-collapse ref="collapseRef" :value="activeCollapses" :border="false">
|
||||
<template v-for="(fields, groupIndex) in currentGroup">
|
||||
<up-collapse-item v-if="fields.label !== '全部'">
|
||||
@@ -185,32 +172,6 @@
|
||||
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 == 'input'"
|
||||
v-model="field.value"
|
||||
placeholder="请输入"
|
||||
/> -->
|
||||
|
||||
<!-- <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>
|
||||
</view>
|
||||
<u-picker
|
||||
v-if="field.type === 'select'"
|
||||
:show="field.showPicker"
|
||||
:columns="[field.options]"
|
||||
keyName="dictValue"
|
||||
@cancel="field.showPicker = false"
|
||||
@confirm="event => dicPickerConfirm(event, field)"
|
||||
/> -->
|
||||
<!--普通输入框 使用文本显示-->
|
||||
<view class="content-my-text" v-if="field.dataType != 'select'">
|
||||
<text v-if="!field.value" class="content-my-text-placeholder">{{
|
||||
@@ -239,9 +200,6 @@
|
||||
</up-collapse-item>
|
||||
</template>
|
||||
</up-collapse>
|
||||
<!-- </view>
|
||||
</view> -->
|
||||
<!-- </template> -->
|
||||
</view>
|
||||
</scroll-view>
|
||||
<u-button class="btn-operation" type="success" @click="saveDetail()">保存样品数据</u-button>
|
||||
@@ -467,7 +425,7 @@ const autoNextSample = indexParam => {
|
||||
|
||||
if (sample.rollbackStatus !== 'in_progress') {
|
||||
// 找到了合法的样品,切换
|
||||
switchSample(index, true)
|
||||
switchSample(index)
|
||||
return
|
||||
}
|
||||
index++
|
||||
@@ -475,16 +433,7 @@ const autoNextSample = indexParam => {
|
||||
}
|
||||
|
||||
//手动切换样品
|
||||
const switchSample = async (index, autoFlag) => {
|
||||
// if (!autoFlag) {
|
||||
// const shouldContinue = await tools.showPromiseModal(
|
||||
// '提示',
|
||||
// `请确认样品【${currentSampleData.value.sampleCode}】数据已经保存,是否继续?`
|
||||
// )
|
||||
// if (!shouldContinue) {
|
||||
// return // 用户点了取消,直接退出
|
||||
// }
|
||||
// }
|
||||
const switchSample = async index => {
|
||||
//重置天平归0
|
||||
weightDataIsToZero.value = false
|
||||
if (index === currentSampleIndex.value) return
|
||||
@@ -991,9 +940,18 @@ function setValueToField() {
|
||||
field.value = value
|
||||
let symbol = getFieldSymbol(field)
|
||||
field.symbol = symbol
|
||||
if (!getField(field)) {
|
||||
field.hidden = 1
|
||||
} else {
|
||||
field.hidden = 0
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
function getField(field) {
|
||||
const fieldObj = currentSampleData.value[field.fieldIndex]
|
||||
return fieldObj
|
||||
}
|
||||
function getFieldValue(field) {
|
||||
const fieldValue = currentSampleData.value[field.fieldIndex]?.value
|
||||
if (fieldValue) {
|
||||
|
||||
1515
pages/analysis/sample/sample-work-detail.vue.bak
Normal file
1515
pages/analysis/sample/sample-work-detail.vue.bak
Normal file
File diff suppressed because it is too large
Load Diff
@@ -331,10 +331,10 @@ function checkPropertyEquality() {
|
||||
for (const column of allColumns) {
|
||||
const formula = column.formula
|
||||
if (!formula) continue
|
||||
for (const [key, value] of Object.entries(dynamicFormData.value)) {
|
||||
for (const [key, value] of Object.entries(realFormData.value)) {
|
||||
if (formula.includes(key)) {
|
||||
const originalValue = value
|
||||
const currentValue = realFormData.value[key]
|
||||
const currentValue = value
|
||||
const originalValue = dynamicFormData.value[key]
|
||||
if (!looseEqual(originalValue, currentValue)) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<view>
|
||||
<up-sticky>
|
||||
<navbar-back title="点检">
|
||||
<navbar-back title="设备巡检">
|
||||
<up-button
|
||||
v-if="detailInfo.id"
|
||||
type="primary"
|
||||
:plain="true"
|
||||
icon="list"
|
||||
size="small"
|
||||
text="设备点检记录"
|
||||
text="设备巡检记录"
|
||||
@click="handleCheckRecord"
|
||||
></up-button>
|
||||
</navbar-back>
|
||||
@@ -16,18 +16,19 @@
|
||||
<view class="container">
|
||||
<n-scanTemp
|
||||
v-if="!detailInfo.id"
|
||||
title="请扫描设备条码进行点检"
|
||||
title="请扫描设备条码进行巡检"
|
||||
icon="dailyCheck"
|
||||
@deviceId="id => getDailyCheckRecord(id)"
|
||||
@scanResult="result => handleScanResult(result)"
|
||||
/>
|
||||
<view v-else class="content">
|
||||
<view>
|
||||
<uni-section titleFontSize="22px" type="line" title="设备点检信息">
|
||||
<uni-section titleFontSize="22px" type="line" title="设备巡检信息">
|
||||
<template v-slot:right>
|
||||
<up-button
|
||||
v-if="detailInfo.submitFlag == '1'"
|
||||
type="success"
|
||||
text="新建点检"
|
||||
text="新建巡检"
|
||||
@click="handleCreateDailyCheck"
|
||||
></up-button>
|
||||
</template>
|
||||
@@ -43,7 +44,7 @@
|
||||
<view>
|
||||
<uni-section titleFontSize="22px" type="line" title="检查项"> </uni-section>
|
||||
<up-row class="p10 font-bold" style="background-color: #f5f5f5">
|
||||
<up-col span="4">点检项目</up-col>
|
||||
<up-col span="4">巡检项目</up-col>
|
||||
<up-col span="3">检查标准</up-col>
|
||||
<up-col span="2"> 频次</up-col>
|
||||
<up-col style="text-align: center" span="3">是否正常</up-col>
|
||||
@@ -75,10 +76,10 @@
|
||||
<up-textarea v-model="detailInfo.content" placeholder="请输入内容"></up-textarea>
|
||||
<view class="p10">附件照片:</view>
|
||||
<n-upload v-model="detailInfo.attachment" />
|
||||
<view class="p10">点检人:</view>
|
||||
<view class="p10">巡检人:</view>
|
||||
<up-input v-model="detailInfo.checkUserName"></up-input>
|
||||
<view v-if="detailInfo.submitFlag == '1'">
|
||||
<view class="p10">点检日期:</view>
|
||||
<view class="p10">巡检日期:</view>
|
||||
<uni-datetime-picker type="datetime" v-model="detailInfo.checkDate" />
|
||||
</view>
|
||||
</view>
|
||||
@@ -129,32 +130,37 @@ const { lockOrientation } = useScreenOrientation()
|
||||
|
||||
const pageLoading = ref(false)
|
||||
let detailInfo = ref({})
|
||||
|
||||
const { scanQRInfo } = toRefs(nx.$store('biz'))
|
||||
watch(scanQRInfo, newVal => {
|
||||
if (newVal && nx.$router.getCurrentPage().route == 'pages/device/deviceBusDailyCheck/index') {
|
||||
try {
|
||||
const codeObj = JSON.parse(newVal)
|
||||
function handleScanResult(result) {
|
||||
const codeObj = JSON.parse(result)
|
||||
if (!pageLoading.value) {
|
||||
getDailyCheckRecord(codeObj.id)
|
||||
}
|
||||
scanQRInfo.value = ''
|
||||
} catch (error) {
|
||||
scanQRInfo.value = ''
|
||||
uni.showToast({
|
||||
title: '请扫描设备码',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// const { scanQRInfo } = toRefs(nx.$store('biz'))
|
||||
// watch(scanQRInfo, newVal => {
|
||||
// if (newVal && nx.$router.getCurrentPage().route == 'pages/device/deviceBusDailyCheck/index') {
|
||||
// try {
|
||||
// const codeObj = JSON.parse(newVal)
|
||||
// if (!pageLoading.value) {
|
||||
// getDailyCheckRecord(codeObj.id)
|
||||
// }
|
||||
// scanQRInfo.value = ''
|
||||
// } catch (error) {
|
||||
// scanQRInfo.value = ''
|
||||
// uni.showToast({
|
||||
// title: '请扫描设备码',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
const modalText = computed(() => {
|
||||
return `确定${modalType.value == '0' ? '暂存' : '提交'}吗?${modalType.value == '0' ? '' : '提交后不能修改'} `
|
||||
})
|
||||
onShow(() => {
|
||||
scanQRInfo.value = ''
|
||||
})
|
||||
let goBack = ref(false)
|
||||
// onShow(() => {
|
||||
// scanQRInfo.value = ''
|
||||
// })
|
||||
let goBack = ref(false) //设备使用前进行点检操作标记
|
||||
onLoad(options => {
|
||||
if (options.deviceId) {
|
||||
goBack.value = true
|
||||
@@ -211,7 +217,7 @@ function handleSubmit(type) {
|
||||
}
|
||||
if (!detailInfo.value.checkUserName) {
|
||||
return uni.showToast({
|
||||
title: '请输入点检人',
|
||||
title: '请输入巡检人',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
@@ -246,11 +252,11 @@ function handleCheckRecord() {
|
||||
nx.$store('biz').deviceInfo = deviceInfo
|
||||
nx.$router.go('/pages/device/deviceBusDailyCheck/list')
|
||||
}
|
||||
// 新建点检
|
||||
// 新建巡检
|
||||
function handleCreateDailyCheck() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定新建点检吗?',
|
||||
content: '确定新建巡检吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
const res = await dailyCheckApi.createDailyCheck({
|
||||
|
||||
@@ -156,7 +156,7 @@ function getLastDailyCheckOfToday(id) {
|
||||
})
|
||||
}, 100)
|
||||
pageLoading.value = false
|
||||
nx.$router.go('/pages/deviceBusDailyCheck/index', { deviceId: id })
|
||||
nx.$router.go('/pages/device/deviceBusDailyCheck/index', { deviceId: id })
|
||||
} else {
|
||||
getDeviceInfo(id)
|
||||
await getUseIngRecord(id)
|
||||
|
||||
@@ -3,38 +3,37 @@
|
||||
<navbar-back title="实验室管理系统【设备管理】" :autoBack="false" leftIcon="" leftText="">
|
||||
<u-icon @click="popupShow = true" size="28" color="#FFF" name="setting-fill" />
|
||||
</navbar-back>
|
||||
<up-grid :border="false" :col="gridCol">
|
||||
<up-grid-item
|
||||
class="mb20 mt20"
|
||||
v-for="(item, listIndex) in list"
|
||||
: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 :col="gridCol" :border="false">
|
||||
<up-grid-item class="mb20 mt20" v-for="item in menuItemList" :key="item.id" @click="goTo(item.component)">
|
||||
<u-icon :name="`/static/images/menus/${item.path}.png`" color="#0055A2" size="80" />
|
||||
<view class="grid-text">{{ item.name }}</view>
|
||||
</up-grid-item>
|
||||
</up-grid>
|
||||
<mePopup v-model:show="popupShow" />
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive, ref, computed } from 'vue'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import nx from '@/nx'
|
||||
import { useGridCol } from '@/nx/hooks/useGridCol'
|
||||
import mePopup from '@/pages/index/me-popup.vue'
|
||||
|
||||
const { gridCol } = useGridCol([400, 600], [2, 3, 4])
|
||||
let popupShow = ref(false)
|
||||
let list = reactive([
|
||||
{ url: '/pages/device/deviceBusDailyCheck/index', name: '点检', icon: 'dailyCheck' },
|
||||
{ url: '/pages/device/deviceBusMaintain/index', name: '维护保养', icon: 'maintain' },
|
||||
{ url: '/pages/device/deviceBusUseRecord/index', name: '使用', icon: 'useRecord' },
|
||||
{ url: '/pages/device/deviceBusInfo/index', name: '设备查询', icon: 'baseInfo' },
|
||||
{ url: '/pages/device/knowledge/index', name: '知识库查询', icon: 'knowledge' }
|
||||
])
|
||||
const menuItemList = computed(() => {
|
||||
let roleMenus = nx.$store('user').roleMenus
|
||||
const result = roleMenus.find(item => item.path === 'device')
|
||||
if (result) {
|
||||
return result.children
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
})
|
||||
|
||||
const roleMenus = computed(() => nx.$store('user').roleMenus)
|
||||
const userInfo = computed(() => nx.$store('user').userInfo)
|
||||
// 方法
|
||||
const goTo = url => {
|
||||
nx.$router.go(url)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
BIN
static/images/menus/device.png
Normal file
BIN
static/images/menus/device.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Reference in New Issue
Block a user