recodeList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 老师考勤列表
  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. >
  242. <template slot-scope="scope" v-if="scope.row.jobNature === 'PART_TIME'">
  243. <el-button type="text" v-if="scope.row.complaintsStatus ==2 " @click="unappeal(scope.row)">撤销申诉</el-button>
  244. <el-button v-if="scope.row.complaintsStatus == '' || scope.row.complaintsStatus == 3" type="text" @click="appeal(scope.row)">申诉</el-button>
  245. </template>
  246. </el-table-column>
  247. </el-table>
  248. <el-dialog title="申诉" :visible.sync="appealVisible">
  249. <appeal
  250. v-if="appealVisible && detail"
  251. :detail="detail"
  252. @close="appealVisible = false"
  253. @submited="getList"
  254. />
  255. </el-dialog>
  256. <pagination
  257. sync
  258. :total.sync="rules.total"
  259. :page.sync="rules.page"
  260. :limit.sync="rules.limit"
  261. :page-sizes="rules.page_size"
  262. @pagination="getList"
  263. />
  264. </div>
  265. </div>
  266. </div>
  267. </template>
  268. <script>
  269. import axios from "axios";
  270. import { getToken } from "@/utils/auth";
  271. import pagination from "@/components/Pagination/index";
  272. import load from "@/utils/loading";
  273. import qs from "qs";
  274. import { getTeacher, getEmployeeOrgan } from "@/api/buildTeam";
  275. import { queryTeacherAttendances } from "@/api/recodeManager";
  276. import { jobNature, courseType } from "@/utils/searchArray";
  277. import { repealComplaints } from './api'
  278. import appeal from './modals/appeal'
  279. let nowTime = new Date();
  280. nowTime =
  281. nowTime.getFullYear() +
  282. "-" +
  283. (nowTime.getMonth() + 1) +
  284. "-" +
  285. nowTime.getDate();
  286. export default {
  287. components: { pagination, appeal },
  288. data() {
  289. return {
  290. searchForm: {
  291. search: null,
  292. organId: null,
  293. signInStatus: null,
  294. signOutStatus: null,
  295. jobNature: null,
  296. },
  297. detail: null,
  298. appealVisible: false,
  299. jobNature: jobNature, // 工作类型
  300. courseTime: [nowTime, nowTime],
  301. courseType,
  302. // teacherList: [],
  303. tableList: [],
  304. organList: [],
  305. rules: {
  306. // 分页规则
  307. limit: 10, // 限制显示条数
  308. page: 1, // 当前页
  309. total: 0, // 总条数
  310. page_size: [10, 20, 40, 50], // 选择限制显示条数
  311. },
  312. };
  313. },
  314. //生命周期 - 创建完成(可以访问当前this实例)
  315. created() {},
  316. //生命周期 - 挂载完成(可以访问DOM元素)
  317. mounted() {
  318. // getTeacher().then(res => {
  319. // if (res.code == 200) {
  320. // this.teacherList = res.data;
  321. // }
  322. // });
  323. // 获取分部
  324. // getEmployeeOrgan().then(res => {
  325. // if (res.code == 200) {
  326. // this.organList = res.data;
  327. // }
  328. // });
  329. this.$store.dispatch("setBranchs");
  330. this.init();
  331. },
  332. activated() {
  333. this.init();
  334. },
  335. methods: {
  336. init() {
  337. this.getList();
  338. },
  339. getList() {
  340. let obj = { page: this.rules.page, rows: this.rules.limit };
  341. Object.assign(obj, this.searchForm);
  342. if (this.courseTime && this.courseTime.length > 0) {
  343. obj.courseStartDate = this.courseTime[0];
  344. obj.courseEndDate = this.courseTime[1];
  345. } else {
  346. this.$message.error("请选择搜索时间");
  347. return;
  348. }
  349. queryTeacherAttendances(obj).then((res) => {
  350. if (res.code == 200) {
  351. this.tableList = res.data.rows;
  352. this.rules.total = res.data.total;
  353. }
  354. });
  355. },
  356. search() {
  357. this.rules.page = 1;
  358. this.getList();
  359. },
  360. onReSet() {
  361. this.searchForm = {
  362. search: null,
  363. organIdList: null,
  364. signInStatus: null,
  365. signOutStatus: null,
  366. jobNature: null,
  367. };
  368. this.courseTime = [nowTime, nowTime];
  369. this.$refs["searchForm"].resetFields();
  370. this.search();
  371. },
  372. appeal(row) {
  373. this.appealVisible = true
  374. this.detail = row
  375. },
  376. async unappeal(row) {
  377. try {
  378. await this.$confirm('是否确认撤销申诉?', '提示', {
  379. type: 'warning'
  380. })
  381. await repealComplaints({
  382. courseScheduleId: row.courseScheduleId,
  383. userId: row.teacherId,
  384. })
  385. this.$message.success('撤销成功')
  386. this.getList()
  387. } catch (error) {}
  388. },
  389. onExport() {
  390. let obj = { page: this.rules.page, rows: this.rules.limit };
  391. Object.assign(obj, this.searchForm);
  392. if (this.courseTime && this.courseTime.length > 0) {
  393. obj.courseStartDate = this.courseTime[0];
  394. obj.courseEndDate = this.courseTime[1];
  395. } else {
  396. this.$message.error("请选择搜索时间");
  397. return;
  398. }
  399. let url = "/api-web/export/queryTeacherAttendances";
  400. const options = {
  401. method: "POST",
  402. headers: {
  403. Authorization: getToken(),
  404. },
  405. params: obj,
  406. url,
  407. responseType: "blob",
  408. };
  409. this.$confirm("您确定导出考勤列表", "提示", {
  410. confirmButtonText: "确定",
  411. cancelButtonText: "取消",
  412. type: "warning",
  413. })
  414. .then(() => {
  415. load.startLoading();
  416. axios(options)
  417. .then((res) => {
  418. let blob = new Blob([res.data], {
  419. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  420. type: "application/vnd.ms-excel;charset=utf-8",
  421. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  422. });
  423. let text = new Response(blob).text();
  424. text.then((res) => {
  425. // 判断是否报错
  426. if (res.indexOf("code") != -1) {
  427. let json = JSON.parse(res);
  428. this.$message.error(json.msg);
  429. } else {
  430. let objectUrl = URL.createObjectURL(blob);
  431. let link = document.createElement("a");
  432. let fname = "考勤列表" + new Date().getTime()+'.xls'; //下载文件的名字
  433. link.href = objectUrl;
  434. link.setAttribute("download", fname);
  435. document.body.appendChild(link);
  436. link.click();
  437. }
  438. });
  439. load.endLoading();
  440. })
  441. .catch((error) => {
  442. this.$message.error("导出数据失败,请联系管理员");
  443. load.endLoading();
  444. });
  445. })
  446. .catch(() => {});
  447. },
  448. },
  449. };
  450. </script>
  451. <style lang='scss' scoped>
  452. </style>