recodeList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 老师考勤管理
  7. <filter-search
  8. @reload="reloadSearch"
  9. :keys="['attendanceStatus', 'visitFlag']"
  10. :moreKeys="['start', 'end', 'organId']"
  11. />
  12. </h2>
  13. <div class="m-core">
  14. <save-form
  15. :inline="true"
  16. @submit="search"
  17. @reset="onReSet"
  18. ref="searchForm"
  19. :model="searchForm"
  20. >
  21. <el-form-item prop="search">
  22. <el-input
  23. v-model.trim="searchForm.search"
  24. clearable
  25. @keyup.enter.native="
  26. (e) => {
  27. e.target.blur();
  28. $refs.searchForm.save();
  29. search();
  30. }
  31. "
  32. placeholder="课程名称/编号"
  33. ></el-input>
  34. </el-form-item>
  35. <el-form-item prop="teacherId">
  36. <remote-search
  37. :commit="'setTeachers'"
  38. v-model="searchForm.teacherId"
  39. />
  40. </el-form-item>
  41. <el-form-item prop="organId">
  42. <el-select
  43. class="multiple"
  44. v-model.trim="searchForm.organId"
  45. filterable
  46. clearable
  47. placeholder="请选择分部"
  48. >
  49. <el-option
  50. v-for="(item, index) in selects.branchs"
  51. :key="index"
  52. :label="item.name"
  53. :value="item.id"
  54. ></el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item prop="courseScheduleType">
  58. <el-select
  59. v-model.trim="searchForm.courseScheduleType"
  60. clearable
  61. placeholder="请选择课程类型"
  62. >
  63. <el-option
  64. v-for="(item, index) in courseType"
  65. :key="index"
  66. :value="item.value"
  67. :label="item.label"
  68. ></el-option>
  69. </el-select>
  70. </el-form-item>
  71. <el-form-item prop="jobNature">
  72. <el-select
  73. v-model.trim="searchForm.jobNature"
  74. filterable
  75. clearable
  76. placeholder="工作类型"
  77. >
  78. <el-option
  79. v-for="item in jobNature"
  80. :key="item.value"
  81. :label="item.label"
  82. :value="item.value"
  83. ></el-option>
  84. </el-select>
  85. </el-form-item>
  86. <el-form-item prop="signInStatus">
  87. <el-select
  88. v-model.trim="searchForm.signInStatus"
  89. clearable
  90. placeholder="签到状态"
  91. >
  92. <el-option :value="1" label="正常签到"></el-option>
  93. <el-option :value="0" label="异常签到"></el-option>
  94. <el-option :value="3" label="未签到"></el-option>
  95. </el-select>
  96. </el-form-item>
  97. <el-form-item prop="signOutStatus">
  98. <el-select
  99. v-model.trim="searchForm.signOutStatus"
  100. clearable
  101. placeholder="签退状态"
  102. >
  103. <el-option :value="1" label="正常签退"></el-option>
  104. <el-option :value="0" label="异常签退"></el-option>
  105. <el-option :value="3" label="未签退"></el-option>
  106. </el-select>
  107. </el-form-item>
  108. <el-form-item prop="courseTime">
  109. <el-date-picker
  110. v-model.trim="searchForm.courseTime"
  111. style="width: 410px"
  112. type="daterange"
  113. value-format="yyyy-MM-dd"
  114. range-separator="至"
  115. start-placeholder="考勤开始日期"
  116. :picker-options="{
  117. firstDayOfWeek: 1,
  118. }"
  119. end-placeholder="考勤结束日期"
  120. >
  121. </el-date-picker>
  122. </el-form-item>
  123. <el-form-item>
  124. <el-button native-type="submit" type="danger">搜索</el-button>
  125. <el-button native-type="reset" type="primary">重置</el-button>
  126. </el-form-item>
  127. <el-form-item>
  128. <!-- <div class="newBand" @click="onExport">导出</div> -->
  129. <el-button
  130. @click="onExport"
  131. type="primary"
  132. v-permission="'export/queryTeacherAttendances'"
  133. >导出</el-button
  134. >
  135. </el-form-item>
  136. </save-form>
  137. <div class="tableWrap">
  138. <el-table
  139. style="width: 100%"
  140. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  141. :data="tableList"
  142. >
  143. <el-table-column
  144. align="center"
  145. prop="organName"
  146. label="分部"
  147. ></el-table-column>
  148. <el-table-column align="center" prop="teacherName" label="老师名称">
  149. <template slot-scope="scope">
  150. <div>
  151. <copy-text>{{ scope.row.teacherName }}</copy-text>
  152. </div>
  153. </template>
  154. </el-table-column>
  155. <el-table-column
  156. align="center"
  157. prop="courseScheduleId"
  158. label="课程编号"
  159. >
  160. <template slot-scope="scope">
  161. <div>
  162. <copy-text>{{ scope.row.courseScheduleId }}</copy-text>
  163. </div>
  164. </template>
  165. </el-table-column>
  166. <el-table-column
  167. align="center"
  168. prop="courseScheduleName"
  169. label="课程名称"
  170. >
  171. <template slot-scope="scope">
  172. <div>
  173. <copy-text>{{ scope.row.courseScheduleName }}</copy-text>
  174. </div>
  175. </template>
  176. </el-table-column>
  177. <el-table-column
  178. align="center"
  179. prop="classDate"
  180. label="上课日期"
  181. ></el-table-column>
  182. <el-table-column
  183. align="center"
  184. prop="startClassTime"
  185. label="上课时间"
  186. >
  187. <template slot-scope="scope">
  188. <div>
  189. {{ scope.row.startClassTime + "-" + scope.row.endClassTime }}
  190. </div>
  191. </template>
  192. </el-table-column>
  193. <el-table-column
  194. align="center"
  195. prop="startClassTime"
  196. label="课程类型"
  197. >
  198. <template slot-scope="scope">
  199. <div>
  200. {{ scope.row.courseScheduleType | coursesType }}
  201. </div>
  202. </template>
  203. </el-table-column>
  204. <el-table-column align="center" label="工作类型">
  205. <template slot-scope="scope">{{
  206. scope.row.jobNature | jobNature
  207. }}</template>
  208. </el-table-column>
  209. <el-table-column align="center" label="签到时间">
  210. <template slot-scope="scope">
  211. <div>
  212. {{ scope.row.signInTime }}
  213. </div>
  214. </template>
  215. </el-table-column>
  216. <el-table-column align="center" label="签到状态">
  217. <template slot-scope="scope">
  218. <div v-if="scope.row.courseScheduleStatus != 'NOT_START'">
  219. {{ scope.row.signInStatus | attendanceType }}
  220. </div>
  221. </template>
  222. </el-table-column>
  223. <el-table-column
  224. align="center"
  225. prop="startClassTime"
  226. label="签退时间"
  227. >
  228. <template slot-scope="scope">
  229. <div>
  230. {{ scope.row.signOutTime }}
  231. </div>
  232. </template>
  233. </el-table-column>
  234. <el-table-column align="center" label="签退状态">
  235. <template slot-scope="scope">
  236. <div v-if="scope.row.courseScheduleStatus != 'NOT_START'">
  237. {{ scope.row.signOutStatus | attendanceOutType }}
  238. </div>
  239. </template>
  240. </el-table-column>
  241. <el-table-column align="center" label="申诉状态">
  242. <template slot-scope="scope">
  243. <div>
  244. {{ $constant.complaintsStatus[scope.row.complaintsStatus] }}
  245. </div>
  246. </template>
  247. </el-table-column>
  248. <el-table-column
  249. align="center"
  250. prop="remark"
  251. label="备注"
  252. ></el-table-column>
  253. <el-table-column
  254. align="center"
  255. label="操作"
  256. fixed="right"
  257. width="220px"
  258. >
  259. <template slot-scope="scope">
  260. <auth auths="teacherAttendance/repealComplaints">
  261. <el-button
  262. type="text"
  263. v-if="
  264. scope.row.jobNature != 'FULL_TIME' &&
  265. scope.row.complaintsStatus == 2
  266. "
  267. @click="unappeal(scope.row)"
  268. >撤销申诉</el-button
  269. >
  270. </auth>
  271. <auth auths="teacherAttendance/addComplaints">
  272. <el-button
  273. v-if="
  274. (scope.row.complaintsStatus == null ||
  275. scope.row.complaintsStatus == 3)
  276. "
  277. type="text"
  278. @click="appeal(scope.row)"
  279. >申诉</el-button
  280. >
  281. </auth>
  282. <auth auths="teacherAttendance/update">
  283. <el-button type="text" @click="hand(scope.row)"
  284. >处理意见</el-button
  285. >
  286. </auth>
  287. </template>
  288. </el-table-column>
  289. </el-table>
  290. <el-dialog title="申诉" width="400px" :visible.sync="appealVisible">
  291. <appeal
  292. v-if="appealVisible && detail"
  293. :detail="detail"
  294. @close="appealVisible = false"
  295. @submited="getList"
  296. />
  297. </el-dialog>
  298. <el-dialog title="处理意见" width="400px" :visible.sync="handVisible">
  299. <hand
  300. v-if="handVisible && detail"
  301. :detail="detail"
  302. @close="handVisible = false"
  303. @submited="getList"
  304. />
  305. </el-dialog>
  306. <pagination
  307. sync
  308. :total.sync="rules.total"
  309. :page.sync="rules.page"
  310. :limit.sync="rules.limit"
  311. :page-sizes="rules.page_size"
  312. @pagination="getList"
  313. />
  314. </div>
  315. </div>
  316. </div>
  317. </template>
  318. <script>
  319. import axios from "axios";
  320. import { getToken, getTenantId } from "@/utils/auth";
  321. import pagination from "@/components/Pagination/index";
  322. import load from "@/utils/loading";
  323. import qs from "qs";
  324. import cleanDeep from "clean-deep";
  325. import { getTeacher, getEmployeeOrgan } from "@/api/buildTeam";
  326. import { queryTeacherAttendances } from "@/api/recodeManager";
  327. import { jobNature, courseType } from "@/utils/searchArray";
  328. import { repealComplaints } from "./api";
  329. import appeal from "./modals/appeal";
  330. import hand from "./modals/hand";
  331. import { getTimes } from "@/utils";
  332. let nowTime = new Date();
  333. nowTime =
  334. nowTime.getFullYear() +
  335. "-" +
  336. (nowTime.getMonth() + 1) +
  337. "-" +
  338. nowTime.getDate();
  339. export default {
  340. components: { pagination, appeal, hand },
  341. data() {
  342. return {
  343. searchForm: {
  344. search: null,
  345. organId: null,
  346. signInStatus: null,
  347. signOutStatus: null,
  348. jobNature: null,
  349. courseTime: [],
  350. },
  351. detail: null,
  352. appealVisible: false,
  353. handVisible: false,
  354. jobNature: jobNature, // 工作类型
  355. courseType,
  356. // teacherList: [],
  357. tableList: [],
  358. organList: [],
  359. rules: {
  360. // 分页规则
  361. limit: 10, // 限制显示条数
  362. page: 1, // 当前页
  363. total: 0, // 总条数
  364. page_size: [10, 20, 40, 50], // 选择限制显示条数
  365. },
  366. };
  367. },
  368. computed: {
  369. isEmptyQuery() {
  370. return (
  371. !Object.keys(
  372. cleanDeep({
  373. ...this.searchForm,
  374. // courseTime: this.courseTime,
  375. })
  376. ).length && !this.teacherAttendanceId
  377. );
  378. },
  379. teacherAttendanceId() {
  380. return this.$route.query.teacherAttendanceId;
  381. },
  382. },
  383. //生命周期 - 创建完成(可以访问当前this实例)
  384. created() {
  385. if (this.searchForm.courseTime.length <= 0)
  386. this.searchForm.courseTime = [nowTime, nowTime];
  387. },
  388. //生命周期 - 挂载完成(可以访问DOM元素)
  389. mounted() {
  390. // getTeacher().then(res => {
  391. // if (res.code == 200) {
  392. // this.teacherList = res.data;
  393. // }
  394. // });
  395. // 获取分部
  396. // getEmployeeOrgan().then(res => {
  397. // if (res.code == 200) {
  398. // this.organList = res.data;
  399. // }
  400. // });
  401. const { query } = this.$route;
  402. this.$store.dispatch("setBranchs");
  403. if (query.organId) {
  404. this.searchForm.organId = query.organId;
  405. }
  406. if (query.start || query.end) {
  407. this.searchForm.courseTime = [query.start, query.end];
  408. } else {
  409. }
  410. this.init();
  411. },
  412. methods: {
  413. init() {
  414. this.getList();
  415. },
  416. getSearchValues() {
  417. const { courseTime, ...rest } = this.searchForm;
  418. let obj = {
  419. ...rest,
  420. page: this.rules.page,
  421. rows: this.rules.limit,
  422. attendanceStatus: this.$route.query.attendanceStatus,
  423. visitFlag: this.$route.query.visitFlag,
  424. ...getTimes(courseTime, ["courseStartDate", "courseEndDate"]),
  425. };
  426. return obj;
  427. },
  428. reloadSearch() {
  429. if (this.isEmptyQuery) {
  430. this.courseTime = [nowTime, nowTime];
  431. }
  432. if (!notSetTime) {
  433. this.searchForm.timer = [nowTime, nowTime];
  434. }
  435. this.rules.page = 1;
  436. this.getList();
  437. },
  438. getList() {
  439. let obj = this.getSearchValues();
  440. if (this.isEmptyQuery) {
  441. this.$message.error("请至少选择一个条件");
  442. return;
  443. }
  444. queryTeacherAttendances(obj).then((res) => {
  445. if (res.code == 200) {
  446. this.tableList = res.data.rows;
  447. this.rules.total = res.data.total;
  448. }
  449. });
  450. },
  451. search() {
  452. this.rules.page = 1;
  453. this.getList();
  454. },
  455. onReSet() {
  456. this.$refs["searchForm"].resetFields();
  457. this.searchForm.courseTime = [nowTime, nowTime];
  458. this.search();
  459. },
  460. hand(row) {
  461. this.detail = row;
  462. this.handVisible = true;
  463. },
  464. appeal(row) {
  465. this.appealVisible = true;
  466. this.detail = row;
  467. },
  468. async unappeal(row) {
  469. try {
  470. await this.$confirm("是否确认撤销申诉?", "提示", {
  471. type: "warning",
  472. });
  473. await repealComplaints({
  474. courseScheduleId: row.courseScheduleId,
  475. userId: row.teacherId,
  476. });
  477. this.$message.success("撤销成功");
  478. this.getList();
  479. } catch (error) {}
  480. },
  481. onExport() {
  482. let obj = this.getSearchValues();
  483. if (this.isEmptyQuery) {
  484. this.$message.error("请至少选择一个条件");
  485. return;
  486. }
  487. let url = "/api-web/export/queryTeacherAttendances";
  488. const options = {
  489. method: "POST",
  490. headers: {
  491. Authorization: getToken(),
  492. tenantId: getTenantId()
  493. },
  494. params: obj,
  495. url,
  496. responseType: "blob",
  497. };
  498. this.$confirm("您确定导出考勤列表", "提示", {
  499. confirmButtonText: "确定",
  500. cancelButtonText: "取消",
  501. type: "warning",
  502. })
  503. .then(() => {
  504. load.startLoading();
  505. axios(options)
  506. .then((res) => {
  507. let blob = new Blob([res.data], {
  508. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  509. type: "application/vnd.ms-excel;charset=utf-8",
  510. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  511. });
  512. let text = new Response(blob).text();
  513. text.then((res) => {
  514. // 判断是否报错
  515. if (res.indexOf("code") != -1) {
  516. let json = JSON.parse(res);
  517. if(json.code == 403) {
  518. this.$message.error(`登录过期,请重新登录!`)
  519. setTimeout(() => {
  520. this.$store.dispatch('user/resetToken').then(() => {
  521. location.reload()
  522. })
  523. }, 1000);
  524. return
  525. }
  526. this.$message.error(json.msg);
  527. } else {
  528. let objectUrl = URL.createObjectURL(blob);
  529. let link = document.createElement("a");
  530. let fname = "考勤列表" + new Date().getTime() + ".xls"; //下载文件的名字
  531. link.href = objectUrl;
  532. link.setAttribute("download", fname);
  533. document.body.appendChild(link);
  534. link.click();
  535. }
  536. });
  537. load.endLoading();
  538. })
  539. .catch((error) => {
  540. this.$message.error("导出数据失败,请联系管理员");
  541. load.endLoading();
  542. });
  543. })
  544. .catch(() => {});
  545. },
  546. },
  547. };
  548. </script>
  549. <style lang='scss' scoped>
  550. </style>