allSportsmanList.vue 6.63 KB
<template>
  <el-dialog v-model="show" :title="title" width="1000px" append-to-body>
    <div class="funcBtns">
      <el-button type="primary" @click="addMember">添加选手</el-button>
      <el-button type="primary" plain @click="importSportman">导入选手</el-button>
    </div>
    <div class="from-Card">
      <el-form :inline="true" :model="query" class="mt20" label-width="60" size="small">
        <el-form-item label="姓名">
          <el-input v-model="query.realName" style="width: 120px;" clearable/>
        </el-form-item>
        <el-form-item label="短名">
          <el-input v-model="query.shortName" style="width: 120px;" clearable/>
        </el-form-item>
        <el-form-item label="手机号码">
          <el-input v-model="query.phone" style="width: 120px;" clearable/>
        </el-form-item>
        <el-form-item label="邮箱">
          <el-input v-model="query.email" style="width: 120px;" clearable/>
        </el-form-item>
        <el-form-item label="证件类型">
          <el-input v-model="query.idcType" style="width: 120px;" clearable/>
        </el-form-item>
        <el-form-item label="证件号">
          <el-input v-model="query.idcode" style="width: 120px;" clearable/>
        </el-form-item>
        <el-form-item label="角色">
          <el-input v-model="query.label" style="width: 120px;" clearable/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getList">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <p v-if="noPhotoCanSign == 0" class="text-danger">*需上传照片才可报名</p>
    <el-table ref="allSportmenTable" v-loading="loading" :data="tableData" height="60vh"
              @selection-change="handleSelectionChange">
      <el-table-column type="selection" label="选择" :selectable="selectable"/>
      <el-table-column label="所属国家" prop="countryName"/>
      <el-table-column label="姓氏" prop="xing"/>
      <el-table-column label="名" prop="ming"/>
      <el-table-column label="短名" prop="shortName"/>
      <el-table-column label="性别" prop="sexStr"/>
      <el-table-column label="年龄" prop="age"/>
      <el-table-column label="出生日期" prop="birth" width="100"/>
      <el-table-column label="手机号码" prop="phone" width="120"/>
      <el-table-column label="邮箱" prop="email" width="150"/>
      <el-table-column label="证件类型" prop="idcTypeStr"/>
      <el-table-column label="证件号码" prop="idcCode" width="200"/>
      <el-table-column label="会员角色" width="200">
        <template #default="scope">
          <div>
            <div style="white-space: nowrap" class="esp">
            <span v-for="item in scope.row.label?.split(',')" :key="item.id">
              <el-tag type="warning" size="small" v-if="item==='0'" effect="plain" class="ml10">运动员</el-tag>
              <el-tag type="warning" size="small" v-if="item==='1'" effect="plain" class="ml10">教练</el-tag>
              <el-tag type="warning" size="small" v-if="item==='2'" effect="plain" class="ml10">领队</el-tag>
              <el-tag type="warning" size="small" v-if="item==='3'" effect="plain" class="ml10">队医</el-tag>
              <el-tag type="warning" size="small" v-if="item==='4'" effect="plain" class="ml10">翻译</el-tag>
              <el-tag type="warning" size="small" v-if="item==='5'" effect="plain" class="ml10">官员</el-tag>
              <el-tag type="warning" size="small" v-if="item==='6'" effect="plain" class="ml10">其他</el-tag>
            </span>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="详细地址" prop="address"/>

      <el-table-column label="操作" width="120" fixed="right" align="center">
        <template #default="scope">
          <el-button type="text" @click="editPerson(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <template #footer>
      <div class="dialog-footer text-center">
        <el-button type="primary" @click="submitForm">确定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </template>
  </el-dialog>

  <addCoach ref="dialogAddCoach" @submitForm="getList"/>
  <Import ref="dialogImportProps"/>
</template>

<script setup>
import {reactive, ref, toRefs, watch} from 'vue'
import {getCurrentInstance, nextTick, onMounted} from '@vue/runtime-core'
import * as match from '@/apiPc/match'
import addCoach from '../components/addCoach'
import {getGroupPersonList} from "@/apiPc/match";
import Import from '../components/import'

const {proxy} = getCurrentInstance()
const emit = defineEmits(['submitForm', 'transfer'])
const data = reactive({
  query: {},
  tableData: [],
  birthArr: [],
  show: false,
  loading: false,
  title: '选择运动员',
  noPhotoCanSign: 0
})
const {query, tableData, show, title, birthArr, loading, noPhotoCanSign} = toRefs(data)
let matchId
let groupId
let choosedList = []
const choosedIds = []
const open = (params) => {
  matchId = params.matchId
  groupId = params.groupId
  noPhotoCanSign.value = params.noPhotoCanSign
  show.value = true
  choosedList = params.choosedList
  for (const p of choosedList) {
    choosedIds.push(p.id)
  }
  getList()
}
defineExpose({
  open
})
const selectable = (row) => {
  if (!row.picUrl && noPhotoCanSign.value == 0) {
    return false
  } else {
    return true
  }
}
const getList = () => {
  loading.value = true
  if (birthArr.value) {
    query.value.birthBegin = birthArr.value[0]
    query.value.birthEnd = birthArr.value[1]
  }
  match.getGroupPersonList(query.value, groupId).then(res => {
    tableData.value = res.rows
    nextTick(() => {
      for (const n in tableData.value) {
        if (choosedIds.indexOf(tableData.value[n].id) > -1) {
          proxy.$refs['allSportmenTable'].toggleRowSelection(tableData.value[n], true)
        }
      }
    })
    loading.value = false
  })
}

function handleSelectionChange(val) {
  // console.log(val)
  choosedList = val
}

function submitForm() {
  emit('transfer', choosedList)
  // emit('submitForm', choosedList)
  show.value = false
}

function cancel() {
  show.value = false
}

function editPerson(row) {
  const params = {
    id: row.id,
    groupId: groupId
  }
  proxy.$refs['dialogAddCoach'].open(params)
}

function addMember() {
  const params = {
    title: '添加人员',
    id: 0,
    groupId: groupId.value
  }
  proxy.$refs['dialogAddCoach'].open(params)
}

function importSportman() {
  const params = {
    title: '批量导入选手',
    groupId: groupId.value
  }
  proxy.$refs['dialogImportProps'].open(params)
}
</script>
<style scoped lang="scss">
.el-form--inline .el-form-item {
  width: auto;
}
</style>