123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <view class="add">
- <u-navbar title="添加排班" :background="background" :border-bottom='false'></u-navbar>
- <view class="form">
- <view class="item">
- <view class="label">
- 排班日期
- </view>
- <view class="right">
- {{details.day}}
- </view>
- </view>
- <view class="item" v-if="details.time_id!=0">
- <view class="label">
- 排班时间
- </view>
- <view class="right">
- {{details.start_time}}--{{details.end_time}}
- </view>
- </view>
- <view class="item" v-if="details.time_id==0">
- <view class="label">
- 排班时间
- </view>
- <view class="right">
- <picker mode="selector" :range="time_set" :value="index"
- :range-key="'range'" @change="bindTimeChange">
- <view class="uni-input">{{index ? time_set[index].range : '请选择时间段'}}</view>
- </picker>
- </view>
- </view>
- <view class="save" @click="add">
- 确认添加
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- background: 'rgba(255,255,255,0)',
- details: '',
- time_set: '', //时间段
- index: '',
-
- }
- },
- onLoad(options) {
- if(this.is_weixin()){
- this.navTitle()
- }
- this.details = options
- this.getTimeSet()
- },
- methods: {
- //判断是否是微信
- is_weixin() {
- let ua = navigator.userAgent.toLowerCase();
- return ua.indexOf('micromessenger') != -1;
- },
- navTitle() {
- let navTitle = document.getElementsByTagName('uni-page-head');
- navTitle[0].style.display = 'none'
- },
- //选择时间段
- bindTimeChange(e) {
- let index = e.detail.value
- console.log(e.detail.value, '-------------')
- this.index = index
- this.details.time_id = this.time_set[index].id
- this.details.start_time=this.time_set[index].start_time
- this.details.end_time=this.time_set[index].end_time
- console.log(this.range,'++++++++++++++++++++++')
- },
- //时间段配置
- getTimeSet() {
- this.$u.get('/mentor/time').then(res => {
- console.log(res, '--------')
- let list = res.data.list
- list.map(item => {
- item.range = item.start_time + '-' + item.end_time
- })
- this.time_set = list
- })
- },
- //添加
- add() {
- let data = {
- status: 1,
- teacher_id: this.$store.state.vuex_user.type_id,
- day: this.details.day,
- time_ids: this.details.time_id
- }
- this.$u.post('/mentor/scheduling', data).then(res => {
- console.log(res, '添加排班')
- if (res.code == 200) {
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- setTimeout(function() {
- uni.navigateBack()
- }, 2000);
- } else {
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .add {
- height: 100%;
- background-image: url(../../static/images/add-bg.png);
- background-size: 100%;
- background-repeat: no-repeat;
- .form {
- margin: 0 28px;
- // background-color: #18B566;
- margin-top: 190px;
- .item {
- padding: 18px 20px;
- background-color: rgba(237, 244, 228, 1);
- opacity: 1;
- border-radius: 8px;
- display: flex;
- align-items: center;
- margin-bottom: 15px;
- .label {
- font-size: 16px;
- font-family: PingFang SC;
- font-weight: bold;
- line-height: 20px;
- color: #282828;
- opacity: 1;
- }
- .right {
- text-align: right;
- flex: 1;
- font-size: 12px;
- font-family: PingFang SC;
- font-weight: 400;
- line-height: 20px;
- color: #282828;
- opacity: 0.42;
- .no {
- font-size: 12px;
- font-family: PingFang SC;
- font-weight: 400;
- line-height: 20px;
- color: #282828;
- opacity: 0.42;
- }
- }
- }
- .save {
- height: 56px;
- background: #3B7653;
- opacity: 1;
- border-radius: 8px;
- line-height: 56px;
- text-align: center;
- font-size: 18px;
- margin-top: 63px;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- opacity: 1;
- }
- }
- }
- </style>
|