classDetail.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view class="content">
  3. <u-card :title="classInfo.name" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
  4. <view slot="body">
  5. <view class="class-info-text">
  6. <u-icon name="clock"></u-icon>
  7. {{classInfo.classStartDate}}&nbsp;{{classInfo.classStartHours}}&nbsp;~&nbsp;{{classInfo.classEndDate}}&nbsp;{{classInfo.classEndHours}}
  8. </view>
  9. <view class="class-info-text" v-for="(item, index) in classInfo.classExtrasList">
  10. <u-icon name="calendar" style="visibility: hidden;"></u-icon>
  11. <text>{{item.week}}&nbsp;{{item.startTime}}-{{item.endTime}}</text>
  12. </view>
  13. <view class="class-info-text">
  14. <u-icon name="map"></u-icon>
  15. {{classInfo.address}}
  16. </view>
  17. </view>
  18. </u-card>
  19. <u-card :title="'学员信息(' + classInfo.studentSignList.length + ')'" title-size="32" margin="0px 0px 10px 0px"
  20. :head-style="cardStyle">
  21. <u-grid :col="3" slot="body" :border="false">
  22. <u-grid-item v-for="(item, index) in classInfo.studentSignList" :key="index" :custom-style="gridCustomStyle" @click="goToStudentInfo(item)">
  23. <view class="class-student-col" :class="item.state ? 'student-active' : ''">
  24. {{item.name}}
  25. <u-icon name="bookmark" :color="mainColor" size="48"></u-icon>
  26. </view>
  27. </u-grid-item>
  28. </u-grid>
  29. </u-card>
  30. <u-card title="班级近况" :sub-title="imgEdit ? '完成' : '管理'" :sub-title-color="imgEdit ? '#19be6b' : '#909399'" :show-foot="false"
  31. title-size="32" margin="0px" :head-style="cardStyle" @sub-click="imgEdit = !imgEdit">
  32. <view class="class-show-box" slot="body">
  33. <view v-for="(item, index) in classShowList" :key="index" class="class-show-card">
  34. <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px"></u-image>
  35. <view class="class-show-name">{{item.name}}</view>
  36. <u-icon name="close-circle-fill" color="#fa3534" size="48" v-if="imgEdit" class="delete-icon" @click="deleteClassShow(item)"></u-icon>
  37. </view>
  38. <view class="class-show-card" style="width: calc(100% - 16px)" v-if="imgEdit">
  39. <u-upload :action="uploadUrl" :header="uploadHeader" :show-upload-list="false" :custom-btn="true" @on-success="uploadSuccess"
  40. @on-error="uploadError">
  41. <view slot="addBtn" style="width: calc(100vw - 32px);text-align: center;">
  42. <u-icon name="plus-circle-fill" size="100" :color="mainColor"></u-icon>
  43. </view>
  44. </u-upload>
  45. </view>
  46. </view>
  47. </u-card>
  48. <view class="handle-fix-box">
  49. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="goToSignForm()">立即签到</u-button>
  50. </view>
  51. <u-top-tips ref="uTips"></u-top-tips>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. mapGetters
  57. } from 'vuex'
  58. const NET = require('@/utils/request')
  59. const API = require('@/config/api')
  60. export default {
  61. computed: {
  62. ...mapGetters([
  63. 'mainColor',
  64. 'customStyle',
  65. ])
  66. },
  67. data() {
  68. return {
  69. uploadUrl: API.uploadFile,
  70. uploadHeader: {
  71. Authorization: uni.getStorageSync('token')
  72. },
  73. classId: '',
  74. classInfo: {
  75. name: '',
  76. classStartDate: '',
  77. classStartHours: '',
  78. classEndDate: '',
  79. classEndHours: '',
  80. residue: '',
  81. address: '',
  82. classExtrasList: [],
  83. studentSignList: [],
  84. showList: [],
  85. },
  86. classShowList: [],
  87. imgEdit: false,
  88. cardStyle: {
  89. fontWeight: 'bold'
  90. },
  91. gridCustomStyle: {
  92. padding: '0 2px'
  93. }
  94. }
  95. },
  96. onLoad(options) {
  97. this.classId = options.id
  98. this.initialize()
  99. this.getClassShow()
  100. },
  101. onReady() {},
  102. onPullDownRefresh() {
  103. this.initialize()
  104. this.getClassShow()
  105. },
  106. methods: {
  107. // 获取初始化数据
  108. initialize() {
  109. NET.request(API.getClassDetail, {
  110. id: this.classId
  111. }, 'POST').then(res => {
  112. this.classInfo = res.data
  113. uni.stopPullDownRefresh();
  114. }).catch(error => {
  115. this.$refs.uTips.show({
  116. title: error.message,
  117. type: 'warning',
  118. })
  119. })
  120. },
  121. // 文件上传成功回调
  122. getClassShow() {
  123. NET.request(API.getClassDetailShowList, {
  124. id: this.classId,
  125. page: 0,
  126. size: 1000
  127. }, 'POST').then(res => {
  128. this.classShowList = res.data.row
  129. }).catch(error => {
  130. this.$refs.uTips.show({
  131. title: error.message,
  132. type: 'warning',
  133. })
  134. })
  135. },
  136. // 文件上传成功回调
  137. uploadSuccess(res, index, lists, name) {
  138. NET.request(API.insertClassShow, {
  139. fileId: [res.data.id],
  140. id: this.classId,
  141. }, 'POST').then(res => {
  142. this.getClassShow()
  143. this.$refs.uTips.show({
  144. title: '班级近况发布成功',
  145. type: 'success',
  146. })
  147. }).catch(error => {
  148. this.$refs.uTips.show({
  149. title: error.message,
  150. type: 'warning',
  151. })
  152. })
  153. return true
  154. },
  155. // 文件上传失败回调
  156. uploadError(res, index, lists, name) {
  157. this.$refs.uTips.show({
  158. title: error.message,
  159. type: 'warning',
  160. })
  161. },
  162. // 删除班级近况
  163. deleteClassShow(site) {
  164. NET.request(API.deleteClassShow, {
  165. id: site.id,
  166. }, 'POST').then(res => {
  167. this.getClassShow()
  168. this.$refs.uTips.show({
  169. title: '删除成功',
  170. type: 'success',
  171. })
  172. }).catch(error => {
  173. this.$refs.uTips.show({
  174. title: error.message,
  175. type: 'warning',
  176. })
  177. })
  178. },
  179. // 跳转学生详情
  180. goToStudentInfo(item) {
  181. uni.navigateTo({
  182. url: '/pagesMain/studentInfo?type=1&id=' + item.id + '&classId=' + this.classId
  183. });
  184. },
  185. // 跳转签到表单
  186. goToSignForm() {
  187. uni.removeStorageSync('signUserList')
  188. uni.navigateTo({
  189. url: '/pagesClass/signForm?id=' + this.classId + '&status=' + this.classInfo.signStatus
  190. });
  191. },
  192. },
  193. }
  194. </script>
  195. <style>
  196. page {
  197. width: 100%;
  198. height: 100%;
  199. background-color: #f7f7f7;
  200. position: relative;
  201. }
  202. </style>
  203. <style lang="scss" scoped>
  204. @import "@/static/css/themes.scss";
  205. .content {
  206. width: 100%;
  207. float: left;
  208. padding-bottom: 60px;
  209. .class-info-text {
  210. color: #999999;
  211. line-height: 18px;
  212. u-icon {
  213. margin-right: 4px;
  214. }
  215. }
  216. .class-student-col {
  217. height: 28px;
  218. display: flex;
  219. padding: 0 10px;
  220. line-height: 28px;
  221. color: $mainColor;
  222. white-space: nowrap;
  223. border: 1px solid $mainColor;
  224. border-radius: 5px;
  225. /deep/u-icon {
  226. margin-left: 5px;
  227. }
  228. }
  229. .student-active {
  230. background-color: $mainColor;
  231. color: #FFFFFF;
  232. }
  233. .class-student-box {
  234. display: flex;
  235. justify-content: space-around;
  236. }
  237. .class-show-box {
  238. width: 100%;
  239. float: left;
  240. .class-show-card {
  241. width: calc(50% - 16px);
  242. margin: 0 8px 16px 8px;
  243. float: left;
  244. position: relative;
  245. .class-show-name {
  246. width: 100%;
  247. text-align: center;
  248. line-height: 20px;
  249. font-size: 14px;
  250. margin-top: 5px;
  251. }
  252. .delete-icon {
  253. position: absolute;
  254. right: -5px;
  255. top: -5px;
  256. }
  257. }
  258. }
  259. }
  260. </style>