dedsudiyu пре 1 дан
родитељ
комит
e495f5ad05

+ 1 - 1
pages/views/pupilPage/pupilHome.vue

@@ -267,7 +267,7 @@
 							})
 							if (codeData.type == 1 || codeData.type == 2 || codeData.type == 3 || codeData.type == 7 ||
 								codeData.type == 8 || codeData.type == 10 ||
-								codeData.type == 11 || codeData.type == 12 || codeData.type == 13 || codeData.type == 14) {
+								codeData.type == 11 || codeData.type == 12 || codeData.type == 13 || codeData.type == 14 || codeData.type == 15) {
 								uni.reLaunch({
 									url: '/pages/views/saoCode/saoCode?q=' + encodeURIComponent(res.result)
 								});

+ 1 - 1
pages/views/saoCode/saoCode.vue

@@ -89,7 +89,7 @@
 					} else if (codeData.type == 15) {
 						//安科院设备信息
 						uni.reLaunch({
-							url: '/pages_equipmentUtilization/views/equipmentInformation/index?code=' + codeData.id,
+							url: '/pages_equipmentUtilization/views/equipmentInformation/index?id=' + codeData.id,
 						});
 					} else if (codeData.type == 7) {
 						//培训课程

+ 1 - 1
pages/views/teacherPage/teacherHome.vue

@@ -370,7 +370,7 @@
 							})
 							if (codeData.type == 1 || codeData.type == 2 || codeData.type == 3 || codeData.type == 7 ||
 								codeData.type == 8 || codeData.type == 10 ||
-								codeData.type == 11 || codeData.type == 12 || codeData.type == 13 || codeData.type == 14) {
+								codeData.type == 11 || codeData.type == 12 || codeData.type == 13 || codeData.type == 14 || codeData.type == 15) {
 								uni.reLaunch({
 									url: '/pages/views/saoCode/saoCode?q=' + encodeURIComponent(res.result)
 								});

+ 19 - 3
pages_equipmentUtilization/api/index.js

@@ -1,13 +1,29 @@
 import { apiResquest,apiResquestForm,apiResquestJsonList,apiResquestFormVideo,apiResquestTimer } from '@/api/request/request.js'
 
-export const demo1 = (data) => {
+//登记使用
+export const mpDeviceUsageStart = (data) => {
 	return apiResquest({
-		url: `/system/dept/dropList`,
+		url: `/device/mp/device/usage/start`,
 		method: 'POST',
 		data: { ...data }
 	})
 };
-
+//结束使用
+export const mpDeviceUsageEnd = (data) => {
+	return apiResquest({
+		url: `/device/mp/device/usage/end/`+data.deviceId,
+		method: 'POST',
+	})
+};
+//我的使用记录
+export const mpDeviceUsageList = (data) => {
+	return apiResquest({
+		url: `/device/mp/device/usage/my-list/`,
+		method: 'POST',
+		data: { ...data }
+	})
+};
+//设备详情
 export const mpDeviceDetail = (data) => {
 	return apiResquest({
 		url: `/device/mp/device/detail`,

+ 128 - 14
pages_equipmentUtilization/views/equipmentInformation/infoPage.vue

@@ -99,7 +99,10 @@
 					<view class="shade-text-box">
 						<view>关机时间</view>
 						<view>
-							<uni-datetime-picker :start="timeApplication" @change="timePickerChange()" return-type="timestamp" v-model="shadeDataA.data4">{{timestampToStr(shadeDataA.data4)}}</uni-datetime-picker>
+							<uni-datetime-picker 
+							:hide-second="true"
+							:start="timeApplication" @change="timePickerChange()" 
+							return-type="timestamp" v-model="shadeDataA.data4">{{timestampToStr(shadeDataA.data4)}}</uni-datetime-picker>
 						</view>
 					</view>
 					
@@ -107,7 +110,7 @@
 						<view>使用总时长</view>
 						<view>{{shadeDataA.data5}}</view>
 					</view>
-					<view class="shade-button" @click="submitButton(1)">确定</view>
+					<view class="shade-button" @click="submitButton(1)">登记使用</view>
 				</view>
 				<!-- 结束 -->
 				<view class="shade-box" v-if="shadeType == 2">
@@ -121,23 +124,23 @@
 					</view>
 					<view class="shade-text-box">
 						<view>开机时间</view>
-						<view>{{shadeDataB.data3}}</view>
+						<view>{{timestampToStr(shadeDataB.data3)}}</view>
 					</view>
 					<view class="shade-text-box">
 						<view>关机时间</view>
-						<view>{{shadeDataB.data4}}</view>
+						<view>{{timestampToStr(shadeDataB.data4)}}</view>
 					</view>
 					<view class="shade-text-box">
 						<view>使用总时长</view>
 						<view>{{shadeDataB.data5}}</view>
 					</view>
-					<view class="shade-button">确定</view>
+					<view class="shade-button" @click="submitButton(2)">结束使用</view>
 				</view>
 				<!-- 查看 -->
 				<view class="shade-box-c" v-if="shadeType == 3">
 					<view class="shade-text-title">当前设备已被【{{shadeDataC.data1}}】登记使用,</view>
 					<view class="shade-text-title">开机时间:{{shadeDataC.data2}}</view>
-					<view class="shade-text-title">如有疑问请联系:{{shadeDataC.data3}}</view>
+					<!-- <view class="shade-text-title">如有疑问请联系:{{shadeDataC.data3}}</view> -->
 				</view>
 				<view class="shade-box" v-if="shadeType == 4">
 					<view class="text-box">
@@ -151,7 +154,7 @@
 
 <script>
 	import {
-		mpDeviceDetail,
+		mpDeviceDetail,mpDeviceUsageStart,mpDeviceUsageEnd
 	} from '@/pages_equipmentUtilization/api/index.js'
 	import { config } from '@/api/request/config.js'
 	export default {
@@ -204,7 +207,7 @@
 			}
 		},
 		mounted() {
-			this.mpDeviceDetail(this.equipmentId);
+			this.mpDeviceDetail();
 		},
 		methods: {
 			pickerChange(val){
@@ -212,11 +215,11 @@
 				this.$set(this,'pickerIndex',val.mp.detail.value);
 			},
 			//获取设备信息
-			async mpDeviceDetail(id) {
+			async mpDeviceDetail() {
 				let self = this;
 				const {
 					data
-				} = await mpDeviceDetail({id:id});
+				} = await mpDeviceDetail({id:this.equipmentId});
 				if (data.code == 200) {
 					this.$set(this,'newData',data.data);
 				}
@@ -257,17 +260,34 @@
 						data5:'0天0小时0分',
 					});
 					this.$set(this,'shadeType',1);
-				}else if(this.newData.runStatus != 0 || this.newData.currentUserId != this.userId){
+				}else if(this.newData.runStatus != 0 && this.newData.currentUserId != this.userId){
 					//别人使用中
+					this.$set(this,'shadeDataC',{
+						data1:this.newData.currentUserName,
+						data2:this.newData.currentStartTime,
+						// data3:this.toTimestamp(this.newData.currentStartTime),
+					});
 					this.$set(this,'shadeType',3);
-				}else if(this.newData.runStatus != 0 || this.newData.currentUserId == this.userId){
+				}else if(this.newData.runStatus != 0 && this.newData.currentUserId == this.userId){
 					//自己使用中
+					const now = new Date();
+					now.setSeconds(0, 0);  // 将秒和毫秒都设为0
+					const timestamp = now.getTime()
+					this.$set(this,'timeApplication',timestamp);
+					this.$set(this,'shadeDataB',{
+						data1:this.newData.currentUserName,
+						data2:this.newData.usageType == 0?'自用':'对外服务',
+						data3:this.toTimestamp(this.newData.currentStartTime),
+						data4:this.timeApplication,
+						data5:this.formatTimeDiff(this.toTimestamp(this.newData.currentStartTime),this.timeApplication),
+					});
 					this.$set(this,'shadeType',2);
 				}
 			},
 			offShade(){
 				this.$set(this,'shadeType',0);
 			},
+			//时间戳格式化
 			timestampToStr(timestamp) {
 			  const date = new Date(timestamp); // 传入毫秒级时间戳
 			  const year = date.getFullYear();
@@ -278,6 +298,21 @@
 			  // 注意:这里没有拼接秒
 			  return `${year}-${month}-${day} ${hours}:${minutes}`;
 			},
+			//时间格式转时间戳
+			toTimestamp(dateStr, isUTC = false) {
+				// 假设 dateStr 格式为 "YYYY-MM-DD HH:mm:ss"
+				const [datePart, timePart] = dateStr.split(' ');
+				const [year, month, day] = datePart.split('-').map(Number);
+				const [hour, minute, second] = timePart.split(':').map(Number);
+				if (isUTC) {
+						// 返回 UTC 时间戳
+						return Date.UTC(year, month - 1, day, hour, minute, second);
+				} else {
+						// 返回本地时间戳
+						return new Date(year, month - 1, day, hour, minute, second).getTime();
+				}
+			},
+			//开始时间-结束时间-相差时间
 			formatTimeDiff(timestamp1, timestamp2) {
 			  // 计算绝对差值(毫秒)
 			  const diffMs = Math.abs(timestamp1 - timestamp2);
@@ -295,12 +330,13 @@
 			  if (minutes > 0 || parts.length === 0) parts.push(minutes + '分'); // 确保至少显示“0分”
 			  return parts.join('');
 			},
+			//登记-结束时间选择
 			timePickerChange(){
 				if(this.shadeDataA.data4>this.shadeDataA.data3){
 					this.$set(this.shadeDataA,'data5',this.formatTimeDiff(this.shadeDataA.data3,this.shadeDataA.data4));
 				}else{
 					uni.showToast({
-						title: '开机时间与关机时间不能相等',
+						title: '请检查关机时间',
 						icon:"none",
 						mask:true,
 						duration: 2000
@@ -308,8 +344,86 @@
 				}
 				
 			},
+			//确定按钮
 			submitButton(type){
-				console.log('shadeDataA',this.shadeDataA)
+				let self = this;
+				if(type == 1){
+					if(this.shadeDataA.data4>this.shadeDataA.data3){
+						uni.showModal({
+							content: '确认提交?',
+							cancelColor: "#999",
+							confirmColor: "#0183FA",
+							success: function(res) {
+								if (res.confirm) {
+									self.mpDeviceUsageStart()
+								} else if (res.cancel) {}
+							}
+						});
+					}else{
+						uni.showToast({
+							title: '请检查关机时间',
+							icon:"none",
+							mask:true,
+							duration: 2000
+						});
+					}
+				}else if(type == 2){
+					uni.showModal({
+						content: '确认提交?',
+						cancelColor: "#999",
+						confirmColor: "#0183FA",
+						success: function(res) {
+							if (res.confirm) {
+								self.mpDeviceUsageEnd()
+							} else if (res.cancel) {}
+						}
+					});
+				}
+			},
+			//登记使用
+			async mpDeviceUsageStart() {
+				let self = this;
+				let obj = {
+					deviceId:this.equipmentId,
+					usageType:this.pickerList[this.pickerIndex]=='自用'?0:1,
+					startTime:this.timestampToStr(this.shadeDataA.data3)+':00',
+					expectedEndTime:this.timestampToStr(this.shadeDataA.data4)+':00',
+				}
+				const {
+					data
+				} = await mpDeviceUsageStart(obj);
+				if (data.code == 200) {
+					this.$set(this,'shadeType',0);
+					this.mpDeviceDetail();
+					uni.showToast({
+						mask: true,
+						icon: "none",
+						position: "center",
+						title: data.message,
+						duration: 2000
+					});
+				}
+			},
+			//结束使用
+			async mpDeviceUsageEnd() {
+				let self = this;
+				let obj = {
+					deviceId:this.newData.currentUsageId,
+				}
+				const {
+					data
+				} = await mpDeviceUsageEnd(obj);
+				if (data.code == 200) {
+					this.$set(this,'shadeType',0);
+					this.mpDeviceDetail();
+					uni.showToast({
+						mask: true,
+						icon: "none",
+						position: "center",
+						title: data.message,
+						duration: 2000
+					});
+				}
 			},
 		},
 	}

+ 89 - 81
pages_equipmentUtilization/views/equipmentInformation/listPage.vue

@@ -5,109 +5,51 @@
 				<view class="left-time-box">
 					<uni-datetime-picker v-model="range" type="daterange"  :clearIcon="false"/>
 				</view>
-				<view class="right-button-box">查询</view>
+				<view class="right-button-box" @click="queryButton()">查询</view>
 			</view>
 			<view class="top-box" style="margin-top:10rpx;">
 				<view class="left-time-box">
 					<input class="input-text" type="text" v-model="text" placeholder="设备名称">
 				</view>
-				<view class="right-button-box-2">重置</view>
+				<view class="right-button-box-2" @click="resetButton()">重置</view>
 			</view>
 		</view>
-		<view class="list-max-big-box">
+		<scroll-view scroll-y @scrolltolower="scrollGet" class="list-max-big-box">
+			<img class="null-img" v-if="!dataList[0]" :src="imagesUrl('commonality/null-data-1.png')">
 			<view class="list-for-max-big-box" v-for="(item,index) in dataList" :key="index">
 				<view class="top-title-box">
-					<view>{{item.data1}}</view>
-					<view>{{item.data2}}</view>
+					<view>{{item.deviceName}}</view>
+					<view>{{item.usageTypeName}}</view>
 				</view>
-				<view class="text-p">{{item.data3}} {{item.data4}} {{item.data5}}</view>
-				<view class="text-p">使用时间:{{item.data6}} 至 {{item.data7}}</view>
+				<view class="text-p">{{item.location}}</view>
+				<view class="text-p">使用时间:{{item.startTime}} 至 {{item.actualEndTime?item.actualEndTime:'未结束'}}</view>
 				<view class="bottom-title-box">
-					<view>设备编号:{{item.data8}}</view>
-					<view>使用人:{{item.data9}}</view>
+					<view>设备编号:{{item.deviceCode}}</view>
+					<view>使用人:{{item.userName}}</view>
 				</view>
 			</view>
-		</view>
+			<view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
+		</scroll-view>
 	</view>
 </template>
 
 <script>
 	import {
-		demo1,
+		mpDeviceUsageList,
 	} from '@/pages_equipmentUtilization/api/index.js'
 	export default {
 		data() {
 			return {
+				getDataType:false,
 				range:[],
 				text:'',
-				dataList:[
-					{
-						data1:'设备名称',
-						data2:'使用类型',
-						data3:'XX楼',
-						data4:'XX层',
-						data5:'XX实验室',
-						data6:'2026-01-19 12:22',
-						data7:'2026-01-19 12:22',
-						data8:'01231231',
-						data9:'张三',
-					},
-					{
-						data1:'设备名称',
-						data2:'使用类型',
-						data3:'XX楼',
-						data4:'XX层',
-						data5:'XX实验室',
-						data6:'2026-01-19 12:22',
-						data7:'2026-01-19 12:22',
-						data8:'01231231',
-						data9:'张三',
-					},
-					{
-						data1:'设备名称',
-						data2:'使用类型',
-						data3:'XX楼',
-						data4:'XX层',
-						data5:'XX实验室',
-						data6:'2026-01-19 12:22',
-						data7:'2026-01-19 12:22',
-						data8:'01231231',
-						data9:'张三',
-					},
-					{
-						data1:'设备名称',
-						data2:'使用类型',
-						data3:'XX楼',
-						data4:'XX层',
-						data5:'XX实验室',
-						data6:'2026-01-19 12:22',
-						data7:'2026-01-19 12:22',
-						data8:'01231231',
-						data9:'张三',
-					},
-					{
-						data1:'设备名称',
-						data2:'使用类型',
-						data3:'XX楼',
-						data4:'XX层',
-						data5:'XX实验室',
-						data6:'2026-01-19 12:22',
-						data7:'2026-01-19 12:22',
-						data8:'01231231',
-						data9:'张三',
-					},
-					{
-						data1:'设备名称',
-						data2:'使用类型',
-						data3:'XX楼',
-						data4:'XX层',
-						data5:'XX实验室',
-						data6:'2026-01-19 12:22',
-						data7:'2026-01-19 12:22',
-						data8:'01231231',
-						data9:'张三',
-					},
-				]
+				// 查询参数
+				queryParams: {
+					page: 1,
+					pageSize: 10,
+				},
+				dataList:[],
+				total:0,
 			}
 		},
 		onLoad(option) {
@@ -117,10 +59,60 @@
 			
 		},
 		mounted() {
+			this.getList()
 		},
 		methods: {
-			maskClick(){
-				
+			queryButton(){
+				this.getList()
+			},
+			resetButton(){
+				this.$set(this,'range',[]);
+				this.$set(this,'text','');
+				this.$set(this,'queryParams',{
+					page: 1,
+					pageSize: 10,
+				});
+				this.$set(this,'dataList',[]);
+				this.$set(this,'total',0);
+				this.getList()
+			},
+			//滚动加载事件
+			scrollGet() {
+				let self = this;
+				if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
+					this.$set(this, 'getDataType', true);
+				} else {
+					this.queryParams.page += 1;
+					this.$nextTick(() => {
+						this.getList();
+					})
+				}
+			},
+			//获取数据列表
+			async getList() {
+				let self = this;
+				let obj = JSON.parse(JSON.stringify(this.queryParams));
+				obj.startTime = this.range[0] ? this.range[0] +'T00:00:00' : '';
+				obj.endTime = this.range[0] ? this.range[1] +'T23:59:59' : '';
+				obj.deviceName = this.text ? this.text : '';
+				const {
+					data
+				} = await mpDeviceUsageList(obj);
+				if (data.code == 200) {
+					if(self.queryParams.page == 1){
+						this.dataList = data.data.records;
+						this.total = data.data.total;
+						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
+							this.$set(this, 'getDataType', true);
+						}
+					}else{
+						this.dataList = [...this.dataList, ...data.data.records]
+						this.total = data.data.total;
+						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
+							this.$set(this, 'getDataType', true);
+						}
+					}
+				}
 			},
 		},
 	}
@@ -178,6 +170,22 @@
 			flex-direction:column;
 			overflow: scroll;
 			padding-bottom:80rpx;
+			
+			.null-img {
+				display block;
+				width: 276rpx;
+				height: 321rpx;
+				position absolute;
+				top: 200rpx;
+				left: 274rpx;
+			}
+			.get-data-null-p {
+				margin-top:20rpx;
+				text-align: center;
+				line-height: 40rpx;
+				padding-bottom: 40px;
+				color: #999;
+			}
 			.list-for-max-big-box{
 				margin:20rpx 0 0;
 				padding:20rpx;