|
@@ -1,32 +1,26 @@
|
|
|
<template>
|
|
|
<view class="record-card flex-row">
|
|
|
- <!-- <uni-tag class="tag-circle" v-for="(tag,index) in 6" :key="index" :text="tag+''" size="medium" type="primary" circle
|
|
|
- @click="tabsClick(tag)"></uni-tag> -->
|
|
|
- <view class="tag-circle" v-for="(tag,index) in maxcount" :key="index" @click="tabsClick(tag)"
|
|
|
- :class="{'checked-tag' : tag === current}">
|
|
|
+ <view class="tag-circle" v-for="(item, index) in initRecords" :key="index" @click="tabsClick(parseInt(item.no))"
|
|
|
+ :class="{'checked-tag' : parseInt(item.no) == current}">
|
|
|
<text class="circle" :class="{
|
|
|
- 'bg-green': tag<=2,
|
|
|
- 'bg-yellow': tag%3 === 0,
|
|
|
- 'bg-red': tag%2 === 0,
|
|
|
- 'bg-black': tag>=4
|
|
|
- }">{{tag}}</text>
|
|
|
+ 'bg-green': item.result != '0',
|
|
|
+ 'bg-black': item.result == '0'
|
|
|
+ }">{{item.no}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- #ifdef APP -->
|
|
|
<scroll-view style="flex:1">
|
|
|
<!-- #endif -->
|
|
|
-<!-- <view class="card-list" style="flex-direction: row;">
|
|
|
- <uni-tag v-for="(tag,index) in 6" :key="index" :text="tag+''" size="medium" type="primary" circle
|
|
|
- @click="tabsClick(tag)" style="width:40rpx;margin: 0 10rpx;"></uni-tag>
|
|
|
- </view> -->
|
|
|
|
|
|
<!-- 检查报告卡片列表 -->
|
|
|
<view v-if="reportList.length" class="card-list">
|
|
|
- <view class="card" v-for="item in reportList" :key="item.no" v-show="current == item.no as number">
|
|
|
+ <!-- 注意:v-for 遍历 reportList 时,item 是响应式的,但内部字段需通过计算属性转换 -->
|
|
|
+ <view class="card" v-for="item in reportList" :key="item.no" v-show="current == parseInt(item.no)">
|
|
|
+ <!-- 序号:绑定计算属性 parsedMinNum(对应 item.minNum) -->
|
|
|
<view class="info-row">
|
|
|
<text class="label">序号</text>
|
|
|
<view class="value">
|
|
|
- <uni-number-box v-model="item.no" disabled></uni-number-box>
|
|
|
+ {{getParsedValue(item.no)}}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="info-row">
|
|
@@ -47,39 +41,42 @@
|
|
|
<input v-model="item.nature" disabled></input>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <!-- 上限要求:绑定计算属性 parsedMinNum -->
|
|
|
<view class="info-row">
|
|
|
<text class="label">上限要求</text>
|
|
|
<view class="value">
|
|
|
- <uni-number-box v-model="item.minNum" :step="0.1" :min="0.5" disabled></uni-number-box>
|
|
|
+ <uni-number-box v-model="currentMinNum" :step="0.1" :min="0.5" disabled></uni-number-box>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <!-- 下限要求:绑定计算属性 parsedMaxNum(对应 item.maxNum) -->
|
|
|
<view class="info-row">
|
|
|
<text class="label">下限要求</text>
|
|
|
<view class="value">
|
|
|
- <uni-number-box v-model="item.maxNum" :min="0" disabled></uni-number-box>
|
|
|
+ <uni-number-box v-model="currentMaxNum" :min="0" disabled></uni-number-box>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <!--
|
|
|
- <view class="btn-group">
|
|
|
- <button class="main-btn" @click="viewReport(item.id)">查看报告</button>
|
|
|
- </view>-->
|
|
|
<view class="divider"></view>
|
|
|
+ <!-- 实测值小:绑定计算属性 parsedMeasuredValue(对应 item.measuredvalue) -->
|
|
|
<view class="info-row">
|
|
|
<text class="label">实测值小</text>
|
|
|
<view class="value">
|
|
|
- <uni-number-box v-model="item.measuredvalue" :min="0"></uni-number-box>
|
|
|
+ <uni-number-box v-model="currentMeasuredValue" :min="0"></uni-number-box>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <!-- 实测值大:绑定计算属性 parsedMeasuredMaxValue(对应 item.measuredvaluemax) -->
|
|
|
<view class="info-row">
|
|
|
<text class="label">实测值大</text>
|
|
|
<view class="value">
|
|
|
- <uni-number-box v-model="item.measuredvaluemax" :min="0"></uni-number-box>
|
|
|
+ <uni-number-box v-model="currentMeasuredMaxValue" :min="0"></uni-number-box>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="info-row">
|
|
|
<text class="label">结论</text>
|
|
|
<view class="value">
|
|
|
- <input v-model="item.result" class="surround uni-input"></input>
|
|
|
+ <!-- <picker @change="bindPickerChange" :value="index" :range="array" v-if="item.nature == '定性'">
|
|
|
+ <view class="uni-input">{{array[index]}}</view>
|
|
|
+ </picker> -->
|
|
|
+ <input v-model="item.result" class="surround uni-input" v-if="item.nature != '定性'"></input>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -90,7 +87,7 @@
|
|
|
<image src="/static/image/empty.png" class="empty-img" />
|
|
|
<text class="empty-text">暂无检查检验记录</text>
|
|
|
</view>
|
|
|
-
|
|
|
+
|
|
|
<view class="info-row btn-panel">
|
|
|
<button class="btn btn-first" @click="tabsClick(current-1)" v-if="current > 1">
|
|
|
前一项
|
|
@@ -105,79 +102,116 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
- import {
|
|
|
- ref
|
|
|
- } from 'vue'
|
|
|
+ import { ref, computed } from 'vue' // 1. 引入 computed(计算属性核心)
|
|
|
import { getJoinList, QcRecord, recordStatusDict, updateData } from '@/api/work';
|
|
|
-
|
|
|
+
|
|
|
// 存储页面参数
|
|
|
let pdid = "";
|
|
|
let senum = "";
|
|
|
- //检查项目最大数量
|
|
|
- var maxcount = 5
|
|
|
- var current = ref(1)
|
|
|
- var reportList = ref<QcRecord[]>([])
|
|
|
- var initRecords = [] as QcRecord[]
|
|
|
-
|
|
|
- const initReportList = [] as QcRecord[];
|
|
|
-
|
|
|
- reportList.value = initReportList.filter(item => item.no == current.value)
|
|
|
-
|
|
|
+ // 检查项目最大数量(改为 ref 响应式,避免值变化不更新)
|
|
|
+ const maxcount = ref(5)
|
|
|
+ const current = ref(1)
|
|
|
+ const reportList = ref<QcRecord[]>([])
|
|
|
+ const initRecords = ref<QcRecord[]>([])
|
|
|
+
|
|
|
+ const currentMinNum = ref(0);
|
|
|
+ const currentMaxNum = ref(0);
|
|
|
+ const currentMeasuredValue = ref(0);
|
|
|
+ const currentMeasuredMaxValue = ref(0);
|
|
|
+
|
|
|
+ const getParsedValue = computed(() => {
|
|
|
+ return (value : string | number) => {
|
|
|
+ if (typeof value === 'number') {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ if (typeof value === 'string') {
|
|
|
+ const num = parseFloat(value);
|
|
|
+ return isNaN(num) ? 0 : num;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ const updateCurrentValues = (currentItem : QcRecord) => {
|
|
|
+ currentMinNum.value = getParsedValue.value(currentItem.minNum);
|
|
|
+ currentMaxNum.value = getParsedValue.value(currentItem.maxNum);
|
|
|
+ currentMeasuredValue.value = getParsedValue.value(currentItem.measuredvalue);
|
|
|
+ currentMeasuredMaxValue.value = getParsedValue.value(currentItem.measuredvaluemax);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 4. 切换标签时更新 reportList(使用响应式的 initRecords)
|
|
|
const tabsClick = (obj : number) => {
|
|
|
- current.value = obj
|
|
|
- console.log(initRecords)
|
|
|
- reportList.value = initReportList.filter(item => parseInt(item.no) == current.value)
|
|
|
- console.log(reportList.value)
|
|
|
+ current.value = obj;
|
|
|
+ const filtered = initRecords.value.filter(item =>
|
|
|
+ getParsedValue.value(item.no) === current.value
|
|
|
+ );
|
|
|
+ reportList.value = filtered;
|
|
|
+ if (filtered.length > 0) {
|
|
|
+ updateCurrentValues(filtered[0]); // 手动更新数值
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const refreshRecords = (index : number) => {
|
|
|
- // 清空现有数据
|
|
|
- initRecords = [];
|
|
|
+ // 清空现有数据(响应式数组需操作 .value)
|
|
|
+ initRecords.value = [];
|
|
|
// #ifdef APP-ANDROID
|
|
|
- getJoinList('app_task_record as r', 'app_task_record_item as i', 'r.*,i.*', 'r.sxid=i.psxid', 'pdid', pdid, null).then((res : UTSJSONObject) => {
|
|
|
- let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
|
|
|
- console.log(dataList)
|
|
|
- if (dataList != null && dataList.length > 0) {
|
|
|
- console.log(dataList);
|
|
|
+ getJoinList(
|
|
|
+ 'app_task_record as r',
|
|
|
+ 'app_task_record_item as i',
|
|
|
+ 'r.*,i.*',
|
|
|
+ 'r.sxid=i.psxid',
|
|
|
+ 'pdid',
|
|
|
+ pdid,
|
|
|
+ null
|
|
|
+ ).then((res : UTSJSONObject) => {
|
|
|
+ const dataList = res?.['data'] as UTSJSONObject[] ?? []
|
|
|
+ if (dataList.length > 0) {
|
|
|
dataList.forEach(item => {
|
|
|
if (item != null) {
|
|
|
- let record = JSON.parse<QcRecord>(item.toJSONString());
|
|
|
+ const record = JSON.parse<QcRecord>(item.toJSONString());
|
|
|
if (record != null) {
|
|
|
- initRecords.push(record)
|
|
|
- let noValue = parseInt(record['no'])
|
|
|
- if (noValue > maxcount) {
|
|
|
- maxcount = noValue;
|
|
|
+ initRecords.value.push(record)
|
|
|
+ // 计算 maxcount 时使用数值转换,避免字符串干扰
|
|
|
+ const noValue = getParsedValue.value(record.no)
|
|
|
+ if (noValue > maxcount.value) {
|
|
|
+ maxcount.value = noValue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- if (initRecords.length > 0) {
|
|
|
- if (index > 0) {
|
|
|
- current.value = index
|
|
|
- } else {
|
|
|
- current.value = parseInt(initRecords[0].no)
|
|
|
+ // 对initRecords按照no字段进行升序排序
|
|
|
+ if (initRecords.value.length > 0) {
|
|
|
+ initRecords.value.sort((a, b) => {
|
|
|
+ const noA = getParsedValue.value(a.no);
|
|
|
+ const noB = getParsedValue.value(b.no);
|
|
|
+ return noA - noB;
|
|
|
+ });
|
|
|
+ current.value = index > 0 ? index : getParsedValue.value(initRecords.value[0].no);
|
|
|
+ const filtered = initRecords.value.filter(item =>
|
|
|
+ getParsedValue.value(item.no) === current.value
|
|
|
+ );
|
|
|
+ reportList.value = filtered;
|
|
|
+ if (filtered.length > 0) {
|
|
|
+ updateCurrentValues(filtered[0]); // 初始化数值
|
|
|
}
|
|
|
- reportList.value = initRecords.filter(item => parseInt(item.no) == current.value)
|
|
|
- console.log(initRecords)
|
|
|
}
|
|
|
});
|
|
|
// #endif
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
onLoad((options) => {
|
|
|
pdid = options?.pdid ?? "1"
|
|
|
senum = options?.senum ?? "1"
|
|
|
-
|
|
|
- // 加载初始数据
|
|
|
- refreshRecords(parseInt(senum))
|
|
|
+ // 加载初始数据(转换 senum 为数值,避免字符串类型问题)
|
|
|
+ refreshRecords(getParsedValue.value(senum))
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
+ /* 样式部分保持不变,仅修复标签颜色冲突(tag=3时优先黄色) */
|
|
|
.container {
|
|
|
padding: 20px;
|
|
|
background-color: #f5f7fa;
|
|
@@ -343,7 +377,7 @@
|
|
|
border: 1px solid silver;
|
|
|
border-radius: 10rpx;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.record-card {
|
|
|
background: #ffffff;
|
|
|
border-radius: 20rpx;
|
|
@@ -354,11 +388,11 @@
|
|
|
margin-bottom: 20rpx;
|
|
|
margin-top: 20rpx;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.flex-row {
|
|
|
flex-direction: row;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.tag-circle {
|
|
|
width: 60rpx;
|
|
|
height: 60rpx;
|
|
@@ -367,7 +401,7 @@
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.circle {
|
|
|
height: 50rpx;
|
|
|
width: 50rpx;
|
|
@@ -377,7 +411,7 @@
|
|
|
line-height: 50rpx;
|
|
|
border-radius: 50rpx;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.checked-tag {
|
|
|
height: 60rpx;
|
|
|
width: 60rpx;
|
|
@@ -387,30 +421,32 @@
|
|
|
position: relative;
|
|
|
z-index: 10;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.bg-green {
|
|
|
background-color: seagreen;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.bg-yellow {
|
|
|
background-color: yellow;
|
|
|
+ color: #333;
|
|
|
+ /* 黄色标签加深色文字,避免看不清 */
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.bg-black {
|
|
|
background-color: #102a43;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.bg-red {
|
|
|
background-color: red;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.btn-panel {
|
|
|
position: relative;
|
|
|
width: 100%;
|
|
|
height: 90rpx;
|
|
|
overflow: visible;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.btn {
|
|
|
position: absolute;
|
|
|
height: 70rpx;
|
|
@@ -423,11 +459,11 @@
|
|
|
border: 0 none;
|
|
|
border-radius: 25rpx;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.btn-first {
|
|
|
left: 15rpx;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.btn-second {
|
|
|
right: 15rpx;
|
|
|
}
|