From 3897a86d1a714cca8087d589f55b00446679e48e Mon Sep 17 00:00:00 2001
From: wbc <2597324127@qq.com>
Date: 星期一, 08 十二月 2025 22:46:53 +0800
Subject: [PATCH] 通用界面补充
---
pages/Repair/DefectRegistration.vue | 361 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 361 insertions(+), 0 deletions(-)
diff --git a/pages/Repair/DefectRegistration.vue b/pages/Repair/DefectRegistration.vue
new file mode 100644
index 0000000..00a42d3
--- /dev/null
+++ b/pages/Repair/DefectRegistration.vue
@@ -0,0 +1,361 @@
+<template>
+ <view class="content">
+ <!-- 澶撮儴鏍囬 -->
+
+
+ <!-- 琛ㄥ崟鍖哄煙 -->
+ <view class="form-container">
+ <!-- 鏌ヨ宸ュ崟 -->
+ <view class="form-item">
+ <text class="label">鏌ヨ宸ュ崟</text>
+ <input class="input" type="text" v-model="formData.queryWorkOrder" placeholder="璇疯緭鍏ユ煡璇㈠伐鍗�" @input="onQueryWorkOrderChange" />
+ </view>
+
+ <!-- 鐢熶骇宸ュ崟 -->
+ <view class="form-item">
+ <text class="label">鐢熶骇宸ュ崟</text>
+ <picker class="picker" :range="productionWorkOrderOptions" range-key="text" :value="productionWorkOrderIndex" @change="onProductionWorkOrderChange">
+ <view class="picker-content">
+ {{ productionWorkOrderOptions[productionWorkOrderIndex] ? productionWorkOrderOptions[productionWorkOrderIndex].text : '璇烽�夋嫨/鎵弿鐢熶骇宸ュ崟' }}
+ </view>
+ </picker>
+ <view class="scan-icon" @click="scanProductionWorkOrder">
+ <uni-icons type="scan" size="24" color="#28a745"></uni-icons>
+ </view>
+ </view>
+
+ <!-- 浜у搧缂栫爜 -->
+ <view class="form-item">
+ <text class="label">浜у搧缂栫爜</text>
+ <view class="value">{{ formData.productCode }}</view>
+ </view>
+
+ <!-- 浜у搧鍚嶇О -->
+ <view class="form-item">
+ <text class="label">浜у搧鍚嶇О</text>
+ <view class="value">{{ formData.productName }}</view>
+ </view>
+
+ <!-- 宸ュ簭 -->
+ <view class="form-item">
+ <text class="label">宸ュ簭</text>
+ <picker class="picker" :range="processOptions" range-key="text" :value="processIndex" @change="onProcessChange">
+ <view class="picker-content">
+ {{ processOptions[processIndex] ? processOptions[processIndex].text : '璇烽�夋嫨/鎵弿宸ュ簭' }}
+ </view>
+ </picker>
+ <view class="scan-icon" @click="scanProcess">
+ <uni-icons type="scan" size="24" color="#28a745"></uni-icons>
+ </view>
+ </view>
+
+ <!-- 涓嶈壇绫诲瀷 -->
+ <view class="form-item">
+ <text class="label">涓嶈壇绫诲瀷</text>
+ <picker class="picker" :range="defectTypeOptions" range-key="text" :value="defectTypeIndex" @change="onDefectTypeChange">
+ <view class="picker-content">
+ {{ defectTypeOptions[defectTypeIndex] ? defectTypeOptions[defectTypeIndex].text : '璇烽�夋嫨/鎵弿涓嶈壇绫诲瀷' }}
+ </view>
+ </picker>
+ <view class="scan-icon" @click="scanDefectType">
+ <uni-icons type="scan" size="24" color="#28a745"></uni-icons>
+ </view>
+ </view>
+
+ <!-- 涓嶈壇椤圭洰 -->
+ <view class="form-item">
+ <text class="label">涓嶈壇椤圭洰</text>
+ <picker class="picker" :range="defectItemOptions" range-key="text" :value="defectItemIndex" @change="onDefectItemChange">
+ <view class="picker-content">
+ {{ defectItemOptions[defectItemIndex] ? defectItemOptions[defectItemIndex].text : '璇烽�夋嫨/鎵弿涓嶈壇椤圭洰' }}
+ </view>
+ </picker>
+ <view class="scan-icon" @click="scanDefectItem">
+ <uni-icons type="scan" size="24" color="#28a745"></uni-icons>
+ </view>
+ </view>
+
+ <!-- 涓嶈壇鏉$爜 -->
+ <view class="form-item">
+ <text class="label">涓嶈壇鏉$爜</text>
+ <input class="input" type="text" v-model="formData.defectBarcode" placeholder="璇疯緭鍏ヤ笉鑹潯鐮�" />
+ </view>
+
+ <!-- 鏉$爜鏁伴噺 -->
+ <view class="form-item">
+ <text class="label">鏉$爜鏁伴噺</text>
+ <input class="input" type="number" v-model="formData.barcodeQuantity" placeholder="璇疯緭鍏ユ潯鐮佹暟閲�" />
+ </view>
+
+ <!-- 鎻愮ず淇℃伅 -->
+ <view class="form-item">
+ <text class="label">鎻愮ず淇℃伅</text>
+ <view class="value hint">{{ formData.hintInfo }}</view>
+ </view>
+ </view>
+
+ <!-- 鎻愪氦鎸夐挳 -->
+ <view class="footer">
+ <button class="submit-btn" @click="submitForm">鐧昏鎻愪氦</button>
+ </view>
+ </view>
+</template>
+
+<script>
+import uniIcons from "@/components/uni-icons/uni-icons.vue"
+
+export default {
+ components: {uniIcons},
+ data() {
+ return {
+ formData: {
+ queryWorkOrder: '',
+ productionWorkOrder: '',
+ productCode: '',
+ productName: '',
+ process: '',
+ defectType: '',
+ defectItem: '',
+ defectBarcode: '',
+ barcodeQuantity: '',
+ hintInfo: ''
+ },
+ productionWorkOrderOptions: [],
+ productionWorkOrderIndex: -1,
+ processOptions: [],
+ processIndex: -1,
+ defectTypeOptions: [],
+ defectTypeIndex: -1,
+ defectItemOptions: [],
+ defectItemIndex: -1
+ };
+ },
+ onLoad() {
+ this.initData();
+ },
+ methods: {
+ goBack() {
+ uni.navigateBack();
+ },
+ initData() {
+ // 棰勭暀API璋冪敤浣嶇疆
+ this.loadProductionWorkOrders();
+ this.loadProcesses();
+ this.loadDefectTypes();
+ this.loadDefectItems();
+ },
+ loadProductionWorkOrders() {
+ // 妯℃嫙API鑾峰彇鐢熶骇宸ュ崟鍒楄〃
+ // this.$post({url: '/api/getWorkOrders'}).then(...)
+ this.productionWorkOrderOptions = [
+ {text: 'MO-20231201001', value: 'WO001'},
+ {text: 'MO-20231201002', value: 'WO002'}
+ ];
+ },
+ loadProcesses() {
+ // 妯℃嫙API鑾峰彇宸ュ簭鍒楄〃
+ this.processOptions = [
+ {text: 'SMT璐寸墖', value: 'P001'},
+ {text: 'DIP鎻掍欢', value: 'P002'},
+ {text: '缁勮', value: 'P003'}
+ ];
+ },
+ loadDefectTypes() {
+ // 妯℃嫙API鑾峰彇涓嶈壇绫诲瀷鍒楄〃
+ this.defectTypeOptions = [
+ {text: '鐗╂枡涓嶈壇', value: 'DT001'},
+ {text: '鍒剁▼涓嶈壇', value: 'DT002'}
+ ];
+ },
+ loadDefectItems() {
+ // 妯℃嫙API鑾峰彇涓嶈壇椤圭洰鍒楄〃
+ this.defectItemOptions = [
+ {text: '铏氱剨', value: 'DI001'},
+ {text: '鐭矾', value: 'DI002'},
+ {text: '缂轰欢', value: 'DI003'}
+ ];
+ },
+ onQueryWorkOrderChange(e) {
+ // 瀹炴椂鏌ヨ宸ュ崟瀵瑰簲涓嬫媺妗嗗彂鐢熷彉鍖�
+ const query = this.formData.queryWorkOrder;
+ console.log('Querying work orders with:', query);
+
+ // 杩欓噷搴旇璋冪敤鎺ュ彛鏍规嵁杈撳叆鍐呭绛涢�夌敓浜у伐鍗�
+ // this.$post({url: '/api/searchWorkOrders', data: {keyword: query}}).then(...)
+
+ // 妯℃嫙绛涢��
+ if(query) {
+ this.productionWorkOrderOptions = this.productionWorkOrderOptions.filter(item => item.text.includes(query));
+ } else {
+ this.loadProductionWorkOrders(); // 鎭㈠榛樿鍒楄〃
+ }
+ },
+ onProductionWorkOrderChange(e) {
+ this.productionWorkOrderIndex = e.target.value;
+ const selected = this.productionWorkOrderOptions[this.productionWorkOrderIndex];
+ if (selected) {
+ this.formData.productionWorkOrder = selected.value;
+ // 妯℃嫙鏍规嵁宸ュ崟甯﹀嚭浜у搧淇℃伅
+ this.formData.productCode = 'PROD-' + selected.value;
+ this.formData.productName = '浜у搧 ' + selected.text;
+ }
+ },
+ onProcessChange(e) {
+ this.processIndex = e.target.value;
+ if (this.processOptions[this.processIndex]) {
+ this.formData.process = this.processOptions[this.processIndex].value;
+ }
+ },
+ onDefectTypeChange(e) {
+ this.defectTypeIndex = e.target.value;
+ if (this.defectTypeOptions[this.defectTypeIndex]) {
+ this.formData.defectType = this.defectTypeOptions[this.defectTypeIndex].value;
+ }
+ },
+ onDefectItemChange(e) {
+ this.defectItemIndex = e.target.value;
+ if (this.defectItemOptions[this.defectItemIndex]) {
+ this.formData.defectItem = this.defectItemOptions[this.defectItemIndex].value;
+ }
+ },
+ scanProductionWorkOrder() {
+ uni.scanCode({
+ success: (res) => {
+ console.log('Scanned:', res.result);
+ // 澶勭悊鎵弿缁撴灉锛岃嚜鍔ㄩ�変腑瀵瑰簲宸ュ崟
+ uni.showToast({title: '鎵弿鎴愬姛: ' + res.result, icon: 'none'});
+ }
+ });
+ },
+ scanProcess() {
+ uni.scanCode({
+ success: (res) => {
+ console.log('Scanned Process:', res.result);
+ uni.showToast({title: '鎵弿鎴愬姛: ' + res.result, icon: 'none'});
+ }
+ });
+ },
+ scanDefectType() {
+ uni.scanCode({
+ success: (res) => {
+ console.log('Scanned DefectType:', res.result);
+ uni.showToast({title: '鎵弿鎴愬姛: ' + res.result, icon: 'none'});
+ }
+ });
+ },
+ scanDefectItem() {
+ uni.scanCode({
+ success: (res) => {
+ console.log('Scanned DefectItem:', res.result);
+ uni.showToast({title: '鎵弿鎴愬姛: ' + res.result, icon: 'none'});
+ }
+ });
+ },
+ submitForm() {
+ console.log('Submitting:', this.formData);
+ if (!this.formData.productionWorkOrder) {
+ uni.showToast({title: '璇烽�夋嫨鐢熶骇宸ュ崟', icon: 'none'});
+ return;
+ }
+ // 鎻愪氦閫昏緫
+ // this.$post({url: '/api/submitDefect', data: this.formData}).then(...)
+
+ uni.showToast({
+ title: '鐧昏鎻愪氦鎴愬姛',
+ icon: 'success'
+ });
+ }
+ }
+};
+</script>
+
+<style>
+.content {
+ background-color: #f5f5f5;
+ min-height: 100vh;
+ display: flex;
+ flex-direction: column;
+}
+.page-header {
+ background-color: #90CAF9; /* Light Blue */
+ padding: 44px 15px 10px 15px; /* Status bar padding */
+}
+.header-content {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+.page-title {
+ font-size: 18px;
+ font-weight: bold;
+ color: #333;
+}
+.header-right {
+ color: #fff;
+ font-size: 14px;
+}
+.form-container {
+ background-color: #fff;
+ margin-top: 0;
+ flex: 1;
+}
+.form-item {
+ display: flex;
+ align-items: center;
+ padding: 12px 15px;
+ border-bottom: 1px solid #eee;
+}
+.label {
+ width: 90px;
+ font-size: 15px;
+ color: #333;
+}
+.input {
+ flex: 1;
+ font-size: 15px;
+}
+.value {
+ flex: 1;
+ font-size: 15px;
+ color: #666;
+}
+.picker {
+ flex: 1;
+}
+.picker-content {
+ font-size: 15px;
+ color: #333;
+}
+.scan-icon {
+ width: 30px;
+ height: 30px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ margin-left: 10px;
+ background-color: #4CD964; /* Green background for icon */
+ border-radius: 4px;
+}
+.scan-icon uni-icons {
+ /* Make icon white if background is green, but uni-icons color prop handles it */
+}
+/* Override uni-icons color to white since background is green */
+.scan-icon ::v-deep span {
+ color: #fff !important;
+}
+
+.footer {
+ padding: 20px;
+}
+.submit-btn {
+ background-color: #7B68EE; /* Purple */
+ color: #fff;
+ border-radius: 5px;
+ font-size: 16px;
+ height: 44px;
+ line-height: 44px;
+}
+.hint {
+ color: #999;
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3