|
@@ -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>
|