提交 3680fcfb 编写于 作者: 刘英杰's avatar 刘英杰

V20240827 完成学生赛事报名

上级
<script setup>
const props = defineProps({
item: {
type: Object,
default: () => {
}
}
})
</script>
<template>
<div class="w-full h-full bg-white rounded-[8px] my-2 p-3 relative">
<div class="w-full h-1/2 flex items-center justify-between">
<div v-font:{size:18,color:`#323233`} class="w-[95%] ">
<van-icon name="contact" :color="['#0099ff','#f80c72'][props.item.gender ==='男'? 0:1]" class="mb-3 "/>
{{ props.item.name }}{{ `(${props.item.number})` }}
</div>
<slot name="checkbox"></slot>
</div>
<div class="w-full h-1/2 flex items-center ">
<div v-font:{size:14,color:`#323233`}>{{ '学生' }}</div>
<div v-show="props.item.sfzh " class="mx-1">|</div>
<div v-show="props.item.sfzh " v-font:{size:14,color:`#323233`}>{{ props.item.sfzh }}</div>
<div v-show="props.item.phone" class="mx-1">|</div>
<div v-show="props.item.phone" v-font:{size:14,color:`#323233`}>{{ props.item.phone }}</div>
</div>
</div>
</template>
<style scoped>
</style>
<script setup>
const props = defineProps({
item: {
type: Object,
default: () => {
}
}
})
</script>
<template>
<div class="w-full h-full bg-white rounded-[8px] my-2 p-3 relative">
<div class="w-full h-1/2 flex items-center justify-between">
<div v-font:{size:18,color:`#323233`} class="w-[95%] ">
<van-icon name="contact" :color="['#0099ff','#f80c72'][props.item.gender_name ==='男'? 0:1]" class="mb-3 "/>
{{ props.item.name }}{{ `(${props.item.number})` }}
</div>
<slot name="checkbox"></slot>
</div>
<div class="w-full h-1/2 flex items-center ">
<div v-font:{size:14,color:`#323233`}>{{ props.item.dept_name }}</div>
<div v-show="props.item.sfzh " class="mx-1">|</div>
<div v-show="props.item.sfzh " v-font:{size:14,color:`#323233`}>{{ props.item.sfzh }}</div>
<div v-show="props.item.phone" class="mx-1">|</div>
<div v-show="props.item.phone" v-font:{size:14,color:`#323233`}>{{ props.item.phone }}</div>
</div>
</div>
</template>
<style scoped>
</style>
<script setup>
const props = defineProps({
item: {
type: Object,
default: () => {
}
}
})
</script>
<template>
<!--含教学分-->
<div class="w-full h-full bg-white flex rounded-[8px] text-[#323233] my-2 p-3 relative">
<div class="w-[80%] h-full ">
<div class="w-full h-full flex items-center">
<div v-font:{size:18,color:`#323233`} class="w-[fit] ">{{ props.item.name }}</div>
<van-icon name="contact" :color="['#0099ff','#f80c72'][props.item.gender ==='男'? 0:1]" class="mb-3 mx-1"/>
<div v-font:{size:12,color:`#323233`} class="w-[fit-content] ">
{{ props.item.card_name }}
</div>
</div>
<div class="w-full h-full flex items-center">
<div v-font:{size:14,color:`#323233`}>{{ props.item.unit }}</div>
</div>
<div class="w-full h-full flex items-center">
<div v-font:{size:14,color:`#323233`}>{{ props.item.dept }}</div>
<div v-show="props.item.sfzh " class="mx-1">|</div>
<div v-show="props.item.sfzh " v-font:{size:14,color:`#323233`}>{{ props.item.sfzh }}</div>
<div v-show="props.item.phone" class="mx-1">|</div>
<div v-show="props.item.phone" v-font:{size:14,color:`#323233`}>{{ props.item.phone }}</div>
</div>
</div>
<div class="w-[20%] h-full my-auto flex items-center justify-center flex-wrap relative">
<!-- <div v-font:{size:22,color:`#1989fa`} class="w-full ccFlex h-[30%] ">524</div>
<div v-font:{size:12,color:`#323233`} class="w-full ccFlex h-[30%]">教学分</div>-->
</div>
<slot name="delete" class="absolute top-0 right-0"></slot>
</div>
</template>
<style scoped>
</style>
<script setup>
const props = defineProps({
item: {
type: Object,
default: () => {
}
}
})
</script>
<template>
<!--含教学分-->
<div class="w-full h-full bg-white flex rounded-[8px] text-[#323233] my-2 p-3 relative">
<div class="w-[80%] h-full ">
<div class="w-full h-full flex items-center">
<div v-font:{size:18,color:`#323233`} class="w-[fit] ">{{ props.item.name }}</div>
<van-icon name="contact" :color="['#0099ff','#f80c72'][props.item.gender_name ==='男'? 0:1]" class="mb-3 mx-1"/>
<div v-font:{size:12,color:`#323233`} class="w-[fit-content] ">
{{ props.item.card_name }}
</div>
</div>
<div class="w-full h-full flex items-center">
<div v-font:{size:14,color:`#323233`}>{{ props.item.unit }}</div>
</div>
<div class="w-full h-full flex items-center">
<div v-font:{size:14,color:`#323233`}>{{ props.item.dept }}</div>
<div v-show="props.item.sfzh " class="mx-1">|</div>
<div v-show="props.item.sfzh " v-font:{size:14,color:`#323233`}>{{ props.item.sfzh }}</div>
<div v-show="props.item.phone" class="mx-1">|</div>
<div v-show="props.item.phone" v-font:{size:14,color:`#323233`}>{{ props.item.phone }}</div>
</div>
</div>
<div class="w-[20%] h-full my-auto flex items-center justify-center flex-wrap relative">
<!-- <div v-font:{size:22,color:`#1989fa`} class="w-full ccFlex h-[30%] ">524</div>
<div v-font:{size:12,color:`#323233`} class="w-full ccFlex h-[30%]">教学分</div>-->
</div>
<slot name="delete" class="absolute top-0 right-0"></slot>
</div>
</template>
<style scoped>
</style>
<script setup>
const props = defineProps({
item: {
type: Object,
default: () => {
}
}
})
</script>
<template>
<!--含教学分-->
<div class="w-full h-full bg-white flex rounded-[8px] text-[#323233] my-2 p-3 relative">
<div class="w-[80%] h-full ">
<div class="w-full h-full flex items-center">
<div v-font:{size:18,color:`#323233`} class="w-[fit] ">{{ props.item.name }}</div>
<van-icon name="contact" :color="['#0099ff','#f80c72'][props.item.gender ==='男'? 0:1]" class="mb-3 mx-1"/>
<div v-font:{size:12,color:`#323233`} class="w-[fit-content] ">
{{ props.item.card_name }}
</div>
</div>
<div class="w-full h-full flex items-center">
<div v-font:{size:14,color:`#323233`}>{{ props.item.unit }}</div>
</div>
<div class="w-full h-full flex items-center">
<div v-font:{size:14,color:`#323233`}>{{ props.item.dept || '暂无班级数据' }}</div>
<div v-show="props.item.sfzh " class="mx-1">|</div>
<div v-show="props.item.sfzh " v-font:{size:14,color:`#323233`}>{{ props.item.sfzh }}</div>
<div v-show="props.item.phone" class="mx-1">|</div>
<div v-show="props.item.phone" v-font:{size:14,color:`#323233`}>{{ props.item.phone }}</div>
</div>
</div>
<div class="w-[20%] h-full my-auto flex items-center justify-center flex-wrap relative">
<!-- <div v-font:{size:22,color:`#1989fa`} class="w-full ccFlex h-[30%] ">524</div>
<div v-font:{size:12,color:`#323233`} class="w-full ccFlex h-[30%]">教学分</div>-->
</div>
<slot name="delete" class="absolute top-0 right-0"></slot>
</div>
</template>
<style scoped>
</style>
<template>
<van-popup v-model="show" position="bottom" :style="{height: '100%'}" class="popup">
<!-- 搜索框 -->
<van-search
class="zd-search"
v-model="searchInput"
placeholder="请输入关键词搜索"
:disabled="sType != 0"
@input="searchChange"
background="#fff"/>
<div class="content">
<!-- 侧边菜单栏 -->
<div class="left" v-if="sType != 2">
<van-sidebar v-model="siderVal" @change="sidebarChange">
<van-sidebar-item title="学生" v-if="sType == 0"/>
<van-sidebar-item title="教师" v-if="sType == 0"/>
<van-sidebar-item title="年级" v-if="sType == 1"/>
</van-sidebar>
</div>
<!-- 人员列表 -->
<div class="right">
<!-- 人员列表、年级列表 -->
<van-pull-refresh v-model="refreshing" @refresh="onRefresh" v-if="sType != 2">
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<van-cell
v-for="(item, i) in list"
:key="sType == 0 ? item.card_number : item.id"
:title="sType == 0 ? item.name : item.label"
:label="sType == 0 ? item.card_number : item.id"
@click="selection(item, i)">
<template>
<van-checkbox v-model="item.check"></van-checkbox>
</template>
</van-cell>
</van-list>
</van-pull-refresh>
<!-- 班级院系树形列表 -->
<div v-else>
<van-loading v-if="treeLoading" type="spinner" color="#1989fa"/>
<div v-if="reloadTree && !treeLoading">
<tree
:data="list"
:options="options"
@node:selected="onSelected"
@node:checked="onChecked"
@node:unchecked="onUnchecked"
ref="tree"/>
</div>
</div>
</div>
</div>
<!-- 底部已选择人员、确认取消按钮 -->
<div class="bottom">
<div class="chooseDiv">
<a @click="sType == 2 ? '' : slcPopupShow = true">
已选择:{{ selectList.length }}{{ sType == 0 ? '人' : '个' }}
<van-icon v-if="sType != 2" name="arrow-up"/>
</a>
</div>
<div class="buttonDiv">
<van-button type="default" @click="cancel">取消</van-button>
<van-button type="info" @click=submit>确定</van-button>
</div>
</div>
<!-- 已选人员列表(弹出层) -->
<van-popup v-model="slcPopupShow" round position="bottom" :style="{ height: '70%' }" class="selectionListDiv">
<div class="listTitle">
<span><b>已选择{{ selectList.length }}{{ sType == 0 ? '人' : '个' }}</b></span>
<span class="deleteBt" @click="removeAll"><van-icon name="delete-o"/>全部移除</span>
<a @click="slcPopupShow = false">确认</a>
</div>
<div class="listDiv">
<van-cell-group>
<van-cell
v-for="(item, index) in selectList"
:key="item.id"
:title="item.name"
:label="item.id">
<template #default>
<van-button type="default" size="small" @click="removeRow(item, index)">移除</van-button>
</template>
</van-cell>
</van-cell-group>
</div>
</van-popup>
</van-popup>
</template>
<script>
/*import * as apiCommon from '@/api/common'*/
import {Dialog, Loading} from 'vant'
export default {
components: {
// ListMenu,
},
data() {
return {
// 当前组件显示
show: false,
// 搜索值
searchInput: '',
// 侧边菜单,教师、学生
siderVal: 0,
// 列表
pageIndex: 1,
pageSize: 20,
totalCount: 0,
list: [],
// 已选人员列表
selectList: [],
// 下拉刷新、上滑加载
loading: false,
finished: false,
refreshing: false,
// 已选人员列表显示
slcPopupShow: false,
sType: 0, // 0.人员选择, 1.年级选择,2.院系班级
// 班级院系选择时↓
reloadTree: true, // 树形重载
options: {
checkbox: true,
propertyNames: {
text: 'label',
},
},
treeLoading: false, // 加载中
}
},
// watch: {
// sType() {
// // console.log('sType发生改变')
// this.selectList = []
// },
// },
computed: {},
created() {
},
mounted() {
},
methods: {
// 刷新liquor-tree树形组件
reloadTreeM() {
this.reloadTree = false
this.$nextTick(() => {
this.reloadTree = true
})
},
// 树形组件点击和勾选
onSelected(node) {
},
onChecked(node) {
// console.log(node)
node.name = node.text
this.selectList.push(node)
},
onUnchecked(node) {
// console.log(node)
this.selectList.splice(this.selectList.findIndex(item => item.id == node.id), 1)
},
// 显示组件初始化
init(val) {
this.selectList = []
let ID = this.sType == 0 ? 'user_id' : 'id'
let NAME = this.sType == 0 ? 'user_name' : 'label'
// this.siderVal = 0
setTimeout(() => {
this.selectList = val.map(item => {
return {id: item[ID], name: item[NAME]}
})
}, 100);
this.searchInput = ''
this.list = [];
this.pageIndex = 1
this.totalCount = 0
if (this.siderVal == 0) {
this.onRefresh()
} else {
this.siderVal = 0
}
},
// 改变侧边栏
sidebarChange(index) {
this.searchInput = ''
this.list = [];
this.pageIndex = 1
this.totalCount = 0
this.onRefresh()
},
// 搜索值改变时
searchChange(val) {
// console.log(val)
this.list = [];
this.pageIndex = 1
this.totalCount = 0
this.onRefresh()
},
// 加载
async onLoad() {
// 刷新
if (this.refreshing) {
this.list = [];
this.pageIndex = 1
this.totalCount = 0
this.refreshing = false;
}
this.treeLoading = true // 加在班级院系时的loading
/* const res = this.sType == 0 ?
await apiCommon.person(this.searchInput, this.siderVal, this.pageIndex, this.pageSize):
this.sType == 1 ?
await apiCommon.getGrade():
await apiCommon.getDeptTree()*/
// console.log(res)
var arr = []
if (this.sType == 0) {
// 人员选择
arr = res.response.data.map(item => {
if (this.selectList.some(a => a.id == item.card_number))
item.check = true
else
item.check = false
return item
})
} else if (this.sType == 1) {
// 年级选择
arr = res.response.map(item => {
if (this.selectList.some(a => a.id == item.id))
item.check = true
else
item.check = false
return item
})
} else if (this.sType == 2) {
// 院系班级选择
arr = this.liquorTreeFormat(res.response)
}
this.list = this.list.concat(arr)
this.pageIndex++
this.totalCount = res.response.data_count
this.loading = false
if (this.list.length >= this.totalCount || this.sType != 0) {
this.finished = true;
}
if (this.sType == 2) {
this.treeLoading = false
this.reloadTreeM()
}
},
// 下拉刷新
onRefresh() {
// 清空列表数据
this.finished = false;
// 重新加载数据
// 将 loading 设置为 true,表示处于加载状态
this.loading = true;
this.onLoad();
},
// 点击人员列表
selection(item, i) {
// console.log(item)
let ID = this.sType == 0 ? 'card_number' : 'id'
let NAME = this.sType == 0 ? 'name' : 'label'
if (item.check) {
this.selectList.splice(this.selectList.findIndex(item2 => item2.id == item[ID]), 1)
} else {
this.selectList.push({id: item[ID], name: item[NAME]})
}
this.list[i].check = !this.list[i].check
},
// 人员列表移除全部
removeAll() {
Dialog.confirm({
title: '提示',
message: '是否确认全部移除?',
}).then(() => {
this.list = [];
this.pageIndex = 1
this.totalCount = 0
this.selectList = []
this.onRefresh()
}).catch(() => {
})
},
// 人员列表移除已选择
removeRow(item, index) {
console.log(item, index)
this.list = [];
this.pageIndex = 1
this.totalCount = 0
this.selectList.splice(index, 1)
this.onRefresh()
},
// 确定
submit() {
this.show = false
this.$emit('selectConfirm', this.selectList, this.sType)
},
// 取消
cancel() {
this.show = false
},
// liquor-tree格式化
liquorTreeFormat(arr) {
arr.forEach(item => {
if (item.hasOwnProperty('children') && item.children.length != 0) {
item.children = this.liquorTreeFormat(item.children)
}
})
return arr.map(item => {
// item.text = item.label
if (this.selectList.some(a => a.id == item.id))
item.state = {checked: true}
item.name = item.label
return item
})
},
},
}
</script>
<style scoped lang="less">
.popup {
.content {
display: flex;
height: calc(100% - 117px);
overflow: auto;
.left {
width: 20%;
.van-sidebar-item--select::before {
background-color: #1989fa;
}
.van-sidebar-item--select {
color: #1989fa;
}
}
.right {
width: 100%;
height: 100%;
overflow: auto;
.van-cell {
.van-cell__value {
display: flex;
flex-direction: row-reverse;
}
}
.van-loading {
text-align: center;
}
.tree {
overflow: unset;
}
}
}
.bottom {
height: 60px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 16px;
.chooseDiv {
a {
color: #1989fa;
}
}
.buttonDiv {
.van-button {
margin: 8px;
}
}
}
.selectionListDiv {
.listTitle {
height: 50px;
width: 100%;
padding: 0 20px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
.deleteBt {
color: #969799;
font-size: 14px;
}
a {
color: #1989fa;
font-size: 14px;
}
}
.listDiv {
height: calc(100% - 50px);
overflow: auto;
}
}
}
</style>
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或