attendance_rating.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <div>
  3. <div class="integral_statistics_box" v-loading="attendload">
  4. <el-row :gutter="10" style="margin-right:8px;">
  5. <el-form :inline="true">
  6. <el-form-item label="考勤组">
  7. <el-select
  8. v-model="formData.group_id"
  9. @change="selectgroupId"
  10. filterable
  11. :clearable="false"
  12. placeholder="请选择考勤组"
  13. >
  14. <el-option
  15. v-for="item in checkingInGroup"
  16. :key="item.id"
  17. :label="item.name"
  18. :value="item.id"
  19. ></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="排名类型">
  23. <el-select
  24. v-model="formData.type"
  25. @change="selectgroupId"
  26. style="width:80px"
  27. placeholder="请选择"
  28. >
  29. <el-option
  30. v-for="(item, index) in type"
  31. :key="index"
  32. :label="item.name"
  33. :value="item.id"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="时间">
  38. <el-date-picker
  39. v-model="Month_range"
  40. class="date-picker-width"
  41. type="month"
  42. :clearable='false'
  43. value-format="yyyy-MM"
  44. placeholder="选择月份排名"
  45. @change="onFilterChanged"
  46. ></el-date-picker>
  47. <!-- <el-date-picker
  48. style="width:290px"
  49. class="first-element-btn"
  50. :clearable="false"
  51. v-model="time_range"
  52. type="daterange"
  53. value-format="yyyy-MM-dd"
  54. range-separator="至"
  55. start-placeholder="开始日期"
  56. end-placeholder="结束日期"
  57. :picker-options="instantPickerOptions"
  58. @change="onFilterChanged"
  59. ></el-date-picker> -->
  60. </el-form-item>
  61. <el-form-item>
  62. <el-button type="primary" plain @click="exportRanking"
  63. >导出排名</el-button
  64. >
  65. </el-form-item>
  66. </el-form>
  67. </el-row>
  68. <el-table
  69. :data="all_integral_list"
  70. style="width: 100%"
  71. v-loading="loading"
  72. >
  73. <el-table-column label="名次" width="100" align="center">
  74. <template slot-scope="scope">
  75. <img
  76. v-if="scope.row.rank === 1"
  77. src="static/images/statistics_NO1.png"
  78. alt
  79. />
  80. <img
  81. v-if="scope.row.rank === 2"
  82. src="static/images/statistics_NO2.png"
  83. alt
  84. />
  85. <img
  86. v-if="scope.row.rank === 3"
  87. src="static/images/statistics_NO3.png"
  88. alt
  89. />
  90. <span v-if="scope.row.rank > 3">{{ scope.row.rank }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="姓名" align="left">
  94. <template slot-scope="scope">
  95. <userImage
  96. class="fl"
  97. :id="scope.row.id"
  98. :user_name="scope.row.name"
  99. :img_url="scope.row.img_url"
  100. width="50px"
  101. height="50px"
  102. ></userImage>
  103. <span style="line-height: 50px; padding-left: 10px;">{{
  104. scope.row.name
  105. }}</span>
  106. </template>
  107. </el-table-column>
  108. <el-table-column prop="point" label="B分" align="left">
  109. <template slot-scope="scope">
  110. <b style="font-size:15px;color:#909399">{{ scope.row.point }}</b>
  111. </template>
  112. </el-table-column>
  113. <template slot="empty">
  114. <div class="nopoint_box">
  115. <div class="noimg noperson"></div>
  116. <span class="title">没有对应的数据</span>
  117. </div>
  118. </template>
  119. </el-table>
  120. <center style="padding: 20px 0;">
  121. <el-pagination
  122. background
  123. @size-change="handleSizeChange1"
  124. @current-change="handleCurrentChange"
  125. :current-page="formData.page"
  126. :page-sizes="[10, 20, 50, 100]"
  127. layout="total, sizes, prev, pager, next"
  128. :page-size="pageLimit1"
  129. :total="total"
  130. >
  131. </el-pagination>
  132. </center>
  133. </div>
  134. <!-- 导出弹窗 -->
  135. <el-dialog title="导出排名" :visible.sync="dialogVisible" width="730px">
  136. <div style="font-size:15px;margin:20px 0 20px 0;">
  137. 系统将按以下已选条件导出对应的排名报表
  138. </div>
  139. <div v-loading="exportLoad">
  140. <el-form :inline="true">
  141. <el-form-item label="考勤组">
  142. <el-select
  143. v-model="exportData.group_id"
  144. @change="selectgroupId"
  145. filterable
  146. :clearable="false"
  147. placeholder="请选择考勤组"
  148. >
  149. <el-option
  150. v-for="item in checkingInGroup"
  151. :key="item.id"
  152. :label="item.name"
  153. :value="item.id"
  154. ></el-option>
  155. </el-select>
  156. </el-form-item>
  157. <el-form-item label="排名类型">
  158. <el-select
  159. v-model="exportData.type"
  160. @change="selectgroupId"
  161. style="width:150px"
  162. placeholder="请选择"
  163. >
  164. <el-option
  165. v-for="(item, index) in type"
  166. :key="index"
  167. :label="item.name"
  168. :value="item.id"
  169. ></el-option>
  170. </el-select>
  171. </el-form-item>
  172. <el-form-item label="时间">
  173. <el-date-picker
  174. v-model="exportMonth_range"
  175. class="date-picker-width"
  176. type="month"
  177. :clearable='false'
  178. value-format="yyyy-MM"
  179. placeholder="选择月份排名"
  180. ></el-date-picker>
  181. <!-- <el-date-picker
  182. class="first-element-btn"
  183. :clearable="false"
  184. v-model="exportTime_range"
  185. type="daterange"
  186. value-format="yyyy-MM-dd"
  187. range-separator="至"
  188. start-placeholder="开始日期"
  189. end-placeholder="结束日期"
  190. :picker-options="instantPickerOptions"
  191. ></el-date-picker> -->
  192. </el-form-item>
  193. </el-form>
  194. <span class="dialog-footer" style="display:flex;justify-content: flex-end;">
  195. <el-button @click="dialogVisible = false">取 消</el-button>
  196. <el-button type="primary" @click="exportExcel">导 出</el-button>
  197. </span>
  198. </div>
  199. </el-dialog>
  200. </div>
  201. </template>
  202. <script>
  203. export default {
  204. data() {
  205. return {
  206. exportLoad:false,
  207. dialogVisible: false,
  208. checkingInGroup: [],
  209. type: [
  210. { id: 1, name: "总分" },
  211. { id: 2, name: "早到" },
  212. { id: 3, name: "迟到" },
  213. { id: 4, name: "加班" },
  214. { id: 5, name: "请假" }
  215. ],
  216. attendload: false,
  217. loading: false,
  218. all_integral_list: null,
  219. Month_range:this.$moment().format("YYYY-MM"),
  220. time_range: [
  221. this.$moment()
  222. .startOf("month")
  223. .format("YYYY-MM-DD"),
  224. this.$moment()
  225. .endOf("month")
  226. .format("YYYY-MM-DD")
  227. ],
  228. formData: {
  229. group_id: "",
  230. date_type: 3,
  231. page: 1,
  232. page_size: 10,
  233. type: 1
  234. },
  235. exportMonth_range:this.$moment().format("YYYY-MM"),
  236. exportTime_range: [
  237. this.$moment()
  238. .startOf("month")
  239. .format("YYYY-MM-DD"),
  240. this.$moment()
  241. .endOf("month")
  242. .format("YYYY-MM-DD")
  243. ],
  244. exportData: {
  245. group_id: "",
  246. type: 1
  247. },
  248. total: 0,
  249. dept_tree: [],
  250. dept_name: [],
  251. pageLimit1: 10,
  252. instantPickerOptions: {
  253. shortcuts: [
  254. {
  255. text: "本周",
  256. onClick(picker) {
  257. const now = new Date();
  258. const start = new Date();
  259. start.setTime(
  260. now.getTime() - (now.getDay() - 1) * 24 * 60 * 60 * 1000
  261. );
  262. now.setTime(start.getTime() + 6 * 24 * 60 * 60 * 1000 - 1000);
  263. picker.$emit("pick", [start, now]);
  264. }
  265. },
  266. {
  267. text: "上周",
  268. onClick(picker) {
  269. const end = new Date();
  270. const start = new Date();
  271. start.setTime(
  272. start.getTime() - (start.getDay() + 6) * 3600 * 1000 * 24
  273. );
  274. end.setTime(start.getTime() + 6 * 24 * 60 * 60 * 1000 - 1000);
  275. picker.$emit("pick", [start, end]);
  276. }
  277. },
  278. {
  279. text: "本月",
  280. onClick(picker) {
  281. const now = new Date();
  282. const startDate = new Date(now.getFullYear(), now.getMonth(), 1);
  283. const endDate = new Date(
  284. now.getFullYear(),
  285. now.getMonth() + 1,
  286. 0
  287. );
  288. picker.$emit("pick", [startDate, endDate]);
  289. }
  290. },
  291. {
  292. text: "上月",
  293. onClick(picker) {
  294. const now = new Date();
  295. const startDate = new Date(
  296. now.getFullYear() - (now.getMonth() > 0 ? 0 : 1),
  297. (now.getMonth() + 11) % 12,
  298. 1
  299. );
  300. const endDate = new Date(now.getFullYear(), now.getMonth(), 0);
  301. picker.$emit("pick", [startDate, endDate]);
  302. }
  303. }
  304. ]
  305. }
  306. };
  307. },
  308. components: {},
  309. watch: {},
  310. mounted() {
  311. this.checkingIn_group(); //考勤组
  312. },
  313. methods: {
  314. exportRanking(){
  315. if(this.checkingInGroup.length>0){
  316. this.exportData.group_id = this.checkingInGroup[0].id
  317. }
  318. this.dialogVisible = true
  319. },
  320. exportExcel() {
  321. this.exportLoad = true
  322. let params = this.exportData;
  323. params.date_type = 3,
  324. params.month_date = this.exportMonth_range
  325. // params.date_type = 2,
  326. // params.start_date = this.exportTime_range[0];
  327. // params.end_date = this.exportTime_range[1];
  328. params.page = 0,
  329. params.page_size = 2000,
  330. this.$jtoken.get(this.serveAd + "/ad/statistics/get_group_rank_code", {params: params}).then((res)=>{
  331. if(res.data.code == 1){
  332. window.open(this.serveAd+'/ad/statistics/group_rank_export?code='+res.data.data.code,'_blank')
  333. this.dialogVisible = false
  334. }else{
  335. this.$message.error(res.data.msg);
  336. }
  337. }).finally(()=>{
  338. this.exportLoad = false
  339. })
  340. },
  341. selectgroupId() {
  342. this.get_all_integral();
  343. },
  344. onFilterChanged() {
  345. this.get_all_integral();
  346. },
  347. //分页
  348. handleSizeChange1(val) {
  349. this.pageLimit1 = val;
  350. this.formData.page_size = this.pageLimit1;
  351. this.get_all_integral();
  352. },
  353. handleCurrentChange(val) {
  354. this.formData.page = val;
  355. this.get_all_integral();
  356. },
  357. //请求数据
  358. checkingIn_group() {
  359. this.attendload = true;
  360. let self = this;
  361. let params = {
  362. page: 1,
  363. page_size: 2000
  364. };
  365. this.$jtoken
  366. .get(this.serveAd + "/ad/group", {
  367. params: params
  368. })
  369. .then(res => {
  370. if (res.data.code == 1) {
  371. this.checkingInGroup = res.data.data.list;
  372. this.formData.group_id = res.data.data.list[0].id;
  373. }
  374. })
  375. .finally(() => {
  376. this.get_all_integral();
  377. this.attendload = false;
  378. });
  379. },
  380. //请求数据
  381. get_all_integral() {
  382. let self = this;
  383. self.loading = true;
  384. // let data = self.formData;
  385. let data = {
  386. group_id:this.formData.group_id,
  387. date_type:this.formData.date_type,
  388. page:this.formData.page-1,
  389. page_size:this.formData.page_size,
  390. type:this.formData.type,
  391. month_date:this.Month_range,
  392. }
  393. // data.month_date = this.Month_range
  394. // data.start_date = this.time_range[0];
  395. // data.end_date = this.time_range[1];
  396. // data.page = data.page-1
  397. this.$jtoken({
  398. url: this.serveAd + "/ad/statistics/group/rank",
  399. data: data,
  400. method: "post"
  401. })
  402. .then(res => {
  403. if (res.data.code == 1) {
  404. self.all_integral_list = res.data.data.list;
  405. this.total = res.data.data.total
  406. } else {
  407. self.$message.error(res.data.data.msg);
  408. }
  409. })
  410. .finally(() => {
  411. self.loading = false;
  412. });
  413. }
  414. }
  415. };
  416. </script>
  417. <style scoped>
  418. .el-date-editor.el-input {
  419. width: auto;
  420. }
  421. .date-picker-width {
  422. width: 145px !important;
  423. }
  424. .search /deep/ .el-input-group__append:active {
  425. background: #26a2ff;
  426. }
  427. .search /deep/ .el-input-group__append:active .el-icon-search {
  428. color: #fff;
  429. }
  430. </style>
  431. <style lang="scss" scoped>
  432. .integral_statistics_box {
  433. background-color: #ffffff;
  434. padding: 20px;
  435. min-height: calc(100vh - 160px);
  436. }
  437. /deep/ .el-dialog__body {
  438. padding: 0px 20px 30px;
  439. }
  440. </style>