From ea87c908fb6cdfc3e227a584a53e6730efb8262a Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 26 十月 2023 13:41:12 +0800
Subject: [PATCH] 小程序代码

---
 minipro_standard/pages_adjust/pages/workOrderReporting/workOrderReporting.vue |  276 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 178 insertions(+), 98 deletions(-)

diff --git a/minipro_standard/pages_adjust/pages/workOrderReporting/workOrderReporting.vue b/minipro_standard/pages_adjust/pages/workOrderReporting/workOrderReporting.vue
index a3859e1..7f7965e 100644
--- a/minipro_standard/pages_adjust/pages/workOrderReporting/workOrderReporting.vue
+++ b/minipro_standard/pages_adjust/pages/workOrderReporting/workOrderReporting.vue
@@ -172,25 +172,24 @@
 					</div>
 				</div>
 			</div>
-
 		</div>
 		<div class="details_dj" v-if="typeView === 1">
 
-			<div class="details_dj_list">
-				
-				<u-swipe-action>
-					<u-swipe-action-item v-for="(item, index) in djData" :key="index" :options="options"
-						@click="dele(item.id)">
-						<div class="details_dj_list_item">
-							<span>{{ item.attrName }}锛歿{ item.val }}</span>
-							<span>{{ item.userName }} {{ item.createTime }}</span>
-						</div>
-					</u-swipe-action-item>
-				</u-swipe-action>
+			<div class="details_dj_list">
+				<scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="getLists">
+					<u-swipe-action v-for="(item, index) in djData" :key="index">
+						<u-swipe-action-item :options="options" @click="dele(item.id)">
+							<div class="details_dj_list_item">
+								<span>{{ item.attrName }}锛歿{ item.val }}</span>
+								<span>{{ item.userName }} {{ item.createTime }}</span>
+							</div>
+						</u-swipe-action-item>
+					</u-swipe-action>
+				</scroll-view>
 			</div>
 		</div>
 		<!-- v-if="info.status === 2 || info.procedureNeedcheck === 1" -->
-		<template>
+		<template v-if="info.status === 2 || info.procedureNeedcheck === 1">
 			<div class="bh_zw"></div>
 			<div class="bg_footer bg_f7">
 				<div class="bg_footer_submit bg_m" v-if="typeView == 0" @click="submit">纭鎶ュ伐</div>
@@ -249,6 +248,9 @@
 		queryOne,
 		queryList
 	} from '@/util/api/PlanningAPI'
+	import {
+		REGULAR
+	} from '@/util/utils'
 	export default {
 		components: {
 			workOrderInfo
@@ -264,7 +266,7 @@
 				],
 				form: {
 					time: '',
-					efective: [],
+					defective: [],
 					defectiveName: '',
 					durationName: '0灏忔椂0鍒嗛挓',
 					duration: 0,
@@ -276,37 +278,14 @@
 				typeView: 0,
 				workorderId: '',
 				info: {},
-				feedingData: [
-					// {
-					// 	id: 0,
-					// 	materialName: '澧欎綋鐮�',
-					// 	procedureName: '鍘嬪埗',
-					// 	qualityType: 1,
-					// 	locationName: 'CP-01',
-					// 	batch: '20230713',
-					// 	num: 2,
-					// 	maxNum: 10,
-					// 	unitAttribute: 1,
-					// 	unitName: '鍧�'
-					// },
-				],
+				feedingData: [],
 				options: [{
 					text: '鍒犻櫎',
 					style: {
 						backgroundColor: 'red',
 					}
 				}],
-				arrType: [{
-						name: '璁℃椂',
-						type: 1,
-						salary: 1000,
-					},
-					{
-						name: '璁′欢',
-						type: 0,
-						salary: 100
-					},
-				],
+				arrType: [],
 				// 浜у嚭鍚堟牸/涓嶈壇
 				produceFrom: {
 					qualifiedId: '',
@@ -314,23 +293,14 @@
 					undesirableId: '',
 					undesirable: '' // 涓嶈壇
 				},
-				djData: [{
-					attrName: '鍑烘按鏃堕棿',
-					val: '2022-05-28 16:3',
-					userName: '寮犱笁 ',
-					createTime: '2022-05-28 16:32:'
-				}],
-				cateList: [
-					// {
-					// 	active: false,
-					// 	name: '姣涘埡',
-					// 	num: 0
-					// },
-				],
-				pages: {
-					capacity: 10,
-					page: 1,
-					total: 0
+				triggered: false,
+				finished: true,
+				djData: [],
+				cateList: [],
+				pages: {
+					capacity: 10,
+					page: 1,
+					total: 0
 				}
 			};
 		},
@@ -339,6 +309,15 @@
 			this.queryByIds()
 			this.getOrocessRecords()
 			this.getData()
+			uni.$on('spotAdd', () => {
+				if (this.typeView == 1) {
+					this.pages.page = 1
+					this.pageDJs()
+				}
+			})
+			uni.$on('addMaterial', () => {
+				this.getOrocessRecords()
+			})
 		},
 		computed: {
 			expectedSalary() {
@@ -359,10 +338,10 @@
 					return (Number(h) * (this.arrType[this.form.index].salary / 10 / 10)).toFixed(2) || 0
 				}
 			},
-			complianceRate() {
-				if (this.arrType.length === 0) return 0;
-				if (!this.produceFrom.qualified && !this.produceFrom.undesirable) return 0;
-				if (!this.form.duration) return 0;
+			complianceRate() {
+				if (this.arrType.length === 0) return 0;
+				if (!this.produceFrom.qualified && !this.produceFrom.undesirable) return 0;
+				if (!this.form.duration) return 0;
 				if (!this.arrType[this.form.index].num) return 0;
 				// 鎸変欢璁$畻
 				// if (infoBox.value.type == 0) {
@@ -373,9 +352,9 @@
 					return ((Number(a) / Number(b)) * 100).toFixed(2)
 					// let total = (Number(from.qualified) + Number(from.undesirable)) / ((from.duration * 60 * 60) * infoBox.value.num / )
 					// return total * infoBox.value.salary;
-				} else {
+				} else {
 					let a = (this.produceFrom.qualified / (this.form.duration / 3600)).toFixed(2)
-					let b = (this.arrType[this.form.index].num / (this.arrType[this.form.index].times / 3600)).toFixed(2)
+					let b = (this.arrType[this.form.index].num / (this.arrType[this.form.index].times / 3600)).toFixed(2)
 					return ((Number(a) / Number(b)) * 100).toFixed(2)
 					// return Number(from.qualified) * infoBox.value.salary;
 				}
@@ -436,6 +415,10 @@
 			},
 			clickIten(index) {
 				this.typeView = index
+				if (this.typeView == 1) {
+					this.pages.page = 1
+					this.pageDJs()
+				}
 			},
 			timeConfirm({
 				value
@@ -499,10 +482,14 @@
 				// })
 			},
 			changeCC(downType, num, recordId) {
-				if (!num) return
+				if (!num) return
 				console.log(Number(this.produceFrom.qualified) + Number(this.produceFrom.undesirable))
-				if ((Number(this.produceFrom.qualified) + Number(this.produceFrom.undesirable)) > this.info.planNum) {
-					uni.showToast({ title:'浜у嚭鏁伴噺涓嶈兘澶т簬璁″垝鏁伴噺', duration: 2000, icon:'none' })
+				if ((Number(this.produceFrom.qualified) + Number(this.produceFrom.undesirable)) > this.info.planNum) {
+					uni.showToast({
+						title: '浜у嚭鏁伴噺涓嶈兘澶т簬璁″垝鏁伴噺',
+						duration: 2000,
+						icon: 'none'
+					})
 					return
 				}
 				if (num >= 0) {
@@ -520,52 +507,120 @@
 						this.produceFrom.qualified = 0
 					} else {
 						this.produceFrom.undesirable = 0
-					}
-					uni.showToast({ title:'浜у嚭鏁伴噺涓嶈兘灏忎簬', duration: 2000, icon:'none' })
+					}
+					uni.showToast({
+						title: '浜у嚭鏁伴噺涓嶈兘灏忎簬',
+						duration: 2000,
+						icon: 'none'
+					})
 				}
 			},
 			clickPerformanceType(item, index) {
 				this.form.index = index
 				this.form.type = item.type
 			},
-			submit() {},
-			jumpdj() {
-				uni.navigateTo({
-					url: `/pages_adjust/pages/spotCheck/spotCheck?id=${this.workorderId}`
-				})
+			submit() {
+				let createUnqualifiedDTOList = this.form.defective.map((item) => {
+					return {
+						categoryId: item.id,
+						unQualifiedNum: item.num
+					}
+				})
+				let createWorkorderRecordDTO = {
+					workorderId: this.workorderId,
+					duration: this.form.duration ? this.form.duration : 0,
+					qualifiedNum: this.produceFrom.qualified ? this.produceFrom.qualified : 0,
+					unQualifiedNum: this.produceFrom.undesirable ? this.produceFrom.undesirable : 0
+				}
+				// id: route.query.id
+				comfirmDoneStandard({
+					createUnqualifiedDTOList,
+					createWorkorderRecordDTO
+				}).then(res => {
+					if (res.code === 200) {
+						uni.$u.toast('鎶ュ伐鎴愬姛')
+						setTimeout(() => {
+							uni.navigateBack({
+								data: 2
+							})
+						}, 2000)
+					}
+				})
 			},
-			pageDJs() {},
+			jumpdj() {
+				uni.navigateTo({
+					url: `/pages_adjust/pages/spotCheck/spotCheck?id=${this.workorderId}`
+				})
+			},
+			getLists() {
+				if (!this.finished) {
+					return
+				}
+				this.finished = false
+				this.pages.page += 1
+				this.pageDJs()
+			},
+			pageDJs() {
+
+				pageDJ({
+						capacity: this.pages.capacity,
+						page: this.pages.page,
+						model: {
+							workorderId: this.workorderId
+						}
+					}).then(res => {
+						let {
+							data
+						} = res
+						if (data.page == 1) {
+							this.djData = []
+						}
+						this.djData.push(...data.records)
+						// loading.value = false
+					}).catch(err => {
+						// loading.value = false
+						// finished.value = true
+					})
+					.finally(() => {
+						this.finished = true
+					})
+			},
 			dele(id) {
-				// deletedj(id)
-				//     .then(res => {
-				//       if (res.code === 200) {
-				//         djData.value = []
-				//         finished.value = false
-				//         page.page = 1
-				//         djData.value = []
-				//         pageDJs()
-				//       }
-				//     })
+				deletedj(id)
+					.then(res => {
+						if (res.code === 200) {
+							this.finished = true
+							this.pages.page = 1
+							this.pageDJs()
+						}
+					})
 			},
 			confirm() {
-				console.log('confirm', this.cateList);
 				let isOpen = false
 				this.cateList.forEach((item, index) => {
 					if (item.active) {
 						isOpen = true
 					}
 				})
-				if (!isOpen) {
-					uni.showToast({ title:'璇烽�夋嫨涓嶈壇椤�', duration: 2000, icon:'none' })
-					return
+				if (!isOpen) {
+					uni.showToast({
+						title: '璇烽�夋嫨涓嶈壇椤�',
+						duration: 2000,
+						icon: 'none'
+					})
+					return
 				}
 				let arr = []
 				let total = 0
 				let name = ''
 				this.cateList.forEach((item, index) => {
 					if (item.active) {
-						if (item.num <= 0) {
-							uni.showToast({ title:'涓嶈壇鏁伴噺蹇呴』澶т簬0', duration: 2000, icon:'none' })
+						if (item.num <= 0) {
+							uni.showToast({
+								title: '涓嶈壇鏁伴噺蹇呴』澶т簬0',
+								duration: 2000,
+								icon: 'none'
+							})
 							return
 						}
 						total = total += item.num
@@ -573,9 +628,13 @@
 						name += item.name + item.num + '锛�'
 					}
 				})
-				if (total != Number(this.produceFrom.undesirable)) {
-					uni.showToast({ title:'涓嶈壇鏁板繀椤荤瓑浜庝骇鍑轰笉鑹暟', duration: 2000, icon:'none' })
-					return
+				if (total != Number(this.produceFrom.undesirable)) {
+					uni.showToast({
+						title: '涓嶈壇鏁板繀椤荤瓑浜庝骇鍑轰笉鑹暟',
+						duration: 2000,
+						icon: 'none'
+					})
+					return
 				}
 				this.form.defective = arr
 				this.form.defectiveName = name
@@ -583,12 +642,33 @@
 			},
 			changeChecked(i) {
 				this.cateList[i].active = !this.cateList[i].active
-			},
-			jumpTL() {
-				uni.navigateTo({
-					// url: ''
-					url: `/pages_adjust/pages/manualFeed/manualFeed?id=${this.workorderId}`
-				})
+			},
+			jumpTL() {
+				uni.navigateTo({
+					// url: ''
+					url: `/pages_adjust/pages/manualFeed/manualFeed?id=${this.workorderId}`
+				})
+			},
+			deleItem(id, type) {
+				uni.showModal({
+					title: '鎻愮ず',
+					content: '纭畾鍒犻櫎姝ゆ潯璁板綍鍚楋紵',
+					success: (res) => {
+						if (res.confirm) {
+							console.log('鐢ㄦ埛鐐瑰嚮纭畾');
+							deleteCT(id)
+								.then(res => {
+									this.getOrocessRecords()
+									// if (type === 'C') {
+									// 	this.getOrocessRecordCC()
+									// } else if (type === 'T') {
+									// 	this.getOrocessRecords()
+									// }
+								})
+								.catch(err => {})
+						}
+					}
+				})
 			}
 		}
 	}

--
Gitblit v1.9.3