classReport.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div style="padding-bottom: 20px">
  3. <div class="search">
  4. <div class="student_search">
  5. <div>班级筛选</div>
  6. <el-select v-model="classChoose" @change="searchStudent">
  7. <el-option label="全部" value="">全部</el-option>
  8. <el-option
  9. v-for="(c, cIndex) in classJuri"
  10. :key="cIndex"
  11. :value="c.id"
  12. :label="c.name"
  13. ></el-option>
  14. </el-select>
  15. </div>
  16. <div class="rightSearch">
  17. <div class="searchImg">
  18. <img src="../../../assets/icon/search.png" alt="" />
  19. </div>
  20. <el-input v-model="sName" placeholder="请输入课程名称"></el-input>
  21. <el-button size="mini" type="primary" @click="searchStudent"
  22. >查询</el-button
  23. >
  24. </div>
  25. </div>
  26. <el-table
  27. :data="tableData"
  28. border
  29. :fit="true"
  30. v-loading="isLoading"
  31. style="width: 100%"
  32. :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
  33. :row-class-name="tableRowClassName"
  34. >
  35. <el-table-column prop="cName" align="center" label="班级" min-width="25%">
  36. </el-table-column>
  37. <el-table-column
  38. prop="course"
  39. align="center"
  40. label="课程"
  41. min-width="40%"
  42. >
  43. </el-table-column>
  44. <el-table-column label="操作" align="center" min-width="25%">
  45. <template slot-scope="scope">
  46. <el-button
  47. size="mini"
  48. type="primary"
  49. @click="lookEvaCourse(scope.row.id, scope.row.courseid)"
  50. >报告</el-button
  51. >
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <div class="student_page">
  56. <el-pagination
  57. background
  58. layout="prev, pager, next"
  59. :page-size="10"
  60. :total="total"
  61. v-if="page"
  62. @current-change="handleCurrentChange"
  63. ></el-pagination>
  64. </div>
  65. <el-dialog
  66. title="选择学生"
  67. :visible.sync="dialogVisible"
  68. :append-to-body="true"
  69. width="650px"
  70. :before-close="handleClose"
  71. class="dialog_diy"
  72. >
  73. <div v-if="!isLoading1">
  74. <div v-if="studentJuri.length == 0">暂无数据</div>
  75. <el-table
  76. v-else
  77. :data="studentJuri"
  78. border
  79. v-loading="isLoading1"
  80. style="width: 100%; margin-top: 10px"
  81. :row-class-name="tableRowClassName"
  82. >
  83. <el-table-column
  84. prop="sName"
  85. align="center"
  86. label="姓名"
  87. min-width="25%"
  88. >
  89. </el-table-column>
  90. <el-table-column label="选择" align="center" min-width="25%">
  91. <template slot-scope="scope">
  92. <input
  93. type="checkbox"
  94. :id="scope.row.userid"
  95. :value="scope.row.sName"
  96. @change="isChooseS(scope.row.userid)"
  97. />
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. </div>
  102. <div v-else>正在加载数据中...</div>
  103. <span slot="footer" class="dialog-footer">
  104. <el-button @click="dialogVisible = false">取 消</el-button>
  105. <el-button type="primary" @click="getCStudentReport">确定</el-button>
  106. </span>
  107. </el-dialog>
  108. </div>
  109. </template>
  110. <script>
  111. export default {
  112. props: ["ooid","checkid"],
  113. data() {
  114. return {
  115. sName: "",
  116. classChoose: "",
  117. isChooseClass: "",
  118. page: 1,
  119. total: 0,
  120. classJuri: [],
  121. tableData: [],
  122. dialogVisible: false,
  123. isLoading: false,
  124. isLoading1: false,
  125. isChooseList: [],
  126. studentJuri: [],
  127. };
  128. },
  129. watch: {
  130. ooid: {
  131. immediate: true,
  132. deep: true,
  133. handler(newValue, oldValue) {
  134. this.getClass();
  135. this.getCData();
  136. this.$forceUpdate();
  137. },
  138. },
  139. },
  140. methods: {
  141. tableRowClassName({ row, rowIndex }) {
  142. if ((rowIndex + 1) % 2 === 0) {
  143. return "even_row";
  144. } else {
  145. return "";
  146. }
  147. },
  148. getCStudentReport() {
  149. if (this.isChooseList.length > 0) {
  150. this.$emit("getCStReport", this.isChooseList, this.isChooseCourseid);
  151. this.dialogVisible = false;
  152. } else {
  153. this.$message.error("请选择至少一项课程!");
  154. }
  155. },
  156. handleClose(done) {
  157. done();
  158. },
  159. handleCurrentChange(val) {
  160. this.page = val;
  161. this.getCData();
  162. },
  163. searchStudent() {
  164. this.page = 1;
  165. this.getCData();
  166. },
  167. lookEvaCourse(id, courseid) {
  168. this.isChooseClass = id;
  169. this.isChooseCourseid = courseid;
  170. this.getSData();
  171. this.dialogVisible = true;
  172. },
  173. isChooseS(uid) {
  174. if (this.isChooseList.length > 0) {
  175. if (this.isChooseList.indexOf(uid) == -1) {
  176. this.isChooseList.push(uid);
  177. } else {
  178. this.isChooseList.splice(this.isChooseList.indexOf(uid), 1);
  179. }
  180. } else {
  181. this.isChooseList.push(uid);
  182. }
  183. this.$forceUpdate();
  184. },
  185. getClass() {
  186. let params = {
  187. oid: this.ooid,
  188. };
  189. this.ajax
  190. .get(this.$store.state.api + "selectClassBySchool", params)
  191. .then((res) => {
  192. this.classJuri = res.data[0];
  193. })
  194. .catch((err) => {
  195. console.error(err);
  196. });
  197. },
  198. getSData() {
  199. this.isLoading1 = true;
  200. let params = {
  201. cid: this.isChooseClass,
  202. courseid: this.isChooseCourseid,
  203. };
  204. this.ajax
  205. .get(this.$store.state.api + "selectCStudent", params)
  206. .then((res) => {
  207. this.isLoading1 = false;
  208. this.studentJuri = [];
  209. for (var i = 0; i < res.data[0].length; i++) {
  210. this.studentJuri.push(res.data[0][i]);
  211. }
  212. })
  213. .catch((err) => {
  214. this.isLoading1 = false;
  215. console.error(err);
  216. });
  217. },
  218. getCData() {
  219. this.isLoading = true;
  220. let params = {
  221. cu: this.sName,
  222. cn: this.classChoose,
  223. oid: this.ooid,
  224. page: this.page,
  225. };
  226. this.ajax
  227. .get(this.$store.state.api + "selectCr", params)
  228. .then((res) => {
  229. this.isLoading = false;
  230. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  231. this.tableData = res.data[0];
  232. })
  233. .catch((err) => {
  234. this.isLoading = false;
  235. console.error(err);
  236. });
  237. },
  238. },
  239. created() {
  240. if(this.checkid){
  241. this.classChoose = this.checkid
  242. }
  243. this.getClass();
  244. this.getCData();
  245. },
  246. };
  247. </script>
  248. <style scoped>
  249. .dialog_diy >>> .el-dialog__header {
  250. padding: 9px 20px 10px;
  251. background: #32455b !important;
  252. }
  253. .dialog_diy >>> .el-dialog__title {
  254. color: #fff;
  255. font-size: 15px;
  256. }
  257. .dialog_diy >>> .el-dialog__headerbtn {
  258. top: 14px;
  259. }
  260. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close {
  261. color: #fff;
  262. }
  263. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover {
  264. color: #fff;
  265. }
  266. .check_diy >>> .el-dialog__body {
  267. padding-bottom: 0;
  268. }
  269. .dialog_diy >>> .el-dialog__body,
  270. .dialog_diy >>> .el-dialog__footer {
  271. background: #fafafa;
  272. }
  273. .search {
  274. display: flex;
  275. flex-direction: row;
  276. flex-wrap: nowrap;
  277. align-items: center;
  278. justify-content: space-between;
  279. margin: 0 0 20px 0;
  280. }
  281. .search > div:nth-child(2) {
  282. position: relative;
  283. }
  284. .searchImg {
  285. width: 25px;
  286. height: 25px;
  287. position: absolute;
  288. z-index: 9;
  289. top: 8px;
  290. left: 5px;
  291. }
  292. .searchImg > img {
  293. width: 100%;
  294. height: 100%;
  295. }
  296. .search > div:nth-child(2) >>> .el-input__inner {
  297. width: 250px;
  298. text-indent: 20px;
  299. }
  300. .el-table >>> .even_row {
  301. background-color: #f1f1f1;
  302. }
  303. .student_search {
  304. display: flex;
  305. flex-direction: row;
  306. flex-wrap: nowrap;
  307. align-items: center;
  308. }
  309. .student_search > div:nth-child(1) {
  310. margin-right: 10px;
  311. }
  312. .rightSearch {
  313. display: flex;
  314. flex-direction: row;
  315. flex-wrap: nowrap;
  316. align-items: center;
  317. }
  318. .rightSearch >>> .el-button {
  319. margin-left: 5px;
  320. height: 35px;
  321. width: 80px;
  322. font-size: 14px;
  323. }
  324. .student_page {
  325. margin-top: 10px;
  326. }
  327. </style>