recodeList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 老师考勤列表
  7. </h2>
  8. <div class="m-core">
  9. <save-form
  10. :inline="true"
  11. @submit="search"
  12. @reset="onReSet"
  13. ref="searchForm"
  14. :model="searchForm"
  15. >
  16. <el-form-item>
  17. <el-input
  18. v-model.trim="searchForm.search"
  19. clearable
  20. @keyup.enter.native="search"
  21. placeholder="老师课程名、课程编号"
  22. ></el-input>
  23. </el-form-item>
  24. <el-form-item prop="organId">
  25. <el-select
  26. class="multiple"
  27. v-model.trim="searchForm.organId"
  28. filterable
  29. clearable
  30. placeholder="请选择分部"
  31. >
  32. <el-option
  33. v-for="(item, index) in selects.branchs"
  34. :key="index"
  35. :label="item.name"
  36. :value="item.id"
  37. ></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-select
  42. v-model.trim="searchForm.courseScheduleType"
  43. clearable
  44. placeholder="请选择课程类型"
  45. >
  46. <el-option
  47. v-for="(item, index) in courseType"
  48. :key="index"
  49. :value="item.value"
  50. :label="item.label"
  51. ></el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-select
  56. v-model.trim="searchForm.signInStatus"
  57. clearable
  58. placeholder="签到状态"
  59. >
  60. <el-option :value="1" label="正常签到"></el-option>
  61. <el-option :value="0" label="异常签到"></el-option>
  62. <el-option :value="3" label="未签到"></el-option>
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item>
  66. <el-select
  67. v-model.trim="searchForm.signOutStatus"
  68. clearable
  69. placeholder="签退状态"
  70. >
  71. <el-option :value="1" label="正常签退"></el-option>
  72. <el-option :value="0" label="异常签退"></el-option>
  73. <el-option :value="3" label="未签退"></el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item>
  77. <el-date-picker
  78. v-model.trim="courseTime"
  79. style="width: 410px"
  80. type="daterange"
  81. value-format="yyyy-MM-dd"
  82. range-separator="至"
  83. start-placeholder="考勤开始日期"
  84. :picker-options="{
  85. firstDayOfWeek: 1,
  86. }"
  87. end-placeholder="考勤结束日期"
  88. >
  89. </el-date-picker>
  90. </el-form-item>
  91. <el-form-item>
  92. <el-button native-type="submit" type="danger">搜索</el-button>
  93. <el-button native-type="reset" type="primary">重置</el-button>
  94. </el-form-item>
  95. <el-form-item>
  96. <!-- <div class="newBand" @click="onExport">导出</div> -->
  97. <el-button
  98. @click="onExport"
  99. type="primary"
  100. v-permission="'export/queryTeacherAttendances'"
  101. style="background-color: #14928a; border: 1px solid #14928a"
  102. >导出</el-button
  103. >
  104. </el-form-item>
  105. </save-form>
  106. <div class="tableWrap">
  107. <el-table
  108. style="width: 100%"
  109. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  110. :data="tableList"
  111. >
  112. <el-table-column
  113. align="center"
  114. prop="organName"
  115. label="分部"
  116. ></el-table-column>
  117. <el-table-column align="center" prop="teacherName" label="老师名称">
  118. <template slot-scope="scope">
  119. <div>
  120. <copy-text>{{ scope.row.teacherName }}</copy-text>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. align="center"
  126. prop="courseScheduleId"
  127. label="课程编号"
  128. >
  129. <template slot-scope="scope">
  130. <div>
  131. <copy-text>{{ scope.row.courseScheduleId }}</copy-text>
  132. </div>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. align="center"
  137. prop="courseScheduleName"
  138. label="课程名称"
  139. >
  140. <template slot-scope="scope">
  141. <div>
  142. <copy-text>{{ scope.row.courseScheduleName }}</copy-text>
  143. </div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column
  147. align="center"
  148. prop="classDate"
  149. label="上课日期"
  150. ></el-table-column>
  151. <el-table-column
  152. align="center"
  153. prop="startClassTime"
  154. label="上课时间"
  155. >
  156. <template slot-scope="scope">
  157. <div>
  158. {{ scope.row.startClassTime + "-" + scope.row.endClassTime }}
  159. </div>
  160. </template>
  161. </el-table-column>
  162. <el-table-column
  163. align="center"
  164. prop="startClassTime"
  165. label="课程类型"
  166. >
  167. <template slot-scope="scope">
  168. <div>
  169. {{ scope.row.courseScheduleType | coursesType }}
  170. </div>
  171. </template>
  172. </el-table-column>
  173. <el-table-column align="center" label="签到时间">
  174. <template slot-scope="scope">
  175. <div>
  176. {{ scope.row.signInTime }}
  177. </div>
  178. </template>
  179. </el-table-column>
  180. <el-table-column align="center" label="签到状态">
  181. <template slot-scope="scope">
  182. <div>
  183. {{ scope.row.signInStatus | attendanceType }}
  184. </div>
  185. </template>
  186. </el-table-column>
  187. <el-table-column
  188. align="center"
  189. prop="startClassTime"
  190. label="签退时间"
  191. >
  192. <template slot-scope="scope">
  193. <div>
  194. {{ scope.row.signOutTime }}
  195. </div>
  196. </template>
  197. </el-table-column>
  198. <el-table-column align="center" label="签退状态">
  199. <template slot-scope="scope">
  200. <div>
  201. {{ scope.row.signOutStatus | attendanceOutType }}
  202. </div>
  203. </template>
  204. </el-table-column>
  205. <el-table-column
  206. align="center"
  207. prop="remark"
  208. label="备注"
  209. ></el-table-column>
  210. </el-table>
  211. <pagination
  212. sync
  213. :total.sync="rules.total"
  214. :page.sync="rules.page"
  215. :limit.sync="rules.limit"
  216. :page-sizes="rules.page_size"
  217. @pagination="getList"
  218. />
  219. </div>
  220. </div>
  221. </div>
  222. </template>
  223. <script>
  224. import axios from "axios";
  225. import { getToken } from "@/utils/auth";
  226. import pagination from "@/components/Pagination/index";
  227. import load from "@/utils/loading";
  228. import qs from "qs";
  229. import cleanDeep from 'clean-deep'
  230. import { getTeacher, getEmployeeOrgan } from "@/api/buildTeam";
  231. import { queryTeacherAttendances } from "@/api/recodeManager";
  232. import { courseType } from "@/utils/searchArray";
  233. let nowTime = new Date();
  234. nowTime =
  235. nowTime.getFullYear() +
  236. "-" +
  237. (nowTime.getMonth() + 1) +
  238. "-" +
  239. nowTime.getDate();
  240. export default {
  241. components: { pagination },
  242. data() {
  243. return {
  244. searchForm: {
  245. search: null,
  246. organId: null,
  247. signInStatus: null,
  248. signOutStatus: null,
  249. },
  250. courseTime: [nowTime, nowTime],
  251. courseType,
  252. // teacherList: [],
  253. tableList: [],
  254. organList: [],
  255. rules: {
  256. // 分页规则
  257. limit: 10, // 限制显示条数
  258. page: 1, // 当前页
  259. total: 0, // 总条数
  260. page_size: [10, 20, 40, 50], // 选择限制显示条数
  261. },
  262. };
  263. },
  264. computed: {
  265. isEmptyQuery() {
  266. return !Object.keys(cleanDeep({...this.searchForm})).length
  267. }
  268. },
  269. //生命周期 - 创建完成(可以访问当前this实例)
  270. created() {},
  271. //生命周期 - 挂载完成(可以访问DOM元素)
  272. mounted() {
  273. // getTeacher().then(res => {
  274. // if (res.code == 200) {
  275. // this.teacherList = res.data;
  276. // }
  277. // });
  278. // 获取分部
  279. // getEmployeeOrgan().then(res => {
  280. // if (res.code == 200) {
  281. // this.organList = res.data;
  282. // }
  283. // });
  284. this.$set(this.searchForm, 'search', this.$route.query.search)
  285. this.$store.dispatch("setBranchs");
  286. this.init();
  287. },
  288. activated() {
  289. this.init();
  290. },
  291. methods: {
  292. init() {
  293. this.getList();
  294. },
  295. getSearchValues() {
  296. let obj = {
  297. page: this.rules.page,
  298. rows: this.rules.limit,
  299. };
  300. Object.assign(obj, this.searchForm);
  301. if (this.courseTime && this.courseTime.length > 0) {
  302. obj.courseStartDate = this.courseTime[0];
  303. obj.courseEndDate = this.courseTime[1];
  304. }
  305. console.log(obj, this.$route.query.search)
  306. return obj
  307. },
  308. getList() {
  309. let obj = this.getSearchValues()
  310. if (this.isEmptyQuery) {
  311. this.$message.error("请至少选择一个条件");
  312. return
  313. }
  314. queryTeacherAttendances(obj).then((res) => {
  315. if (res.code == 200) {
  316. this.tableList = res.data.rows;
  317. this.rules.total = res.data.total;
  318. }
  319. });
  320. },
  321. search() {
  322. this.rules.page = 1;
  323. this.getList();
  324. },
  325. onReSet() {
  326. this.searchForm = {
  327. search: null,
  328. organIdList: null,
  329. signInStatus: null,
  330. signOutStatus: null,
  331. };
  332. this.courseTime = [nowTime, nowTime];
  333. this.$refs["searchForm"].resetFields();
  334. this.search();
  335. },
  336. onExport() {
  337. let obj = this.getSearchValues()
  338. if (this.isEmptyQuery) {
  339. this.$message.error("请至少选择一个条件");
  340. return
  341. }
  342. let url = "/api-web/export/queryTeacherAttendances";
  343. const options = {
  344. method: "POST",
  345. headers: {
  346. Authorization: getToken(),
  347. },
  348. params: obj,
  349. url,
  350. responseType: "blob",
  351. };
  352. this.$confirm("您确定导出考勤列表", "提示", {
  353. confirmButtonText: "确定",
  354. cancelButtonText: "取消",
  355. type: "warning",
  356. })
  357. .then(() => {
  358. load.startLoading();
  359. axios(options)
  360. .then((res) => {
  361. let blob = new Blob([res.data], {
  362. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  363. type: "application/vnd.ms-excel;charset=utf-8",
  364. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  365. });
  366. let text = new Response(blob).text();
  367. text.then((res) => {
  368. // 判断是否报错
  369. if (res.indexOf("code") != -1) {
  370. let json = JSON.parse(res);
  371. this.$message.error(json.msg);
  372. } else {
  373. let objectUrl = URL.createObjectURL(blob);
  374. let link = document.createElement("a");
  375. let fname = "考勤列表" + new Date().getTime()+'.xls'; //下载文件的名字
  376. link.href = objectUrl;
  377. link.setAttribute("download", fname);
  378. document.body.appendChild(link);
  379. link.click();
  380. }
  381. });
  382. load.endLoading();
  383. })
  384. .catch((error) => {
  385. this.$message.error("导出数据失败,请联系管理员");
  386. load.endLoading();
  387. });
  388. })
  389. .catch(() => {});
  390. },
  391. },
  392. };
  393. </script>
  394. <style lang='scss' scoped>
  395. </style>