chooseExaminer.vue 4.22 KB
<template>
	<view>
    <view class="nolineform">
      <uni-form @submit="getList">
        <uni-forms-item label="考官姓名">
          <uni-easyinput  :placeholderStyle="placeholderStyle"
            :input-border="false"
            v-model="query.name" placeholder="考官姓名">
          </uni-easyinput>
        </uni-forms-item>
        <uni-forms-item label="考官编号">
          <uni-easyinput  :placeholderStyle="placeholderStyle"
            :input-border="false"
            v-model="query.certCode" placeholder="考官编号">
          </uni-easyinput>
        </uni-forms-item>
      </uni-form>
      <view class="button-group">
        <button size="mini" @click="resetQuery">重置</button>
        <button type="primary" size="mini" @click="getList">查询</button>
      </view>
    </view>
		<view class="indexboxre">
			<view class="userlist">
				<view class="item" v-for="(n,index) in list" :key="index">
<!-- 					<view class="photobox">
						<image class="photo" v-if="n.photo" :src="n.photo" mode='aspectFill'></image>
						<view class="colorful" v-else>{{n.name.slice(1,2)}}</view>
					</view> -->
					<view>
						<view class="name">{{n.name}}</view>
						<view class="date">会员号:{{n.perCode||'-'}}</view>
						<view class="date">证件号码:{{n.idcCode||'-'}}</view>
						<view class="date">注册地:{{n.memName||'-'}}</view>
					</view>
					<view class="status">
						<text v-if="n.disabled">已选</text>
						<text v-else class="text-primary" @click="handleChoose(n)">选择</text>

					</view>
				</view>
			</view>
			<view class="nodata" v-if="list.length==0">
				<image mode="aspectFit" src="/static/nodata.png"></image>
				<text>请输入考官姓名和编号精确查找</text>
			</view>
		</view>

	</view>
</template>

<script setup>
	import * as api from '@/common/api.js'
	import {
		ref,
		getCurrentInstance
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import _ from 'underscore'
	const {
		proxy
	} = getCurrentInstance()
	const app = getApp();
	const query = ref({

	})
  const placeholderStyle = ref('text-align: right;font-size:30rpx')
  const list = ref([])
	const total = ref(0)
	const userType = ref('')
	let chosen = []
	let ec = null
	onLoad((option) => {
		query.value.type = option.type
		chosen = JSON.parse(decodeURIComponent(option.chosen)) || []
		ec = option.ec
		console.log(chosen)
	})
  function resetQuery() {
    query.value = {}
    list.value = []
  }
	function getList() {
		if (!query.value.name) {
			return
		}
		if (!query.value.certCode) {
			return
		}
		uni.showLoading({
			title: `查找中`
		})
		api.getCoachList(query.value).then(res => {
			if (res.rows.length == 0) {
				uni.showToast({
					title: '未查询到考官信息',
					icon: "error"
				})
				list.value = []
				return
			}
			list.value = res.rows
			for(var l of list.value){
				// if(l.photo&&l.photo.indexOf('http')==-1){
				// 	l.photo = config.baseUrl_api + l.photo
				// }
				for(var t of chosen){
					if(t.perId == l.perId){
						l.disabled = true
					}
				}
			}
			uni.hideLoading()
		})
	}

	function checkChosen(n) {
		return _.some(chosen, (c) => {
			return c.perId == n.perId
		})
	}

	function handleChoose(row) {
    if (row.canChoose != 1){
      uni.showToast({
        title: '该考官资质已过期!',
        icon: "error"
      })
      return
    }

		var pages = getCurrentPages()
		var prevPage = pages[pages.length - 2]
		var obj = {
			perId: row.perId,
			name: row.name,
		 }

	// 	prevPage.onShow(obj)
		uni.$emit('chosen',{
			obj:obj,
			ec
		})
		uni.navigateBack({delta:1})
	}

	function handleInfo(n) {
		uni.navigateTo({
			url: `/personalVip/detail?perId=${n.perId}`
		})
	}
</script>

<style scoped lang="scss">
	.indexboxre {
		padding: 0 30rpx;

		.tt {
			font-size: 30rpx;
			margin: 0 0 30rpx;
			color: #4C5359;
		}

		position: relative;
		height: calc(100vh - 300rpx);
	}

	.searchbar {
		display: flex;
		align-items: center;
		padding: 25rpx;
		box-sizing: border-box;

		:deep(.uni-easyinput .uni-easyinput__content) {
			border-radius: 35rpx;
			border: none;
			height: 70rpx;
		}

		:deep(.uni-easyinput__content-input) {
			font-size: 26rpx;
		}
	}
  .button-group {
    text-align: right;

    button {
      margin-left: 30rpx;
    }
  }
</style>