index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div>
  3. <div class="d-flex flex-between pt7">
  4. <div><el-button type="primary" @click="exportData">导出</el-button></div>
  5. <el-form :inline="true" :model="firstForm">
  6. <el-form-item class="mr10" label="">
  7. <el-select
  8. v-model="firstForm.class"
  9. placeholder="请选择班级"
  10. @change="getListData"
  11. >
  12. <el-option
  13. v-for="item in classList"
  14. :label="item.class_name"
  15. :value="item.class_num"
  16. ></el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item class="mr10" label="">
  20. <el-select
  21. v-model="firstForm.type"
  22. placeholder="请选择检查类别"
  23. @change="getListData"
  24. >
  25. <el-option
  26. v-for="item in typeList"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value"
  30. ></el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item class="mr10" label="">
  34. <el-date-picker
  35. v-model="firstForm.time"
  36. @change="getTime"
  37. type="daterange"
  38. value-format="yyyy-MM-dd"
  39. range-separator="至"
  40. start-placeholder="开始日期"
  41. end-placeholder="结束日期"
  42. >
  43. </el-date-picker>
  44. </el-form-item>
  45. <el-button type="primary" class="ml5 mb20" @click="getListData"
  46. >搜索</el-button
  47. >
  48. </el-form>
  49. </div>
  50. <el-table
  51. @selection-change="handleSelectionChange"
  52. :data="firstTable"
  53. v-loading="loading"
  54. tooltip-effect="dark"
  55. style="width: 100%"
  56. >
  57. <el-table-column type="selection" align="center" width="55">
  58. </el-table-column>
  59. <el-table-column
  60. label="晨午检"
  61. prop="xdcbj_tjlx"
  62. width="100"
  63. ></el-table-column>
  64. <el-table-column label="班级" prop="class_name" width="150">
  65. </el-table-column>
  66. <el-table-column label="体检日期" prop="xdcbj_tjrq" width="150">
  67. </el-table-column>
  68. <el-table-column
  69. label="应到人数"
  70. prop="xdcbj_ydrs"
  71. align="center"
  72. width=""
  73. >
  74. </el-table-column>
  75. <el-table-column
  76. label="实到人数"
  77. prop="xdcbj_sdrs"
  78. align="center"
  79. width=""
  80. >
  81. </el-table-column>
  82. <el-table-column
  83. label="因病缺勤人数"
  84. prop="xdcbj_ybqqrs"
  85. align="center"
  86. width=""
  87. >
  88. </el-table-column>
  89. <el-table-column
  90. label="因事缺勤人数"
  91. align="center"
  92. prop="xdcbj_ysqqrs"
  93. width=""
  94. >
  95. </el-table-column>
  96. <el-table-column
  97. label="异常学生人数"
  98. align="center"
  99. prop="xdcbj_ysqqrs"
  100. width=""
  101. >
  102. </el-table-column>
  103. <el-table-column label="操作" width="150">
  104. <template slot-scope="scope">
  105. <el-button type="text" @click="toClass(scope.row)">查看 </el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <footer
  110. class="flex-item-none"
  111. style="display: flex; justify-content: flex-end; margin-top: 30px"
  112. >
  113. <el-pagination
  114. background
  115. layout="total,prev, pager, next"
  116. :page-size="limit"
  117. :total="total"
  118. :current-page.sync="cur_page"
  119. @current-change="handleCurrentChange"
  120. ></el-pagination>
  121. </footer>
  122. </div>
  123. </template>
  124. <script>
  125. import { cj_bj, class_list } from "./api";
  126. import { useUserStore } from "@/stores/user";
  127. const { token, real_name } = useUserStore();
  128. export default {
  129. name: "index",
  130. data() {
  131. return {
  132. limit: 10,
  133. total: 0,
  134. cur_page: 1,
  135. loading: false,
  136. grade_id: "",
  137. firstForm: {
  138. class: "",
  139. type: "",
  140. time: ["", ""],
  141. },
  142. classList: [],
  143. typeList: [
  144. {
  145. label: "全部",
  146. value: 0,
  147. },
  148. {
  149. label: "晨检",
  150. value: 1,
  151. },
  152. {
  153. label: "午检",
  154. value: 2,
  155. },
  156. ],
  157. firstTable: [],
  158. curDate: "",
  159. multipleSelection: [],
  160. };
  161. },
  162. methods: {
  163. handleSelectionChange(val) {
  164. this.multipleSelection = [];
  165. val.forEach((item) => {
  166. this.multipleSelection.push(item.class_id);
  167. });
  168. },
  169. getTimeFormat() {
  170. var date = new Date();
  171. var month = date.getMonth() + 1;
  172. var strDate = date.getDate();
  173. if (month >= 1 && month <= 9) {
  174. month = "0" + month;
  175. }
  176. if (strDate >= 0 && strDate <= 9) {
  177. strDate = "0" + strDate;
  178. }
  179. this.firstForm.time = [
  180. date.getFullYear() + "-" + month + "-" + strDate,
  181. date.getFullYear() + "-" + month + "-" + strDate,
  182. ];
  183. },
  184. getClassList() {
  185. let data = {
  186. grade_id: this.grade_id,
  187. page: 1,
  188. limit: 999,
  189. };
  190. class_list(data).then((res) => {
  191. if (res.code == 1) {
  192. this.classList = res.data.page_data;
  193. // let obj = {
  194. // class_id: "",
  195. // class_name: "",
  196. // };
  197. // this.classList.unshift(obj);
  198. }
  199. });
  200. },
  201. getListData() {
  202. this.loading = true;
  203. let data = {
  204. page: this.cur_page,
  205. limit: this.limit,
  206. grade_id: this.grade_id,
  207. class_id: this.firstForm.class,
  208. xdcbj_tjlx: this.firstForm.type,
  209. xdcbj_tjrq: this.curDate,
  210. };
  211. if (this.firstForm.time.length > 1) {
  212. data.xdcbj_tjrq =
  213. this.firstForm.time[0] + " - " + this.firstForm.time[1];
  214. } else {
  215. data.xdcbj_tjrq = "";
  216. }
  217. cj_bj(data).then((res) => {
  218. this.loading = false;
  219. if (res.code == 1) {
  220. this.firstTable = res.data.page_data;
  221. this.cur_page = Number(res.data.page_now);
  222. this.total = Number(res.data.total_rows);
  223. }
  224. });
  225. },
  226. handleCurrentChange(val) {
  227. this.cur_page = val;
  228. this.getListData();
  229. },
  230. getTime() {
  231. if (!this.firstForm.time) {
  232. this.firstForm.time = ["", ""];
  233. }
  234. this.cur_page = 1;
  235. this.getListData();
  236. },
  237. exportData() {
  238. let time = "";
  239. if (this.firstForm.time.length > 1) {
  240. time = this.firstForm.time[0] + " - " + this.firstForm.time[1];
  241. } else {
  242. time = "";
  243. }
  244. let link =
  245. window.globalVariables.api +
  246. "/xddy/dygl_cjxt_bj/index?api=xls&page=1&limit=10000&token=" +
  247. token +
  248. "&grade_id=" +
  249. this.grade_id +
  250. "&class_id=" +
  251. this.multipleSelection.join(",") +
  252. "&xdcbj_tjlx=" +
  253. this.firstForm.type +
  254. "&xdcbj_tjrq=" +
  255. time;
  256. window.open(link, "_self");
  257. },
  258. toClass(item) {
  259. this.$router.push({
  260. name: "cjxt_tjdj_bjck",
  261. params: { grade_id: item.grade_id, class_id: item.class_id },
  262. });
  263. },
  264. },
  265. mounted() {
  266. this.getTimeFormat();
  267. if (this.$route.params.id != "") {
  268. this.grade_id = this.$route.params.id;
  269. this.getClassList();
  270. this.getListData();
  271. }
  272. },
  273. };
  274. </script>
  275. <style scoped>
  276. ::v-deep .el-input {
  277. width: 160px;
  278. }
  279. ::v-deep .el-date-editor.el-input,
  280. .el-date-editor.el-input__inner {
  281. width: 300px;
  282. }
  283. ::v-deep .el-date-editor .el-range-separator {
  284. width: 8%;
  285. }
  286. </style>