step4.vue 12.2 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
<template>
  <div>
    <div class="panel-box">
      <h3 class="train-h3">个人信息</h3>
      <el-descriptions :column="4" :style="{'--el-fill-color-blank':'#f9f9f9'}">
        <el-descriptions-item label="姓名:">{{ personal.name }}</el-descriptions-item>
        <el-descriptions-item label="会员编号:">{{ personal.perCode }}</el-descriptions-item>
        <el-descriptions-item label="有效期:">{{ parseTime(personal.validityDate,'{y}-{m}-{d}') }}</el-descriptions-item>
        <el-descriptions-item label="段位:">{{ (personal.levelDuan && personal.levelDuan!=0)? (szToHz(personal.levelDuan)+'段/品') :'--' }}</el-descriptions-item>
        <el-descriptions-item label="教练员等级:">{{ personal.coachLabel?.name||'--' }}</el-descriptions-item>
        <el-descriptions-item label="裁判员等级:">{{ personal.refereeLabel?.name||'--' }}</el-descriptions-item>
        <el-descriptions-item label="晋级官等级:">{{ personal.examinerJiLabel?.name||'--' }}</el-descriptions-item>
        <el-descriptions-item label="晋段官等级:">{{ personal.examinerDuanLabel?.name||'--' }}</el-descriptions-item>
      </el-descriptions>

      <h3 class="train-h3">培训科目</h3>
      <el-checkbox-group v-model="form.trainIds" @change="checkRelateTrain">
        <el-row :gutter="20">
          <el-col v-for="t in trainList" :key="t.id" :class="{delText:t.disabled}" :span="12">
            <div class="kmitem">
              <el-checkbox :label="t.id" :checked="t.required" :disabled="t.required || t.disabled">
                <div class="ffsp">
                  <span style="color: #000">{{ t.name }}</span>
                  <div>
                    <span style="color: #BF3031">{{ t.price }}</span>
                    <span style="color: #000">/</span>
                  </div>
                </div>
                <div class="mt10">
                  <span>报名限制条件:</span>
                  <span v-if="signRules[t.twoSubjectId]?.openFlag">
                    <span>等级</span><span>{{ signRules[t.twoSubjectId]?.name }}</span>
                    <span>段位</span><span>{{ signRules[t.twoSubjectId]?.duanStr }}</span>
                    <span>年限</span><span>{{ signRules[t.twoSubjectId]?.limitStr }}</span>
                  </span>
                  <span v-else>
                    --
                  </span>
                </div>
              </el-checkbox>
            </div>
          </el-col>
        </el-row>
      </el-checkbox-group>
      <el-empty v-if="trainList.length==0" />

      <h3 class="train-h3">考试科目</h3>
      <el-checkbox-group v-model="form.examIds">
        <el-row :gutter="20">
          <el-col v-for="t in examList" :key="t.id" :span="12" :class="{delText:(t.disabled || !t.passRelate)}">
            <div class="kmitem">
              <el-checkbox :label="t.id" :checked="t.required" :disabled="t.required || t.disabled || !t.passRelate">
                <div>
                  <span style="color: #000">{{ t.name }}</span>
                  <span style="color: #BF3031">{{ t.price }}</span>
                  <span style="color: #000">/</span>
                </div>
                <div class="mt10 mb10">
                  <span>报名限制条件:</span>
                  <span v-if="signRules[t.twoSubjectId]?.openFlag">
                    <span>等级</span><span>{{ signRules[t.twoSubjectId]?.name }}</span>
                    <span>段位</span><span>{{ signRules[t.twoSubjectId]?.duanStr }}</span>
                    <span>年限</span><span>{{ signRules[t.twoSubjectId]?.limitStr }}</span>
                  </span>
                  <span v-else>
                    --
                  </span>
                </div>
                <div>
                  <span>关联培训:</span>
                  <span>{{ t.relateTrainNames||'--' }}</span>
                </div>
              </el-checkbox>
            </div>
          </el-col>
        </el-row>
      </el-checkbox-group>
      <el-empty v-if="examList.length==0" />

    </div>
    <div class="panel-footer text-center">
      <el-button class="back" type="" round @click="prev">上一步</el-button>
      <el-button type="primary" round @click="submitForm()">提交审核</el-button>
    </div>

    <el-dialog v-model="bankShow" title="线下支付" width="400px">
      <el-descriptions :column="1" border>
        <el-descriptions-item label="单位名称" label-class-name="w100px">{{ bankInfo.name }}</el-descriptions-item>
        <el-descriptions-item label="开户行">{{ bankInfo.bank }}</el-descriptions-item>
        <el-descriptions-item label="账户">{{ bankInfo.account }}</el-descriptions-item>
        <el-descriptions-item label="打款金额">{{ totalAmount }}</el-descriptions-item>
      </el-descriptions>
      <template #footer>
        <div class="dialog-footer text-center">
          <el-button type="primary" round @click="sure">确定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { computed, reactive, watch } from 'vue'
import { getCurrentInstance, onMounted } from '@vue/runtime-core'
import * as train from '@/apiPc/train'
import { toRefs } from '@vueuse/shared'
import { useRoute } from 'vue-router'
import { szToHz } from '@/utils/ruoyi'
import _ from 'lodash'


const emit = defineEmits(['prev', 'publish'])
const { proxy } = getCurrentInstance()
const route = useRoute()

const props = defineProps({
  activity: {
    type: Object,
    default: () => {}
  },
  personal: {
    type: Object,
    default: () => {}
  },
  examList: {
    type: Array,
    default: () => []
  },
  trainList: {
    type: Array,
    default: () => []
  }
})

const bankInfo = computed(() => {
  if (props.activity.receivingInfo) {
    return JSON.parse(props.activity.receivingInfo)
  } else {
    return {}
  }
})

const data = reactive({
  form: {
    trainIds: [],
    examIds: []
  },
  signRules: {},
  bankShow: false,
  totalAmount: null
})
const { form, signRules, bankShow, totalAmount } = toRefs(data)

onMounted(() => {
  getRules()
})

function getRules() {
  Promise.all([
    train.getCoachRules(),
    train.getRefereeRules(),
    train.getExaminerJiRules(),
    train.getExaminerDuanRules()
  ]).then((res) => {
    _.each(res, (r) => _.each(r.data, (d) => {
      signRules.value[d.id] = d
    }))
  })
}

watch([() => Object.keys(signRules.value).length, () => props.trainList.length], (val) => {
  if (val[0] && val[1]) {
    checkCanSign(props.trainList, 1)
    checkCanSign(props.examList, 2)

    // 考试关联培训
    fillRelateTrain()
    checkRelateTrain()
  }
})

function checkCanSign(list, flag) {
  _.each(list, (l) => {
    if (l.requiredFlag == '1') {
      l.required = true
      switch (flag) {
        case 1:// 培训
          form.value.trainIds.push(l.id)
          break
        case 2:// 考试
          form.value.examIds.push(l.id)
          break
      }
    }
    if (l.twoSubjectId && signRules.value[l.twoSubjectId.toString()]) {
      const rule = signRules.value[l.twoSubjectId]
      // 有报名条件
      if (rule.openFlag) {
        let currLevel, currYear
        const currDuan = parseInt(props.personal.levelDuan || 0)
        switch (l.parentSubjectId) {
          case 100:// 教练
            currLevel = parseInt(props.personal.coachLabel?.type || 0)
            currYear = parseInt(props.personal.coachLabel?.yearLimit || 0)
            if (!(currLevel >= parseInt(rule.type) && currDuan >= parseInt(rule.duan) && currYear >= parseInt(rule.limit))) {
              l.disabled = true
            }
            break
          case 200:// 裁判
            currLevel = parseInt(props.personal.refereeLabel?.type || 0)
            currYear = parseInt(props.personal.refereeLabel?.yearLimit || 0)
            if (!(currLevel >= parseInt(rule.type) && currDuan >= parseInt(rule.duan) && currYear >= parseInt(rule.limit))) {
              l.disabled = true
            }
            break
          case 300:// 晋级
            if (!(currDuan >= parseInt(rule.duan))) {
              l.disabled = true
            }
            break
          case 400:// 晋段
            currLevel = parseInt(props.personal.examinerDuanLabel?.type || 0)
            if (!(currLevel >= parseInt(rule.type) && currDuan >= parseInt(rule.duan))) {
              l.disabled = true
            }
            break
        }
      }
    }
  })
}

function fillRelateTrain() {
  _.each(props.examList, (e) => {
    if (e.relateTrainIds) {
      const trainNames = []
      _.each(e.relateTrainIds.split(','), (id) => {
        const train = _.find(props.trainList, (t) => t.id == id)
        trainNames.push(train?.name || '关联错误的培训')
      })
      e.relateTrainNames = trainNames.join(',')
    }
  })
}

function checkRelateTrain() {
  _.each(props.examList, (e) => {
    e.passRelate = true
    if (e.relateTrainIds) {
      if (_.some(e.relateTrainIds.split(','), (id) => form.value.trainIds.indexOf(id) == -1)) {
        e.passRelate = false
      }
    }
  })
}

function submitForm() {
  if (form.value.trainIds.length == 0) {
    proxy.$modal.msgError('请选择培训科目')
    return
  }

  if (_.some(form.value.trainIds, (id) => {
    const train = _.find(props.trainList, (t) => t.id == id)
    return train.disabled
  })) {
    proxy.$modal.msgError('选中了不满足报名条件的培训科目,无法提交审核')
    return
  }

  if (_.some(form.value.examIds, (id) => {
    const exam = _.find(props.examList, (t) => t.id == id)
    return exam.disabled || !exam.passRelate
  })) {
    proxy.$modal.msgError('选中了不满足报名条件的考试科目,无法提交审核')
    return
  }

  let amount = _.chain(props.trainList)
    .filter((t) => form.value.trainIds.indexOf(t.id) > -1)
    .sumBy((t) => parseFloat(t.price))
    .valueOf()

  amount += _.chain(props.examList)
    .filter((e) => form.value.examIds.indexOf(e.id) > -1)
    .sumBy((e) => parseFloat(e.price))
    .valueOf()

  totalAmount.value = amount.toFixed(2)
  bankShow.value = true
}

function sure() {
  form.value.activityId = route.params.id
  train.commitSign(form.value).then(() => {
    proxy.$modal.alertSuccess('提交成功,待审核').finally(() => {
      emit('publish')
    })
  })
}

function prev() {
  emit('prev')
}

</script>

<style scope lang="scss" scoped>
.panel-box{
  border:1px solid #F5766A;
  padding:10px 20px;
}
.train-h3{
  font-size: 16px;
  font-weight: 600;
  color: var(--el-color-primary);
  padding-left: 20px;
  border-left: 3px solid var(--el-color-primary) ;
 }
.back{
  border:1px solid var(--el-color-primary) ;
  color:var(--el-color-primary)
}

.row-bg{
  background: #F9F9F9;
  border-radius: 2px;
  padding: 20px;
  div{
    font-size: 14px;
    font-weight: 400;
    color: #4C5359;
    padding: 5px;
  }
  span{
    font-size: 14px;
    font-weight: 400;
    color: #000000;
  }
}
.app-container {
  padding: 0;
  background: #f5f7f9;
}

.panel-footer .el-button--success {
  background: linear-gradient(270deg, #39dba7, #38ef7d);
  border: none;
  padding: 0 40px;
  font-size: 16px;
}

.signForm {
  .el-form-item__label {
    color: #4c5359;
  }
}

.tip {
  font-size: 13px;
  color: #999;
  margin: 10px 0;

  i {
    color: red;
    margin: 0 4px 0 0;
  }
}

.threeFour {
  width: 100%;
}

:deep(.el-upload--picture-card) {
  width: 120px;
  height: 160px;
}

:deep(.el-upload-list--picture-card .el-upload-list__item) {
  width: 120px;
  height: 160px;
}

.red {
  color: #f56c6c;
}

//多选框
.checkbox{
  :deep(.el-form-item__content){
    margin-left: 20px!important;
    width: 100% !important;
  }
  :deep(.el-checkbox){
    width: 100%;
    border:1px solid #DCDFE6;
    padding:7px;
  }
  :deep(.el-checkbox__label){
    width: 100% !important;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
  }
}
.kmitem{padding: 10px;margin-bottom: 10px;
  border: 1px solid #DCDFE6;
  :deep(.el-checkbox){height: auto;width: 100%}
  .ffsp{display: flex;justify-content:space-between;width: 100%;}
  :deep(.el-checkbox__label){  flex: 1 1 auto}
}
.delText{opacity: 0.6;
  .kmitem{background: #efefef;}
}
.required{opacity: 1!important;
  .kmitem{background: #fff;}
}
:deep(.el-descriptions__body .el-descriptions__table .el-descriptions__cell){
  padding: 8px 0 8px 15px;
}
:deep(.el-descriptions__label){
  color: #4C5359;}
:deep(.el-descriptions__content){
  color: #000000;}
</style>