empusersign.vue 12 KB

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