From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 28 五月 2025 16:48:52 +0800
Subject: [PATCH] 初始化项目

---
 pages/wareHouse/outsource/sampling.vue |  173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 173 insertions(+), 0 deletions(-)

diff --git a/pages/wareHouse/outsource/sampling.vue b/pages/wareHouse/outsource/sampling.vue
new file mode 100644
index 0000000..804ff5f
--- /dev/null
+++ b/pages/wareHouse/outsource/sampling.vue
@@ -0,0 +1,173 @@
+<template>
+	<layout title="鎶芥" @scanHandle="addScanCode">
+		<view style="padding-top: 100rpx;" v-if="list.length == 0">
+			<u-empty text="璇锋壂鐮�" mode="list" icon-color="black" color="black"></u-empty>
+		</view>
+		<view class="formWrap">
+			<view class="formBox" v-for="(item, index) in list" :key="item.certificateNo" :index="index">
+				<u-form class="form" :model="item" :rules="rules" :ref="item.certificateNo" label-position="left">
+					<u-form-item label="鎶ユ娴佹按鍙�" prop="inspectionSerialNo" label-width="180" >
+						<text>{{item.inspectionSerialNo}}</text>
+					</u-form-item>
+					<u-form-item label="鍚堟牸璇佸彿" prop="certificateNumber" label-width="180" >
+						<text>{{item.certificateNumber}}</text>
+					</u-form-item>
+					<u-form-item label="闀垮害(km)" prop="inspectionQuantity" label-width="180" >
+						<text>{{item.inspectionQuantity}}</text>
+					</u-form-item>
+					<u-form-item label="鎶芥鐘舵��" prop="samplingState" label-width="180" >
+						<!-- <text>{{item.samplingState=='1'?'宸叉娊妫�':'鏈娊妫�'}}</text> -->
+						<text>寰呮娊妫�</text>
+					</u-form-item>
+					<u-form-item label="鎶芥鏃堕棿" prop="createTime" label-width="180" >
+						<text>{{nowTime}}</text>
+					</u-form-item>
+				</u-form>
+				<view class="delBtnWrap">
+					<u-button class="delBtn" type="primary" size="mini"  @click="deleteItem(item)">
+						<u-icon size="30" name="trash" class="icon"/>鍒犻櫎
+					</u-button>
+				</view>	
+			</view>
+			
+		</view>
+		<view class="form-footer" v-if="list.length > 0">
+			<u-button class="btn" type="primary" @click="submit">鎶芥</u-button>
+		</view>
+		<scan></scan>
+	</layout>
+</template>
+
+<script>
+	import scan from "@/components/scan/scan.vue";
+	import util from "@/util/ble/util.js";
+	import layout from "./layout";
+	let defaultState = '寰呮娊妫�'
+	export default {
+		components: {
+			scan,layout
+		},
+		data() {
+			return {
+				type: 'sampling',//inspDeclaration锛氭姤妫�  sampling锛氭娊妫�  declaration锛氭娴�  packaging锛氬寘瑁�  stock锛氬叆搴�
+				list: [
+					// {
+					// id: 0,
+					// no: 'BJ00001',
+					// certificateNo:'00001',
+					// len:0.2,
+					// state:defaultState,
+					// createTime:util.formatTime(new Date())
+					// },
+				],
+				rules: {
+					// len: [{
+					// 	required: true,
+					// 	message: '闀垮害涓嶈兘涓虹┖',
+					// 	trigger: 'blur'
+					// }],
+				},
+				nowTime:util.formatTime(new Date())
+			}
+		},
+		onShow() {
+		
+			let that = this
+		
+			uni.$off('scan') // 姣忔杩涙潵鍏� 绉婚櫎鍏ㄥ眬鑷畾涔変簨浠剁洃鍚櫒
+			uni.$on('scan', function(data) {
+				console.log('onscan');
+				//鎵爜鎴愬姛鍚庣殑鍥炶皟锛屼綘鍙互鍐欒嚜宸辩殑閫昏緫浠g爜鍦ㄨ繖閲�
+				console.log('鎵爜缁撴灉锛�', data.code);
+				that.addScanCode(data.code)
+				that.$forceUpdate();
+		
+			})
+		},
+		onNavigationBarButtonTap(e) {
+			uni.scanCode({
+				success: res => {
+					try {
+						// uni.showToast({
+						// 	title:res.result
+						// })
+						// const result = JSON.parse(res.result)
+						// console.log('鎵爜缁撴灉锛�', result);
+						this.addScanCode(res.result)
+					} catch (e) {}
+				}
+			});
+		},
+		onLoad(){
+			// this.addScanCode('00003')
+			// this.addScanCode('00001')
+		},
+		methods: {
+			//鑾峰彇鎵竴鎵暟鎹�
+			addScanCode(code){
+				//妫�娴嬫槸鍚﹀凡鎵繃
+				let result = this.list.find(item => item.certificateNumber==code)
+				if (result) {
+					this.$u.toast('宸插瓨鍦ㄥ垪琛ㄤ腑')
+				} else {
+					//娣诲姞涓�鏉℃暟鎹�
+					let param = {
+						current: 1,
+						size: 100,
+						certificateNumber:code
+					}
+					this.$u.api.outsource.queryData(param).then(res => {
+						console.log(res);
+						if (res.code === 0) {
+							let data = res.data.records
+							let exist = false
+							if (data.length > 0) {
+								for (var i = 0; i < data.length; i++) {
+									if (data[i].state == 'unSampling') {
+										//鍙栧緟鎶芥鐨�
+										this.list.push(data[i])
+										exist = true
+									}
+								}
+							} 
+							if (!exist){
+								this.$u.toast('娌℃湁鍙娊妫�鐨勬暟鎹�')
+							}
+							
+						}
+						
+					});
+				}
+				
+				
+			},
+			//鎻愪氦
+			submit(){
+				this.$u.api.outsource.submitReport(this.list, this.type).then(res => {
+					if (res.code == 0) { 
+						this.$u.toast('鎻愪氦鎴愬姛')
+						this.list = []
+					} else {
+						this.$u.toast('鎻愪氦澶辫触')
+					}
+				});
+			},
+			deleteItem(model) {
+				uni.showModal({
+					title: '鎻愮ず',
+					content: '鏄惁纭畾鍒犻櫎?',
+					success: res => {
+						if (res.confirm) {
+							this.list = this.list.filter(item => item.certificateNo!=model.certificateNo)
+						}
+					}
+				});
+				
+			}
+		}
+	}
+</script>
+
+<style>
+
+</style>

--
Gitblit v1.9.3