teamusersign.vue 11 KB

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