studentSignIn.vue 16.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
<template>
	<view class="registration_review" :style="vuex_theme">

		<view class="search_box">
			<view style="width: 148px;">
				<u-subsection :list="['未签到','全部']" :current="curNow" :fontSize="26" :activeColor="'#000'"
					@change="sectionChange"></u-subsection>
			</view>
			<view style="display: flex; justify-content: space-between; align-items: center;">
				<u-icon slot="icon" size="40" :name="'/static/img/home/dateIcon.png'" @click="showTime = true"></u-icon>
				<view style="width: 16px;"></view>
				<u-icon slot="icon" size="40" :name="'/static/img/home/search.png'" @click="searchCli"></u-icon>
				<view style="width: 16px;"></view>
				<u-icon slot="icon" size="40" :name="'/static/img/home/selectIcon.png'" @click="show = true"></u-icon>
			</view>
		</view>

		<u-calendar :minDate="minDate" :maxDate="maxDate" :monthNum="25" :show="showTime" :defaultDate="defaultDateMultiple"
			@close="showTime = false" :showSubtitle="false" color="var(--primary-color)" @confirm="confirm">
		</u-calendar>

		<view class="list_box" v-if="list.length > 0">
			<view class="item" v-for="(item, i) in list" :key="i">

				<view class="bg_image" v-if="item.waitAttendance == 'not_attendance'">
					<u-image src="/static/img/home/labelBgGreen.png" width="142rpx" height="48rpx"></u-image>
					<text>未签到</text>
				</view>

				<view class="bg_image" v-else>
					<u-image src="/static/img/home/labelBgGrey.png" width="142rpx" height="48rpx"></u-image>
					<text>已签到</text>
				</view>

				<view class="info">
					<view class="avatar">{{getNameLastTwo(item.studentName)}}</view>
					<view class="name">{{overflowHide(item.studentName)}}</view>
					<view class="number">{{item.studentNumber}}</view>
				</view>
				<view class="company">
					<text>实习项目</text>
					<text>{{item.projectName || '--'}}</text>
				</view>
				<view class="company">
					<text>班级</text>
					<text>{{item.className || '--'}}</text>
				</view>
				<view class="company position">
					<text>手机号</text>
					<text>{{item.studentPhone|| '--'}}</text>
				</view>

				<view class="time">
					<text>签到时间</text>
					<text>{{timeFormat(item.signIn, 'yyyy-mm-dd hh:MM')}}</text>
				</view>

			</view>
			<c-loading :loading="loading"></c-loading>
		</view>
		<view v-else class="no_data">
			<c-no-data></c-no-data>
		</view>
		
		<u-popup :show="show" mode="bottom" @close="close" :round="22">
			<view class="popup">
				<view style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px;">
					<view class="title">
						项目筛选
					</view>
					<image class="close" src="/static/img/home/closepop.png" @click="close" mode=""></image>
				</view>
				<view class="search">
					<u-search placeholder="请输入项目关键词搜索" placeholderColor="#C1C1C9" searchIconSize="36" height="64rpx"
						bgColor="#F4F4F4" :showAction="true" shape="round" v-model="sxsearch" @custom="workSearch()" @search="workSearch()">
					</u-search>
				</view>
				<scroll-view v-if="works.length>0" scroll-y="true" style="height: 80%; margin-top: 40rpx;"
					@scrolltolower="lower()">
					<view class="item_box" v-for="(item,index) in works" :key="index" @click="popupSelItem(item)">
						<view style="display: flex; align-items: center; justify-content: space-between;">
							<view class="item_title">
								{{item.name}}
							</view>
							<image v-if="item.id == projectId" style="width: 20px; height: 20px;"
								src="/static/img/home/popselect.png" mode=""></image>
						</view>
					</view>
				</scroll-view>
				<view v-else class="no_data" @click="jumpVerified">
					<view class="text_black_28">
						暂未搜索到该项目
					</view>
				</view>
			</view>
		</u-popup>
		
		<!-- <u-popup :show="show" mode="right" @close="close" @open="open" :closeOnClickOverlay="false">
			<view class="popup_search">
				<view class="content">
					<view class="title">按项目筛选</view>
					<scroll-view class="scroll" scroll-y="true">
						<view class="item" v-for="(item, i) in projectList" :key="i" @click="handelClick(item)">
							<view class="selectItem" v-if="item.id == projectId">
								<text>{{item.name}}</text>
							</view>
							<view v-else>
								<text>{{item.name}}</text>
							</view>
						</view>
					</scroll-view>
					<view class="switch">
						<text>未签到</text>
						<u-switch v-model="switchValue" size="48" activeColor="var(--primary-color)" @change="handelChange">
						</u-switch>
					</view>
				</view>

				<view class="footer">
					<view class="left_btn">
						<c-button type="cancel" text="重置" @click="handelCancel">
						</c-button>
					</view>
					<view class="right_btn">
						<c-button type="confirm" text="确定" @click="hancelSubmit">
						</c-button>
					</view>
				</view>

			</view>
		</u-popup> -->

	</view>
</template>

<script>
	import {
		mapGetters,
		mapState,
		mapActions
	} from 'vuex'
	import listMixin from "@/common/mixins/list-mixin.js";
	import miment from 'miment'

	import {
		getStudentSignInListApi,
		getProjectListApi,
	} from '@/config/api.js';

	export default {
		mixins: [listMixin],
		data() {

			const d = new Date();
			const year = d.getFullYear();
			let month = d.getMonth() + 1;
			month = month < 10 ? `0${month}` : month;
			const date = d.getDate();

			return {
				checkboxValue: [],
				// 基本案列数据
				checkboxList: [{
					name: '未签到',
					disabled: false
				}],
				keyword: '',
				show: false,
				search: {
					//搜索对象必须为key search的对象
					keySearch: "",
					waitAttendance: '',
					time: '',

				},
				showTime: false,
				minDate: `${year-2}-${month}-${date+1}`,
				maxDate: `${year}-${month}-${date+1}`,
				timeValue: `${year}-${month}-${date}`,
				defaultDateMultiple: [`${year}-${month}-${date}`],
				list: [], //列表必须为key list的数组
				projectId: '',
				switchValue: false,
				
				curNow: 1,
				sxsearch: '',
				works: [],
				workspage: 1,
				workstotal: 0,
			}
		},

		onLoad(option) {
			// this.$store.dispatch(`home/getProjectList`, {
			// 	pageSize: -1,
			// })

			// this.search.keySearch = '';

			// this.finished = false;
			// this.loading = "loadmore";
			// this.page = 0;
			// this.list = [];

			this.worksloadData()
			
			if (option && option.status) {
				// this.search.status = 'wait';
				this.curNow = 0;
				// this.checkboxValue = ['待处理'];
				// this.switchValue = true;
			}
			

		},

		onShow() {
			this.finished = false;
			this.loading = "loadmore";
			this.page = 0;
			this.list = [];
			this._getList();
		},

		computed: {
			...mapState('home', {
				// 箭头函数可使代码更简练
				projectList: 'projectList',

			}),

		},

		methods: {
			
			searchCli() {
				this.$u.route('/pages/main/home/search/search?type=student&searchkey=' + this.keyword);
			},
			
			sectionChange(index) {
				this.curNow = index;
			
				this.finished = false;
				this.loading = "loadmore";
				this.page = 0;
				this.list = [];
				this._getList();
			},
			

			getNameLastTwo(value) {
				if (value && value.length > 3) {
					return value.substring(value.length - 3)
				} else {
					return value;
				}
			},

			overflowHide(value, num = 4) {
				if (value && value.length > num) {
					return `${value.slice(0, num)}...`
				} else {
					return value;
				}
			},

			confirm(e) {
				this.timeValue = e[0];
				this.time = miment(e[0]).valueOf();

				this.finished = false;
				this.loading = "loadmore";
				this.page = 0;
				this.list = [];
				this._getList();

				this.showTime = false;
			},

			handelDetail(record) {
				this.$u.route({
					url: `pages/main/home/registrationDetail/registrationDetail?&id=${record.id}`
				})
			},

			timeFormat(timestamp, format = 'yyyy-mm-dd') {
				return timestamp > 0 ? uni.$u.timeFormat(timestamp, format) : '--'
			},

			checkboxChange(n) {
				console.log('change', n);

				this.search.waitAttendance = n.length > 0 ? 'not_attendance' : '';

				this.switchValue = n.length > 0 ? true : false;

				this.finished = false;
				this.loading = "loadmore";
				this.page = 0;
				this.list = [];
				this._getList();
			},

			handelSearch(value) {
				this.finished = false;
				this.loading = "loadmore";
				this.page = 0;
				this.list = [];
				this._getList();
			},

			open() {
				// console.log('open');
			},
			close() {
				this.show = false
				// console.log('close');
			},
			// scroll-view到底部加载更多
			onreachBottom() {},
			// 搜索
			searchSubmit() {
				// 调用混合搜索
				this._searchData();
			},
			// 模拟后端分页
			async getData(requestParams) {
				const {
					search = {}
				} = requestParams;

				let params = {};
				params.pageNumber = requestParams.page + 1;
				params.pageSize = 5;

				// if (search.waitAttendance) {
				// 	params.waitAttendance = search.waitAttendance;
				// }
				
				if (this.curNow == 0) {
					params.waitAttendance = 'not_attendance';
				}

				if (this.keyword) {
					params.keySearch = this.keyword
				}

				if (this.projectId) {
					params.projectId = this.projectId
				}

				if (this.time) {
					params.time = this.time
				}

				return await getStudentSignInListApi(params);
			},
			// 数据请求(没错就是这么少的代码)
			async _getList() {
				if (this.page == 0) {
					this.list = [];
				}

				// 根据实际情况修改自己修改key
				let result = await this.getData({
					page: this.page, // 传入页码
					size: this.size, // 传入每页条数
					search: this.search, // 传入搜索的对象
				});

				this.total = result.total;

				if (this.list.length == 0 && result.records.length == 0) {
					this.shownoData = false
				} else {
					this.shownoData = true
				}

				this.list = this.list.concat(result.records)

				// 判断是否全部加载完成
				if (this.total == this.list.length) {
					this.finished = true;
					this.loading = 'nomore';
				} else {
					this.loading = 'loadmore';
				}
			},

			handelClick(values) {
				console.log(values);
				this.projectId = values.id;
			},

			handelChange(e) {
				console.log(e)
				this.checkboxValue = e ? ['未签到'] : [];
				this.search.waitAttendance = e ? 'not_attendance' : '';
			},

			handelCancel() {
				this.switchValue = false;
				this.projectId = '';
			},

			hancelSubmit() {
				this.finished = false;
				this.loading = "loadmore";
				this.page = 0;
				this.list = [];
				this._getList();

				this.show = false;
			},
			
			workSearch() {
				uni.hideKeyboard();
				this.works = []
				this.worksloadData()
			},
			
			lower() {
				setTimeout(() => {
					this.worksloadData(true);
				}, 200)
			},
			
			worksloadData(e) {
				let params = {}
				// this.loading = 'loading'
			
				if (e) {
					if (this.total <= this.works.length) {
						// this.loading = 'nomore'
						return
					}
					this.workspage++
				} else {
					this.workspage = 1
				}
				params['pageNumber'] = this.workspage
				if (this.sxsearch) {
					params['keyWord'] = this.sxsearch
				}
				getProjectListApi(params).then(async res => {
					if (res) {
						this.total = res.total
						// this.loading = 'loadmore'
						this.works = this.works.concat(res.records)
					}
				})
			},
			popupSelItem(item) {
				this.show = false
				this.projectId = item.id;
				this.finished = false;
				this.loading = "loadmore";
				this.page = 0;
				this.list = [];
				this._getList();
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.registration_review {
		width: 100%;
		min-height: 100%;
		height: auto;
		background-color: #F7F7F7;

		// .search_box {
		// 	padding: 36rpx 30rpx 0;
		// 	background-color: #FFFFFF;

		// 	.top {
		// 		display: flex;
		// 		flex-flow: row nowrap;
		// 		justify-content: space-between;

		// 		.check {
		// 			padding: 20rpx 0 0 0;
		// 		}

		// 		.search {
		// 			width: 410rpx;
		// 		}

		// 		.icon {
		// 			display: flex;
		// 			flex-flow: row nowrap;
		// 		}
		// 	}

		// 	.bottom {
		// 		.time {
		// 			padding: 30rpx 0 30rpx 40rpx;
		// 		}
		// 	}


		// }
		
		.search_box {
			padding: 36rpx 30rpx 12rpx;
			background-color: #FFFFFF;
			display: flex;
			flex-flow: row nowrap;
			justify-content: space-between;
		
			.check {
				padding: 20rpx 0 0 0;
			}
		
			.search {
				width: 468rpx;
			}
		}

		.list_box {
			padding: 0 0 50rpx 0;

			.item {
				position: relative;
				width: 630rpx;
				margin: 30rpx auto;
				padding: 30rpx;
				border-radius: 12rpx;
				background-color: #FFFFFF;

				.bg_image {
					position: absolute;
					top: 0;
					right: 0;

					text {
						position: absolute;
						top: 12rpx;
						right: 30rpx;
						font-size: 24rpx;
						line-height: 24rpx;
						color: #FFFFFF;
					}
				}

				.info {
					display: flex;
					flex-flow: row nowrap;
					align-items: center;
					margin: 0 0 30rpx 0;

					.avatar {
						width: 78rpx;
						height: 94rpx;
						padding: 0 8rpx;
						border-radius: 4rpx;
						background-color: var(--primary-color);
						font-size: 24rpx;
						line-height: 94rpx;
						color: #FFFFFF;
						text-align: center;
					}

					.name {
						font-size: 32rpx;
						line-height: 44rpx;
						color: #202131;
						font-weight: 500;
						margin: 0 20rpx;
					}

					.number {
						font-size: 28rpx;
						line-height: 32rpx;
						color: #909097;
					}
				}

				.company {
					display: flex;
					flex-flow: row nowrap;
					margin: 0 0 30rpx 0;

					text {
						width: 130rpx;
						font-size: 28rpx;
						line-height: 32rpx;
						color: #909097;
						margin: 0 0 0 16rpx;
					}

					text:first-child {
						text-align: justify;
						text-align-last: justify;
					}

					text:last-child {
						width: 400rpx;
						color: #202131;
						margin: 0 0 0 30rpx;
					}
				}

				.time {
					border-top: 2rpx solid #E2E2E8;
					padding: 28rpx 0 0 0;

					text {
						font-size: 28rpx;
						line-height: 32rpx;
						color: #909097;
					}

					text:last-child {
						color: #202131;
						margin: 0 0 0 78rpx;
					}
				}
			}
		}

		.popup_search {
			width: 640rpx;
			position: relative;

			.content {
				padding: 0 40rpx;

				.title {
					padding: 24rpx 0;
					font-size: 28rpx;
					line-height: 36rpx;
					color: #202131;
				}

				.scroll {
					max-height: 60vh;

					.item {

						view {
							display: flex;
							flex-flow: row wrap;
							align-items: center;
							width: 500rpx;
							height: 74rpx;
							border-radius: 4rpx;
							border: 2rpx solid #C1C1C9;
							margin: 0 10rpx 20rpx;
							font-size: 24rpx;
							line-height: 32rpx;
							color: #C0C0C9;
							padding: 16rpx 20rpx;
						}

						.selectItem {
							background-color: var(--primary-color);
							color: #FFFFFF;
							border: 2rpx solid var(--primary-color);
						}
					}
				}

				.time {
					padding: 40rpx 0 0 0;
				}

				.switch {
					display: flex;
					flex-flow: row nowrap;
					justify-content: space-between;
					padding: 40rpx 0 0 0;

					text {
						font-size: 28rpx;
						line-height: 36rpx;
						color: #202131;
					}
				}


			}

			.footer {
				width: 560rpx;
				height: 96rpx;
				padding: 28rpx 40rpx;
				background: #FFFFFF;
				position: fixed;
				bottom: 0;
				right: 0;
				z-index: 99;
				border-top: 2rpx solid #E2E2E8;

				view {
					display: inline-block;
				}

				.left_btn {
					width: 194rpx;
					margin: 0 20rpx 0 0;
				}

				.right_btn {
					width: 346rpx;
				}
			}
		}
		
		.popup {
			height: 500px;
			padding: 19px 16px;
		
			.title {
				font-size: 18px;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #000000;
			}
		
			.close {
				width: 22px;
				height: 22px;
			}
		
			.item_box {
				border-radius: 4px;
				margin: 0 0 48rpx;
		
				.item_title {
					height: 20px;
					font-size: 14px;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: rgba(0, 0, 0, 0.65);
					line-height: 20px;
				}
		
			}
		
			.no_data {
				width: 100%;
				margin-top: 310rpx;
		
				.text_black_28 {
					font-size: 14px;
					font-family: PingFangSC-Light, PingFang SC;
					font-weight: 300;
					color: rgba(0, 0, 0, 0.65);
					text-align: center;
				}
		
			}
		
		}
	}
</style>