recodeList.vue 16 KB

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