detailList.bak.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card" style="margin-bottom: 30px">
  4. <el-row :gutter="24">
  5. <el-col :span="5">
  6. <div style="padding-right: 20px">
  7. {{ evaluation.name }}
  8. </div>
  9. </el-col>
  10. <el-col :span="5" style="text-align: right">
  11. <el-radio-group v-model="option" @change="onOptionChanged">
  12. <el-radio-button
  13. v-for="i in options"
  14. :key="i.value"
  15. :label="i.value"
  16. style="border-radius: 18px"
  17. >{{ i.name }}</el-radio-button
  18. >
  19. </el-radio-group>
  20. </el-col>
  21. <el-col :span="12" style="text-align: left">
  22. <el-radio-group
  23. style="margin-left: 30px"
  24. v-model="subOption"
  25. v-if="subOptions.length"
  26. @change="onSubOptionChanged"
  27. >
  28. <el-radio-button
  29. v-for="i in subOptions"
  30. :key="i.value"
  31. :label="i.value"
  32. style="border-radius: 18px"
  33. >{{ i.name }}</el-radio-button
  34. >
  35. </el-radio-group>
  36. <span v-if="subOptions.length == 0" v-html="'\u00a0'"></span>
  37. </el-col>
  38. <el-col :span="2" style="text-align: right">
  39. <el-button size="small" @click="back()" round>返回</el-button>
  40. </el-col>
  41. </el-row>
  42. </el-card>
  43. <el-table
  44. :key="subjectiveRefreshKey"
  45. v-loading="loading"
  46. :data="dynamicRows"
  47. :span-method="spanMethod"
  48. style="width: 100%"
  49. v-if="!isOptionObjective"
  50. >
  51. <el-table-column label="序号" type="index" align="center" width="50" />
  52. <el-table-column label="姓名" prop="studentName" align="center">
  53. <template slot-scope="scope">
  54. <table
  55. border="0"
  56. width="100%"
  57. bordercolor="#fff"
  58. bgcolor="#fff"
  59. v-if="scope.$index == dynamicRows.length - 1"
  60. >
  61. <tr>
  62. <th rowspan="3" style="border: none">班级统计</th>
  63. <th style="border: none; text-align: center">优</th>
  64. </tr>
  65. <tr>
  66. <th style="border: none; text-align: center">良</th>
  67. </tr>
  68. <tr>
  69. <th style="border: none; text-align: center">中</th>
  70. </tr>
  71. </table>
  72. <span v-else>{{ scope.row.studentName }}</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. v-for="(header, idx) in dynamicHeaders"
  77. :key="idx"
  78. align="center"
  79. >
  80. <template #header="">
  81. <div v-if="header.score">
  82. <div>{{ header.name }}</div>
  83. <div>({{ header.score }}分)</div>
  84. </div>
  85. <span v-else>{{ header.name || header }}</span>
  86. </template>
  87. <template slot-scope="scope">
  88. <table
  89. border="0"
  90. width="100%"
  91. bordercolor="#fff"
  92. bgcolor="#fff"
  93. v-if="scope.$index == dynamicRows.length - 1"
  94. >
  95. <tr>
  96. <th style="border: none; text-align: center">
  97. {{ dynamicStatistics[idx][0] }}
  98. </th>
  99. </tr>
  100. <tr>
  101. <th style="border: none; text-align: center">
  102. {{ dynamicStatistics[idx][1] }}
  103. </th>
  104. </tr>
  105. <tr>
  106. <th style="border: none; text-align: center">
  107. {{ dynamicStatistics[idx][2] }}
  108. </th>
  109. </tr>
  110. </table>
  111. <span v-else>{{ dynamicRows[scope.$index].scores[idx] }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="个人统计" align="center">
  115. <el-table-column label="优" width="80px" align="center">
  116. <template slot-scope="scope">
  117. <span>{{ dynamicRows[scope.$index].stats[0] }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="良" width="80px" align="center">
  121. <template slot-scope="scope">
  122. <span>{{ dynamicRows[scope.$index].stats[1] }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="中" width="80px" align="center">
  126. <template slot-scope="scope">
  127. <span>{{ dynamicRows[scope.$index].stats[2] }}</span>
  128. </template>
  129. </el-table-column>
  130. </el-table-column>
  131. <el-table-column label="操作" align="center">
  132. <template slot-scope="scope">
  133. <el-button
  134. v-if="scope.$index != dynamicRows.length - 1"
  135. type="text"
  136. icon="el-icon-view"
  137. @click="userDetail(scope.$index)"
  138. >查看详情</el-button
  139. >
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <el-table
  144. :key="objectiveRefreshKey"
  145. v-loading="loading"
  146. :data="dynamicRows"
  147. :span-method="spanMethod"
  148. style="width: 100%"
  149. v-if="isOptionObjective"
  150. >
  151. <el-table-column label="序号" type="index" align="center" width="50" />
  152. <el-table-column label="姓名" prop="studentName" align="center">
  153. <template slot-scope="scope">
  154. <table
  155. border="0"
  156. width="100%"
  157. bordercolor="#fff"
  158. bgcolor="#fff"
  159. v-if="scope.$index == dynamicRows.length - 1"
  160. >
  161. <tr>
  162. <th :rowspan="option == 1 ? 1 : 2" style="border: none">
  163. 班级统计
  164. </th>
  165. <th v-if="option != 1">已掌握</th>
  166. </tr>
  167. <tr v-if="option != 1">
  168. <th>未掌握</th>
  169. </tr>
  170. </table>
  171. <span v-else>{{ scope.row.studentName }}</span>
  172. </template>
  173. </el-table-column>
  174. <el-table-column
  175. v-for="(header, idx) in dynamicHeaders"
  176. :key="idx"
  177. align="center"
  178. >
  179. <template #header>
  180. <div v-if="header.score">
  181. <div>{{ header.name }}</div>
  182. <div>({{ header.score }}分)</div>
  183. </div>
  184. <span v-else>{{ header.name || header }}</span>
  185. </template>
  186. <template slot-scope="scope">
  187. <table
  188. border="0"
  189. width="100%"
  190. bordercolor="#fff"
  191. bgcolor="#fff"
  192. v-if="scope.$index == dynamicRows.length - 1"
  193. >
  194. <tr>
  195. <th style="border: none; text-align: center" v-if="option == 1">
  196. {{ dynamicStatistics[idx][0] }}
  197. </th>
  198. </tr>
  199. <tr v-if="option != 1">
  200. <th style="border: none; text-align: center" v-if="dynamicStatistics[idx] && dynamicStatistics[idx].length>0">
  201. {{
  202. dynamicStatistics[idx] && dynamicStatistics[idx][0]
  203. }}人
  204. </th>
  205. </tr>
  206. <tr v-if="option != 1">
  207. <th style="border: none; text-align: center" v-if="dynamicStatistics[idx] && dynamicStatistics[idx].length>1">
  208. {{
  209. dynamicStatistics[idx] && dynamicStatistics[idx][1]
  210. }}人
  211. </th>
  212. </tr>
  213. </table>
  214. <span
  215. v-else-if="dynamicRows[scope.$index].scores[idx] == ''"
  216. v-html="'\u00a0'"
  217. ></span>
  218. <span v-else-if="option != 1">{{ scope.row.scores[idx] }}分</span>
  219. <span
  220. v-else-if="convertToBoolean(scope.row.scores[idx])"
  221. class="el-icon-circle-check"
  222. style="color: #67c23a; font-size: 24px"
  223. ></span>
  224. <span
  225. v-else
  226. class="el-icon-circle-close"
  227. style="color: #f56c6c; font-size: 24px"
  228. ></span>
  229. </template>
  230. </el-table-column>
  231. <el-table-column :label="option == 1 ? '个人统计':'掌握比'" align="center">
  232. <template slot-scope="scope">
  233. <span v-if="scope.$index != dynamicRows.length - 1">{{
  234. dynamicRows[scope.$index].stats[0]
  235. }}</span>
  236. <span v-else v-html="'\u00a0'"></span>
  237. </template>
  238. </el-table-column>
  239. <el-table-column label="操作" align="center">
  240. <template slot-scope="scope">
  241. <el-button
  242. v-if="scope.$index != dynamicRows.length - 1"
  243. type="text"
  244. icon="el-icon-view"
  245. @click="userDetail(scope.$index)"
  246. >查看详情</el-button
  247. >
  248. <span v-else v-html="'\u00a0'"></span>
  249. </template>
  250. </el-table-column>
  251. </el-table>
  252. </div>
  253. </template>
  254. <script>
  255. import { getEvaluationQuestionTypes, getClassStat } from "@/api/webApi/front";
  256. export default {
  257. data() {
  258. return {
  259. loading: false,
  260. evaluation: {},
  261. queryParams: {
  262. evaluationClassId: "",
  263. questionType: "1",
  264. questionOptions: "0",
  265. },
  266. options: [],
  267. subOptions: [],
  268. option: "", // 1 客观题, 2 主观题
  269. subOption: "",
  270. isOptionObjective: true, // true:客观题, false: 主观题
  271. objectiveRefreshKey: "",
  272. subjectiveRefreshKey: "",
  273. dynamicHeaders: [],
  274. dynamicRows: [],
  275. dynamicStatistics: {},
  276. studentStatsKeyPrefix: "dynamicItem_stats_",
  277. };
  278. },
  279. created() {
  280. this.evaluation = this.$route.query;
  281. this.queryParams.evaluationClassId = this.evaluation.evaluationClassId;
  282. this.queryParams.evaluationId = this.evaluation.evaluationId;
  283. this.getOptions();
  284. },
  285. methods: {
  286. back() {
  287. this.$router.back();
  288. },
  289. userDetail(idx) {
  290. const row = this.dynamicRows[idx];
  291. const nextParams = {
  292. evaluationName: this.evaluation.name,
  293. examineeId: row.examineeId,
  294. studentName: row.studentName,
  295. };
  296. this.$router.push({
  297. path: "/idc/EvaluationDatabase/statistics",
  298. query: nextParams,
  299. });
  300. },
  301. onOptionChanged(op) {
  302. this.subOptions = this.options.find((o) => o.value == op).options || [];
  303. if (this.subOptions.length > 0) {
  304. this.subOption = this.subOptions[0].value;
  305. this.onSubOptionChanged(this.subOption);
  306. }
  307. },
  308. onSubOptionChanged(op) {
  309. this.getList();
  310. },
  311. getOptions() {
  312. // this.getDicts("question_type").then((rp) => {
  313. // console.log("getDicts question_type rep =", rp);
  314. // var map = {};
  315. // rp.data.forEach((r) => (map[r.dictValue] = r.dictLabel));
  316. getEvaluationQuestionTypes(this.evaluation.evaluationClassId).then(
  317. (rep) => {
  318. console.log("getEvaluationQuestionTypes rep =", rep);
  319. if (rep.code == 200 || rep.code == 0) {
  320. // // 将options的显示替换为字典配置
  321. // rep.data.forEach(
  322. // (item) => (item.name = map[item.name] || item.name)
  323. // );
  324. this.options = rep.data;
  325. this.option = this.options[0].value;
  326. this.onOptionChanged(this.option);
  327. } else {
  328. this.msgError(rep.msg || "getEvaluationQuestionTypes请求异常");
  329. }
  330. }
  331. );
  332. // });
  333. },
  334. getList() {
  335. this.loading = true;
  336. this.queryParams.questionType = this.option;
  337. this.queryParams.questionOptions = this.subOption;
  338. getClassStat(this.queryParams).then((rep) => {
  339. console.log("getClassStat rep =", rep);
  340. if (rep.code == 200 || rep.code == 0) {
  341. this.resolveDynamicData(rep.data);
  342. } else {
  343. this.msgError(rep.msg || "getClassStat请求异常");
  344. }
  345. this.loading = false;
  346. });
  347. },
  348. spanMethod({ row, column, rowIndex, columnIndex }) {
  349. // 数据最后一行,第1、2列合并
  350. if (rowIndex == this.dynamicRows.length - 1) {
  351. if (columnIndex == 0) return [0, 0];
  352. else if (columnIndex == 1) return [1, 2];
  353. }
  354. return [1, 1];
  355. },
  356. resolveDynamicData(data) {
  357. // 先解析主客观题类型
  358. this.isOptionObjective = !(
  359. data.datas.length > 0 && data.datas[0].stats.length > 2
  360. );
  361. console.log("isOptionObjective =", this.isOptionObjective);
  362. const randomKey = new Date().toString();
  363. if (this.isOptionObjective) this.objectiveRefreshKey = randomKey;
  364. else this.subjectiveRefreshKey = randomKey;
  365. this.dynamicHeaders = data.headers; // 开头的序号与姓名为固定列
  366. this.dynamicRows = data.datas;
  367. this.dynamicStatistics = data.stats;
  368. // 伪造一行,用行替换成统计行
  369. if (this.dynamicRows.length > 0) this.dynamicRows.push({});
  370. console.log(
  371. "resolveDynamicData this.dynamicHeaders,this.dynamicRows,this.dynamicStatistics",
  372. this.dynamicHeaders,
  373. this.dynamicRows,
  374. this.dynamicStatistics
  375. );
  376. },
  377. convertToBoolean(raw) {
  378. if (raw == "true" || raw == "True") return true;
  379. if (raw == "false" || raw == "False") return false;
  380. return !!raw;
  381. },
  382. },
  383. };
  384. </script>
  385. <style>
  386. </style>