usersign.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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}} <span style="margin-left: 20px;">{{item.checkinType}}</span>
  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. count:'',
  137. ToDay:new Date(),
  138. }
  139. },
  140. created: function() {
  141. // 在vue初始化时调用
  142. this.initData(null)
  143. this.querys(null)
  144. },
  145. methods: {
  146. initData: function(cur) {
  147. // var leftcount = 0 // 存放剩余数量
  148. var date
  149. if (cur) {
  150. date = new Date(cur)
  151. } else {
  152. var now = new Date()
  153. var d = new Date(this.formatDate(now.getFullYear(), now.getMonth(), 1))
  154. d.setDate(35)
  155. date = new Date(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  156. }
  157. this.currentDay = date.getDate()
  158. this.currentYear = date.getFullYear()
  159. this.currentMonth = date.getMonth() + 1
  160. this.currentWeek = date.getDay() // 1...6,0
  161. if (this.currentWeek === 0) {
  162. this.currentWeek = 7
  163. }
  164. var str = this.formatDate(
  165. this.currentYear,
  166. this.currentMonth,
  167. this.currentDay
  168. )
  169. this.days.length = 0
  170. // 今天是周日,放在第一行第7个位置,前面6个
  171. // 初始化本周
  172. for (var i = this.currentWeek; i >= 0; i--) {
  173. var d2 = new Date(str)
  174. d2.setDate(d2.getDate() - i)
  175. var dayobjectSelf = {} // 用一个对象包装Date对象 以便为以后预定功能添加属性
  176. dayobjectSelf.day = d2
  177. this.days.push(dayobjectSelf) // 将日期放入data 中的days数组 供页面渲染使用
  178. }
  179. // 其他周
  180. for (var j = 1; j <= 37 - this.currentWeek; j++) {
  181. var d3 = new Date(str)
  182. d3.setDate(d3.getDate() + j)
  183. var dayobjectOther = {}
  184. dayobjectOther.day = d3
  185. this.days.push(dayobjectOther)
  186. }
  187. var s=this.days
  188. console.log(s)
  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. },
  197. querys:function(s){
  198. if(s!=null &&s!=""){
  199. var date=this.formats(s);
  200. }else{
  201. var t=new Date()
  202. var date=this.formats(t);
  203. }
  204. this.SetMdays=this.formatt(date);
  205. this.$http.get(this.userUrl,{params:{userid:this.$store.getters.userid,date:date}}).then(res=>{
  206. this.SetData=res.data.date;
  207. if(res.data.day.length>0&&res.data.day!=[]){
  208. this.SetDays=res.data.day;
  209. }
  210. this.Setdds=res.data.data;
  211. this.count=res.data.count;
  212. console.log(res)
  213. }).catch(err => {
  214. console.log(err);
  215. });
  216. },
  217. formats:function(e){
  218. var date = new Date(e);
  219. var seperator1 = "-";
  220. var year = date.getFullYear();
  221. var month = date.getMonth() + 1;
  222. var strDate = date.getDate();
  223. if (month >= 1 && month <= 9) {
  224. month = "0" + month;
  225. }
  226. if (strDate >= 0 && strDate <= 9) {
  227. strDate = "0" + strDate;
  228. }
  229. var currentdate = year + seperator1 + month + seperator1 + strDate;
  230. return currentdate;
  231. },
  232. formatt:function(e){
  233. var date = new Date(e);
  234. var seperator1 = "月";
  235. var day="日";
  236. var month = date.getMonth() + 1;
  237. var strDate = date.getDate();
  238. var currentdate = month + seperator1 + strDate+day;
  239. return currentdate;
  240. },
  241. pickPre: function(year, month) {
  242. // setDate(0); 上月最后一天
  243. // setDate(-1); 上月倒数第二天
  244. // setDate(dx) 参数dx为 上月最后一天的前后dx天
  245. var d = new Date(this.formatDate(year, month, 1))
  246. d.setDate(0)
  247. this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  248. this.querys(d);
  249. },
  250. pickNext: function(year, month) {
  251. var d = new Date(this.formatDate(year, month, 1))
  252. var ds=this.formatDate(year, month, null);
  253. var nowDate = new Date();
  254. var dt=this.formatDate(nowDate.getFullYear(),nowDate.getMonth(),null);
  255. if(ds<=dt){
  256. d.setDate(35)
  257. this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  258. this.querys(d);
  259. }
  260. },
  261. // 返回 类似 2016-01-02 格式的字符串
  262. formatDate: function(year, month, day) {
  263. var y = year
  264. var m = month
  265. if (m < 10) m = '0' + m
  266. var d = day
  267. if (d < 10) d = '0' + d
  268. return y + '-' + m + '-' + d
  269. },
  270. ret(){
  271. this.$Router.push({name:'index'})
  272. }
  273. }
  274. }
  275. </script>
  276. <style>
  277. .steps {
  278. counter-reset: step; /*创建步骤数字计数器*/
  279. width: 360px;
  280. margin: 0 auto;
  281. margin-left: -30px;
  282. margin-top: 10px;
  283. }
  284. /*步骤描述*/
  285. .steps li {
  286. position: relative;
  287. padding: 0 20px 20px;
  288. list-style: none;
  289. line-height: 22px;
  290. border-left: 2px solid #ccc;
  291. }
  292. /*步骤数字*/
  293. .steps li:before {
  294. content: counter(step); /*设定计数器内容*/
  295. counter-increment: step; /*计数器值递增*/
  296. display: block;
  297. position: absolute;
  298. margin-left: -6px;
  299. top: 0;
  300. left: -5px;
  301. width: 22px;
  302. height: 22px;
  303. line-height: 23px;
  304. text-align: center;
  305. background: #B4C3E0;
  306. color: #EDF1F7;
  307. font-size: 14px;
  308. border-radius: 50%;
  309. }
  310. li {
  311. list-style-type: none;
  312. }
  313. #calendar {
  314. font-size: 12px;
  315. width: 100%;
  316. margin: 0 auto;
  317. box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.1),
  318. 0 1px 5px 0 rgba(0, 0, 0, 0.12);
  319. }
  320. .month {
  321. width: 100%;
  322. color: #333333;
  323. background: #ffffff;
  324. }
  325. .month ul {
  326. margin: 0;
  327. padding: 0;
  328. display: flex;
  329. justify-content: space-between;
  330. height: 35px;
  331. }
  332. .year-month {
  333. display: flex;
  334. align-items: center;
  335. justify-content: space-around;
  336. margin-top: 10px;
  337. }
  338. .choose-month {
  339. text-align: center;
  340. font-size: 12px;
  341. }
  342. .arrow {
  343. padding: 15px;
  344. color: #999999;
  345. }
  346. .month ul li {
  347. font-size: 12px;
  348. text-transform: uppercase;
  349. letter-spacing: 3px;
  350. }
  351. .weekdays {
  352. margin: 0;
  353. padding: 10px;
  354. display: flex;
  355. flex-wrap: wrap;
  356. color: #999;
  357. justify-content: space-around;
  358. background: #ffffff;
  359. }
  360. .weekdays li {
  361. display: inline-block;
  362. width: 13.6%;
  363. text-align: center;
  364. }
  365. .days {
  366. padding: 10px;
  367. background: #ffffff;
  368. margin: 0;
  369. display: flex;
  370. flex-wrap: wrap;
  371. }
  372. .ts {
  373. padding: 20px;
  374. background: #ffffff;
  375. margin: 0;
  376. display: flex;
  377. flex-wrap: wrap;
  378. }
  379. .days li {
  380. list-style-type: none;
  381. display: inline-block;
  382. width: 14.2%;
  383. text-align: center;
  384. padding-bottom: 4px;
  385. padding-top: 5px;
  386. font-size: 13px;
  387. color: #000;
  388. height: 40px;
  389. }
  390. .days li .active {
  391. padding: 8px 10px;
  392. border-radius: 5%;
  393. background: #00b8ec;
  394. color: #fff;
  395. }
  396. .days li .other-month {
  397. padding: 5px;
  398. color: gainsboro;
  399. }
  400. .days li:hover .act{
  401. padding: 6px 10px;
  402. border-radius: 50%;
  403. background: #e1e1e1;
  404. color: #fff;
  405. }
  406. .top{
  407. background-color: #5677AC;
  408. width: 100%;
  409. height: 40px;
  410. }
  411. </style>