recodeList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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.organId) {
  370. this.searchForm.organId = query.organId
  371. }
  372. if (query.start || query.end) {
  373. this.courseTime = [query.start, query.end]
  374. } else {
  375. this.courseTime = [nowTime, nowTime]
  376. }
  377. this.init();
  378. },
  379. activated() {
  380. this.init();
  381. },
  382. methods: {
  383. init() {
  384. this.getList();
  385. },
  386. getSearchValues() {
  387. let obj = {
  388. page: this.rules.page,
  389. rows: this.rules.limit,
  390. attendanceStatus: this.$route.query.attendanceStatus,
  391. visitFlag: this.$route.query.visitFlag,
  392. };
  393. Object.assign(obj, this.searchForm);
  394. if (this.courseTime && this.courseTime.length > 0) {
  395. obj.courseStartDate = this.courseTime[0];
  396. obj.courseEndDate = this.courseTime[1];
  397. }
  398. return obj
  399. },
  400. reloadSearch() {
  401. if (this.isEmptyQuery) {
  402. this.courseTime = [nowTime, nowTime]
  403. }
  404. this.getList()
  405. },
  406. getList() {
  407. let obj = this.getSearchValues()
  408. if (this.isEmptyQuery) {
  409. this.$message.error("请至少选择一个条件");
  410. return
  411. }
  412. queryTeacherAttendances(obj).then((res) => {
  413. if (res.code == 200) {
  414. this.tableList = res.data.rows;
  415. this.rules.total = res.data.total;
  416. }
  417. });
  418. },
  419. search() {
  420. this.rules.page = 1;
  421. this.getList();
  422. },
  423. onReSet() {
  424. this.searchForm = {
  425. search: null,
  426. organIdList: null,
  427. signInStatus: null,
  428. signOutStatus: null,
  429. jobNature: null,
  430. };
  431. this.courseTime = [nowTime, nowTime];
  432. this.$refs["searchForm"].resetFields();
  433. this.search();
  434. },
  435. hand(row) {
  436. this.handVisible = true
  437. this.detail = row
  438. },
  439. appeal(row) {
  440. this.appealVisible = true
  441. this.detail = row
  442. },
  443. async unappeal(row) {
  444. try {
  445. await this.$confirm('是否确认撤销申诉?', '提示', {
  446. type: 'warning'
  447. })
  448. await repealComplaints({
  449. courseScheduleId: row.courseScheduleId,
  450. userId: row.teacherId,
  451. })
  452. this.$message.success('撤销成功')
  453. this.getList()
  454. } catch (error) {}
  455. },
  456. onExport() {
  457. let obj = this.getSearchValues()
  458. if (this.isEmptyQuery) {
  459. this.$message.error("请至少选择一个条件");
  460. return
  461. }
  462. let url = "/api-web/export/queryTeacherAttendances";
  463. const options = {
  464. method: "POST",
  465. headers: {
  466. Authorization: getToken(),
  467. },
  468. params: obj,
  469. url,
  470. responseType: "blob",
  471. };
  472. this.$confirm("您确定导出考勤列表", "提示", {
  473. confirmButtonText: "确定",
  474. cancelButtonText: "取消",
  475. type: "warning",
  476. })
  477. .then(() => {
  478. load.startLoading();
  479. axios(options)
  480. .then((res) => {
  481. let blob = new Blob([res.data], {
  482. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  483. type: "application/vnd.ms-excel;charset=utf-8",
  484. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  485. });
  486. let text = new Response(blob).text();
  487. text.then((res) => {
  488. // 判断是否报错
  489. if (res.indexOf("code") != -1) {
  490. let json = JSON.parse(res);
  491. this.$message.error(json.msg);
  492. } else {
  493. let objectUrl = URL.createObjectURL(blob);
  494. let link = document.createElement("a");
  495. let fname = "考勤列表" + new Date().getTime()+'.xls'; //下载文件的名字
  496. link.href = objectUrl;
  497. link.setAttribute("download", fname);
  498. document.body.appendChild(link);
  499. link.click();
  500. }
  501. });
  502. load.endLoading();
  503. })
  504. .catch((error) => {
  505. this.$message.error("导出数据失败,请联系管理员");
  506. load.endLoading();
  507. });
  508. })
  509. .catch(() => {});
  510. },
  511. },
  512. };
  513. </script>
  514. <style lang='scss' scoped>
  515. </style>