empusersign.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <div>
  3. <cu-custom bgColor="bg-gradual-pink" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">考勤查询</block>
  6. </cu-custom>
  7. <div id='calendar'>
  8. <!-- 年份 月份 -->
  9. <div class='month'>
  10. <ul>
  11. <!--点击会触发pickpre函数,重新刷新当前日期 @click(vue v-on:click缩写) -->
  12. <li class='arrow' @click='pickPre(currentYear,currentMonth)'>上个月</li>
  13. <li class='year-month'>
  14. <span class='choose-year'>{{ currentYear }}年</span>
  15. <span class='choose-month'>{{ currentMonth }}月</span>
  16. </li>
  17. <li class='arrow' @click='pickNext(currentYear,currentMonth)'>下个月</li>
  18. </ul>
  19. <br>
  20. </div>
  21. <hr>
  22. <!-- 星期 -->
  23. <ul class='weekdays'>
  24. <li>日</li>
  25. <li>一</li>
  26. <li>二</li>
  27. <li>三</li>
  28. <li>四</li>
  29. <li>五</li>
  30. <li>六</li>
  31. </ul>
  32. <!-- 日期 -->
  33. <ul class='days'>
  34. <!-- 核心 v-for循环 每一次循环用<li>标签创建一天 -->
  35. <li v-for='(dayobject,i) in days' :key='i'>
  36. <!--本月-->
  37. <!--如果不是本月 改变类名加灰色-->
  38. <span v-if='dayobject.day.getMonth()+1 != currentMonth' class='other-month' >{{ dayobject.day.getDate() }}</span>
  39. <!--如果是本月 还需要判断是不是这一天-->
  40. <span v-else>
  41. <!--今天 同年同月同日-->
  42. <!-- <span v-for='(s,i) in rows' v-if='s=='></span> -->
  43. <span v-if='dayobject.day.getFullYear() == new Date().getFullYear() && dayobject.day.getMonth() == new Date().getMonth() && dayobject.day.getDate() == new Date().getDate()'
  44. class='active' @click="getDayTime(dayobject.day)">今
  45. </span>
  46. <span v-else @click="getDayTime(dayobject.day)">
  47. <span class="act" >{{ dayobject.day.getDate() }}</span>
  48. <div style="margin-top: -10px;" v-if='SetDays!=[] &&SetDays.length>0' v-for='(dayobj,i) in SetDays'>
  49. <strong v-if='dayobj.iss == dayobject.day.getDate() && dayobj.is=="2" &&dayobject.day<=ToDay &&dayobject.day.getDay()!=0&&dayobject.day.getDay()!=6' style="color: #4E6FE2;font-size: 20px;">.</strong>
  50. <strong v-if='dayobj.iss == dayobject.day.getDate() && dayobj.is=="1" &&dayobject.day<=ToDay &&dayobject.day.getDay()!=0&&dayobject.day.getDay()!=6' style="color: red;font-size: 20px;">.</strong>
  51. </div>
  52. <div style="margin-top: -10px;" v-if='SetDays==[] ||SetDays.length<1'>
  53. <strong v-if='dayobject.day.getDay()!=0&&dayobject.day.getDay()!=6' style="color: red;font-size: 20px;">.</strong>
  54. </div>
  55. </span>
  56. </span>
  57. </li>
  58. </ul>
  59. <div class='ts' v-if='count=="2"'>
  60. <span style="width: 10px;height: 30px;background-color: #96A8F3;border-radius:2px 0 0 2px;">
  61. </span>
  62. <span style="display: flex; width: 250px; height: 30px; align-items: center;background-color: #F1F3F6;">
  63. <span style="flex: 1; display: flex; justify-content: center;"> <strong>{{SetMdays}}考勤正常 </strong></span>
  64. </span>
  65. </div>
  66. <div class='ts' v-if='count=="1"'>
  67. <span style="width: 10px;height: 30px;background-color: #DA402B;border-radius:2px 0 0 2px;">
  68. </span>
  69. <span style="display: flex; width: 250px; height: 30px; align-items: center;background-color: #F1F3F6;">
  70. <span style="flex: 1; display: flex; justify-content: center;"> <strong>{{SetMdays}}考勤异常 </strong></span>
  71. </span>
  72. </div>
  73. <div style="background: #ffffff;padding: 20px;">
  74. <span style="color: #9599A5;font-size: 15px;">
  75. 打卡记录: <span v-if='SetData.length<1'>无</span>
  76. <ul class="steps">
  77. <li v-for="(item,index) in SetData" :key="item+index" :class="{'active':Steps===index}" >
  78. {{item.userDate}}
  79. </li>
  80. </ul>
  81. </span>
  82. </div>
  83. <div class='ts'>
  84. <span style="height: 2px;width: 100%;background-color: #B4C3E0;"></span>
  85. <br>
  86. <span style="color: #9599A5;font-size: 15px;">
  87. 请假/外出记录:<span v-if='Setdds=="" || Setdds==null'>无</span>
  88. <br>
  89. <br>
  90. <span v-if='Setdds!=""&& Setdds!=null &&Setdds.holidayType=="1"'>
  91. 年假&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  92. </span>
  93. <span v-if='Setdds!="" && Setdds!=null &&Setdds.holidayType=="2"'>
  94. 事假&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  95. </span>
  96. <span v-if='Setdds!="" && Setdds!=null &&Setdds.holidayType=="3"'>
  97. 病假&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  98. </span>
  99. <span v-if='Setdds!="" && Setdds!=null &&Setdds.holidayType=="4"'>
  100. 调休假&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  101. </span>
  102. <span v-if='Setdds!="" && Setdds!=null &&Setdds.holidayType=="5"'>
  103. 婚假&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  104. </span>
  105. <span v-if='Setdds!="" && Setdds!=null &&Setdds.holidayType=="6"'>
  106. 产假&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  107. </span>
  108. <span v-if='Setdds!="" && Setdds!=null &&Setdds.holidayType=="7"'>
  109. 陪产假&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  110. </span>
  111. <span v-if='Setdds!="" && Setdds!=null &&Setdds.holidayType=="8"'>
  112. 其他&nbsp;&nbsp;({{Setdds.holidayCount/24}}天)
  113. </span>
  114. </span>
  115. </div>
  116. </div>
  117. </div>
  118. </template>
  119. <script>
  120. export default {
  121. data() {
  122. return {
  123. userUrl:'/attendance/attendance/list2',
  124. currentDay: 1,
  125. currentMonth: 1,
  126. currentYear: 1970,
  127. currentWeek: 1,
  128. days: [],
  129. rows: ["2021-1-8"],
  130. SetData:[],
  131. SetDays:[],
  132. SetBeginDay:null,
  133. SetEndDay:null,
  134. SetMdays:null,
  135. Setdds:null,
  136. ToDay:new Date(),
  137. count:''
  138. }
  139. },
  140. created: function() {
  141. // 在vue初始化时调用
  142. var s=this.$store.getters.date;
  143. this.initData(s)
  144. var date=this.formatDate(this.currentYear,this.currentMonth,1);
  145. this.querys(date)
  146. },
  147. methods: {
  148. initData: function(cur) {
  149. // var leftcount = 0 // 存放剩余数量
  150. var date
  151. if (cur) {
  152. date = new Date(cur)
  153. } else {
  154. var now = new Date()
  155. var d = new Date(this.formatDate(now.getFullYear(), now.getMonth(), 1))
  156. d.setDate(35)
  157. date = new Date(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  158. }
  159. this.currentDay = date.getDate()
  160. this.currentYear = date.getFullYear()
  161. this.currentMonth = date.getMonth() + 1
  162. this.currentWeek = date.getDay() // 1...6,0
  163. if (this.currentWeek === 0) {
  164. this.currentWeek = 7
  165. }
  166. var str = this.formatDate(
  167. this.currentYear,
  168. this.currentMonth,
  169. this.currentDay
  170. )
  171. this.days.length = 0
  172. // 今天是周日,放在第一行第7个位置,前面6个
  173. // 初始化本周
  174. for (var i = this.currentWeek; i >= 0; i--) {
  175. var d2 = new Date(str)
  176. d2.setDate(d2.getDate() - i)
  177. var dayobjectSelf = {} // 用一个对象包装Date对象 以便为以后预定功能添加属性
  178. dayobjectSelf.day = d2
  179. this.days.push(dayobjectSelf) // 将日期放入data 中的days数组 供页面渲染使用
  180. }
  181. // 其他周
  182. for (var j = 1; j <= 37 - this.currentWeek; j++) {
  183. var d3 = new Date(str)
  184. d3.setDate(d3.getDate() + j)
  185. var dayobjectOther = {}
  186. dayobjectOther.day = d3
  187. this.days.push(dayobjectOther)
  188. }
  189. },
  190. getDayTime(el) {
  191. var date=new Date()
  192. var date2 =new Date(el)
  193. if(date2<=date){
  194. this.querys(el);
  195. }
  196. console.log(el)
  197. },
  198. querys:function(s){
  199. if(s!=null &&s!=""){
  200. var date=this.formats(s);
  201. }else{
  202. var t=new Date()
  203. var date=this.formats(t);
  204. }
  205. this.SetMdays=this.formatt(date);
  206. this.$http.get(this.userUrl,{params:{userid:this.$store.getters.id,date:date}}).then(res=>{
  207. this.SetData=res.data.date;
  208. if(res.data.day.length>0&&res.data.day!=[]){
  209. this.SetDays=res.data.day;
  210. }
  211. this.Setdds=res.data.data;
  212. this.count=res.data.count;
  213. console.log(res)
  214. }).catch(err => {
  215. console.log(err);
  216. });
  217. },
  218. formats:function(e){
  219. var date = new Date(e);
  220. var seperator1 = "-";
  221. var year = date.getFullYear();
  222. var month = date.getMonth() + 1;
  223. var strDate = date.getDate();
  224. if (month >= 1 && month <= 9) {
  225. month = "0" + month;
  226. }
  227. if (strDate >= 0 && strDate <= 9) {
  228. strDate = "0" + strDate;
  229. }
  230. var currentdate = year + seperator1 + month + seperator1 + strDate;
  231. return currentdate;
  232. },
  233. formatt:function(e){
  234. var date = new Date(e);
  235. var seperator1 = "月";
  236. var day="日";
  237. var month = date.getMonth() + 1;
  238. var strDate = date.getDate();
  239. var currentdate = month + seperator1 + strDate+day;
  240. return currentdate;
  241. },
  242. pickPre: function(year, month) {
  243. // setDate(0); 上月最后一天
  244. // setDate(-1); 上月倒数第二天
  245. // setDate(dx) 参数dx为 上月最后一天的前后dx天
  246. var d = new Date(this.formatDate(year, month, 1))
  247. d.setDate(0)
  248. this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  249. this.querys(d);
  250. },
  251. pickNext: function(year, month) {
  252. var d = new Date(this.formatDate(year, month, 1))
  253. var ds=this.formatDate(year, month, null);
  254. var nowDate = new Date();
  255. var dt=this.formatDate(nowDate.getFullYear(),nowDate.getMonth(),null);
  256. if(ds<=dt){
  257. d.setDate(35)
  258. this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  259. this.querys(d);
  260. }
  261. },
  262. // 返回 类似 2016-01-02 格式的字符串
  263. formatDate: function(year, month, day) {
  264. var y = year
  265. var m = month
  266. if (m < 10) m = '0' + m
  267. var d = day
  268. if(day!=null &&day !=""){
  269. if (d < 10) d = '0' + d
  270. return y + '-' + m + '-' + d
  271. }else{
  272. return y + '-' + m
  273. }
  274. },
  275. ret(){
  276. this.$Router.push({name:'empsign'})
  277. }
  278. }
  279. }
  280. </script>
  281. <style>
  282. .steps {
  283. counter-reset: step; /*创建步骤数字计数器*/
  284. width: 360px;
  285. margin: 0 auto;
  286. margin-left: -30px;
  287. margin-top: 10px;
  288. }
  289. /*步骤描述*/
  290. .steps li {
  291. position: relative;
  292. padding: 0 20px 20px;
  293. list-style: none;
  294. line-height: 22px;
  295. border-left: 2px solid #ccc;
  296. }
  297. /*步骤数字*/
  298. .steps li:before {
  299. content: counter(step); /*设定计数器内容*/
  300. counter-increment: step; /*计数器值递增*/
  301. display: block;
  302. position: absolute;
  303. margin-left: -6px;
  304. top: 0;
  305. left: -5px;
  306. width: 22px;
  307. height: 22px;
  308. line-height: 23px;
  309. text-align: center;
  310. background: #B4C3E0;
  311. color: #EDF1F7;
  312. font-size: 14px;
  313. border-radius: 50%;
  314. }
  315. li {
  316. list-style-type: none;
  317. }
  318. #calendar {
  319. font-size: 12px;
  320. width: 100%;
  321. margin: 0 auto;
  322. box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.1),
  323. 0 1px 5px 0 rgba(0, 0, 0, 0.12);
  324. }
  325. .month {
  326. width: 100%;
  327. color: #333333;
  328. background: #ffffff;
  329. }
  330. .month ul {
  331. margin: 0;
  332. padding: 0;
  333. display: flex;
  334. justify-content: space-between;
  335. height: 35px;
  336. }
  337. .year-month {
  338. display: flex;
  339. align-items: center;
  340. justify-content: space-around;
  341. margin-top: 10px;
  342. }
  343. .choose-month {
  344. text-align: center;
  345. font-size: 12px;
  346. }
  347. .arrow {
  348. padding: 15px;
  349. color: #999999;
  350. }
  351. .month ul li {
  352. font-size: 12px;
  353. text-transform: uppercase;
  354. letter-spacing: 3px;
  355. }
  356. .weekdays {
  357. margin: 0;
  358. padding: 10px;
  359. display: flex;
  360. flex-wrap: wrap;
  361. color: #999;
  362. justify-content: space-around;
  363. background: #ffffff;
  364. }
  365. .weekdays li {
  366. display: inline-block;
  367. width: 13.6%;
  368. text-align: center;
  369. }
  370. .days {
  371. padding: 10px;
  372. background: #ffffff;
  373. margin: 0;
  374. display: flex;
  375. flex-wrap: wrap;
  376. }
  377. .ts {
  378. padding: 20px;
  379. background: #ffffff;
  380. margin: 0;
  381. display: flex;
  382. flex-wrap: wrap;
  383. }
  384. .days li {
  385. list-style-type: none;
  386. display: inline-block;
  387. width: 14.2%;
  388. text-align: center;
  389. padding-bottom: 4px;
  390. padding-top: 5px;
  391. font-size: 13px;
  392. color: #000;
  393. height: 40px;
  394. }
  395. .days li .active {
  396. padding: 8px 10px;
  397. border-radius: 5%;
  398. background: #00b8ec;
  399. color: #fff;
  400. }
  401. .days li .other-month {
  402. padding: 5px;
  403. color: gainsboro;
  404. }
  405. .days li:hover .act{
  406. padding: 6px 10px;
  407. border-radius: 50%;
  408. background: #e1e1e1;
  409. color: #fff;
  410. }
  411. .top{
  412. background-color: #5677AC;
  413. width: 100%;
  414. height: 40px;
  415. }
  416. </style>