From 9e7bbd1a203c39c74b81624640a5ea8f6e247ba3 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 14 五月 2024 10:08:02 +0800
Subject: [PATCH] 1.外协收料不良数量可填多个

---
 pages/wwgl/wxsl.vue |  660 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 659 insertions(+), 1 deletions(-)

diff --git a/pages/wwgl/wxsl.vue b/pages/wwgl/wxsl.vue
index 02409e3..b3ff920 100644
--- a/pages/wwgl/wxsl.vue
+++ b/pages/wwgl/wxsl.vue
@@ -1,8 +1,666 @@
 <template>
+	<view>
+		<page-nav title="濮斿鏀舵枡"></page-nav>
+
+
+		<view v-show="topContent.length===0">
+			<div class="sacnBody">
+				<div class="scanImg" @click="topScanClick"></div>
+				<div class="scanText">鎵弿浠诲姟鏉$爜</div>
+			</div>
+		</view>
+
+		<view v-show="topContent.length!==0" class="mainContent">
+			<u-gap height="10" bgColor="#eff0f1"></u-gap>
+			<view class="head">
+				<view class="head_block">
+					<view class="head_left">
+						<view class="head_bar"></view>
+						<view class="head_title" style="font-weight: bolder;">
+							鏀舵枡淇℃伅
+						</view>
+					</view>
+				</view>
+
+				<view class="marginLeft20 marginRight20" style="height: 410rpx;" v-if="topContent.length!==0">
+					<view class="marginBottom20" style="display: flex;">
+						<!--  v-for="item in purchorderArr"  -->
+						<view class="flex_column titleFont">
+							<view>宸ュ崟缂栧彿锛�</view>
+							<view>浜у搧缂栫爜锛�</view>
+							<view>浜у搧鍚嶇О锛�</view>
+							<view>浜у搧瑙勬牸锛�</view>
+							<view>褰撳墠宸ュ簭锛�</view>
+							<view>浠诲姟鏁伴噺锛�</view>
+							<view>鏈敹/宸叉敹锛�</view>
+							<view>涓嬮亾宸ュ簭锛�</view>
+						</view>
+						<view class="flex_column contentFont">
+							<view>{{topContent[0].wo_code}}</view>
+							<view>{{topContent[0].partnumber}}</view>
+							<view>{{topContent[0].partname}}</view>
+							<view>{{topContent[0].partspec?topContent[0].partspec:'/'}}</view>
+							<view>{{topContent[0].stepname}}</view>
+							<view>{{topContent[0].planqty}}</view>
+							<view>{{topContent[0].startqty+'/'+topContent[0].reportqty}}</view>
+							<view>{{topContent[0].nextstepname?topContent[0].nextstepname:'/'}}</view>
+						</view>
+					</view>
+				</view>
+
+			</view>
+
+
+			<u-gap height="10" bgColor="#eff0f1"></u-gap>
+			<view class="head">
+				<view class="head_block">
+					<view class="head_left">
+						<view class="head_bar"></view>
+						<view class="head_title" style="font-weight: bolder;">
+							鏀舵枡鎿嶄綔
+						</view>
+					</view>
+				</view>
+
+				<view class="flex_column">
+
+					<view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
+						<view style="display: flex;" class="titleFont">
+							<view style="color: red;margin-right: 6rpx;">*</view> 澶栧崗渚涙柟
+						</view>
+						<view style="margin-left: 20rpx;">
+							<view @click='WXSheetClick' class="custominputClass">
+								<view v-show='WXSheetValue===""' style="color: rgb(192, 196, 204);">璇烽�夋嫨</view>
+								<view v-show='WXSheetValue!==""' class="ellipsis" style="width: 390rpx;">
+									{{WXSheetValue}}
+								</view>
+								<u-icon :name="!WXSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
+							</view>
+						</view>
+					</view>
+
+					<view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
+						<view style="display: flex;" class="titleFont">
+							<view style="color: red;margin-right: 6rpx;">*</view> 鏀舵枡浜哄憳
+						</view>
+						<view style="margin-left: 20rpx;">
+							<view @click='userSheetClick' class="custominputClass">
+								<view v-show='userSheetValue===""' style="color: rgb(192, 196, 204);">璇烽�夋嫨</view>
+								<view v-show='userSheetValue!==""' class="ellipsis" style="width: 390rpx;">
+									{{userSheetValue}}
+								</view>
+								<u-icon :name="!userSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
+							</view>
+						</view>
+					</view>
+
+
+					<view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
+						<view style="color: red;margin-right: 6rpx;">*</view> 鏀舵枡鏁伴噺
+						<view style="margin-left: 20rpx;">
+							<view class='inputClass'>
+								<u--input placeholder="璇疯緭鍏�" border="surround" type='number' v-model="sqty">
+								</u--input>
+							</view>
+						</view>
+					</view>
+
+
+
+				</view>
+
+
+
+				<u-gap height="10" bgColor="#eff0f1"></u-gap>
+				<view class="head" v-if="topContent.length!==0">
+					<view class="head_block">
+						<view class="head_left">
+							<view class="head_bar"></view>
+							<view class="head_title" style="font-weight: bolder;">
+								鍙敹鏂欎緵搴斿晢
+							</view>
+						</view>
+					</view>
+
+					<view class="flex_column marginLeft20 marginRight20 marginBottom20 titleFont">
+						<view v-for='(i,index) in topContent[0].list'
+							v-if="parseFloat(i.fqty) - parseFloat(i.sqty) - parseFloat(i.ng_qty) - parseFloat(i.laborbad_qty)- parseFloat(i.materielbad_qty)>0"
+							style="display: flex;">
+							<view>{{index+1}}</view>
+							<view class="ellipsis" style="width: 400rpx;margin: 0 30rpx;">{{i.tp}}</view>
+							<view>
+								{{ parseFloat(i.fqty) - parseFloat(i.sqty) - parseFloat(i.ng_qty) - parseFloat(i.laborbad_qty)- parseFloat(i.materielbad_qty)}}
+							</view>
+							<!-- <view>浠�</view> -->
+						</view>
+
+					</view>
+
+				</view>
+
+				<u-gap height="10" bgColor="#eff0f1"></u-gap>
+
+
+				<view class="head  marginLeft10 marginRight10" style="padding-bottom: 20rpx;">
+					<view class="head_block">
+						<view class="head_left">
+							<view class="head_bar"></view>
+							<view class="head_title">
+								涓嶈壇缁熻
+							</view>
+						</view>
+
+					</view>
+					<view class="flex_column ">
+
+
+						<u-button type="primary" :plain="true" icon='plus-circle' text="娣诲姞"
+							style="width: 90%;margin: 20rpx auto;" @click="add"></u-button>
+
+
+						<view v-for='(item,index) in ngqtyArr' class="badSheetClass" :key="item.uid">
+
+							<view class="badNumber">{{index+1}}</view>
+							<u-icon name="trash" size="20" class="trash" v-if="ngqtyArr.length!==1"
+								@click="trashDelete(index)" color="rgb(0, 102, 255)"></u-icon>
+
+							<view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
+								<view style="color: #fff;margin-right: 6rpx;">*</view> 涓嶈壇鏁伴噺锛�
+								<view class='inputClass'>
+									<u--input placeholder="璇疯緭鍏�" border="surround" :adjustPosition='false' type='number'
+										v-model="item.ngqty"></u--input>
+								</view>
+
+							</view>
+							<view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
+								<view style="display: flex;" class="titleFont">
+									<view style="color: #fff;margin-right: 6rpx;">*</view> 涓嶈壇鍘熷洜锛�
+								</view>
+								<view @click='badSheetClick(item)' class="custominputClass">
+									<view v-show='item.badSheetValue.length===0' style="color: rgb(192, 196, 204);">璇烽�夋嫨
+									</view>
+									<view v-show='item.badSheetValue.length!==0' class="ellipsis"
+										style="width: 390rpx;">
+										{{item.badSheetValue}}
+									</view>
+									<u-icon :name="item.arrowDown?'arrow-down-fill':'arrow-up-fill'"></u-icon>
+								</view>
+							</view>
+
+							<u-divider></u-divider>
+
+
+						</view>
+
+					</view>
+				</view>
+
+
+
+
+
+			</view>
+
+
+			<u-picker v-if="topContent.length!==0" :show="WXSheetShow" :columns="WXColumns" :itemHeight='55'
+				:closeOnClickOverlay='true' @close='WXSheetShow=false' @confirm='WXPickerConfirm'
+				@cancel='WXSheetShow=false'>
+			</u-picker>
+
+
+			<u-picker v-if="topContent.length!==0" :show="userSheetShow" :columns="userColumns" :itemHeight='55'
+				:closeOnClickOverlay='true' @close='userSheetShow=false' @confirm='userPickerConfirm'
+				@cancel='userSheetShow=false'>
+			</u-picker>
+
+
+			<!-- 涓嶈壇鍘熷洜 -->
+			<u-action-sheet v-if="topContent.length!==0" :actions="badSelectArr" :safeAreaInsetBottom='true'
+				:closeOnClickOverlay="true" :closeOnClickAction="true" @close="badSelectClose" :show="badSheetShow"
+				@select='badSheetSelect'>
+				<view style="min-height: 100rpx;">
+					<u-checkbox-group @change="checkboxChange" size='20px' v-model="checkBoxValue" iconPlacement="right"
+						placement="column">
+						<view v-for="(item,index) in badSelectArr">
+							<u-checkbox activeColor="rgb(0, 102, 255)" labelSize='18' :key="item.code+index"
+								:name='item.name' :label="item.name">
+							</u-checkbox>
+						</view>
+					</u-checkbox-group>
+				</view>
+			</u-action-sheet>
+
+
+
+
+		</view>
+
+		<u-button size="large" v-show="topContent.length!==0" :loading="isDisabledSubmitButton"
+			loadingText="姝e湪鎻愪氦,璇风◢绛�..." type="primary" @click="submit" text="鏀舵枡">
+		</u-button>
+
+
+		<!-- 鎮诞鐞� -->
+		<!-- 	<view v-show="topContent.length!==0&&!WXSheetShow&&!userSheetShow&&!badSheetShow" @click="topScanClick">
+			<drag-ball :x='$DeviceInformation.screenWidth*0.8' :y="$DeviceInformation.screenHeight*0.7"></drag-ball>
+		</view> -->
+
+		<!-- <scan-code></scan-code> -->
+
+
+	</view>
 </template>
 
+
 <script>
+	import {
+		MesOrderStepStart,
+		CustomerPermissions,
+		PersonPermissions,
+		DefectPermissions,
+		SavaMesOrderStepIn,
+		LabelBarCode
+	} from '../../config/api.js';
+	// import scanCode from '@/components/scan-code/scan-code.vue'
+
+	export default {
+		onLoad(option) {
+
+		},
+
+		onPullDownRefresh() {
+			setTimeout(() => {
+				this.init(() => {
+					uni.stopPullDownRefresh();
+				})
+			}, 1000);
+		},
+
+		data() {
+			return {
+				topRightMessageCount: '',
+
+				isDisabledSubmitButton: false,
+
+				topContent: [],
+				// {
+				// "wo_code": "MO-2023-06-0003_1",
+				// "partnumber": "308",
+				// "partname": "鐢垫睜鍖�",
+				// "partspec": "",
+				// "seq": "2",
+				// "stepcode": "ZSStep03",
+				// "stepname": "鍘绘瘺鍒�",
+				// "nextstepcode": "ZSStep06",
+				// "nextstepname": "鍖呰2",
+				// "stepdesc": "",
+				// "wkshopcode": "ZS001",
+				// "wkshopname": "娉ㄥ杞﹂棿",
+				// "planqty": 50.00,
+				// "startqty": 29.00,
+				// "noreportqty": 29.00,
+				// "reportqty": 21.00,
+				// "noputqty": 0.0,
+				// "list": null
+				// }, //鎵弿浠诲姟鏉$爜鎵�甯﹀嚭鏉ョ殑鍐呭
+
+				WXSheetValue: '',
+				WXSheetShow: false, //涓婃媺鍒楄〃鏄惁灞曞紑
+				WXColumns: [],
+				WXSheetList: [],
+
+
+				userSheetValue: '',
+				userSheetShow: false,
+				userColumns: [],
+				userSheetList: [],
+
+				sqty: null,
+				ngqty: null,
+
+
+				badSelectArr: [],
+				checkBoxValue: '',
+				badSheetShow: false,
+				badSheetValue: '',
+
+
+				ngqtyArr: [{
+						uid: new Date().getTime(),
+						ngqty: '',
+						badSheetValue: '',
+						arrowDown: true //鍚戜笅绠ご
+					},
+					// {
+					// 	ngqty: '',
+					// 	badSheetValue: '',
+					// 	arrowDown: true //鍚戜笅绠ご
+					// },
+				], //涓嶈壇鏁伴噺銆佷笉鑹師鍥犳暟缁�
+
+
+
+				notes: null //澶囨敞
+
+
+
+
+			}
+		},
+		created() {
+
+		},
+		mounted() {
+			this.init()
+
+
+			// this.getMesOrderStepStart('MO-2023-09-0002_1;106')
+
+
+			this.handleSelectAllApi()
+		},
+		methods: {
+			init() {
+				uni.stopPullDownRefresh();
+			},
+			async handleSelectAllApi() {
+				await this.getCustomerPermissions()
+				await this.getPersonPermissions()
+				await this.getDefectPermissions()
+			},
+
+			async getPersonPermissions(val) {
+				const data = {
+					usercode: val
+				}
+				const res = await PersonPermissions(this.global.formatData(data))
+				this.userSheetList = res.data
+				this.userColumns = [res.data.map(i => i.username)]
+			},
+
+			async getCustomerPermissions() {
+
+				const res = await CustomerPermissions()
+				this.WXSheetList = res.data
+				this.WXColumns = [res.data.map(i => i.name)]
+			},
+			// 鑾峰彇涓嶈壇鍘熷洜
+			async getDefectPermissions() {
+				const res = await DefectPermissions()
+				if (res.code === '200') {
+					this.badSelectArr = res.data
+				}
+			},
+
+
+			async getMesOrderStepStart(val) {
+				const data = {
+					OperType: 'WX',
+					SelectType: 'IN',
+					wocode: val ? val.split(';')[0] : '',
+					stepcode: val ? val.split(';')[1] : ''
+				}
+
+				const res = await MesOrderStepStart(this.global.formatData(data))
+				console.log(res, 3)
+
+				if (res.code === '200') {
+					// this.getCustomerPermissions(val)
+					// this.getMesOrderSelectUser(val)
+					// this.getDefectPermissions(val)
+					this.WXSheetValue = ''
+					this.userSheetValue = ''
+					this.checkBoxValue = ''
+					this.badSheetValue = ''
+					this.sqty = null
+					this.ngqty = null
+					this.notes = null
+					this.topContent = []
+					this.topContent.push(res.data)
+				}
+				// console.log(this.topContent,6)
+
+			},
+
+			//  浠诲姟鏉$爜  鐨勬壂鐮佹鐐瑰嚮
+			topScanClick() {
+				let that = this;
+
+				uni.scanCode({
+					onlyFromCamera: true,
+					// scanType: ['barCode', 'qrCode'],
+					scanType: ['qrCode'],
+					success: function(res) {
+						console.log('鏉$爜绫诲瀷锛�' + res.scanType);
+						console.log('鏉$爜鍐呭锛�' + res.result);
+
+						that.getMesOrderStepStart(res.result)
+
+					},
+					complete: function(res) {
+
+					},
+					fail: function(res) {
+						console.log('鏉$爜绫诲瀷锛�' + res.scanType);
+						console.log('鏉$爜鍐呭锛�' + res.result);
+					}
+
+				});
+			},
+			badSheetClick(item) {
+				if (!item.ngqty) {
+					return uni.$u.toast('璇峰厛濉啓涓嶈壇鏁伴噺锛�')
+				}
+				item.arrowDown = !item.arrowDown
+
+				this.checkBoxValue = item.badSheetValue.split(',')
+				this.badSheetShow = true
+			},
+
+			badSheetSelect(val) {
+				console.log('鎵ц浜嗭紒')
+			},
+			checkboxChange(val) {
+				this.badSheetValue = val.join(',')
+			},
+
+
+			WXSheetClick() {
+				this.WXSheetShow = true
+			},
+
+			WXPickerConfirm(val) {
+				this.WXSheetValue = val.value[0]
+				this.WXSheetShow = false
+			},
+
+			userSheetClick() {
+				this.userSheetShow = true
+			},
+
+			userPickerConfirm(val) {
+				this.userSheetValue = val.value[0]
+				this.userSheetShow = false
+			},
+
+			// 娣诲姞
+			add() {
+
+				// if (this.ngqtyArr.find(i => i.badSheetValue === '')) {
+				// 	return uni.$u.toast('璇峰厛瀹屽杽鍓嶉潰涓嶈壇閫夐」锛�')
+				// }
+
+				this.ngqtyArr.unshift({
+					uid: new Date().getTime(),
+					ngqty: '',
+					badSheetValue: '',
+					arrowDown: true //鍚戜笅绠ご
+				})
+
+			},
+
+			//鍒犻櫎
+			trashDelete(index) {
+				this.ngqtyArr.splice(index, 1)
+			},
+
+			badSelectClose() {
+				let index = this.ngqtyArr.findIndex(i => !i.arrowDown)
+
+				this.ngqtyArr[index].badSheetValue = this.checkBoxValue.join(',')
+				this.ngqtyArr[index].arrowDown = true
+
+				this.checkBoxValue = []
+				this.badSheetShow = false
+			},
+
+
+			async submit() {
+
+				if (!this.WXSheetValue) {
+					return uni.$u.toast('澶栧崗渚涙柟涓嶈兘涓虹┖锛�')
+				}
+
+				if (!this.userSheetValue) {
+					return uni.$u.toast('鏀舵枡浜哄憳涓嶈兘涓虹┖锛�')
+				}
+
+				if (!this.sqty) {
+					return uni.$u.toast('鏀舵枡鏁伴噺涓嶈兘涓虹┖锛�')
+				}
+
+				let t = this.topContent[0].list.find(i => i.tp === this.WXSheetValue)
+
+				if (!t) {
+					return uni.$u.toast('璇烽�夋嫨鍙敹鏂欑殑渚涘簲鍟嗭紒')
+				}
+
+				if (!this.ngqtyArr[0].ngqty && (parseFloat(this.sqty) > parseFloat(t.fqty) - parseFloat(t.sqty) -
+						parseFloat(t
+							.ng_qty) - parseFloat(t.laborbad_qty) - parseFloat(t.materielbad_qty))) {
+					return uni.$u.toast('鏀舵枡鏁伴噺涓嶈兘澶т簬璇ヤ緵搴斿晢鐨勫彲鏀舵敹鏂欙紒')
+				}
+
+				// 涓嶈壇鍘熷洜
+				const defectlist = []
+				//涓嶈壇鏁伴噺
+				let ngqtyNumber = 0
+
+				this.ngqtyArr.forEach(i => {
+					if (i.badSheetValue.toString().length > 0) {
+						let codeArr = []
+						ngqtyNumber += parseFloat(i.ngqty)
+						i.badSheetValue.split(',').forEach(j => {
+							codeArr.push(this.badSelectArr.find(i => i.name === j).code)
+						})
+						defectlist.push({
+							badqty: i.ngqty,
+							defect_code: codeArr.join(',')
+						})
+					}
+				})
+
+				if ((parseFloat(this.sqty) + parseFloat(ngqtyNumber) > parseFloat(t.fqty) - parseFloat(t
+						.sqty) - parseFloat(t.ng_qty) - parseFloat(t.laborbad_qty) - parseFloat(t.materielbad_qty))) {
+					return uni.$u.toast('鏀舵枡鏁伴噺+涓嶈壇鏁伴噺涓嶈兘澶т簬璇ヤ緵搴斿晢鐨勫彲鏀舵敹鏂欙紒')
+				}
+
+
+				const D = {
+					rightcode: '0601',
+					partcode: this.topContent[0].partnumber,
+					qty: parseFloat(this.sqty),
+					onelabqty: parseFloat(this.sqty)
+				}
+				const {
+					data: R
+				} = await LabelBarCode(D)
+
+
+				const data = {
+					mesordercode: this.topContent[0].wo_code, // 宸ュ崟缂栧彿
+					partcode: this.topContent[0].partnumber, // 浜у搧缂栫爜
+					stepseq: this.topContent[0].seq, // 宸ュ簭搴忓彿    
+					stepcode: this.topContent[0].stepcode, // 宸ュ簭缂栫爜
+					wxcode: this.WXSheetList.find(i => i.name === this.WXSheetValue).code, // 澶栧崗渚涘簲鍟嗙紪鐮�
+					inuser: this.userSheetList.find(i => i.username === this.userSheetValue).usercode, // 鍙戞枡浜哄憳
+					taskqty: this.topContent[0].planqty, // 浠诲姟鏁伴噺
+					sqty: this.sqty, // 鏀舵枡鏁伴噺
+					// ngqty: !this.ngqty ? 0 : this.ngqty,
+					remarks: this.notes,
+					defectlist,
+					inbarcode: R[0].labcode, //鍏ュ簱鏉$爜
+				}
+
+				console.log(JSON.parse(JSON.stringify(data)), 6)
+
+				this.isDisabledSubmitButton = true
+				const res = await SavaMesOrderStepIn(data)
+
+				if (res.code === '200') {
+					uni.$u.toast('鏀舵枡鎴愬姛锛�')
+
+					this.WXSheetValue = ''
+					this.userSheetValue = ''
+					this.checkBoxValue = ''
+					this.badSheetValue = ''
+					this.sqty = null
+					this.ngqty = null
+					this.notes = null
+					this.topContent = []
+
+					this.isDisabledSubmitButton = false
+				}
+
+			}
+		}
+	}
 </script>
 
-<style>
+<style lang="scss" scoped>
+	@import url('@/style/global.css');
+
+	::v-deep .uicon-arrow-left>span {
+		display: block;
+	}
+
+	::v-deep .u-action-sheet {
+		max-height: 600rpx !important;
+		overflow: auto !important;
+	}
+
+	::v-deep .u-checkbox-label--right {
+		padding: 30rpx;
+		border-bottom: 1rpx solid #eee;
+	}
+
+	.custominputClass {
+		width: 412rpx;
+		display: flex;
+		justify-content: space-between;
+		border: 3rpx #eff0f1 solid;
+		border-radius: 10rpx;
+		padding: 0 16rpx;
+		line-height: 68rpx;
+	}
+
+
+	.badSheetClass {
+		position: relative;
+	}
+
+	.badNumber {
+		position: absolute;
+		top: 20rpx;
+		left: 20rpx;
+		font-size: 26rpx;
+		color: rgb(0, 102, 255)
+	}
+
+	.trash {
+		position: absolute;
+		top: 20rpx;
+		right: 30rpx;
+		font-size: 26rpx;
+	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3