homework.vue 18 KB

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