index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div id="index">
  3. <list-frame title="问卷完成度查询" :total="total" :needFilter="false" :needAdd="false" :needPag="views === 'plan'">
  4. <transition name="el-fade-in-linear">
  5. <self-cards :title="planTitle" v-if="views === `plan`">
  6. <data-table :fields="fields" :data="list" :opera="opera" @view="data => toView(data, 'term')"></data-table>
  7. </self-cards>
  8. <self-cards :title="termTitle" v-if="views === `term`" :returns="toReturns">
  9. <data-table :fields="termFields" :data="termList" :opera="opera" @view="data => toView(data, 'batch')"></data-table>
  10. </self-cards>
  11. <self-cards :title="batchTitle" v-if="views === `batch`" :returns="toReturns">
  12. <el-alert :title="`进度:${batch.answertotal || 0}/${batch.alltotal || 0}`" :closable="false"></el-alert>
  13. <data-table :fields="batchFields" :data="batch.list" :opera="opera" @view="data => toView(data, 'class')"></data-table>
  14. </self-cards>
  15. <self-cards :title="classTitle" v-if="views === `class`" :returns="toReturns">
  16. <el-alert :title="`进度:${classes.answertotal || 0}/${classes.alltotal || 0}`" :closable="false"></el-alert>
  17. <data-table :fields="classFields" :data="classes.list" :opera="opera" @view="data => toView(data, 'student')"></data-table>
  18. </self-cards>
  19. <self-cards :title="studentTitle" v-if="views === `student`" :returns="toReturns">
  20. <el-alert :title="`进度:${student.answertotal || 0}/${student.alltotal || 0}`" :closable="false"></el-alert>
  21. <data-table :fields="studFields" :data="student.list" :opera="[]"></data-table>
  22. </self-cards>
  23. </transition>
  24. </list-frame>
  25. </div>
  26. </template>
  27. <script>
  28. import listFrame from '@frame/layout/admin/list-frame';
  29. import dataTable from '@frame/components/data-table';
  30. import selfCards from './parts/cards';
  31. import { createNamespacedHelpers } from 'vuex';
  32. const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
  33. const { mapActions: classes } = createNamespacedHelpers('classes');
  34. const { mapActions: student } = createNamespacedHelpers('student');
  35. const { mapActions: completion } = createNamespacedHelpers('completion');
  36. export default {
  37. name: 'index',
  38. metaInfo: { title: '问卷完成度查询' },
  39. props: {},
  40. components: {
  41. listFrame,
  42. dataTable,
  43. selfCards,
  44. },
  45. data: () => ({
  46. views: 'plan', // term, batch, class
  47. planTitle: '全年计划',
  48. termTitle: '',
  49. batchTitle: '',
  50. classTitle: '',
  51. studentTitle: '',
  52. planid: undefined,
  53. opera: [
  54. {
  55. label: '查看',
  56. icon: 'el-icon-view',
  57. method: 'view',
  58. },
  59. ],
  60. fields: [
  61. { label: '计划标题', prop: 'title' },
  62. { label: '年度', prop: 'year' },
  63. {
  64. label: '状态',
  65. prop: 'status',
  66. format: i => {
  67. return i === '0' ? '筹备中' : i === '1' ? '发布中' : '已结束';
  68. },
  69. },
  70. ],
  71. list: [],
  72. termFields: [{ label: '期数', prop: 'term' }],
  73. termList: [],
  74. batchFields: [
  75. { label: '批次', prop: 'name' },
  76. { label: '进度', prop: 'completion' },
  77. ],
  78. batch: {
  79. list: [],
  80. },
  81. classFields: [
  82. { label: '班级', prop: 'name' },
  83. { label: '进度', prop: 'completion' },
  84. ],
  85. classes: {
  86. list: [],
  87. },
  88. total: 0,
  89. studFields: [
  90. { label: '姓名', prop: 'name' },
  91. { label: '进度', prop: 'completion' },
  92. ],
  93. student: {
  94. list: [],
  95. },
  96. studFilter: [
  97. { label: '姓名', model: 'name' },
  98. { label: '进度', prop: 'completion' },
  99. ],
  100. classid: '',
  101. studTotal: 0,
  102. }),
  103. created() {
  104. this.search();
  105. },
  106. computed: {},
  107. methods: {
  108. ...trainPlan(['query', 'delete', 'update']),
  109. ...completion({ getCompletion: 'query' }),
  110. ...classes({ getClassesList: 'query' }),
  111. ...student({ getStudentList: 'query' }),
  112. async search({ skip = 0, limit = 10, ...info } = {}) {
  113. const res = await this.query({ skip, limit, status: '1', ...info });
  114. if (this.$checkRes(res)) {
  115. this.$set(this, `list`, res.data);
  116. this.$set(this, `total`, res.total);
  117. }
  118. },
  119. async toView({ data }, type) {
  120. this.views = type;
  121. if (type === 'term') {
  122. let planid = data._id;
  123. this.planid = planid;
  124. this.$set(this, `termTitle`, data.title);
  125. this.$set(this, `termList`, data.termnum);
  126. }
  127. if (type === 'batch') {
  128. let termid = data._id;
  129. let res = await this.getCompletion({ type: '0', typeid: termid, trainplanid: this.planid });
  130. if (this.$checkRes(res)) {
  131. let { data: completion, answertotal, alltotal, completiontotal } = res;
  132. completion = completion.map(i => {
  133. i.completion.includes('NaN') ? (i.completion = '-') : '';
  134. return i;
  135. });
  136. this.$set(this, `batch`, { list: completion, answertotal, alltotal, completiontotal });
  137. }
  138. this.$set(this, `batchTitle`, `第${data.term}期`);
  139. }
  140. if (type === 'class') {
  141. let batch = data.id;
  142. let res = await this.getCompletion({ type: '1', typeid: batch });
  143. if (this.$checkRes(res)) {
  144. let { data: completion, answertotal, alltotal, completiontotal } = res;
  145. completion = completion.map(i => {
  146. i.completion.includes('NaN') ? (i.completion = '-') : '';
  147. return i;
  148. });
  149. this.$set(this, `classes`, { list: completion, answertotal, alltotal, completiontotal });
  150. }
  151. this.$set(this, `classTitle`, `${data.name}`);
  152. }
  153. if (type === 'student') {
  154. let res = await this.getCompletion({ type: '2', typeid: data.id });
  155. if (this.$checkRes(res)) {
  156. let { data: completion, answertotal, alltotal, completiontotal } = res;
  157. completion = completion.map(i => {
  158. i.completion.includes('NaN') ? (i.completion = '-') : '';
  159. return i;
  160. });
  161. this.$set(this, `student`, { list: completion, answertotal, alltotal, completiontotal });
  162. }
  163. this.$set(this, `studentTitle`, `${data.name}`);
  164. }
  165. },
  166. toReturns() {
  167. if (this.views === 'term') this.views = 'plan';
  168. else if (this.views === 'batch') this.views = 'term';
  169. else if (this.views === 'class') this.views = 'batch';
  170. else if (this.views === 'student') this.views = 'class';
  171. },
  172. },
  173. watch: {
  174. views: {
  175. handler(val) {
  176. if (val === 'plan') this.planid = undefined;
  177. },
  178. },
  179. },
  180. };
  181. </script>
  182. <style lang="less" scoped></style>