Procházet zdrojové kódy

fix:修改筛选部分

seamwang před 2 roky
rodič
revize
9a69fcfe77
2 změnil soubory, kde provedl 144 přidání a 95 odebrání
  1. 58 11
      src/pages/index/index.vue
  2. 86 84
      src/pages/studentcenter/absent.vue

+ 58 - 11
src/pages/index/index.vue

@@ -63,29 +63,53 @@
63 63
         :style="[{top:topHeader+'px',height:'calc(100vh - ' + topHeader + 'px)'}]">
64 64
 					<view class="filter-title">机构筛选</view>
65 65
 				  <view class="btn-check-group padding-lr">
66
-						<checkbox-group @change="checkboxChange" class="flex" style="flex-wrap: wrap;" id="agency">
66
+						<!-- <checkbox-group @change="checkboxChange" class="flex" style="flex-wrap: wrap;" id="agency">
67 67
 							<label class="btn-check-label margin-top-sm padding-lr-xs text-sm text-ellipsis" :class="{'bg-cyan':params.agency.includes(item.id+'')}"
68 68
 								v-for="item in filters.agency" :key="item.id">
69 69
 								<checkbox :value="item.id"/>
70 70
 								{{item.name}}
71 71
 							</label>
72
-						</checkbox-group>
72
+						</checkbox-group> -->
73
+						<radio-group  class="flex" style="flex-wrap: wrap;" id="agency">
74
+								<label class="btn-check-label margin-top-sm padding-lr-xs text-sm text-ellipsis" :class="{'bg-cyan':params.agency.includes(item.id)}"
75
+									v-for="item in filters.agency" :key="item.id" @tap="radioChange('agency',item.id)">
76
+									<radio :value="item.id"/>
77
+									{{item.name}}
78
+								</label>
79
+						</radio-group>
80
+        	</view>
81
+					<view class="filter-title">分类筛选</view>
82
+					<view class="btn-check-group padding-lr">
83
+						<radio-group  class="flex" style="flex-wrap: wrap;" id="category">
84
+								<label class="btn-check-label margin-top-sm padding-lr-xs text-sm text-ellipsis" :class="{'bg-cyan':params.category.includes(item.id)}"
85
+									v-for="item in filters.category" :key="item.id" @tap="radioChange('category',item.id)">
86
+									<radio :value="item.id"/>
87
+									{{item.name}}
88
+								</label>
89
+						</radio-group>
73 90
         	</view>
74 91
 					<view class="filter-title">周期筛选</view>
75 92
 					<view class="btn-check-group padding-lr">
76
-						<checkbox-group @change="checkboxChange" class="flex" style="flex-wrap: wrap;" id="day">
93
+						<!-- <checkbox-group @change="checkboxChange" class="flex" style="flex-wrap: wrap;" id="day">
77 94
 							<label class="btn-check-label margin-top-sm padding-lr-xs text-sm" :class="{'bg-cyan':params.day.includes(index+'')}"
78 95
 								v-for="(item,index) in filters.week" :key="index">
79 96
 								<checkbox :value="index"/>
80 97
 								{{item}}
81 98
 							</label>
82
-						</checkbox-group>
99
+						</checkbox-group> -->
100
+						<radio-group  class="flex" style="flex-wrap: wrap;" id="day">
101
+								<label class="btn-check-label margin-top-sm padding-lr-xs text-sm" :class="{'bg-cyan':params.day.includes(index+'')}"
102
+									v-for="(item,index) in filters.week" :key="index" @tap="radioChange('day',index)">
103
+									<radio :value="index"/>
104
+									{{item}}
105
+								</label>
106
+						</radio-group>
83 107
         	</view>
84 108
 					<view class="filter-title">价格区间(元)</view>
85 109
 					<view class="btn-check-group padding-lr">
86 110
 						<radio-group  class="flex" style="flex-wrap: wrap;" id="price">
87 111
 							<label class="btn-check-label margin-top-sm padding-lr-xs text-sm" :class="{'bg-cyan':params.price===item.name}"
88
-								 v-for="item in filters.price_list" :key="item.id" @tap="radioChange(item.name)">
112
+								 v-for="item in filters.price_list" :key="item.id" @tap="radioChange('price',item.name)">
89 113
 								<radio :value="item.name"/>
90 114
 								{{item.name}}
91 115
 							</label>
@@ -105,6 +129,7 @@ import course from './components/course.vue'
105 129
 import card from './components/card.vue'
106 130
 import { _optionCourse, _filter } from '@/api/course'
107 131
 import { filterParams } from '@/common/utils/tool'
132
+import { deepClone } from '@/common/utils'
108 133
 import { mapGetters } from 'vuex'
109 134
 export default {
110 135
   components: {
@@ -160,6 +185,7 @@ export default {
160 185
         course_name: '',
161 186
         agency: [],
162 187
         day: [],
188
+        category: [],
163 189
         price: '',
164 190
         sort: '',
165 191
         list_type: 0// 0 课程,1 餐饮,2活动
@@ -169,6 +195,7 @@ export default {
169 195
         course_name: '',
170 196
         agency: [],
171 197
         day: [],
198
+        category: [],
172 199
         price: '',
173 200
         sort: '',
174 201
         list_type: 0// 0 课程,1 餐饮,2活动
@@ -232,11 +259,22 @@ export default {
232 259
     hideModal (e) {
233 260
       this.modalName = null
234 261
     },
235
-    radioChange(v) {
236
-      if (this.params.price === v) { // 选中取消
237
-        this.params.price = null
238
-      } else { // 空则赋值
239
-        this.params.price = v
262
+    radioChange(type, v) {
263
+      switch (type) {
264
+        case 'agency':
265
+          this.params.agency = this.params.agency[0] === v ? [] : [v]
266
+          break
267
+        case 'day':
268
+          this.params.day = this.params.day[0] === v ? [] : [v]
269
+          break
270
+        case 'category':
271
+          this.params.category = this.params.category[0] === v ? [] : [v]
272
+          break
273
+        case 'price':
274
+          this.params.price = this.params.price === v ? null : v
275
+          break
276
+        default:
277
+          console.log('error')
240 278
       }
241 279
     },
242 280
     checkboxChange(e) {
@@ -301,13 +339,22 @@ export default {
301 339
       this.get_list()
302 340
     },
303 341
     get_list(init = false) {
304
-      let params = Object.assign({}, this.params)
342
+      let params = deepClone(this.params)
305 343
       params = filterParams(params)
306 344
       if (params.day.length > 0) {
307 345
         params.day = JSON.stringify(params.day)
346
+      } else {
347
+        delete params.day
308 348
       }
309 349
       if (params.agency.length > 0) {
310 350
         params.agency = JSON.stringify(params.agency)
351
+      } else {
352
+        delete params.agency
353
+      }
354
+      if (params.category.length > 0) {
355
+        params.category = JSON.stringify(params.category)
356
+      } else {
357
+        delete params.category
311 358
       }
312 359
       _optionCourse(params).then(res => {
313 360
         if (params.page_num > 1) {

+ 86 - 84
src/pages/studentcenter/absent.vue

@@ -1,84 +1,86 @@
1
-<template>
2
-	<view class="page">
3
-		<cu-custom :isBack="true" title="请假"></cu-custom>
4
-		<form>
5
-			<view class="cu-form-group">
6
-				<view class="title">请假类型</view>
7
-				<picker @change="changeType" :value="index" :range="types" range-key="name">
8
-					<view class="picker">
9
-						{{index>-1? types[index].name:'请选择请假类型'}}
10
-					</view>
11
-				</picker>
12
-			</view>
13
-			<view class="cu-form-group align-start">
14
-				<view class="title">请假理由</view>
15
-				<textarea maxlength="-1"  placeholder="请输入请假理由" v-model="params.reason"></textarea>
16
-			</view>
17
-		</form>
18
-		<view class="solids-bottom bg-white text-center padding text-student margin-top" @tap="apply">
19
-        提交申请
20
-    </view>
21
-	</view>
22
-</template>
23
-
24
-<script>
25
-import { _leaveType, _askLeave } from '@/api/course'
26
-import validate from '@/common/utils/ys-validate'
27
-export default {
28
-  data() {
29
-    return {
30
-      key: 1212,
31
-      index: -1,
32
-      types: [],
33
-      params: {
34
-        plan_id: '',
35
-        reason: '',
36
-        type_id: ''
37
-      },
38
-      rules: [
39
-        { name: 'reason', required: true, type: 'required', errmsg: '请输入请假理由' },
40
-        { name: 'type_id', required: true, type: 'required', errmsg: '请选择请假类型' }
41
-      ]
42
-    }
43
-  },
44
-  onLoad(options) {
45
-    const id = decodeURIComponent(options.id)
46
-    if (!id) uni.navigateBack()
47
-    this.params.plan_id = id
48
-    this.getTypes()
49
-  },
50
-  methods: {
51
-    getTypes() {
52
-      _leaveType().then(res => {
53
-        this.types = res.data.leave_type_data
54
-      })
55
-    },
56
-    changeType(e) {
57
-      this.index = e.detail.value
58
-      this.params.type_id = this.types[this.index].id
59
-    },
60
-    apply() {
61
-      const validRes = validate.validate(this.params, this.rules)
62
-      if (!validRes.isOk) {
63
-        uni.showToast({
64
-          icon: 'none',
65
-          title: validRes.errmsg
66
-        })
67
-        return false
68
-      }
69
-      _askLeave(this.params).then(res => {
70
-        uni.showToast({ title: '提交成功', icon: 'success' })
71
-        setTimeout(() => {
72
-          uni.navigateBack()
73
-        }, 800)
74
-      })
75
-    }
76
-  }
77
-}
78
-</script>
79
-
80
-<style lang="scss" scoped>
81
-.page{
82
-	height:100vh;
83
-}
84
-</style>
1
+<template>
2
+	<view class="page">
3
+		<cu-custom :isBack="true" title="请假"></cu-custom>
4
+		<form>
5
+			<view class="cu-form-group">
6
+				<view class="title">请假类型</view>
7
+				<picker @change="changeType" :value="index" :range="types" range-key="name">
8
+					<view class="picker">
9
+						{{index>-1? types[index].name:'请选择请假类型'}}
10
+					</view>
11
+				</picker>
12
+			</view>
13
+			<view class="cu-form-group align-start">
14
+				<view class="title">请假理由</view>
15
+				<textarea maxlength="-1"  placeholder="请输入请假理由" v-model="params.reason"></textarea>
16
+			</view>
17
+		</form>
18
+		<view class="solids-bottom bg-white text-center padding text-student margin-top" @tap="apply">
19
+        提交申请
20
+    </view>
21
+	</view>
22
+</template>
23
+
24
+<script>
25
+import { _leaveType, _askLeave } from '@/api/course'
26
+import validate from '@/common/utils/ys-validate'
27
+export default {
28
+  data() {
29
+    return {
30
+      key: 1212,
31
+      index: -1,
32
+      types: [],
33
+      params: {
34
+        plan_id: '',
35
+        reason: '',
36
+        type_id: ''
37
+      },
38
+      rules: [
39
+        { name: 'reason', required: true, type: 'required', errmsg: '请输入请假理由' },
40
+        { name: 'type_id', required: true, type: 'required', errmsg: '请选择请假类型' }
41
+      ]
42
+    }
43
+  },
44
+  onLoad(options) {
45
+    const id = decodeURIComponent(options.id)
46
+    if (!id) uni.navigateBack()
47
+    this.params.plan_id = id
48
+    this.getTypes()
49
+  },
50
+  methods: {
51
+    getTypes() {
52
+      _leaveType().then(res => {
53
+        this.types = res.data.leave_type_data
54
+      })
55
+    },
56
+    changeType(e) {
57
+      this.index = e.detail.value
58
+      this.params.type_id = this.types[this.index].id
59
+    },
60
+    apply() {
61
+      const validRes = validate.validate(this.params, this.rules)
62
+      if (!validRes.isOk) {
63
+        uni.showToast({
64
+          icon: 'none',
65
+          title: validRes.errmsg
66
+        })
67
+        return false
68
+      }
69
+      _askLeave(this.params).then(res => {
70
+        if (res.code === 1) {
71
+          uni.showToast({ title: '提交成功', icon: 'success' })
72
+        }
73
+        setTimeout(() => {
74
+          uni.navigateBack()
75
+        }, 2000)
76
+      })
77
+    }
78
+  }
79
+}
80
+</script>
81
+
82
+<style lang="scss" scoped>
83
+.page{
84
+	height:100vh;
85
+}
86
+</style>