recodeList.vue 16 KB

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