From 03a05815d7ea5612206b6cfe5d6537b4d4cedc0a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 15 九月 2026 11:41:32 +0800
Subject: [PATCH] 天津潜宇塑胶app 1.添加采购需求、库存盘点、计件单价配置、产量统计、材料消耗核算、成本核算分析页面
---
src/pages/qualityManagement/materialInspection/add.vue | 124 +++++++++++++++++++++++++++++++++--------
1 files changed, 100 insertions(+), 24 deletions(-)
diff --git a/src/pages/qualityManagement/materialInspection/add.vue b/src/pages/qualityManagement/materialInspection/add.vue
index e04391f..3ed5666 100644
--- a/src/pages/qualityManagement/materialInspection/add.vue
+++ b/src/pages/qualityManagement/materialInspection/add.vue
@@ -16,9 +16,9 @@
<up-input v-model="form.supplier"
placeholder="璇烽�夋嫨渚涘簲鍟�"
readonly
- :disabled="supplierQuantityDisabled" />
+ :disabled="supplierQuantityDisabled || isReadonly" />
<template #right>
- <up-icon @click="showSupplierSheet = true"
+ <up-icon @click="!isReadonly && (showSupplierSheet = true)"
name="arrow-right" />
</template>
</up-form-item>
@@ -29,10 +29,10 @@
<up-input v-model="form.productName"
placeholder="璇烽�夋嫨浜у搧"
readonly
- @click="showProductTree = true"
- :disabled="isEdit" />
+ @click="!isReadonly && (showProductTree = true)"
+ :disabled="isEdit || isReadonly" />
<template #right>
- <up-icon @click="showProductTree = true"
+ <up-icon @click="!isReadonly && (showProductTree = true)"
name="arrow-right" />
</template>
</up-form-item>
@@ -43,9 +43,17 @@
<up-input v-model="form.model"
placeholder="璇烽�夋嫨瑙勬牸鍨嬪彿"
readonly
- :disabled="isEdit" />
+ :disabled="isEdit || isReadonly" />
<template #right>
- <up-icon @click="showModelSheet = true"
+ <view v-if="!isEdit"
+ class="scan-entry"
+ @click.stop="scanBarcode">
+ <up-icon name="scan"
+ size="18"
+ color="#3c9cff" />
+ <text class="scan-entry-text">鎵爜</text>
+ </view>
+ <up-icon @click="!isReadonly && (showModelSheet = true)"
name="arrow-right" />
</template>
</up-form-item>
@@ -55,7 +63,8 @@
border-bottom>
<up-input v-model="testStandardDisplay"
placeholder="璇烽�夋嫨鎸囨爣"
- readonly />
+ readonly
+ :disabled="isReadonly" />
<template #right>
<up-icon @click="openTestStandardSheet"
name="arrow-right" />
@@ -75,13 +84,14 @@
<up-input v-model="form.quantity"
type="number"
placeholder="璇疯緭鍏ユ暟閲�"
- :disabled="supplierQuantityDisabled" />
+ :disabled="supplierQuantityDisabled || isReadonly" />
</up-form-item>
<up-form-item label="妫�娴嬪崟浣�"
prop="checkCompany"
border-bottom>
<up-input v-model="form.checkCompany"
placeholder="璇疯緭鍏ユ娴嬪崟浣�"
+ :disabled="isReadonly"
clearable />
</up-form-item>
<up-form-item label="妫�娴嬬粨鏋�"
@@ -91,9 +101,10 @@
<up-input v-model="form.checkResult"
placeholder="璇烽�夋嫨妫�娴嬬粨鏋�"
readonly
+ :disabled="isReadonly"
@click="showResultSheet" />
<template #right>
- <up-icon @click="showResultSheet = true"
+ <up-icon @click="!isReadonly && (showResultSheet = true)"
name="arrow-right" />
</template>
</up-form-item>
@@ -103,9 +114,10 @@
<up-input v-model="form.checkName"
placeholder="璇烽�夋嫨妫�楠屽憳"
readonly
+ :disabled="isReadonly"
@click="showInspectorSheet" />
<template #right>
- <up-icon @click="showInspectorSheet = true"
+ <up-icon @click="!isReadonly && (showInspectorSheet = true)"
name="arrow-right" />
</template>
</up-form-item>
@@ -116,6 +128,7 @@
<up-input v-model="form.checkTime"
placeholder="璇烽�夋嫨妫�娴嬫棩鏈�"
readonly
+ :disabled="isReadonly"
@click="showDatePicker" />
<!-- <template #right>
<up-icon name="arrow-right"
@@ -163,6 +176,7 @@
<text class="step-label">妫�楠屽�硷細</text>
<up-input v-model="item.testValue"
placeholder="璇疯緭鍏ユ楠屽��"
+ :disabled="isReadonly"
clearable
border-bottom
class="step-input" />
@@ -182,14 +196,16 @@
size="default"
@click="goBack"
class="bottom-btn">
- 鍙栨秷
+ {{ isReadonly ? '杩斿洖' : '鍙栨秷' }}
</up-button>
- <up-button type="primary"
+ <!-- 宸叉彁浜ゅ崟鎹彧璇伙紝闅愯棌淇濆瓨/鎻愪氦 -->
+ <up-button v-if="!isReadonly"
+ type="primary"
size="default"
@click="submitForm"
:loading="loading"
class="bottom-btn">
- {{ isEdit ? '淇濆瓨' : '鎻愪氦' }}
+ 淇濆瓨
</up-button>
</view>
<!-- 鏃ユ湡閫夋嫨鍣� -->
@@ -319,7 +335,11 @@
import PageHeader from "@/components/PageHeader.vue";
import dayjs from "dayjs";
import { getOptions } from "@/api/procurementManagement/procurementLedger.js";
- import { modelList, productTreeList } from "@/api/basicData/product.js";
+ import {
+ modelList,
+ productTreeList,
+ modelByBarcode,
+ } from "@/api/basicData/product.js";
import {
qualityInspectAdd,
qualityInspectUpdate,
@@ -421,6 +441,7 @@
return modelOptions.value.map(item => ({
name: item.model,
value: item.id,
+ subname: item.barcode ? `鏉$爜锛�${item.barcode}` : "",
}));
});
@@ -477,6 +498,9 @@
return !!(v.productMainId != null || v.purchaseLedgerId != null);
});
+ // 宸叉彁浜わ紙inspectState=1锛夊崟鎹暣浣撳彧璇�
+ const isReadonly = computed(() => Number(form.value?.inspectState) === 1);
+
// 杩斿洖涓婁竴椤�
const goBack = () => {
uni.navigateBack();
@@ -484,6 +508,7 @@
// 鏄剧ず鏃ユ湡閫夋嫨鍣�
const showDatePicker = () => {
+ if (isReadonly.value) return;
showDate.value = true;
};
@@ -610,7 +635,7 @@
});
};
const openTestStandardSheet = () => {
- console.log("openTestStandardSheet");
+ if (isReadonly.value) return;
showTestStandardSheet.value = true;
};
@@ -640,19 +665,51 @@
}
};
- // 鑾峰彇鍨嬪彿鍒楄〃
+ // 鑾峰彇鍨嬪彿鍒楄〃锛堣繑鍥� Promise锛屼究浜庢壂鐮佸悗椤哄簭鍥炲~锛�
const getModels = value => {
form.value.productModelId = "";
form.value.unit = "";
modelOptions.value = [];
currentProductId.value = value;
form.value.productName = findNodeById(productOptions.value, value);
- modelList({ id: value }).then(res => {
- modelOptions.value = res;
+ const task = modelList({ id: value }).then(res => {
+ modelOptions.value = res?.data || res || [];
});
if (currentProductId.value) {
getList();
}
+ return task;
+ };
+
+ // 鎵爜鎸夋潯鐮佺簿纭洖濉骇鍝�+瑙勬牸鍨嬪彿
+ const scanBarcode = () => {
+ if (isEdit.value) return;
+ uni.scanCode({
+ scanType: ["barCode", "qrCode"],
+ success: async res => {
+ const barcode = (res.result || "").trim();
+ if (!barcode) return;
+ uni.showLoading({ title: "鍖归厤涓�...", mask: true });
+ try {
+ const resp = await modelByBarcode({ barcode });
+ const info = resp?.data || resp;
+ if (info && info.productId) {
+ // 鍏堟寜 productId 鑱斿姩鍑轰骇鍝佸眰锛屼繚璇� UI 鐘舵�佷笌鎵嬪姩閫夋嫨涓�鑷�
+ await getModels(info.productId);
+ form.value.productId = info.productId;
+ form.value.productName = info.productName || form.value.productName;
+ form.value.productModelId = info.id;
+ form.value.model = info.model || "";
+ form.value.unit = info.unit || "";
+ }
+ uni.hideLoading();
+ uni.showToast({ title: "宸插尮閰嶈鏍�", icon: "success" });
+ } catch (e) {
+ // 鏈尮閰嶇瓑閿欒宸叉湁鍏ㄥ眬 toast锛岃繖閲屽彧鎭㈠ loading
+ uni.hideLoading();
+ }
+ },
+ });
};
// 鑾峰彇鎸囨爣鍒楄〃
@@ -687,6 +744,11 @@
// 鎻愪氦琛ㄥ崟
const submitForm = async () => {
console.log("submitForm", form.value, tableData.value);
+ // 宸叉彁浜ゅ崟鎹姝繚瀛�/鎻愪氦
+ if (isReadonly.value) {
+ showToast("妫�楠屽崟宸叉彁浜わ紝涓嶅厑璁镐慨鏀�");
+ return;
+ }
try {
// await formRef.value.validate();
if (!form.value.productModelId) {
@@ -726,21 +788,22 @@
const data = { ...form.value, qualityInspectParams: tableData.value };
data.quantity = Number(data.quantity);
if (isEdit.value) {
- const res = await qualityInspectUpdate(data);
+ await qualityInspectUpdate(data);
showToast("淇濆瓨鎴愬姛");
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
- const res = await qualityInspectAdd(data);
- showToast("鎻愪氦鎴愬姛");
+ // 鏂板浠呬繚瀛樿崏绋匡紝姝e紡鎻愪氦鍦ㄥ垪琛ㄩ〉銆屾彁浜ゃ�嶆寜閽紙浼氱敓鎴愬叆搴撹褰曪級
+ await qualityInspectAdd(data);
+ showToast("淇濆瓨鎴愬姛");
setTimeout(() => {
uni.navigateBack();
}, 1500);
}
} catch (error) {
- console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
- showToast("鎻愪氦澶辫触锛岃閲嶈瘯");
+ // request.ts 宸茬粺涓� toast 鍚庣 msg锛岃繖閲屽彧璁板綍
+ console.error("鎻愪氦澶辫触:", error);
} finally {
loading.value = false;
}
@@ -912,6 +975,19 @@
<style scoped lang="scss">
@import "@/static/scss/form-common.scss";
+ // 瑙勬牸琛屾壂鐮佸叆鍙�
+ .scan-entry {
+ display: flex;
+ align-items: center;
+ margin-right: 8px;
+
+ .scan-entry-text {
+ font-size: 13px;
+ color: #3c9cff;
+ margin-left: 2px;
+ }
+ }
+
.material-inspection-add {
min-height: 100vh;
background: #f8f9fa;
--
Gitblit v1.9.3