mao 1 жил өмнө
parent
commit
46404546ae

+ 1 - 1
api/base/path.js

@@ -1,3 +1,3 @@
-const baseURL = 'http://192.168.31.26:8099'
+const baseURL = 'http://192.168.31.216:8099'
 
 export default baseURL

+ 28 - 19
components/dialog-confirm/dialog-confirm.vue

@@ -2,8 +2,8 @@
 	<dialog-base ref="baseDialog" title="提示">
 		<view class="msg uni-row">{{message}}</view>
 		<view class="btn-container uni-row">
-			<button type="primary" ref="confirm" class="btn" @click="handleChoice()">确认</button>
-			<button type="primary" ref="cancel" class="btn" @click="handleChoice()">取消</button>
+			<button type="primary"  class="btn" @click="handleConfirm">确认</button>
+			<button type="primary"  class="btn" @click="handleCancel">取消</button>
 		</view>
 	</dialog-base>
 </template>
@@ -13,29 +13,38 @@
 		ref,
 		getCurrentInstance
 	} from 'vue'
+	import {
+		saveUserequipment
+	} from '@/api/business/userEquipment/userEquipment.js'
+	import { defineProps } from 'vue'
 	const baseDialog = ref(null)
 	const message = ref('')
-	const confirm = ref(null)
-	const cancel = ref(null)
-
+	const reqParam = ref({})
+	const fatMethod = defineProps({
+	  init: Function
+	})
+ 
 
-	async function open(data) {
-		message.value = data;
+	function open(msg,data) {
+		message.value = msg;
+		reqParam.value = data;
 		baseDialog.value.open();
-		const result = await handleChoice();
-		return result;
 	}
 
-	async function handleChoice() {
-		// let flag = null;
-		// confirm.value.addEventListener('click', function() {
-		// 	flag = 1;
-		// })
-		// cancel.value.addEventListener('click',function(){
-		// 	flag = 0;
-		// })
-		close()
-		return 1;
+	function handleConfirm() {
+		saveUserequipment(reqParam.value).then(res => {
+			if(res.code === 200){
+				uni.showToast({
+					icon: "success",
+					title: "设备绑定成功"
+				})
+			}
+		})
+		close();
+	} 
+
+	function handleCancel() {
+		close();
 	}
 
 	function close() {

+ 12 - 17
pages/equipmentList/index.vue

@@ -12,7 +12,7 @@
 			<button class="btn" @click="handleScanCode">扫码</button>
 		</view>
 	</view>
-	<dialog-confirm ref="confirm"></dialog-confirm>
+	<dialog-confirm ref="confirm" :init="init"></dialog-confirm>
 </template>
 
 <script setup>
@@ -41,7 +41,6 @@
 	const curBindEquipmentIds = ref([]) // 分配给当前员工的设备id列表
 	const userInfo = ref({}) // 当前登录用信息
 	const confirm = ref(null)
-
 	onLoad(() => {
 		init();
 	})
@@ -113,15 +112,10 @@
 				userEquipmentData.value.nickName = userInfo.value.nickName;
 				// 判断该设备是否分配给改员工
 				if (!curBindEquipmentIds.value.includes(equipment.equipmentId)) {
-					let msg = '当前员工没有分配到该设备,确定继续绑定吗?'
-					confirm.value.open(msg).then(res => {
-						console.log(flag)
-						if(flag){
-							handleSaveInfo();
-						}else{
-							return;
-						}
-					});
+					let msg = '当前员工没有分配到该设备,确定继续绑定吗?';		 
+					confirm.value.open(msg,userEquipmentData.value);
+				}else{
+					handleSaveInfo();
 				}
 			}  
 		});
@@ -133,12 +127,13 @@
 	function handleSaveInfo() {
 		// console.log(userEquipmentData.value)
 		saveUserequipment(userEquipmentData.value).then(res => {
-			init();
-			console.log(equipmentList.value)
-			uni.showToast({
-				icon: "success",
-				title: "设备绑定成功"
-			})
+			if(res.code === 200){
+				init();
+				uni.showToast({
+					icon: "success",
+					title: "设备绑定成功"
+				})
+			}
 		})
 	}
 </script>