task-box.vue 15 KB

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