homework.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <view class="homework-container">
  3. <!-- 头部区域 -->
  4. <top-box :timeStamp="timeStamp" />
  5. <view class="module-container">
  6. <view style="margin: 0 20rpx;">
  7. <u-tabs :list="list" :current="current" @change="changeModule"
  8. :activeStyle="{color: '#4169E1',fontWeight: 'bold',transform: 'scale(1.08)',}"
  9. :inactiveStyle="{fontWeight: 'bold',transform: 'scale(1)'}" lineColor="#4169E1" lineWidth="60">
  10. </u-tabs>
  11. </view>
  12. <!-- 模块卡片 -->
  13. <view class="module-box">
  14. <!-- 评测 -->
  15. <view class="card" style="background-color: #4169E1;" v-if="current == 0">
  16. <view class="box">
  17. <view class="flex">
  18. <text class="card-title">今日评测数:</text>
  19. <text class="card-title" style="margin-left: 20rpx;">{{testData.length}}</text>
  20. </view>
  21. <view class="box" style="margin: 10rpx 0 0 0;">
  22. <view class="flex">
  23. <text class="card-subtitle">完成数量:</text>
  24. <text class="card-subtitle" style="margin-left: 20rpx;">{{testFinish}}</text>
  25. </view>
  26. <view class="flex">
  27. <text class="card-subtitle">完成情况:</text>
  28. <text class="card-subtitle" style="margin-left: 20rpx;">{{list[0].level}}</text>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="image" :style="{backgroundImage:`url(${list[0].image})`}"></view>
  33. </view>
  34. <!-- 作业 -->
  35. <view class="card" style="background-color: #ff8caf;" v-if="current == 1">
  36. <view class="box">
  37. <view class="flex">
  38. <text class="card-title">今日作业数:</text>
  39. <text class="card-title" style="margin-left: 20rpx;">{{homeworkData.length}}</text>
  40. </view>
  41. <view class="box" style="margin: 10rpx 0 0 0;">
  42. <view class="flex">
  43. <text class="card-subtitle">完成数量:</text>
  44. <text class="card-subtitle" style="margin-left: 20rpx;">{{homeworkFinish}}</text>
  45. </view>
  46. <view class="flex">
  47. <text class="card-subtitle">完成情况:</text>
  48. <text class="card-subtitle" style="margin-left: 20rpx;">{{list[1].level}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="image" :style="{backgroundImage:`url(${list[1].image})`}"></view>
  53. </view>
  54. <!-- 活动 -->
  55. <view class="card" style="background-color: #f9c752;" v-if="current == 2">
  56. <view class="box">
  57. <view class="flex">
  58. <text class="card-title">今日活动数:</text>
  59. <text class="card-title" style="margin-left: 20rpx;">{{activityData.length}}</text>
  60. </view>
  61. <view class="box" style="margin: 10rpx 0 0 0;">
  62. <view class="flex">
  63. <text class="card-subtitle">完成数量:</text>
  64. <text class="card-subtitle" style="margin-left: 20rpx;">{{activityFinish}}</text>
  65. </view>
  66. <view class="flex">
  67. <text class="card-subtitle">完成情况:</text>
  68. <text class="card-subtitle" style="margin-left: 20rpx;">{{list[2].level}}</text>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="image" :style="{backgroundImage:`url(${list[2].image})`}"></view>
  73. </view>
  74. <!-- 中间标题 -->
  75. <view class="flex">
  76. <view class="cut-off" v-if="current == 0">评测信息</view>
  77. <view class="cut-off" v-if="current == 1">作业信息</view>
  78. <view class="cut-off" v-if="current == 2">活动信息</view>
  79. </view>
  80. <!-- 列表 -->
  81. <view class="detail-box">
  82. <!-- 图表模块 -->
  83. <view class="detail-box-item">
  84. <view class="item-info">
  85. <view class="t-icon t-icon-ceping"></view>
  86. <view class="item-text">近期完成率数据</view>
  87. </view>
  88. <view class="charts-box" v-if="current == 0">
  89. <qiun-data-charts type="fin-area" :chartData="assignment.testData" :loadingType="4"
  90. :canvas2d='true' tooltipFormat='HomeworkPercent' canvasId='canvans0980111' />
  91. </view>
  92. <view class="charts-box" v-if="current == 1">
  93. <qiun-data-charts type="fin-area" :chartData="assignment.homeworkData" :loadingType="4"
  94. :canvas2d='true' tooltipFormat='HomeworkPercent' canvasId='canvans0933511' />
  95. </view>
  96. <view class="charts-box" v-if="current == 2">
  97. <qiun-data-charts type="fin-area" :chartData="assignment.activityData" :loadingType="4"
  98. :canvas2d='true' tooltipFormat='HomeworkPercent' canvasId='canvans0531032' />
  99. </view>
  100. </view>
  101. <!-- 详情列表 -->
  102. <!-- 评测 -->
  103. <view class="detail-box-item" v-if="current == 0">
  104. <view class="item-info">
  105. <view class="t-icon t-icon-daiban"></view>
  106. <view class="item-text">评测列表</view>
  107. <view class="btn" @click="navData">
  108. <view class="t-icon t-icon-fenlei"></view>
  109. <view class="msg">详情列表</view>
  110. </view>
  111. </view>
  112. <view style="margin-bottom: 20rpx;">
  113. <view class="block-box" v-for="(item,i) in testData" :key="i">
  114. <view class="index" :style="{backgroundColor: item.examInfo.progress === 'finish'? '#23b46c':'#4169E1'} "></view>
  115. <view class="class-block" style="width: 90%;">
  116. <view style="width: 40%;">
  117. <view class="list-item-title">{{item.examInfo.name}}</view>
  118. </view>
  119. <view style=" display: flex; justify-content: space-between; width: 50%;">
  120. <view class="block-tag-box">
  121. <view class="block-tag">{{item.examInfo.subjects[0].name}}</view>
  122. </view>
  123. <view class="block-tag-box">
  124. <view class="block-tag">{{item.examInfo.examType.name}}</view>
  125. </view>
  126. <view class="block-tag-box">
  127. <view class="block-tag">
  128. {{item.examInfo.progress === 'finish' ? '已完成' : (item.examInfo.progress === 'going' ? '进行中' : '待发布')}}
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. <!-- 作业 -->
  137. <view class="detail-box-item" v-if="current == 1">
  138. <view class="item-info">
  139. <view class="t-icon t-icon-daiban"></view>
  140. <view class="item-text">作业列表</view>
  141. <view class="btn" @click="navData">
  142. <view class="t-icon t-icon-fenlei"></view>
  143. <view class="msg">详情列表</view>
  144. </view>
  145. </view>
  146. <view style="margin-bottom: 20rpx;">
  147. <view class="block-box" v-for="(item,i) in homeworkData" :key="i">
  148. <view class="index" :style="{backgroundColor: item.work.progress === 'finish'? '#23b46c':'#ff8caf'}" ></view>
  149. <view class="class-block" style="width: 90%;justify-content: flex-start;">
  150. <view style="display: flex; flex-direction: column;">
  151. <view style="display: flex;margin-left: 30rpx;align-items: center;">
  152. <view class="list-item-title">{{item.work.name}}</view>
  153. <view class="block-tag-box" style="margin-left: 40rpx;">
  154. <view class="block-tag">{{item.work.scope === 'private' ? '个人':'学校'}}作业
  155. </view>
  156. </view>
  157. <view class="block-tag-box" style="margin-left: 20rpx;">
  158. <view class="block-tag">
  159. {{item.work.progress === 'finish' ? '已完成' : (item.work.progress === 'going' ? '进行中' : '待发布')}}
  160. </view>
  161. </view>
  162. </view>
  163. <rich-text class="block-subtitle" style="margin:10rpx 0 0 30rpx;"
  164. :nodes="item.work.description"></rich-text>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. <!-- 活动 -->
  171. <view class="detail-box-item" v-if="current == 2">
  172. <view class="item-info">
  173. <view class="t-icon t-icon-daiban"></view>
  174. <view class="item-text">活动列表</view>
  175. <view class="btn" @click="navData">
  176. <view class="t-icon t-icon-fenlei"></view>
  177. <view class="msg">详情列表</view>
  178. </view>
  179. </view>
  180. <view style="margin-bottom: 20rpx;">
  181. <view class="block-box" v-for="(item,i) in activityData" :key="i">
  182. <view class="index" :style="{ backgroundColor: item.survey.progress === 'finish' || item.vote.progress === 'finish'? '#23b46c':'#f9c752'}" ></view>
  183. <view class="class-block" style="width: 90%;justify-content: flex-start;">
  184. <view style="display: flex; flex-direction: column;">
  185. <view style="display: flex;margin-left: 30rpx;align-items: center;">
  186. <view class="list-item-title">
  187. {{item.survey.name || item.vote.name}}
  188. </view>
  189. <view class="block-tag-box" style="margin-left: 40rpx;">
  190. <view class="block-tag">
  191. {{item.survey.scope === 'private' ? '个人':'学校' || item.vote.scope === 'private' ? '个人':'学校'}}活动
  192. </view>
  193. </view>
  194. <view class="block-tag-box" style="margin-left: 20rpx;">
  195. <view class="block-tag">
  196. {{item.survey.progress === 'finish' || item.vote.progress === 'finish' ? '已完成' : (item.survey.progress === 'going' || item.vote.progress === 'going' ? '进行中' : '待发布')}}
  197. </view>
  198. </view>
  199. </view>
  200. <rich-text class="block-subtitle" style="margin:10rpx 0 0 30rpx;"
  201. :nodes="item.vote.description || item.survey.description"></rich-text>
  202. </view>
  203. </view>
  204. </view>
  205. </view>
  206. </view>
  207. </view>
  208. </view>
  209. </view>
  210. </view>
  211. </template>
  212. <script>
  213. import {
  214. mapState,
  215. mapMutations
  216. } from 'vuex'
  217. export default {
  218. computed: {
  219. ...mapState('m_chart', ['assignment']),
  220. },
  221. data() {
  222. return {
  223. //模块名
  224. list: [{
  225. name: '评测详情',
  226. level: '',
  227. image: 'https://ouch-cdn2.icons8.com/yFl5NWU3aVehLBlQf9ctvnZPqtm5U0hqM3IzWvFDCaQ/rs:fit:912:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9wbmcvNzY5/LzY1ZTQxZmZjLTg1/YWQtNDYyMi1hYzU0/LWQ3NDEzZmY2NGI1/YS5wbmc.png',
  228. }, {
  229. name: '作业详情',
  230. level: '',
  231. image: 'https://ouch-cdn2.icons8.com/AVOwJ9emg_ZOeHvQaunQAZlgeLsG-b1cGhiYvgoJ06g/rs:fit:912:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9wbmcvNTAw/LzI5YjU1YWQ4LWMw/YTEtNDE1MS1iYmQw/LWIyMDdhYmRkOTE0/Mi5wbmc.png',
  232. }, {
  233. name: '活动详情',
  234. level: '',
  235. image: 'https://ouch-cdn2.icons8.com/LW70TMgW1cGfYeGNSTEp7__kiKVgIhwdZwUmykdLYMY/rs:fit:912:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9wbmcvOTI0/LzU3MWU4ZDZkLTg0/NzEtNGM5YS04MDJk/LTEzNTM5YmZmZTM2/YS5wbmc.png',
  236. }],
  237. //当前模块
  238. current: 0,
  239. //页面数据内容
  240. testData: {},
  241. homeworkData: {},
  242. activityData: {},
  243. //完成内容
  244. testFinish: '',
  245. homeworkFinish: '',
  246. activityFinish: '',
  247. //历史数据
  248. historyData: {
  249. test: [50, 55, 60],
  250. homework: [10, 60, 50, 88, 100],
  251. activity: [70, 19, 28, 40, 60, 100, 83]
  252. },
  253. //时间戳
  254. timeStamp: '',
  255. };
  256. },
  257. onLoad(options) {
  258. this.init()
  259. if (options.index)
  260. this.current = options.index
  261. },
  262. //刷新页面
  263. onPullDownRefresh() {
  264. this.init()
  265. setTimeout(function() {
  266. uni.stopPullDownRefresh();
  267. }, 1000);
  268. },
  269. methods: {
  270. ...mapMutations('m_chart', ['updateTestArea', 'updateHomeworkArea', 'updateActivityArea']),
  271. ...mapMutations('m_children', ['updateDetail']),
  272. //初始化页面
  273. init() {
  274. this.timeStamp = (new Date()).format("hh:mm")
  275. this.$initHomework()
  276. this.saveToStudyChart()
  277. this.getLevel()
  278. },
  279. //更改模块
  280. changeModule(e) {
  281. this.current = e.index
  282. },
  283. //获得评判信息
  284. getLevel() {
  285. let testArr = this.historyData.test
  286. let homeworkArr = this.historyData.homework
  287. let activityArr = this.historyData.activity
  288. this.list[0].level = testArr[testArr.length - 1] >= 40 ?
  289. (testArr[testArr.length - 1] >= 70 ? '优秀' : '良好') : '较差'
  290. this.list[1].level = homeworkArr[homeworkArr.length - 1] >= 40 ?
  291. (homeworkArr[homeworkArr.length - 1] >= 70 ? '优秀' : '良好') : '较差'
  292. this.list[2].level = activityArr[activityArr.length - 1] >= 40 ?
  293. (activityArr[activityArr.length - 1] >= 70 ? '优秀' : '良好') : '较差'
  294. },
  295. //记录完成率到图表
  296. saveToStudyChart() {
  297. let temp = {
  298. categories: [],
  299. series: [{
  300. "name": "",
  301. "data": []
  302. }]
  303. }
  304. // 测试
  305. this.historyData.test.push(parseInt(this.testFinish * 100 / this.testData.length))
  306. if (this.historyData.test.length > 7)
  307. this.historyData.test.shift()
  308. temp.categories = this.$getRecentDateArray(this.historyData.test.length)
  309. //数据
  310. //解除对象指向同一块内存(拷贝)
  311. temp.series[0].data = this.historyData.test
  312. let testDataTemp = JSON.parse(JSON.stringify(temp))
  313. this.updateTestArea(testDataTemp)
  314. //作业
  315. this.historyData.homework.push(parseInt(this.homeworkFinish * 100 / this.homeworkData
  316. .length))
  317. if (this.historyData.homework.length > 7)
  318. this.historyData.homework.shift()
  319. temp.categories = this.$getRecentDateArray(this.historyData.homework.length)
  320. temp.series[0].data = this.historyData.homework
  321. let homeworkDataTemp = JSON.parse(JSON.stringify(temp))
  322. this.updateHomeworkArea(homeworkDataTemp)
  323. //活动
  324. this.historyData.activity.push(parseInt(this.activityFinish * 100 / this.activityData
  325. .length))
  326. if (this.historyData.activity.length > 7)
  327. this.historyData.activity.shift()
  328. temp.categories = this.$getRecentDateArray(this.historyData.activity.length)
  329. temp.series[0].data = this.historyData.activity
  330. let activityDataTemp = JSON.parse(JSON.stringify(temp))
  331. this.updateActivityArea(activityDataTemp)
  332. },
  333. //导航到详情页面
  334. navData() {
  335. if (this.current === 0) {
  336. this.updateDetail(this.testData)
  337. uni.navigateTo({
  338. url: `/subpkg/detaillist/examlist`
  339. })
  340. }
  341. if (this.current === 1) {
  342. this.updateDetail(this.homeworkData)
  343. uni.navigateTo({
  344. url: `/subpkg/detaillist/homeworklist`
  345. })
  346. }
  347. if (this.current === 2) {
  348. this.updateDetail(this.activityData)
  349. uni.navigateTo({
  350. url: `/subpkg/detaillist/activitylist`
  351. })
  352. }
  353. }
  354. }
  355. }
  356. </script>
  357. <style lang="scss">
  358. @import '@/pages/common/blockmsg.scss';
  359. .list-item-title {
  360. font-size: 30rpx;
  361. font-weight: bold;
  362. color: $color-title;
  363. }
  364. .home-topinfo {
  365. background: linear-gradient($color-yellow, $page-background-color) !important;
  366. }
  367. //模块
  368. .module-container {
  369. margin-top: -70rpx;
  370. //头部卡片
  371. .card {
  372. display: flex;
  373. justify-content: space-around;
  374. margin: 20rpx auto 20rpx auto;
  375. height: 220rpx;
  376. width: 95%;
  377. // background: linear-gradient(to right, #ff95007a,#ff8419);
  378. border-radius: $card-border-radius;
  379. .card-title {
  380. font-size: 50rpx;
  381. font-weight: bold;
  382. color: #FFF;
  383. }
  384. .card-subtitle {
  385. font-size: 30rpx;
  386. color: #FFF;
  387. }
  388. .border-bottom {
  389. height: 10rpx;
  390. width: 100%;
  391. border-radius: $card-border-radius;
  392. background-color: #FFF;
  393. margin: 5rpx 0 5rpx 0;
  394. }
  395. .image {
  396. position: relative;
  397. right: -30rpx;
  398. height: 300rpx;
  399. width: 300rpx;
  400. background-size: 100%;
  401. background-repeat: no-repeat;
  402. z-index: 2;
  403. }
  404. }
  405. //头部卡片
  406. .box {
  407. display: flex;
  408. flex-direction: column;
  409. justify-content: space-around;
  410. margin: 25rpx 0;
  411. }
  412. //中间标题
  413. .cut-off {
  414. font-size: 30rpx;
  415. font-weight: bold;
  416. color: #606266;
  417. margin-left: 40rpx;
  418. }
  419. //列表block
  420. .detail-box {
  421. display: flex;
  422. flex-flow: row wrap;
  423. margin: 20rpx 20rpx 0 20rpx;
  424. justify-content: space-between;
  425. .detail-box-item {
  426. margin: 0 0 4% 0;
  427. width: 100%;
  428. height: auto;
  429. background-color: #FFF;
  430. border-radius: $card-border-radius;
  431. .item-info {
  432. display: flex;
  433. align-items: center;
  434. padding: 20rpx;
  435. .t-icon {
  436. width: 40rpx;
  437. height: 40rpx;
  438. }
  439. .item-text {
  440. font-size: 30rpx;
  441. font-weight: bold;
  442. color: $color-title;
  443. margin-left: 15rpx;
  444. }
  445. }
  446. }
  447. }
  448. }
  449. //图表
  450. .charts-box {
  451. width: 100%;
  452. height: 300rpx;
  453. }
  454. .flex {
  455. display: flex;
  456. align-items: center;
  457. margin-left: 20rpx;
  458. }
  459. .msg {
  460. color: $color-mixblue;
  461. margin-left: 10rpx;
  462. font-size: 30rpx;
  463. }
  464. .btn {
  465. display: flex;
  466. align-items: center;
  467. margin: 0 5rpx 0 auto;
  468. }
  469. </style>