Bladeren bron

Merge branch 'master' into dev_seam_intelligent

seamwang 1 jaar geleden
bovenliggende
commit
859fa17ff8

+ 13 - 1
src/api/course.js

@@ -112,7 +112,7 @@ export function _commentDetail (params) {
112 112
 export function _leaveType (params) {
113 113
 	return fetch('/teacher/leave/get_leave_type', params)
114 114
 }
115
-// 申请请假 parents/schedule/student_leave
115
+// 申请请假
116 116
 export function _askLeave (params) {
117 117
 	return fetch('/parents/schedule/student_leave', params)
118 118
 }
@@ -120,3 +120,15 @@ export function _askLeave (params) {
120 120
 export function _getStudentFiles (params) {
121 121
 	return fetch('/parents/courseFiles/get_list', params)
122 122
 }
123
+//获取年级
124
+export function _getGrades () {
125
+	return fetch('/parents/init/get_grades')
126
+}
127
+//获取班级
128
+export function _getClasses (params) {
129
+	return fetch('/parents/init/get_classes', params)
130
+}
131
+//修改信息
132
+export function _fixStudent (params) {
133
+	return fetch('/parents/init/edit_student', params)
134
+}

+ 52 - 48
src/common/utils/fetch.js

@@ -2,52 +2,56 @@ import store from '@/store/index'
2 2
 
3 3
 // 统一请求方法
4 4
 export default function fetch (url, params = {}, method = 'POST', showFail = true) {
5
-  let showLoading = true
6
-  if (params && params.notShowLoading) {
7
-    showLoading = false
8
-  }
9
-  if (showLoading) {
10
-    uni.showLoading({
11
-      mask: true,
12
-      title: '加载中...'
13
-    })
14
-  }
15
-  url = process.env.VUE_APP_BASE_URL + url
16
-  params.token = store.getters.token
17
-  params.student_id = params.student_id || store.getters.kid
18
-  return new Promise((resolve, reject) => {
19
-    uni.request({
20
-      url,
21
-      data: params,
22
-      method,
23
-      header: {},
24
-      success: (res) => {
25
-        uni.hideLoading()
26
-        // 0:错误; 1:正确; 10000:没有token -2: 需要绑定手机
27
-        const rs = res.data
28
-        if (rs && rs.code === 1) {
29
-          resolve(rs)
30
-        } else if (rs.code === 10000) {
31
-          // // 跳转至登录页
32
-          uni.showModal({
33
-            title: '请先登录',
34
-            content: '您还没有登录,请先去登录',
35
-            success: res => {
36
-              if (res.confirm) {
37
-                uni.navigateTo({ url: '/pages/login/index' })
38
-              }
39
-            }
40
-          })
41
-        } else {
42
-          if (showFail) uni.showToast({ title: rs.msg, icon: 'none', duration: 2000 })// 直接提示错误
43
-          resolve(rs)
44
-        }
45
-      },
46
-      fail: (err) => {
47
-        uni.hideLoading()
48
-        uni.showToast({ title: err, icon: 'none', duration: 2000 })
49
-        reject(err)
50
-      }
51
-    })
52
-  })
5
+	let showLoading = true
6
+	//不需要token请求
7
+	const noTokenUrls = ['/parents/login/wx_login', '/parents/login/wx_auth']
8
+	if (params && params.notShowLoading) {
9
+		showLoading = false
10
+	}
11
+	if (showLoading) {
12
+		uni.showLoading({
13
+			mask: true,
14
+			title: '加载中...'
15
+		})
16
+	}
17
+	if (!noTokenUrls.includes(url)) {
18
+		params.token = store.getters.token
19
+		params.student_id = params.student_id || store.getters.kid
20
+	}
21
+	url = process.env.VUE_APP_BASE_URL + url
22
+	return new Promise((resolve, reject) => {
23
+		uni.request({
24
+			url,
25
+			data: params,
26
+			method,
27
+			header: {},
28
+			success: (res) => {
29
+				uni.hideLoading()
30
+				// 0:错误; 1:正确; 10000:没有token -2: 需要绑定手机
31
+				const rs = res.data
32
+				if (rs && rs.code === 1) {
33
+					resolve(rs)
34
+				} else if (rs.code === 10000) {
35
+					// // 跳转至登录页
36
+					uni.showModal({
37
+						title: '请先登录',
38
+						content: '您还没有登录,请先去登录',
39
+						success: res => {
40
+							if (res.confirm) {
41
+								uni.navigateTo({ url: '/pages/login/index' })
42
+							}
43
+						}
44
+					})
45
+				} else {
46
+					if (showFail) uni.showToast({ title: rs.msg, icon: 'none', duration: 2000 })// 直接提示错误
47
+					resolve(rs)
48
+				}
49
+			},
50
+			fail: (err) => {
51
+				uni.hideLoading()
52
+				uni.showToast({ title: err, icon: 'none', duration: 2000 })
53
+				reject(err)
54
+			}
55
+		})
56
+	})
53 57
 }

+ 121 - 10
src/pages/myStudents/myStudents.vue

@@ -17,7 +17,7 @@
17 17
           <view class="students-title flex justify-between align-center">
18 18
             <view class="text-lg">学生列表</view>
19 19
             <view class="text-xs text-grey">
20
-              <text class="text-red">点击选择,左滑删除,右侧添加</text>
20
+              <text class="text-red">点击选择,左滑操作,右侧添加</text>
21 21
               <text class="cuIcon-roundaddfill text-cyan margin-left-xl add-icon" @tap="showModal" data-target="ChooseModal"></text>
22 22
             </view>
23 23
           </view>
@@ -47,6 +47,7 @@
47 47
                   <text class="cuIcon-check text-student font-check" v-if="item.id === kid"></text>
48 48
                 </view>
49 49
                 <view class="move student-move">
50
+                  <view class="bg-cyan" @tap.stop="fixStudent(item)">修改</view>
50 51
                   <view class="bg-red" @tap.stop="unbind(item.id)">删除</view>
51 52
                 </view>
52 53
               </view>
@@ -95,13 +96,46 @@
95 96
         </view>
96 97
       </view>
97 98
     </view>
99
+    <!-- 修改学生 -->
100
+    <view class="cu-modal" :class="modalName == 'FixModal' ? 'show' : ''" @tap="hideModal">
101
+      <view class="cu-dialog bg-student" @tap.stop="">
102
+        <view class="cu-bar justify-around">
103
+          <view class="content modal-title">修改学生</view>
104
+        </view>
105
+        <view class="padding-xl text-left modal-body">
106
+          <view>{{ info.name }}</view>
107
+          <view class="margin-top">
108
+            <picker class="student-input" @change="gradeChange" :value="gradeIndex" :range="grades" range-key="name">
109
+              <view class="picker text-lg text-black">
110
+                {{ gradeIndex > -1 ? grades[gradeIndex].name : '请选择年级' }}
111
+              </view>
112
+            </picker>
113
+          </view>
114
+          <view class="margin-top">
115
+            <picker class="student-input" @change="classChange" :value="classIndex" :range="classes" range-key="name">
116
+              <view class="picker text-lg text-black">
117
+                {{ classIndex > -1 ? classes[classIndex].name : '请选择班级' }}
118
+              </view>
119
+            </picker>
120
+            <!-- <input type="text" v-model.trim="info.class_name" placeholder="修改班级" class="student-input text-black text-lg" /> -->
121
+          </view>
122
+        </view>
123
+        <view class="cu-bar modal-footer justify-center">
124
+          <view class="action">
125
+            <button class="cu-btn btn-lg round bg-cyan margin-right-sm" @tap="confirmFix">确定</button>
126
+            <button class="cu-btn btn-lg round bg-grey" @tap="hideModal">取消</button>
127
+          </view>
128
+        </view>
129
+      </view>
130
+    </view>
98 131
   </view>
99 132
 </template>
100 133
 
101 134
 <script>
102 135
 import { _getStudents, _bindStudent, _unbindStudent } from '@/api/auth'
103
-import { _shopList } from '@/api/course'
136
+import { _shopList, _getGrades, _getClasses, _fixStudent } from '@/api/course'
104 137
 import { mapGetters } from 'vuex'
138
+import validate from '@/common/utils/ys-validate'
105 139
 export default {
106 140
   data() {
107 141
     return {
@@ -113,6 +147,21 @@ export default {
113 147
         student_name: '',
114 148
         school_name: ''
115 149
       },
150
+      info: {
151
+        id: '',
152
+        name: '',
153
+        school_id: '',
154
+        grade_id: '',
155
+        class_id: ''
156
+      },
157
+      rules: [
158
+        { name: 'grade_id', required: true, type: 'number', errmsg: '请选择相应年级' },
159
+        { name: 'class_id', required: true, type: 'number', errmsg: '请选择相应班级' }
160
+      ],
161
+      gradeIndex: -1, //年级index
162
+      classIndex: -1, //班级index
163
+      grades: [], //年级列表
164
+      classes: [], //班级列表
116 165
       result: null,
117 166
       chooseList: [],
118 167
       moveModel: null,
@@ -124,7 +173,7 @@ export default {
124 173
   computed: {
125 174
     ...mapGetters(['kid', 'phone'])
126 175
   },
127
-  onLoad() {},
176
+  onLoad(options) {},
128 177
   onShow() {
129 178
     this.get_list()
130 179
     const kid = this.kid
@@ -138,6 +187,7 @@ export default {
138 187
         success: res => {}
139 188
       })
140 189
     }
190
+    this.get_grades()
141 191
   },
142 192
   methods: {
143 193
     showModal(e) {
@@ -181,6 +231,66 @@ export default {
181 231
         }
182 232
       })
183 233
     },
234
+    fixStudent(item) {
235
+      this.info.id = item.id
236
+      this.info.name = item.name
237
+      this.info.school_id = item.school
238
+      this.gradeIndex = this.grades.findIndex(e => e.name === item.grade_name)
239
+      this.info.grade_id = this.grades[this.gradeIndex]['id']
240
+      this.get_classes().then(res => {
241
+        this.classIndex = res.findIndex(c => c.name === item.class_name)
242
+        this.info.class_id = this.classes[this.classIndex]['id']
243
+      })
244
+      this.modalName = 'FixModal'
245
+    },
246
+    get_grades() {
247
+      _getGrades().then(res => {
248
+        this.grades = res.data
249
+      })
250
+    },
251
+    get_classes() {
252
+      return new Promise((resolve, reject) => {
253
+        _getClasses({ school_id: this.info.school_id, grade_id: this.info.grade_id }).then(res => {
254
+          this.classes = res.data
255
+          resolve(res.data)
256
+        })
257
+      })
258
+    },
259
+    gradeChange(e) {
260
+      this.gradeIndex = e.detail.value
261
+      this.info.grade_id = this.grades[this.gradeIndex].id
262
+      this.classIndex = -1
263
+      this.info.class_id = ''
264
+      this.get_classes()
265
+    },
266
+    classChange(e) {
267
+      this.classIndex = e.detail.value
268
+      this.info.class_id = this.classes[this.classIndex].id
269
+    },
270
+    confirmFix() {
271
+      const validRes = validate.validate(this.info, this.rules)
272
+      if (!validRes.isOk) {
273
+        uni.showToast({
274
+          icon: 'none',
275
+          title: validRes.errmsg
276
+        })
277
+        return false
278
+      }
279
+      uni.showModal({
280
+        title: '确认',
281
+        content: '确定修改?',
282
+        confirmText: '确定',
283
+        cancelText: '取消',
284
+        success: res => {
285
+          if (res.confirm) {
286
+            _fixStudent(this.info).then(res => {
287
+              this.get_list()
288
+              this.hideModal()
289
+            })
290
+          }
291
+        }
292
+      })
293
+    },
184 294
     unbind(id) {
185 295
       const _self = this
186 296
       uni.showModal({
@@ -267,6 +377,7 @@ export default {
267 377
   font-size: 22px;
268 378
 }
269 379
 .student-input {
380
+  padding-left: 20rpx;
270 381
   height: 40px;
271 382
   line-height: 40px;
272 383
   border-radius: 20px;
@@ -297,11 +408,11 @@ export default {
297 408
 .font-check {
298 409
   font-size: 22px;
299 410
 }
300
-.cu-list > .cu-item .move.student-move {
301
-  width: 130rpx;
302
-  text-align: center;
303
-}
304
-.cu-list > .cu-item.move-cur {
305
-  transform: translateX(-130rpx);
306
-}
411
+// .cu-list > .cu-item .move.student-move {
412
+//   width: 130rpx;
413
+//   text-align: center;
414
+// }
415
+// .cu-list > .cu-item.move-cur {
416
+//   transform: translateX(-130rpx);
417
+// }
307 418
 </style>

BIN
生成代码加固配置文件.exe


BIN
生成代码加固配置文件_linux