StudentScore.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div class="student-score">
  3. <div class="part-box part-box-filter">
  4. <Form ref="FilterForm" label-position="left" inline>
  5. <FormItem v-if="IS_INSPECTION">
  6. <Select
  7. v-model="filter.workId"
  8. @on-change="workChange"
  9. placeholder="工作文件夹"
  10. style="width: 150px"
  11. >
  12. <Option
  13. v-for="(work, windex) in works"
  14. :key="windex"
  15. :value="work.id"
  16. :label="work.name"
  17. ></Option>
  18. </Select>
  19. </FormItem>
  20. <FormItem>
  21. <Select
  22. v-model="filter.subject"
  23. @on-change="subjecChange"
  24. placeholder="科目"
  25. style="width: 100px;"
  26. clearable
  27. >
  28. <Option
  29. v-for="(item, index) in subjects"
  30. :key="index"
  31. :value="item.subject"
  32. :label="item.name"
  33. ></Option>
  34. </Select>
  35. </FormItem>
  36. <FormItem v-if="IS_INSPECTION">
  37. <Select v-model="filter.questionId" placeholder="考区">
  38. <Option
  39. v-for="area in areas"
  40. :key="area.id"
  41. :value="area.id"
  42. :label="area.areaName"
  43. ></Option>
  44. </Select>
  45. </FormItem>
  46. <FormItem>
  47. <Select
  48. v-model="filter.type"
  49. placeholder="号码类型"
  50. style="width: 100px"
  51. >
  52. <Option
  53. v-for="(val, key) in CODE_TYPE"
  54. :key="key"
  55. :value="key"
  56. :label="val"
  57. ></Option>
  58. </Select>
  59. </FormItem>
  60. <FormItem>
  61. <Input
  62. v-model.trim="filter.number"
  63. placeholder="输入号码"
  64. clearable
  65. ></Input>
  66. </FormItem>
  67. <FormItem>
  68. <Input
  69. v-model.trim="filter.studentName"
  70. placeholder="输入姓名"
  71. clearable
  72. ></Input>
  73. </FormItem>
  74. <FormItem>
  75. <Button
  76. class="btn-form-search"
  77. size="small"
  78. type="primary"
  79. @click="toSearch"
  80. >查询</Button
  81. >
  82. </FormItem>
  83. </Form>
  84. </div>
  85. <div class="student-score-content" v-if="curStudent.name">
  86. <div class="score-content-head">
  87. <h1 class="score-content-title">{{ curStudent.name }}</h1>
  88. <p class="score-content-info">
  89. <span>考号:</span><span>{{ curStudent.examNumber }}</span>
  90. </p>
  91. <p class="score-content-tscore">
  92. <span>总分:</span><span>{{ curStudent.sumScore }}</span>
  93. </p>
  94. </div>
  95. <div class="score-content-body">
  96. <image-action-list
  97. :data="curStudent.scores"
  98. :column-number="curStudent.scores.length"
  99. loop
  100. ref="ImageActionList"
  101. ></image-action-list>
  102. <table :class="['table', `table-column-${curStudent.scores.length}`]">
  103. <tr>
  104. <td
  105. class="color-dark"
  106. v-for="(score, sindex) in curStudent.scores"
  107. :key="sindex"
  108. >
  109. {{ score.level || "空" }}
  110. </td>
  111. </tr>
  112. <tr>
  113. <td
  114. class="color-error"
  115. v-for="(score, sindex) in curStudent.scores"
  116. :key="sindex"
  117. >
  118. {{ score.score ? score.score + "分" : "空" }}
  119. </td>
  120. </tr>
  121. </table>
  122. </div>
  123. </div>
  124. <div class="part-page" v-if="total > size">
  125. <Page
  126. :current="current"
  127. :total="total"
  128. :page-size="size"
  129. show-total
  130. show-elevator
  131. @on-change="toPage"
  132. ></Page>
  133. </div>
  134. </div>
  135. </template>
  136. <script>
  137. import { studentScoreList, workList, subjectList, areaList } from "@/api";
  138. import { CODE_TYPE } from "@/constants/enumerate";
  139. import ImageActionList from "./components/ImageActionList";
  140. export default {
  141. name: "student-score",
  142. components: { ImageActionList },
  143. data() {
  144. return {
  145. filter: {
  146. workId: this.$route.params && this.$route.params.workId,
  147. subject: "",
  148. questionId: "",
  149. type: "examNumber",
  150. number: "",
  151. studentName: ""
  152. },
  153. CODE_TYPE,
  154. IS_INSPECTION: false,
  155. works: [],
  156. subjects: [],
  157. areas: [],
  158. current: 1,
  159. total: 0,
  160. size: 1,
  161. curStudent: { name: "" },
  162. students: []
  163. };
  164. },
  165. mounted() {
  166. this.initData();
  167. },
  168. methods: {
  169. async initData() {
  170. this.IS_INSPECTION =
  171. this.$ls.get("user", { role: "" }).role === "INSPECTION";
  172. if (this.IS_INSPECTION) {
  173. await this.getWorkList();
  174. this.filter.workId = this.works[0].id;
  175. this.workChange();
  176. this.getAreaList();
  177. } else {
  178. await this.getSubjects();
  179. this.filter.subject = this.subjects[0].subject;
  180. }
  181. },
  182. async getWorkList() {
  183. this.works = await workList();
  184. },
  185. async getSubjects() {
  186. const data = await subjectList(this.filter.workId);
  187. this.subjects = data.filter(item => item.enable);
  188. },
  189. async getAreaList() {
  190. const data = await areaList({
  191. workId: this.filter.workId,
  192. subject: this.filter.subject
  193. });
  194. this.areas = data.map(item => {
  195. return {
  196. id: item.id,
  197. areaName: item.areaName,
  198. areaCode: item.areaCode
  199. };
  200. });
  201. },
  202. async toSearch() {
  203. if (!this.filter.number && !this.filter.studentName) {
  204. this.$Message.error("号码和姓名必须填写一个");
  205. return;
  206. }
  207. const data = await studentScoreList(this.filter);
  208. if (!data.length) {
  209. this.$Message.error("无此考生");
  210. return;
  211. }
  212. data.map(student => {
  213. student.scores.map(score => {
  214. score.title = score.subjectName;
  215. });
  216. });
  217. this.students = data;
  218. this.total = this.students.length;
  219. this.toPage(1);
  220. },
  221. toPage(page) {
  222. this.current = page;
  223. this.curStudent = this.students[page - 1] || {};
  224. },
  225. workChange() {
  226. this.filter.subject = null;
  227. this.filter.questionId = null;
  228. const curWork = this.works.find(item => item.id === this.filter.workId);
  229. this.subjects = curWork.subjects;
  230. this.filter.subject = this.subjects[0].subject;
  231. },
  232. subjecChange() {
  233. if (this.IS_INSPECTION) {
  234. this.filter.questionId = null;
  235. this.getAreaList();
  236. }
  237. }
  238. }
  239. };
  240. </script>