From e449a5408265e4bd1f6c66f5be28a42efac444ee Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 20 九月 2026 15:22:46 +0800
Subject: [PATCH] 天津豹鸣app 1.需求修改
---
src/pages/qualityManagement/finalInspection/add.vue | 194 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 188 insertions(+), 6 deletions(-)
diff --git a/src/pages/qualityManagement/finalInspection/add.vue b/src/pages/qualityManagement/finalInspection/add.vue
index 94321dd..b827124 100644
--- a/src/pages/qualityManagement/finalInspection/add.vue
+++ b/src/pages/qualityManagement/finalInspection/add.vue
@@ -125,7 +125,13 @@
<view class="inspection-items-container">
<view class="steps-header">
<text class="steps-title">妫�楠岄」鐩�</text>
- <text class="steps-count">鍏� {{ tableData.length }} 涓」鐩�</text>
+ <view class="steps-header-right">
+ <text class="steps-count">鍏� {{ tableData.length }} 涓」鐩�</text>
+ <up-button type="primary"
+ size="mini"
+ text="杩藉姞妫�娴嬮」"
+ @click="addTempItem" />
+ </view>
</view>
<view class="steps-list">
<view v-for="(item, index) in tableData"
@@ -137,28 +143,106 @@
<view class="step-content">
<view class="step-row">
<text class="step-label">鎸囨爣锛�</text>
- <text class="step-value">{{ item.parameterItem }}</text>
+ <up-input v-if="item.isTemp"
+ v-model="item.parameterItem"
+ placeholder="璇疯緭鍏ユ寚鏍囧悕绉�"
+ border-bottom
+ class="step-input" />
+ <text v-else
+ class="step-value">{{ item.parameterItem }}</text>
</view>
<view class="step-row">
+ <text class="step-label">鍙傛暟绫诲瀷锛�</text>
+ <view v-if="item.isTemp"
+ class="type-switch">
+ <text class="type-option"
+ :class="{ active: item.parameterType === TEXT_TYPE }"
+ @click="setTempType(item, TEXT_TYPE)">鏂囧瓧</text>
+ <text class="type-option"
+ :class="{ active: item.parameterType === NUMERIC_TYPE }"
+ @click="setTempType(item, NUMERIC_TYPE)">鏁板瓧</text>
+ </view>
+ <text v-else
+ class="step-value">{{ isNumeric(item) ? "鏁板瓧" : "鏂囧瓧" }}</text>
+ </view>
+ <!-- 鏁板瓧鍨嬫寜涓婁笅闄愬垽瀹氾紝鎶婁笂涓嬮檺鎽嗗嚭鏉ユ墠鐪嬪緱鎳傝嚜鍔ㄥ垽瀹氱殑渚濇嵁 -->
+ <template v-if="isNumeric(item)">
+ <view class="step-row">
+ <text class="step-label">鏈�澶у�硷細</text>
+ <up-input v-if="item.isTemp"
+ v-model="item.maxValue"
+ type="number"
+ placeholder="璇疯緭鍏ユ渶澶у��"
+ border-bottom
+ class="step-input" />
+ <text v-else
+ class="step-value">{{ item.maxValue }}</text>
+ </view>
+ <view class="step-row">
+ <text class="step-label">鏈�灏忓�硷細</text>
+ <up-input v-if="item.isTemp"
+ v-model="item.minValue"
+ type="number"
+ placeholder="璇疯緭鍏ユ渶灏忓��"
+ border-bottom
+ class="step-input" />
+ <text v-else
+ class="step-value">{{ item.minValue }}</text>
+ </view>
+ </template>
+ <view class="step-row">
<text class="step-label">鍗曚綅锛�</text>
- <text class="step-value">{{ item.unit }}</text>
+ <up-input v-if="item.isTemp"
+ v-model="item.unit"
+ placeholder="璇疯緭鍏ュ崟浣�"
+ border-bottom
+ class="step-input" />
+ <text v-else
+ class="step-value">{{ item.unit }}</text>
</view>
<view class="step-row">
<text class="step-label">鏍囧噯鍊硷細</text>
- <text class="step-value">{{ item.standardValue }}</text>
+ <up-input v-if="item.isTemp"
+ v-model="item.standardValue"
+ placeholder="璇疯緭鍏ユ爣鍑嗗��"
+ border-bottom
+ class="step-input" />
+ <text v-else
+ class="step-value">{{ item.standardValue }}</text>
</view>
<view class="step-row">
<text class="step-label">鍐呮帶鍊硷細</text>
- <text class="step-value">{{ item.controlValue }}</text>
+ <up-input v-if="item.isTemp"
+ v-model="item.controlValue"
+ placeholder="璇疯緭鍏ュ唴鎺у��"
+ border-bottom
+ class="step-input" />
+ <text v-else
+ class="step-value">{{ item.controlValue }}</text>
</view>
<view class="step-row">
<text class="step-label">妫�楠屽�硷細</text>
<up-input v-model="item.testValue"
+ :type="isNumeric(item) ? 'number' : 'text'"
placeholder="璇疯緭鍏ユ楠屽��"
clearable
border-bottom
class="step-input" />
</view>
+ <view class="step-row">
+ <text class="step-label">鍒ゅ畾锛�</text>
+ <text class="step-value judge-text"
+ :class="itemPassClass(item)">
+ {{ judgeText(item) }}
+ </text>
+ </view>
+ </view>
+ <view v-if="item.isTemp"
+ class="delete-btn"
+ @click="removeTempItem(index)">
+ <up-icon name="close"
+ size="14"
+ color="#ffffff" />
</view>
</view>
<view v-if="tableData.length === 0"
@@ -302,7 +386,7 @@
</template>
<script setup>
- import { ref, computed, onMounted, nextTick } from "vue";
+ import { ref, computed, onMounted, nextTick, watch } from "vue";
import { onShow, onLoad } from "@dcloudio/uni-app";
import PageHeader from "@/components/PageHeader.vue";
import dayjs from "dayjs";
@@ -317,6 +401,13 @@
list,
} from "@/api/qualityManagement/materialInspection.js";
import { userListNoPage } from "@/api/system/user.js";
+ import {
+ NUMERIC_TYPE,
+ TEXT_TYPE,
+ createTempItem,
+ isItemPass,
+ judgeInspectionResult,
+ } from "./_utils/inspection";
// 鏄剧ず鎻愮ず淇℃伅
const showToast = message => {
@@ -671,6 +762,54 @@
});
};
+ // 鏁板瓧鍨嬫墠鏈夋渶澶�/鏈�灏忓�硷紝鍒ゅ畾涔熸寜涓婁笅闄愯蛋
+ const isNumeric = item => item?.parameterType === NUMERIC_TYPE;
+
+ const judgeText = item => {
+ const val = item?.testValue;
+ if (val === null || val === undefined || val === "") return "-";
+ return isItemPass(item) ? "鍚堟牸" : "涓嶅悎鏍�";
+ };
+
+ const itemPassClass = item => {
+ const val = item?.testValue;
+ if (val === null || val === undefined || val === "") return "";
+ return isItemPass(item) ? "pass" : "fail";
+ };
+
+ // 闇�姹備節.3锛氭楠屽�间竴鍙樺氨鑷姩鍒ゅ畾锛屽彛寰勮 _utils/inspection.js銆�
+ // 涓庣鐞嗙涓�鑷达紝杩欓噷鏃犳潯浠惰鐩� form.checkResult 鈥斺�� 鎵嬪伐閫夌殑妫�娴嬬粨鏋�
+ // 鍙槸涓存椂鍏滃簳锛屼笅娆℃敼鍔ㄦ楠岄」鏃朵細琚噸鏂板垽瀹氳鐩栥��
+ watch(
+ tableData,
+ rows => {
+ const result = judgeInspectionResult(rows);
+ if (result) form.value.checkResult = result;
+ },
+ { deep: true }
+ );
+
+ // 闇�姹備節.2锛氫复鏃惰拷鍔犳娴嬮」
+ const addTempItem = () => {
+ tableData.value.push(createTempItem());
+ };
+
+ const removeTempItem = index => {
+ tableData.value.splice(index, 1);
+ };
+
+ // 鍒囩被鍨嬫椂娓呮帀涓嶅啀閫傜敤鐨勫�硷紝閬垮厤鏂囧瓧鍨嬫畫鐣欎笂涓嬮檺銆佹暟瀛楀瀷娈嬬暀鏍囧噯鍊�
+ const setTempType = (item, type) => {
+ if (item.parameterType === type) return;
+ item.parameterType = type;
+ if (type === NUMERIC_TYPE) {
+ item.standardValue = "";
+ } else {
+ item.maxValue = null;
+ item.minValue = null;
+ }
+ };
+
// 鎻愪氦琛ㄥ崟
const submitForm = async () => {
console.log("submitForm", form.value, tableData.value);
@@ -700,10 +839,19 @@
showToast("璇烽�夋嫨妫�娴嬬粨鏋�");
return;
}
+ const missingTemp = tableData.value.find(
+ item => item.isTemp && !item.parameterItem
+ );
+ if (missingTemp) {
+ showToast("璇峰~鍐欒拷鍔犳娴嬮」鐨勬寚鏍囧悕绉�");
+ return;
+ }
loading.value = true;
form.value.inspectType = 2;
+ // isTemp 鍙槸鍓嶇鐨勮鏍囪锛屼笉鑳芥彁浜ょ粰鍚庣
+ tableData.value = tableData.value.map(({ isTemp, ...rest }) => rest);
if (!isEdit.value) {
tableData.value.forEach(item => {
delete item.id;
@@ -931,6 +1079,40 @@
color: #909399;
}
+ .steps-header-right {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ }
+
+ // 涓存椂杩藉姞琛岀殑鍙傛暟绫诲瀷鍒囨崲
+ .type-switch {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ .type-option {
+ padding: 4px 14px;
+ font-size: 13px;
+ color: #606266;
+ background: #f4f4f5;
+ border-radius: 12px;
+ }
+
+ .type-option.active {
+ color: #409eff;
+ background: #ecf5ff;
+ }
+
+ .judge-text.pass {
+ color: #67c23a;
+ }
+
+ .judge-text.fail {
+ color: #f56c6c;
+ }
+
.steps-list {
margin-bottom: 20px;
}
--
Gitblit v1.9.3