guoyujia 1 년 전
부모
커밋
f993e6578b
2개의 변경된 파일131개의 추가작업 그리고 24개의 파일을 삭제
  1. 8 0
      api/business/carrier.js
  2. 123 24
      pages/changeBox/index.vue

+ 8 - 0
api/business/carrier.js

@@ -9,4 +9,12 @@ export function getCarrierById(data) {
 		url:'/business/carrier/id=' + data,
 		method: 'GET'
 	})
+}
+
+export function addCarrierReject(data) {
+	return req.request({
+		url:'/business/carrierReject/save',
+		method: 'POST',
+		data: data
+	})
 }

+ 123 - 24
pages/changeBox/index.vue

@@ -3,20 +3,43 @@
 		<view class='content'>
 			<view>
 				<text class='title'>当前箱号</text>
-				<view class="vehicleList uni-row" style="height: 100%;">
-					<view class="vehicleNo uni-row" v-for="(item,index) in vehicleList">
+
+				<view class="vehicleList uni-row" style="overflow: auto;">
+					<view class="vehicleNo uni-row" v-for="(item,index) in vehicleList"
+						>
 						<text>{{item.carrierCode}}</text>
 						<text @click="handleDelVehicleNo(item)">×</text>
 					</view>
 				</view>
+				<view style="border-top:1rpx solid #e1e1e1; height: 500rpx; overflow: auto; width: 90%;margin: 0 auto" >
+				<view class="uni-row" style="align-items: center;">
+					<view style="flex: 3;margin-left: 60rpx;">箱号</view>
+					<view style="flex: 3;">是否废弃</view>
+					<view style="flex: 4; " >废弃原因</view>
+				</view>	
+				<view class="vehicleNo uni-row" v-for="(item,index) in discardVehicleList" style="align-items: center;justify-content: space-around;" >
+					<view class="uni-row discardVehicleNo" ><text>{{item.carrierCode}}</text>
+						<text @click="handleDelDiscardVehicleList(item)">×</text>
+					</view>
+					<view class="uni-row" >
+						<switch v-model="item.checked" color="#ff0000" style="transform:scale(0.7)" @change="handleSwitchChange(item)" />
+					</view>
+					<view  class="uni-row">
+				<uni-data-select v-model="item.reason" :localdata="abanonmentList" style="width: 240rpx;"
+					:clear="false"
+					></uni-data-select>
+					</view>
+				</view>
+
+</view>
+				<view class="btn">
+					<button class='submit code' @click="handleScanCode">扫码</button>
+				</view>
 			</view>
-			<view class="btn">
-				<button class='submit code' @click="handleScanCode">扫码</button>
+			<view class='bottom uni-row'>
+				<button class='submit' type=primary @click="debounce(handleSubmit,300)">提交</button>
 			</view>
 		</view>
-		<view class='bottom uni-row'>
-			<button class='submit' type=primary @click="debounce(handleSubmit,300)">提交</button>
-		</view>
 	</view>
 </template>
 <script setup>
@@ -27,6 +50,9 @@
 		onLoad,
 		onReady
 	} from '@dcloudio/uni-app'
+	import {
+		getDictInfoByType
+	} from '@/api/dict/dict.js'
 	import {
 		getDayworkCarrierList
 	} from '@/api/business/dayworkCarrier.js'
@@ -36,9 +62,17 @@
 	import {
 		store
 	} from '@/store/index.js'
-	import { debounce } from '@/utils/common.js'
-	
+	import {
+		debounce
+	} from '@/utils/common.js'
+	import {
+		addCarrierReject
+	} from '@/api/business/carrier.js'
+
 	const vehicleList = ref([])
+	const discardVehicleList = ref([])
+	const abanonmentList = ref([])
+
 	let dayWorkInfo = store.dayworkInfo;
 
 	onLoad(() => {
@@ -58,10 +92,40 @@
 				console.log(vehicleList.value)
 			}
 		})
+		getDictInfoByType('reason_for_abandonment').then((res) => {
+			for (var i = 0; i < res.data.length; i++) {
+				abanonmentList.value[i] = {
+					text: res.data[i].dictLabel,
+					value: res.data[i].dictValue
+				}
+			}
+		})
 	}
-
+	function handleSwitchChange(item) {
+        item.checked = !item.checked
+	}
+    
+	// function handleSelectRejectReason(item) {
+	// 	for (var i = 0; i < abanonmentList.value.length; i++) {
+	// 		if(abanonmentList.value[i].value == item.reason ) {
+	// 			item.reason = abanonmentList.value[i].text
+	// 		}
+	// 	}
+	// }
 	function handleDelVehicleNo(item) {
 		vehicleList.value.splice(item, 1);
+		let discardVehicleInfo = {
+			carrierCode : item.carrierCode,
+			checked:false,
+			reason:'',
+			carrierId : item.carrierId
+		}
+		discardVehicleList.value.push(discardVehicleInfo)
+	}
+
+	function handleDelDiscardVehicleList(item) {
+		discardVehicleList.value.splice(item, 1)
+		vehicleList.value.push(item)
 	}
 
 	function handleScanCode() {
@@ -96,27 +160,49 @@
 
 	function handleSubmit() {
 		dayWorkInfo.dayworkCarriers = vehicleList.value;
-		console.log(dayWorkInfo);
-		saveDayWork(dayWorkInfo).then(res => {
-			if (res.code === 200) {
+		var carrierRejectList = []
+		for (var i = 0; i < discardVehicleList.value.length; i++) {
+			if(discardVehicleList.value[i].checked && discardVehicleList.value[i].reason == "") {
 				uni.showToast({
-					icon: 'success',
-					title: '添加成功',
-					duration: 2000
-				});
-				// uni.$emit('batchReporting-addBatch')
-				uni.$emit('dayworkItemUpdate');
-				uni.navigateBack({
-					url: '/pages/batchReporting/index'
+							icon: 'error',
+							title: '第'+(i+1)+'条未选择废弃原因',
+							duration: 2000,
+							});
+			}
+			if(discardVehicleList.value[i].checked && discardVehicleList.value[i].reason !== "") {
+				carrierRejectList.push(discardVehicleList.value[i])
+			}
+		}
+		addCarrierReject(carrierRejectList).then((response) => {
+			if(response.code == 200) {
+				saveDayWork(dayWorkInfo).then(res => {
+					if (res.code === 200) {
+						uni.showToast({
+							icon: 'success',
+							title: '添加成功'
+						});
+						// uni.$emit('batchReporting-addBatch')
+						uni.$emit('dayworkItemUpdate');
+						uni.navigateBack({
+							url: '/pages/batchReporting/index'
+						})
+					} else {
+						uni.showToast({
+							icon: 'error',
+							title: '添加失败'
+						});
+					}
 				})
-			} else {
+			}
+			else {
 				uni.showToast({
 					icon: 'error',
 					title: '添加失败',
-					duration: 2000
 				});
 			}
 		})
+		
+		
 	}
 </script>
 
@@ -161,7 +247,8 @@
 			justify-content: flex-start;
 			flex-wrap: wrap;
 			width: 100%;
-			height: 120rpx;
+			height: 45%; 
+			// max-height: 300rpx;
 			overflow: auto;
 			padding: 0 80rpx;
 
@@ -175,8 +262,20 @@
 				border: 1px solid rgba(213, 213, 213, 1);
 				border-radius: 6rpx;
 			}
+		
+
 		}
 	}
+	.discardVehicleNo {
+		padding: 0 10rpx;
+		margin: 10rpx;
+		justify-content: space-between;
+		align-items: center;
+		width: 150rpx;
+		height: 60rpx;
+		border: 1px solid rgba(213, 213, 213, 1);
+		border-radius: 6rpx;
+	}
 
 	.title {
 		margin: 30rpx auto;