classDetail.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. this.$refs.uTips.show({
  130. title: '班级近况发布成功',
  131. type: 'success',
  132. })
  133. }).catch(error => {
  134. this.$refs.uTips.show({
  135. title: error.message,
  136. type: 'warning',
  137. })
  138. })
  139. },
  140. // 文件上传成功回调
  141. uploadSuccess(res, index, lists, name) {
  142. NET.request(API.insertClassShow, {
  143. fileId: [res.data.id],
  144. id: this.classId,
  145. }, 'POST').then(res => {
  146. this.getClassShow()
  147. this.$refs.uTips.show({
  148. title: '班级近况发布成功',
  149. type: 'success',
  150. })
  151. }).catch(error => {
  152. this.$refs.uTips.show({
  153. title: error.message,
  154. type: 'warning',
  155. })
  156. })
  157. return true
  158. },
  159. // 文件上传失败回调
  160. uploadError(res, index, lists, name) {
  161. this.$refs.uTips.show({
  162. title: error.message,
  163. type: 'warning',
  164. })
  165. },
  166. // 删除班级近况
  167. deleteClassShow(site) {
  168. NET.request(API.deleteClassShow, {
  169. id: site.id,
  170. }, 'POST').then(res => {
  171. this.getClassShow()
  172. this.$refs.uTips.show({
  173. title: '删除成功',
  174. type: 'success',
  175. })
  176. }).catch(error => {
  177. this.$refs.uTips.show({
  178. title: error.message,
  179. type: 'warning',
  180. })
  181. })
  182. },
  183. // 跳转学生详情
  184. goToStudentInfo(item) {
  185. uni.navigateTo({
  186. url: '/pagesMain/studentInfo?type=1&id=' + item.id + '&classId=' + this.classId
  187. });
  188. },
  189. // 跳转签到表单
  190. goToSignForm() {
  191. uni.removeStorageSync('signUserList')
  192. uni.navigateTo({
  193. url: '/pagesClass/signForm?id=' + this.classId + '&status=' + this.classInfo.signStatus
  194. });
  195. },
  196. },
  197. }
  198. </script>
  199. <style>
  200. page {
  201. width: 100%;
  202. height: 100%;
  203. background-color: #f7f7f7;
  204. position: relative;
  205. }
  206. </style>
  207. <style lang="scss" scoped>
  208. @import "@/static/css/themes.scss";
  209. .content {
  210. width: 100%;
  211. float: left;
  212. padding-bottom: 60px;
  213. .class-info-text {
  214. color: #999999;
  215. line-height: 18px;
  216. u-icon {
  217. margin-right: 4px;
  218. }
  219. }
  220. .class-student-col {
  221. height: 28px;
  222. display: flex;
  223. padding: 0 10px;
  224. line-height: 28px;
  225. color: $mainColor;
  226. white-space: nowrap;
  227. border: 1px solid $mainColor;
  228. border-radius: 5px;
  229. /deep/u-icon {
  230. margin-left: 5px;
  231. }
  232. }
  233. .student-active {
  234. background-color: $mainColor;
  235. color: #FFFFFF;
  236. }
  237. .class-student-box {
  238. display: flex;
  239. justify-content: space-around;
  240. }
  241. .class-show-box {
  242. width: 100%;
  243. float: left;
  244. .class-show-card {
  245. width: calc(50% - 16px);
  246. margin: 0 8px 16px 8px;
  247. float: left;
  248. position: relative;
  249. .class-show-name {
  250. width: 100%;
  251. text-align: center;
  252. line-height: 20px;
  253. font-size: 14px;
  254. margin-top: 5px;
  255. }
  256. .delete-icon {
  257. position: absolute;
  258. right: -5px;
  259. top: -5px;
  260. }
  261. }
  262. }
  263. }
  264. </style>