punch-list.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="content">
  3. <u-navbar :background="background" back-icon-color="#fff" titleColor="#fff" :title="vuex_now_date"></u-navbar>
  4. <calendar ref='ren' :markDays='markDays' :open="true" :disabledAfter='true' @onDayClick='onDayClick'></calendar>
  5. <view class="rule" style="padding-top: 30rpx;padding-bottom: 30rpx;" v-if="$isEmpty(rule)">
  6. <view class="left">
  7. <text class="text-bold">查看打卡规则</text>
  8. </view>
  9. <view class="right desc">
  10. <text class="cuIcon-right"></text>
  11. </view>
  12. </view>
  13. <view class="rule" v-else>
  14. <view class="left">
  15. <view class="title">上下班打卡</view>
  16. <view class="desc">
  17. <text>打卡规则:</text>
  18. <text>{{rule.beginTime}} ~ {{rule.endTime}}</text>
  19. <text style="padding: 0 15rpx;">|</text>
  20. <text>工作时长:</text>
  21. <text>{{rule.totalTime}}</text>
  22. </view>
  23. </view>
  24. <view class="right desc">
  25. <text class="cuIcon-right"></text>
  26. </view>
  27. </view>
  28. <view class="history" v-if="!$isEmpty(rule)">
  29. <view class="left">
  30. <text class="time">{{rule.beginTime}}</text>
  31. <view class="bar">
  32. <text></text>
  33. </view>
  34. <text class="time">{{rule.endTime}}</text>
  35. </view>
  36. <view class="right" style="width: 100%;">
  37. <view class="working" style="padding-bottom: 25rpx;border-bottom: 1rpx solid #dedede;">
  38. <text class="padding-bottom-10">上班</text>
  39. <text v-if="workPunchRecord[0]&&workPunchRecord[0].exceptionMessage" class="desc" style="color: #da0000;">打卡异常 ({{workCheckinTime | date("hh:MM")}})</text>
  40. <text class="desc" v-else-if="workPunchRecord[0]&&!workPunchRecord[0].exceptionMessage">正常打卡 ({{workCheckinTime | date("hh:MM")}})</text>
  41. <text class="desc" v-else>暂无记录</text>
  42. </view>
  43. <view class="working" style="padding-top: 25rpx;">
  44. <text class="padding-bottom-10">下班</text>
  45. <text v-if="offWorkPunchRecord[0]&&offWorkPunchRecord[0].exceptionMessage" class="desc" style="color: #da0000;">打卡异常 ({{offWorkCheckinTime | date("hh:MM")}})</text>
  46. <text class="desc" v-else-if="offWorkPunchRecord[0]&&!offWorkPunchRecord[0].exceptionMessage">正常打卡 ({{offWorkCheckinTime | date("hh:MM")}})</text>
  47. <text class="desc" v-else>暂无记录</text>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="" v-if="!$isEmpty(outWorkPunchRecord)">
  52. <view style="background-color: #f1f1f1;padding: 8rpx 30rpx;color: #686868;">
  53. <text class="">外出打卡</text>
  54. </view>
  55. <view class="out-punch">
  56. <view class="time">
  57. <text>18:31</text>
  58. </view>
  59. <view class="content">
  60. <text class="name">黄明潘</text>
  61. <text class="desc">临江大道5号</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import calendar from '@/components/calendar/calendar.vue'
  69. export default {
  70. components:{
  71. calendar
  72. },
  73. data() {
  74. return {
  75. userId:'',
  76. background: {
  77. backgroundColor: '#5064eb',
  78. },
  79. isfuture:false,
  80. markDays:[],
  81. rule:{},
  82. //上班打卡记录
  83. workPunchRecord:[],
  84. workCheckinTime:'',
  85. //下班打卡记录
  86. offWorkPunchRecord:[],
  87. offWorkCheckinTime:'',
  88. //外出打卡记录
  89. outWorkPunchRecord:[],
  90. outWorkCheckinTime:''
  91. }
  92. },
  93. watch:{
  94. vuex_now_date(newVal,oldVal){
  95. let newValStr=newVal?newVal.replace('年','/').replace('月','/').replace('日',''):''
  96. let oldValStr=oldVal?oldVal.replace('年','/').replace('月','/').replace('日',''):''
  97. let newValDate=this.$dateTime.createDate(newValStr)
  98. let oldValDate=this.$dateTime.createDate(oldValStr)
  99. let newYearMonth=newValDate.getFullYear()+"-"+(newValDate.getMonth()+1)
  100. let oldYearMonth=oldValDate.getFullYear()+"-"+(oldValDate.getMonth()+1)
  101. if (newYearMonth!=oldYearMonth) {
  102. this.getMarkDays()
  103. }
  104. }
  105. },
  106. onReady() {
  107. let today = this.$refs.ren.getToday().date;
  108. this.$u.vuex("vuex_now_date",this.$dateTime.format(new Date(today),"YYYY年mm月dd日"))
  109. },
  110. onLoad() {
  111. this.userId=this.$cache.get('userId')
  112. this.getRecordsByDate(this.$dateTime.format())
  113. this.getRuleByDate(this.$dateTime.format())
  114. },
  115. onUnload() {
  116. this.$u.vuex("vuex_now_date",null)
  117. },
  118. onBackPress() {
  119. this.$u.vuex("vuex_now_date",null)
  120. },
  121. methods: {
  122. getRuleByDate(date){
  123. let params={
  124. personId:this.userId,
  125. personType:0,
  126. date
  127. }
  128. this.$api.punch.getRuleByDate(params).then(res=>{
  129. this.rule=res.data
  130. })
  131. },
  132. getMarkDays(){
  133. let strDate=this.vuex_now_date.replace('年','/').replace('月','/').replace('日','')
  134. let date=this.$dateTime.createDate(strDate)
  135. let params={
  136. personId:this.userId,
  137. personType:0,
  138. year:date.getFullYear(),
  139. month:date.getMonth()+1
  140. }
  141. this.$api.punch.getMarkDays(params).then(res=>{
  142. this.markDays=res.data
  143. })
  144. },
  145. onDayClick(data){
  146. if (!data) {
  147. this.isfuture=true
  148. this.$u.toast('未来日期')
  149. return
  150. }
  151. this.isfuture=false
  152. this.$u.vuex("vuex_now_date",this.$dateTime.format(new Date(data.date),"YYYY年mm月dd日"))
  153. //获取打卡记录
  154. let date=this.vuex_now_date.replace('年','-').replace('月','-').replace('日','')
  155. this.getRecordsByDate(date)
  156. this.getRuleByDate(date)
  157. },
  158. getRecordsByDate(checkinTime){
  159. let params={
  160. personId:this.$cache.get('userId'),
  161. personType:0,
  162. checkinTime:checkinTime
  163. }
  164. this.$api.punch.getRecordsByDate(params).then(res=>{
  165. let record=res.data
  166. //上班打卡
  167. this.workPunchRecord= record.filter(item=>{
  168. return item.checkinType==0
  169. })
  170. if (!this.$isEmpty(this.workPunchRecord)) {
  171. this.workCheckinTime=this.workPunchRecord[0].checkinTime
  172. }
  173. //下班打卡
  174. this.offWorkPunchRecord= record.filter(item=>{
  175. return item.checkinType==1
  176. })
  177. if (!this.$isEmpty(this.offWorkPunchRecord)) {
  178. this.offWorkCheckinTime=this.offWorkPunchRecord[0].checkinTime
  179. }
  180. //外出打卡
  181. this.outWorkPunchRecord= record.filter(item=>{
  182. return item.checkinType==2
  183. })
  184. if (!this.$isEmpty(this.outWorkPunchRecord)) {
  185. this.outWorkCheckinTime=this.outWorkPunchRecord[0].checkinTime
  186. }
  187. })
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. page{
  194. background-color: #FFFFFF;
  195. }
  196. .flex-center{
  197. display: flex;
  198. justify-content: center;
  199. align-items: center;
  200. }
  201. .desc{
  202. font-size: 28rpx;
  203. color: #8f8f8f;
  204. }
  205. .content {
  206. .change{
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. margin: 0 auto;
  211. margin-top: 100rpx;
  212. height: 100rpx;
  213. color: #b89249;
  214. background-color: #21191b;
  215. }
  216. }
  217. .rule{
  218. padding: 20rpx 30rpx;
  219. display: flex;
  220. justify-content: space-between;
  221. border-bottom: 1rpx solid $dt-border-color-sm;
  222. .left{
  223. .title{
  224. font-size: 30rpx;
  225. font-weight: 800;
  226. padding-bottom: 10rpx;
  227. }
  228. }
  229. .right{
  230. display: flex;
  231. justify-content: center;
  232. align-items: center;
  233. }
  234. }
  235. .history{
  236. display: flex;
  237. padding: 40rpx;
  238. .left{
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: center;
  242. .time{
  243. font-weight: 550;
  244. font-size: 36rpx;
  245. }
  246. .bar{
  247. padding: 10rpx 0;
  248. display: flex;
  249. justify-content: center;
  250. align-items: center;
  251. text{
  252. width: 8rpx;
  253. height: 80rpx;
  254. background-color: #dedede;
  255. }
  256. }
  257. }
  258. .right{
  259. display: flex;
  260. flex-direction: column;
  261. justify-content: space-between;
  262. padding-left: 50rpx;
  263. .working{
  264. display: flex;
  265. flex-direction: column;
  266. text:first-child{
  267. font-weight: 550;
  268. font-size: 32rpx;
  269. }
  270. }
  271. }
  272. }
  273. .out-punch{
  274. display: flex;
  275. padding:15rpx 30rpx;
  276. border-bottom: 1rpx solid $dt-border-color-sm;
  277. .time{
  278. padding-left: 15rpx;
  279. display: flex;
  280. justify-content: center;
  281. align-items: center;
  282. font-weight: 550;
  283. font-size: 36rpx;
  284. }
  285. .content{
  286. padding-left: 50rpx;
  287. display: flex;
  288. flex-direction: column;
  289. .name{
  290. font-weight: 550;
  291. font-size: 32rpx;
  292. padding-bottom: 10rpx;
  293. }
  294. }
  295. }
  296. </style>