c0aee960 by 华明祺

培训报名规则修改

1 parent 4b268e3f
<template>
<view>
<!-- 培训信息完善 -->
<view class="title-left-border">培训信息</view>
<uni-forms ref="baseForm" :modelValue="form" label-width="120">
<uni-forms-item label="所在单位名称" required name="unitName">
<uni-easyinput v-model="form.unitName" placeholder="请输入所在单位名称" />
</uni-forms-item>
<uni-forms-item label="现任职务" required name="unitRole">
<uni-easyinput v-model="form.unitRole" placeholder="请输入现任职务" />
</uni-forms-item>
<view v-if="activity.invoiceFlag=='1'">
<uni-forms-item label="是否需要发票" required name="invoiceFlag">
<uni-data-checkbox v-model="form.invoiceFlag" :localdata="invoiceFlag" />
</uni-forms-item>
<uni-forms-item label="发票形式" v-if="form.invoiceFlag=='1'" required name="invoiceType">
<uni-data-checkbox v-model="form.invoiceType" :localdata="invoiceType" />
</uni-forms-item>
<uni-forms-item label="开票信息" v-if="form.invoiceFlag=='1'" required name="invoiceInfo">
<uni-easyinput v-model="form.invoiceInfo" placeholder="请输入开票信息" />
</uni-forms-item>
</view>
<uni-forms-item :label="c.name" v-for="c in customInfo" :key="c.id">
<uni-easyinput v-if="c.type=='1'" v-model="form.customInfoObj[c.id]" placeholder="请输入" />
<view>
<uni-file-picker v-if="c.type == '2'" limit="1" file-mediatype="all" file-extname="doc,docx,pdf,txt"
v-model="c.value" @select="selectFile"
@delete="delSupplementFile(c,$event)" />
<text v-if="c.type == '2'" style="font-size: 24rpx;color: #999;">仅支持上传doc,docx,pdf,txt</text>
<uni-file-picker v-if="c.type == '3'" v-model="upSupplement3Value" return-type="object" limit="1"
@select="upSupplement3" @delete="delSupplementImg(c,$event)" />
</view>
<uni-data-select v-model="c.value" v-if="c.type == '4'" :localdata="c.option"></uni-data-select>
</uni-forms-item>
</uni-forms>
</view>
<view class="fixedBottom">
<button class="btn btn-red-kx" @click="prev">上一步</button>
<button class="btn btn-red" @click="next">下一步</button>
</view>
<view>
<!-- 培训信息完善 -->
<view class="title-left-border">培训信息</view>
<uni-forms ref="baseForm" :modelValue="form" label-width="120">
<uni-forms-item label="所在单位名称" required name="unitName">
<uni-easyinput v-model="form.unitName" placeholder="请输入所在单位名称" />
</uni-forms-item>
<uni-forms-item label="现任职务" required name="unitRole">
<uni-easyinput v-model="form.unitRole" placeholder="请输入现任职务" />
</uni-forms-item>
<view v-if="activity.invoiceFlag=='1'">
<uni-forms-item label="是否需要发票" required name="invoiceFlag">
<uni-data-checkbox v-model="form.invoiceFlag" :localdata="invoiceFlag" />
</uni-forms-item>
<uni-forms-item label="发票形式" v-if="form.invoiceFlag=='1'" required name="invoiceType">
<uni-data-checkbox v-model="form.invoiceType" :localdata="invoiceType" />
</uni-forms-item>
<uni-forms-item label="开票信息" v-if="form.invoiceFlag=='1'" required name="invoiceInfo">
<uni-easyinput v-model="form.invoiceInfo" placeholder="请输入开票信息" />
</uni-forms-item>
</view>
<uni-forms-item :label="c.name" v-for="c in customInfo" :key="c.id">
<uni-easyinput v-if="c.type=='1'" v-model="form.customInfoObj[c.id]" placeholder="请输入" />
<view>
<uni-file-picker v-if="c.type == '2'" limit="1" file-mediatype="all" file-extname="doc,docx,pdf,txt"
v-model="c.value" @select="selectFile"
@delete="delSupplementFile(c,$event)" />
<text v-if="c.type == '2'" style="font-size: 24rpx;color: #999;">仅支持上传doc,docx,pdf,txt</text>
<uni-file-picker v-if="c.type == '3'" v-model="upSupplement3Value" return-type="object" limit="1"
@select="upSupplement3" @delete="delSupplementImg(c,$event)" />
</view>
<uni-data-select v-model="c.value" v-if="c.type == '4'" :localdata="c.option"></uni-data-select>
</uni-forms-item>
</uni-forms>
</view>
<view class="fixedBottom">
<button class="btn btn-red-kx" @click="prev">上一步</button>
<button class="btn btn-red" @click="next">下一步</button>
</view>
</template>
<script setup>
import {
onLoad
} from '@dcloudio/uni-app'
import {
ref,
reactive,
toRefs,
computed,
watch
} from 'vue'
import _ from 'lodash'
import * as train from '@/training/train.js'
const emit = defineEmits(['prev', 'next'])
const props = defineProps({
activity: {
type: Object,
default: () => {}
},
trainId: {
type: String,
default: () => {}
},
active: {
type: Number,
default: () => {}
}
})
const customInfo = computed(() => {
if (props.activity.customInfo) {
return JSON.parse(props.activity.customInfo).info
} else {
return []
}
})
const data = reactive({
form: {
invoiceFlag: '1',
customInfoObj: {}
},
invoiceFlag: [{
value: '0',
text: '否'
}, {
value: '1',
text: '是'
}],
invoiceType: [{
value: 0,
text: '电子票'
}, {
value: 1,
text: '纸质专票'
}, {
value: 2,
text: '纸质普票'
}]
})
const {
form,
invoiceType,
invoiceFlag
} = toRefs(data)
watch(() => props.activity.invoiceFlag, (val) => {
if (val == '1') {
if (!form.value.invoiceType) {
form.value.invoiceType = _.orderBy(props.activity.invoiceType.split(','))[0]
}
}
}, {
immediate: true
})
watch(() => props.active, (val) => {
if (val == 2) {
uni.showLoading({
title:'加载中'
})
train.getTrainPersonalInfo(props.trainId).then(res => {
form.value = res.data || {}
if (res.data?.customInfo) {
form.value.customInfoObj = JSON.parse(res.data.customInfo)
} else {
form.value.customInfoObj = {}
}
uni.hideLoading()
})
}
})
function prev() {
emit('prev')
}
function next() {
// 判断必填
if(!form.value.unitName){
uni.showToast({
title: '请填写所在单位',
icon: 'none'
})
return
}
if(!form.value.unitRole){
uni.showToast({
title: '请填写职务信息',
icon: 'none'
})
return
}
form.value.activityId = props.trainId
form.value.customInfo = JSON.stringify(form.value.customInfoObj)
train.savePersonalInfo(form.value).then(() => {
uni.showToast({
title: '保存成功',
icon: 'none'
}).finally(res=>{
emit('next')
})
})
}
import {
onLoad
} from '@dcloudio/uni-app'
import {
ref,
reactive,
toRefs,
computed,
watch
} from 'vue'
import _ from 'lodash'
import * as train from '@/training/train.js'
const emit = defineEmits(['prev', 'next'])
const props = defineProps({
activity: {
type: Object,
default: () => {}
},
trainId: {
type: String,
default: () => {}
},
active: {
type: Number,
default: 0
}
})
const customInfo = computed(() => {
if (props.activity.customInfo) {
return JSON.parse(props.activity.customInfo).info
} else {
return []
}
})
const data = reactive({
form: {
invoiceFlag: '1',
customInfoObj: {}
},
invoiceFlag: [{
value: '0',
text: '否'
}, {
value: '1',
text: '是'
}],
invoiceType: [{
value: 0,
text: '电子票'
}, {
value: 1,
text: '纸质专票'
}, {
value: 2,
text: '纸质普票'
}]
})
const {
form,
invoiceType,
invoiceFlag
} = toRefs(data)
watch(() => props.activity.invoiceFlag, (val) => {
if (val == '1') {
if (!form.value.invoiceType) {
form.value.invoiceType = _.orderBy(props.activity.invoiceType.split(','))[0]
}
}
}, {
immediate: true
})
watch(() => props.active, (val) => {
if (val == 2) {
uni.showLoading({
title:'加载中'
})
train.getTrainPersonalInfo(props.trainId).then(res => {
form.value = res.data || {}
if (res.data?.customInfo) {
form.value.customInfoObj = JSON.parse(res.data.customInfo)
} else {
form.value.customInfoObj = {}
}
uni.hideLoading()
})
}
})
function prev() {
emit('prev')
}
function next() {
// 判断必填
if(!form.value.unitName){
uni.showToast({
title: '请填写所在单位',
icon: 'none'
})
return
}
if(!form.value.unitRole){
uni.showToast({
title: '请填写职务信息',
icon: 'none'
})
return
}
form.value.activityId = props.trainId
form.value.customInfo = JSON.stringify(form.value.customInfoObj)
train.savePersonalInfo(form.value).then(() => {
uni.showToast({
title: '保存成功',
icon: 'none'
}).finally(res=>{
emit('next')
})
})
}
</script>
<style scoped lang="scss">
......
<template>
<view>
<!-- 培训考试选择 -->
<view class="title-left-border">个人信息</view>
<view class="descriptionsBox">
<view class="flexRow">
<label>姓名:</label>{{ personal.name }}
</view>
<view class="flexRow">
<label>会员编号:</label>{{ personal.perCode }}
</view>
<view class="flexRow">
<label>有效期:</label>{{ personal.validityDate?.slice(0,10) }}
</view>
<view class="flexRow">
<label>段位:</label>{{ (personal.levelDuan && personal.levelDuan!=0)? (szToHz(personal.levelDuan)+'段/品') :'--' }}
</view>
<view class="flexRow">
<label>教练员等级:</label>{{ personal.coachLabel?.name||'--'}}
</view>
<view class="flexRow">
<label>裁判员等级:</label>{{ personal.refereeLabel?.name||'--'}}
</view>
<view class="flexRow">
<label>晋级官等级:</label>{{ personal.examinerJiLabel?.name||'--'}}
</view>
<view class="flexRow">
<label>晋段官等级:</label>{{ personal.examinerDuanLabel?.name||'--'}}
</view>
</view>
<view class="title-left-border">培训科目</view>
<view>
<view v-for="t in trainList" @click="changeTrainIds(t)" :key="t.id"
:class="t.required || t.disabled?'disabled kkitem':'kkitem'">
<view class="checkarea">
<uni-icons v-if="t.required||t.checked" color="#C5161E" type="checkbox-filled"
size="30"></uni-icons>
<uni-icons v-else type="circle" size="30"></uni-icons>
</view>
<view class="content">
<view class="name">{{ t.name }}
<view>
<text class="text-danger">{{ t.price }}</text>人/次
</view>
</view>
<view class="date">
<text>报名限制条件:</text>
<text v-if="signRules[t.twoSubjectId]?.openFlag">
<text>等级</text><text>{{ signRules[t.twoSubjectId]?.name }}</text>
<text>段位</text><text>{{ signRules[t.twoSubjectId]?.duanStr }}</text>
<text>年限</text><text>{{ signRules[t.twoSubjectId]?.limitStr }}</text>
</text>
<text v-else>
--
</text>
</view>
</view>
</view>
</view>
<view class="title-left-border">考试科目</view>
<view>
<view v-for="t in examList" @click="changeExamIds(t)" :key="t.id"
:class="(t.required || t.disabled|| !t.passRelate)?'disabled kkitem':'kkitem'">
<view class="checkarea">
<uni-icons v-if="t.required||t.checked" color="#C5161E" type="checkbox-filled"
size="30"></uni-icons>
<uni-icons v-else type="circle" size="30"></uni-icons>
</view>
<view class="content">
<view class="name">{{ t.name }}
<view>
<text class="text-danger">{{ t.price }}</text>人/次
</view>
</view>
<view class="date">
<text>报名限制条件:</text>
<text v-if="signRules[t.twoSubjectId]?.openFlag">
<text>等级</text><text>{{ signRules[t.twoSubjectId]?.name }}</text>
<text>段位</text><text>{{ signRules[t.twoSubjectId]?.duanStr }}</text>
<text>年限</text><text>{{ signRules[t.twoSubjectId]?.limitStr }}</text>
</text>
<text v-else>
--
</text>
</view>
</view>
</view>
</view>
</view>
<view class="fixedBottom">
<button class="btn btn-red-kx" @click="prev">上一步</button>
<button class="btn btn-red" @click="submitForm">提交审核</button>
</view>
<view>
<!-- 培训考试选择 -->
<view class="title-left-border">个人信息</view>
<view class="descriptionsBox">
<view class="flexRow">
<label>姓名:</label>{{ personal.name }}
</view>
<view class="flexRow">
<label>会员编号:</label>{{ personal.perCode }}
</view>
<view class="flexRow">
<label>有效期:</label>{{ personal.validityDate?.slice(0,10) }}
</view>
<view class="flexRow">
<label>段位:</label>{{ (personal.levelDuan && personal.levelDuan!=0)? (szToHz(personal.levelDuan)+'段/品') :'--' }}
</view>
<view class="flexRow">
<label>教练员等级:</label>{{ personal.coachLabel?.name||'--'}}
</view>
<view class="flexRow">
<label>裁判员等级:</label>{{ personal.refereeLabel?.name||'--'}}
</view>
<view class="flexRow">
<label>晋级官等级:</label>{{ personal.examinerJiLabel?.name||'--'}}
</view>
<view class="flexRow">
<label>晋段官等级:</label>{{ personal.examinerDuanLabel?.name||'--'}}
</view>
</view>
<view class="title-left-border">培训科目</view>
<view>
<view v-for="t in trainList" @click="changeTrainIds(t)" :key="t.id"
:class="t.required || t.disabled?'disabled kkitem':'kkitem'">
<view class="checkarea">
<uni-icons v-if="t.required||t.checked" color="#C5161E" type="checkbox-filled"
size="30"></uni-icons>
<uni-icons v-else type="circle" size="30"></uni-icons>
</view>
<view class="content">
<view class="name">{{ t.name }}
<view>
<text class="text-danger">{{ t.price }}</text>人/次
</view>
</view>
<view class="date">
<text>报名限制条件:</text>
<text v-if="openFlag && signRules[t.twoSubjectId]">
<text v-if="t.subjectType=='0'">
<text>等级</text><text>{{ signRules[t.twoSubjectId]?.name }}</text>
<text>段位</text><text>{{ signRules[t.twoSubjectId]?.duanStr }}</text>
<text>年限</text><text>{{ signRules[t.twoSubjectId]?.limitStr }}</text>
</text>
<text v-else>
<text>等级</text><text>{{ signRules2[t.twoSubjectId]?.name }}</text>
</text>
</text>
<text v-else>
--
</text>
</view>
</view>
</view>
</view>
<view class="title-left-border">考试科目</view>
<view>
<view v-for="t in examList" @click="changeExamIds(t)" :key="t.id"
:class="(t.required || t.disabled|| !t.passRelate)?'disabled kkitem':'kkitem'">
<view class="checkarea">
<uni-icons v-if="t.required||t.checked" color="#C5161E" type="checkbox-filled"
size="30"></uni-icons>
<uni-icons v-else type="circle" size="30"></uni-icons>
</view>
<view class="content">
<view class="name">{{ t.name }}
<view>
<text class="text-danger">{{ t.price }}</text>人/次
</view>
</view>
<view class="date">
<text>报名限制条件:</text>
<text v-if="openFlag && signRules[t.twoSubjectId]">
<text v-if="t.subjectType=='0'">
<text>等级</text><text>{{ signRules[t.twoSubjectId]?.name }}</text>
<text>段位</text><text>{{ signRules[t.twoSubjectId]?.duanStr }}</text>
<text>年限</text><text>{{ signRules[t.twoSubjectId]?.limitStr }}</text>
</text>
<text v-else>
<text>等级</text><text>{{ signRules2[t.twoSubjectId]?.name }}</text>
</text>
</text>
<text v-else>
--
</text>
</view>
</view>
</view>
</view>
</view>
<view class="fixedBottom">
<button class="btn btn-red-kx" @click="prev">上一步</button>
<button class="btn btn-red" @click="submitForm">提交审核</button>
</view>
<!-- 线下支付 -->
<uni-popup ref="bankShow" type="bottom" background-color="#fff">
<view class="popupBody">
<view class="title">线下支付</view>
<view @click="copyPlat">
<view class="flexRow">
<label>单位名称</label>
<view>{{ bankInfo.name}}</view>
</view>
<view class="flexRow">
<label>开户行</label>
<view>{{bankInfo.bank}}</view>
</view>
<view class="flexRow">
<label>账户</label>
<view>{{ bankInfo.account }}</view>
</view>
<view class="flexRow">
<label>打款金额</label>
<view>{{totalAmount}}</view>
</view>
</view>
<button class="btn btn-red" @click="sure">确定</button>
</view>
</uni-popup>
<!-- 线下支付 -->
<uni-popup ref="bankShow" type="bottom" background-color="#fff">
<view class="popupBody">
<view class="title">线下支付</view>
<view @click="copyPlat">
<view class="flexRow">
<label>单位名称</label>
<view>{{ bankInfo.name}}</view>
</view>
<view class="flexRow">
<label>开户行</label>
<view>{{bankInfo.bank}}</view>
</view>
<view class="flexRow">
<label>账户</label>
<view>{{ bankInfo.account }}</view>
</view>
<view class="flexRow">
<label>打款金额</label>
<view>{{totalAmount}}</view>
</view>
</view>
<button class="btn btn-red" @click="sure">确定</button>
</view>
</uni-popup>
</template>
<script setup>
import {
onLoad
} from '@dcloudio/uni-app'
import _ from 'lodash'
import {
ref,
reactive,
toRefs,
computed,
watch
} from 'vue'
import * as train from '@/training/train.js'
import {
onLoad
} from '@dcloudio/uni-app'
import _ from 'lodash'
import {
ref,
reactive,
toRefs,
computed,
watch,
onMounted
} from 'vue'
import * as train from '@/training/train.js'
import trainListVue from '../trainList.vue';
const data = reactive({
form: {
trainIds: [],
examIds: []
},
signRules: {},
bankShow: null,
totalAmount: null
})
const {
form,
signRules,
bankShow,
totalAmount
} = toRefs(data)
const emit = defineEmits(['prev', 'publish'])
const props = defineProps({
activity: {
type: Object,
default: () => {}
},
personal: {
type: Object,
default: () => {}
},
examList: {
type: Array,
default: () => []
},
trainList: {
type: Array,
default: () => []
},
trainId: {
type: String,
default: () => {}
}
})
const bankInfo = computed(() => {
if (props.activity.receivingInfo) {
return JSON.parse(props.activity.receivingInfo)
} else {
return {}
}
})
onLoad(options => {
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
l.checked = 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() {
console.log(form.value)
if (form.value.trainIds.length == 0) {
uni.showToast({
title: '请选择培训科目',
icon: 'none'
})
return
}
if (_.some(form.value.trainIds, (id) => {
const train = _.find(props.trainList, (t) => t.id == id)
return train.disabled
})) {
uni.showToast({
title: '选中了不满足报名条件的培训科目',
icon: 'none'
})
return
}
if (_.some(form.value.examIds, (id) => {
const exam = _.find(props.examList, (t) => t.id == id)
return exam.disabled || !exam.passRelate
})) {
uni.showToast({
title: '选中了不满足报名条件的考试科目',
icon: 'none'
})
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)
if(totalAmount.value > 0){
bankShow.value.open()
} else {
sure()
}
}
function sure() {
form.value.activityId = props.trainId
train.commitSign(form.value).then(() => {
uni.showToast({
title: '提交成功,等待审核',
icon: 'none'
})
emit('publish')
})
}
function prev() {
emit('prev')
}
function szToHz(num) {
const hzArr = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']
return hzArr[parseInt(num)]
}
function changeTrainIds(item) {
if(item.disabled||item.required){
return
}
if(item.checked){
item.checked = false
if(form.value.trainIds.indexOf(item.id)>-1){
_.pull(form.value.trainIds, item.id)
}
} else {
item.checked = true
form.value.trainIds.push(item.id)
console.log(form.value.trainIds)
}
}
function changeExamIds(item) {
if(item.disabled||item.required){
return
}
if(item.checked){
item.checked = false
if(form.value.examIds.indexOf(item.id)>-1){
_.pull(form.value.examIds, item.id)
}
} else {
item.checked = true
form.value.examIds.push(item.id)
console.log(form.value.examIds)
}
}
function copyPlat(){
let str = `单位名称:${bankInfo.value.name};开户行:${bankInfo.value.bank};账户:${bankInfo.value.account};打款金额:${totalAmount.value};`;
uni.setClipboardData({
data: str,
success: function() {
uni.showToast({
title: '已复制',
icon: 'none'
})
}
});
}
const data = reactive({
form: {
trainIds: [],
examIds: []
},
signRules: {}, // 晋级
signRules2: {}, // 复训
bankShow: null,
totalAmount: null,
openFlag:false
})
const {
form,
signRules,
signRules2,
bankShow,
totalAmount,
openFlag
} = toRefs(data)
const emit = defineEmits(['prev', 'publish'])
const props = defineProps({
activity: {
type: Object,
default: () => {}
},
personal: {
type: Object,
default: () => {}
},
examList: {
type: Array,
default: () => []
},
trainList: {
type: Array,
default: () => []
},
trainId: {
type: String,
default: () => {}
},
active: {
type: Number,
default: 0
}
})
const bankInfo = computed(() => {
if (props.activity.receivingInfo) {
return JSON.parse(props.activity.receivingInfo)
} else {
return {}
}
})
watch(() => props.active, (val) => {
if (val == 3) {
uni.showLoading({
title:'加载中'
})
getRules().then(()=>{
uni.hideLoading()
})
}
})
function getRules() {
return train.getAllRules(props.trainId).then((res) => {
openFlag.value = res.data.openFlag
_.each(res.data.rules, (r) => {
// 晋级
if (r.subjectType == '0') {
_.each(r.list, (l) => {
signRules.value[l.id] = l
})
}
// 复训
else {
_.each(r.list, (l) => {
signRules2.value[l.id] = l
})
}
})
})
}
watch([() => {
return Object.keys(signRules.value).length || Object.keys(signRules2.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) => {
l.required = false
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 (openFlag.value) {
let rule, currLevel, currYear, currDuan
l.disabled = false
// 晋级
if (l.subjectType == '0') {
if (l.twoSubjectId && signRules.value[l.twoSubjectId.toString()]) {
rule = signRules.value[l.twoSubjectId]
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
case 500:// 培训讲师
if (!(currDuan >= parseInt(rule.duan))) {
l.disabled = true
}
break
}
}
}
// 复训
else {
if (l.twoSubjectId && signRules2.value[l.twoSubjectId.toString()]) {
rule = signRules2.value[l.twoSubjectId]
switch (l.parentSubjectId) {
case 100:// 教练
currLevel = parseInt(props.personal.coachLabel?.type || 0)
break
case 200:// 裁判
currLevel = parseInt(props.personal.refereeLabel?.type || 0)
break
case 300:// 晋级
currLevel = parseInt(props.personal.examinerJiLabel?.type || 0)
break
case 400:// 晋段
currLevel = parseInt(props.personal.examinerDuanLabel?.type || 0)
break
case 500:// 培训讲师
currLevel = parseInt(props.personal.lecturerLabel?.type || 0)
break
}
if (currLevel < parseInt(rule.type)) {
l.disabled = true
}
}
}
}
})
}
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) {
uni.showToast({
title: '请选择培训科目',
icon: 'none'
})
return
}
if (_.some(form.value.trainIds, (id) => {
const train = _.find(props.trainList, (t) => t.id == id)
return train.disabled
})) {
uni.showToast({
title: '选中了不满足报名条件的培训科目',
icon: 'none'
})
return
}
if (_.some(form.value.examIds, (id) => {
const exam = _.find(props.examList, (t) => t.id == id)
return exam.disabled || !exam.passRelate
})) {
uni.showToast({
title: '选中了不满足报名条件的考试科目',
icon: 'none'
})
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)
if(totalAmount.value > 0){
bankShow.value.open()
} else {
sure()
}
}
function sure() {
form.value.activityId = props.trainId
train.commitSign(form.value).then(() => {
uni.showToast({
title: '提交成功,等待审核',
icon: 'none'
}).then(()=>{
setTimeout(()=>{
emit('publish')
},1000)
})
})
}
function prev() {
emit('prev')
}
function szToHz(num) {
const hzArr = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']
return hzArr[parseInt(num)]
}
function changeTrainIds(item) {
if(item.disabled||item.required){
return
}
if(item.checked){
item.checked = false
if(form.value.trainIds.indexOf(item.id)>-1){
_.pull(form.value.trainIds, item.id)
}
} else {
item.checked = true
form.value.trainIds.push(item.id)
console.log(form.value.trainIds)
}
}
function changeExamIds(item) {
if(item.disabled||item.required){
return
}
if(item.checked){
item.checked = false
if(form.value.examIds.indexOf(item.id)>-1){
_.pull(form.value.examIds, item.id)
}
} else {
item.checked = true
form.value.examIds.push(item.id)
console.log(form.value.examIds)
}
}
function copyPlat(){
let str = `单位名称:${bankInfo.value.name};开户行:${bankInfo.value.bank};账户:${bankInfo.value.account};打款金额:${totalAmount.value};`;
uni.setClipboardData({
data: str,
success: function() {
uni.showToast({
title: '已复制',
icon: 'none'
})
}
});
}
</script>
......
......@@ -2,20 +2,20 @@ import request from '@/common/request.js'
import config from '@/config.js'
// 获取培训列表
export function getTrainList(params) {
return request({
url: `${config.trainUrl_api}/webPc/getTrains`,
method: 'get',
params: params
})
return request({
url: `${config.trainUrl_api}/webPc/getTrains`,
method: 'get',
params: params
})
}
// 查看培训项目
export function getTrainDetail(id) {
return request({
url: `${config.trainUrl_api}/webPc/getTrainDetails`,
method: 'get',
params: {id}
})
return request({
url: `${config.trainUrl_api}/webPc/getTrainDetails`,
method: 'get',
params: { id }
})
}
export function getPersonalInfo() {
return request({
......@@ -89,4 +89,13 @@ export function commitSign(data) {
method: 'put',
params: data
})
}
\ No newline at end of file
}
export function getAllRules(id) {
return request({
url: `${config.trainUrl_api}/train/activity/getAllRules`,
method: 'get',
params: { id }
})
}
......
<template>
<view class="pd20">
<uni-steps :options="steps" active-icon="checkmarkempty" :active="active" />
</view>
<view class="hasfixedbottom">
<view class="wpage">
<step1 v-show="active==0" @prev="prev" @next="next" :activity="activity" />
<step2 v-show="active==1" @prev="prev" @next="next" :personal="personal" />
<step3 v-show="active==2" @prev="prev" @next="next" :activity="activity" :trainId="trainId"
:active="active" />
<step4 v-show="active==3" @prev="prev" @publish="publish" :personal="personal" :activity="activity"
:exam-list="examList" :train-list="trainList" :trainId="trainId"/>
</view>
</view>
<view class="pd20">
<uni-steps :options="steps" active-icon="checkmarkempty" :active="active" />
</view>
<view class="hasfixedbottom">
<view class="wpage">
<step1 v-show="active==0" @prev="prev" @next="next" :activity="activity" />
<step2 v-show="active==1" @prev="prev" @next="next" :personal="personal" />
<step3 v-show="active==2" @prev="prev" @next="next" :activity="activity" :trainId="trainId"
:active="active" />
<step4 v-show="active==3" @prev="prev" @publish="publish" :personal="personal" :activity="activity"
:exam-list="examList" :train-list="trainList" :trainId="trainId" :active="active"/>
</view>
</view>
</template>
<script setup>
import {
onLoad
} from '@dcloudio/uni-app'
import {
ref,
reactive,
toRefs
} from 'vue'
import * as train from '@/training/train.js'
import step1 from '@/training/components/step1'
import step2 from '@/training/components/step2'
import step3 from '@/training/components/step3'
import step4 from '@/training/components/step4'
const active = ref(0)
import {
onLoad
} from '@dcloudio/uni-app'
import {
ref,
reactive,
toRefs
} from 'vue'
import * as train from '@/training/train.js'
import step1 from '@/training/components/step1'
import step2 from '@/training/components/step2'
import step3 from '@/training/components/step3'
import step4 from '@/training/components/step4'
const active = ref(0)
const steps = ref([{
title: '报名须知'
}, {
title: '个人信息完善'
}, {
title: '培训信息完善'
}, {
title: '培训考试选择'
}])
const steps = ref([{
title: '报名须知'
}, {
title: '个人信息完善'
}, {
title: '培训信息完善'
}, {
title: '培训考试选择'
}])
const data = reactive({
activity: {},
examList: [],
trainList: [],
personal: {},
trainId: ''
})
const {
activity,
examList,
trainList,
personal,
trainId
} = toRefs(data)
onLoad(options => {
active.value = options.step || 0
trainId.value = options.id
train.getTrainDetail(trainId.value).then((res) => {
activity.value = res.data.activity
examList.value = res.data.examVoList
trainList.value = res.data.subjectTrainList
const data = reactive({
activity: {},
examList: [],
trainList: [],
personal: {},
trainId: ''
})
const {
activity,
examList,
trainList,
personal,
trainId
} = toRefs(data)
onLoad(options => {
active.value = options.step || 0
trainId.value = options.id
train.getTrainDetail(trainId.value).then((res) => {
activity.value = res.data.activity
examList.value = res.data.examVoList
trainList.value = res.data.subjectTrainList
if (activity.value.signNoticeAttachment) {
activity.value.signNoticeAttachment = JSON.parse(activity.value.signNoticeAttachment)[0]
}
})
if (activity.value.signNoticeAttachment) {
activity.value.signNoticeAttachment = JSON.parse(activity.value.signNoticeAttachment)[0]
}
})
train.getPersonalInfo().then((res) => {
personal.value = res.data || {}
})
})
train.getPersonalInfo().then((res) => {
personal.value = res.data || {}
})
})
function next() {
active.value++
}
function next() {
active.value++
}
function prev() {
active.value--
}
function prev() {
active.value--
}
function publish() {
uni.redirectTo({
url: `/training/trainList`
});
}
function publish() {
uni.redirectTo({
url: `/training/trainList`
});
}
</script>
<style scoped lang="scss">
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!