123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- <template>
- <view class="content">
- <u-form :model="form" ref="form" label-width="140">
- <u-form-item label="班级种类" prop="className" required>
- <u-input v-model="form.className" placeholder="请选择班级种类" :select-open="classShow" type="select" @click="classShow = true" />
- </u-form-item>
- <u-form-item label="是否用券" prop="useLessonsName" required>
- <u-input v-model="form.useLessonsName" placeholder="是否用券" :select-open="lessonsShow" type="select" @click="lessonsShow = true" />
- </u-form-item>
- <u-form-item label="班级名称" prop="name" required>
- <u-input v-model="form.name" placeholder="请输入班级名称" />
- </u-form-item>
- <u-form-item label="培训方式" prop="classTypeInfo" required>
- <u-input v-model="form.classTypeInfo" placeholder="请选择培训方式" type="select" @click="trainShow = true" />
- </u-form-item>
- <u-form-item v-if="form.classTypeDesc == 5" label="其他方式" prop="otherType">
- <u-input v-model="form.otherType" placeholder="请填写其他方式" />
- </u-form-item>
- <u-form-item label="课程周期开始时间" prop="startDate" right-icon="arrow-right" required @click.native="startDateShow = true">
- <u-input v-model="form.startDate" placeholder="请选择课程周期开始时间" disabled @click="startDateShow = true" />
- </u-form-item>
- <u-form-item label="课程周期结束时间" prop="endDate" right-icon="arrow-right" required @click.native="endDateShow = true">
- <u-input v-model="form.endDate" placeholder="请选择课程周期结束时间" disabled @click="endDateShow = true" />
- </u-form-item>
- <u-form-item label="上课时间" prop="timeReqList" required label-position="top"></u-form-item>
- <u-swipe-action :index="index" v-for="(item, index) in form.timeReqList" :key="item.id" @click="deleteDate" :options="options">
- <u-form-item label=" " right-icon="arrow-right" @click.native="toSetDate(index)" label-width="0px">
- <text :style="{color: item.week ? '' :'#999999'}">{{item.week ? item.week + ' ' +item.startTime + ' ' +item.endTime : '请选择上课时间'}}</text>
- </u-form-item>
- </u-swipe-action>
- <u-form-item label=" " label-width="0px">
- <view style="display: flex; justify-content: space-around;">
- <u-button type="success" :ripple="true" size="medium" :custom-style="{backgroundColor: '#ff6e3e'}" @click="addDate">新增</u-button>
- </view>
- </u-form-item>
- <u-form-item label="归属场馆" prop="venueName" right-icon="arrow-right" required @click.native="venueShow = true">
- <u-input v-model="form.venueName" placeholder="请选择归属场馆" disabled @click="venueShow = true" />
- </u-form-item>
- <u-form-item label="地址">
- <u-input v-model="form.address" disabled placeholder="请输入地址" />
- </u-form-item>
- <u-form-item label="学生数量" prop="maxStudentCount" required>
- <u-input v-model="form.maxStudentCount" type="number" placeholder="请输入学生数量" />
- </u-form-item>
- </u-form>
- <u-popup v-model="classDate" mode="bottom" border-radius="30">
- <view class="dateForm">
- <u-form :model="selectForm" ref="selectForm" label-width="140">
- <u-form-item label="上课时间" prop="week" required>
- <u-radio-group v-model="selectForm.week">
- <u-radio v-for="(item, index) in weekList" :key="index" :name="item.name">
- {{ item.name }}
- </u-radio>
- </u-radio-group>
- </u-form-item>
- <u-form-item label="上课时间" prop="startTime" right-icon="arrow-right" required @click.native="()=>{startTimeShow = true;timeType = 1}">
- <u-input v-model="selectForm.startTime" placeholder="请选择上课时间" disabled @click="()=>{startTimeShow = true;timeType = 1}" />
- </u-form-item>
- <u-form-item label="下课时间" prop="endTime" right-icon="arrow-right" required @click.native="()=>{startTimeShow = true;timeType = 2}">
- <u-input v-model="selectForm.endTime" placeholder="请选择下课时间" disabled @click="()=>{startTimeShow = true;timeType = 2}" />
- </u-form-item>
- </u-form>
- <u-button type="warning" :ripple="true" :custom-style="{...customStyle, marginTop: '15px'}" @click="setDate()">确定</u-button>
- </view>
- </u-popup>
- <u-picker mode="time" v-model="startDateShow" :params="cycleParams" @confirm="setStartDate"></u-picker>
- <u-picker mode="time" v-model="endDateShow" :params="cycleParams" @confirm="setEndDate"></u-picker>
- <u-picker mode="time" v-model="startTimeShow" :params="startTimeParams" @confirm="setStartTime"></u-picker>
- <u-picker mode="selector" v-model="venueShow" :range="venueList" range-key="name" @confirm="setVenue"></u-picker>
- <!-- 班级种类 -->
- <u-action-sheet :list="classTypeList" v-model="classShow" @click="handleClassClick"></u-action-sheet>
- <!-- 体验班 -->
- <u-action-sheet :list="lessonsTypeList" v-model="lessonsShow" @click="handleLessonsClick"></u-action-sheet>
- <!-- 培训方式 -->
- <u-action-sheet :list="trainList" v-model="trainShow" @click="setTrain"></u-action-sheet>
- <view class="handle-fix-box">
- <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm">保存</u-button>
- </view>
- <u-top-tips ref="uTips"></u-top-tips>
- </view>
- </template>
- <script>
- import {
- mapGetters
- } from 'vuex'
- const NET = require('@/utils/request')
- const API = require('@/config/api')
- export default {
- computed: {
- ...mapGetters([
- 'mainColor',
- 'customStyle',
- ])
- },
- data() {
- return {
- form: {
- name: '',
- classType: 0,
- className: '',
- classTypeDesc: '',
- classTypeInfo: '',
- otherType: '',
- useLessonsType: 2,
- useLessonsName: '',
- startDate: '',
- endDate: '',
- address: '',
- venueId: '',
- venueName: '',
- address: '',
- maxStudentCount: '',
- timeReqList: [{
- week: '',
- startTime: '',
- endTime: '',
- }],
- },
- rules: {
- className: [
- {
- required: true,
- message: '请选择班级种类',
- trigger: 'change'
- }],
- useLessonsName: [
- {
- required: true,
- message: '请选择是否用券',
- trigger: 'change'
- }],
- name: [
- {
- required: true,
- message: '请输入班级名称',
- trigger: 'change'
- }],
- classTypeInfo: [
- {
- required: true,
- message: '请选择培训方式',
- trigger: 'change'
- }],
- startDate: [{
- required: true,
- message: '请选择课程周期开始时间',
- trigger: 'change'
- }],
- endDate: [{
- required: true,
- message: '请选择课程周期结束时间',
- trigger: 'change'
- }],
- timeReqList: [{
- type: 'array',
- required: true,
- message: '请选择上课时间',
- trigger: 'change'
- }],
- venueName: [{
- required: true,
- message: '请选择归属场馆',
- trigger: 'change'
- }],
- maxStudentCount: [{
- required: true,
- message: '请输入学生数量',
- trigger: 'change'
- }],
- },
- classShow: false,
- classTypeList: [
- {
- classType: 1,
- text: '篮球'
- },
- {
- classType: 2,
- text: '体能'
- }
- ],
- trainShow: false,
- trainList: [
- {
- id: 1,
- text: '一对一(或一对多)面授'
- },
- {
- id: 2,
- text: '大班额面授课'
- },
- {
- id: 3,
- text: '小班额面授课'
- },
- {
- id: 4,
- text: '本班开班不受最低人数限制'
- },
- {
- id: 5,
- text: '其他方式'
- },
- ],
- lessonsShow: false,
- lessonsTypeList: [
- {
- useLessonsType: 1,
- text: '是'
- },
- {
- useLessonsType: 2,
- text: '否'
- }
- ],
- selectIndex: 0,
- selectForm: {
- week: '',
- startTime: '',
- endTime: '',
- },
- classDate: false,
- weekList: [{
- name: '周一'
- },
- {
- name: '周二'
- },
- {
- name: '周三'
- },
- {
- name: '周四'
- },
- {
- name: '周五'
- },
- {
- name: '周六'
- },
- {
- name: '周日'
- },
- ],
- startDateShow: false,
- endDateShow: false,
- cycleParams: {
- year: true,
- month: true,
- day: true,
- hour: false,
- minute: false,
- second: false
- },
- startTimeShow: false,
- startTimeParams: {
- year: false,
- month: false,
- day: false,
- hour: true,
- minute: true,
- second: true
- },
- venueShow: false,
- venueList: [],
- options: [{
- text: '删除',
- style: {
- color: '#fa3534'
- }
- }]
- }
- },
- onLoad() {
- NET.request(API.getVenueList, {
- page: 1,
- size: 10000,
- }, 'POST').then(res => {
- this.venueList = res.data.row
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.message,
- type: 'warning',
- })
- })
- },
- onReady() {
- this.$refs.form.setRules(this.rules);
- },
- onShow() {},
- methods: {
- // 选择班级类别
- handleClassClick(index) {
- this.form.classType = this.classTypeList[index].classType
- this.form.className = this.classTypeList[index].text
- },
- // 选择培训方式
- setTrain(index) {
- this.form.classTypeDesc = this.trainList[index].id
- this.form.classTypeInfo = this.trainList[index].text
- if(this.trainList[index].id == 5) {
- this.form.otherType = ''
- }
- },
- // 是否为体验班(1是 2否)
- handleLessonsClick(index) {
- this.form.useLessonsType = this.lessonsTypeList[index].useLessonsType
- this.form.useLessonsName = this.lessonsTypeList[index].text
- },
- // 弹出设置时间
- toSetDate(index) {
- this.selectIndex = index
- this.selectForm = {
- week: this.form.timeReqList[index].week,
- startTime: this.form.timeReqList[index].startTime,
- endTime: this.form.timeReqList[index].endTime,
- }
- this.classDate = true
- },
- // 删除时间
- deleteDate(index, index1) {
- if (index1 == 0) {
- this.form.timeReqList.splice(index, 1);
- }
- },
- // 新增时间
- addDate() {
- this.form.timeReqList.push({
- week: '',
- startTime: '',
- endTime: '',
- })
- },
- // 设置课程周期开始时间
- setStartDate(date) {
- this.form.startDate = date.year + '-' + date.month + '-' + date.day
- },
- // 设置课程周期结束时间
- setEndDate(date) {
- this.form.endDate = date.year + '-' + date.month + '-' + date.day
- },
- // 设置上课时间
- setStartTime(date) {
- if (this.timeType == 1) {
- this.selectForm.startTime = date.hour + ':' + date.minute + ':' + date.second
- } else {
- this.selectForm.endTime = date.hour + ':' + date.minute + ':' + date.second
- }
- },
- // 设置上课时间
- setDate() {
- this.form.timeReqList[this.selectIndex] = {
- week: this.selectForm.week,
- startTime: this.selectForm.startTime,
- endTime: this.selectForm.endTime,
- }
- this.classDate = false
- },
- // 设置场馆
- setVenue(data) {
- this.form.venueId = this.venueList[data[0]].id
- this.form.venueName = this.venueList[data[0]].name
- this.form.address = this.venueList[data[0]].address
- },
- // 提交表单
- submitForm() {
- if(this.form.classTypeDesc == 5) {
- if(!this.form.otherType) {
- this.$refs.uTips.show({
- title: '请输入培训方式',
- type: 'warning',
- })
- return
- }
- }
- this.$refs.form.validate(valid => {
- if (valid) {
- NET.request(API.submitClassForm, {
- ...this.form, classTypeDesc : this.form.classTypeDesc == 5 ? this.form.otherType : this.form.classTypeDesc
- }, 'POST').then(res => {
- uni.removeStorageSync({
- key: 'extraLessonsUserList'
- })
- this.$refs.uTips.show({
- title: '提交成功',
- type: 'success',
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 1000)
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.message,
- type: 'warning',
- })
- })
- }
- });
- },
- },
- }
- </script>
- <style>
- page {
- width: 100%;
- height: 100%;
- position: relative;
- }
- </style>
- <style lang="scss" scoped>
- @import "@/static/css/themes.scss";
- .content {
- width: 100%;
- float: left;
- padding: 0 15px 60px 15px;
- box-sizing: border-box;
- .dateForm {
- padding: 20px;
- }
- }
- </style>
|