recodeList.vue 16 KB

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