ruleSet.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="container">
  3. <view class="placeholder"></view>
  4. <!-- 头部新增规则区域 -->
  5. <view class="add" @click="toPageAddRules">
  6. <view class="icon"><img src="../../static/imgs/add.png" /></view>
  7. <view class="title">新增规则</view>
  8. </view>
  9. <!-- 具体规则区域 -->
  10. <view class="rules">
  11. <!-- 每一个规则区域 -->
  12. <view class="box" v-for="item in list" :key="item.id" @click="toPageEditRules(item.id)">
  13. <view class="box_title">
  14. <view class="icon"><img src="../../static/imgs/my1.png" /></view>
  15. <view class="msg">{{ item.name }}</view>
  16. <view class="right"><img src="../../static/imgs/right.png" /></view>
  17. </view>
  18. <view class="box_info">考勤组:{{ item.groups }}</view>
  19. <view class="box_info">
  20. <span>时 间:{{ item.temList.join(',') }}</span>
  21. <span v-for="(time_item, index) in item.periods" :key="index">{{ format_time(time_item.beginTime) }}-{{ format_time(time_item.endTime) }}</span>
  22. </view>
  23. <view class="box_info">打卡地点:{{ item.locations }}</view>
  24. <view class="box_info">提前通知:提前{{ item.noticeTime }}分钟通知</view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. // 规则列表数组
  34. list: []
  35. }
  36. },
  37. onShow() {
  38. // 清空缓存
  39. uni.removeStorageSync('flag_place')
  40. uni.removeStorageSync('flag')
  41. uni.removeStorageSync('chooseList')
  42. uni.removeStorageSync('ruleTime')
  43. // 获取最新打卡规则列表数据
  44. this.getRuleList()
  45. },
  46. methods: {
  47. // 获取打卡规则列表数据
  48. async getRuleList() {
  49. let res = await this.$myRequest_clockIn({
  50. url: '/attendance/api/settings/rule/list'
  51. })
  52. // console.log(res);
  53. if (res.code == 200) {
  54. this.list = res.data.list
  55. this.list.forEach(ele => {
  56. ele.groups = ele.groups.join(',')
  57. ele.locations = ele.locations.join(',')
  58. ele.dayOfWeeks.sort((a, b) => {
  59. return a - b
  60. })
  61. let arr = ['', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天']
  62. ele.temList = ele.dayOfWeeks.map(item => {
  63. return (item = arr[item])
  64. })
  65. })
  66. }
  67. },
  68. // 点击每一项跳转编辑规则页面
  69. toPageEditRules(id) {
  70. // console.log(id);
  71. uni.navigateTo({
  72. url: `/pages/editRules/editRules?id=${id}`
  73. })
  74. },
  75. // 新增规则跳转页面回调
  76. toPageAddRules() {
  77. uni.navigateTo({
  78. url: '/pages/addRules/addRules'
  79. })
  80. },
  81. // 格式化时间
  82. format_time(timestamp) {
  83. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  84. var date = new Date(timestamp)
  85. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
  86. var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  87. let strDate = h + m
  88. return strDate
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .container {
  95. min-width: 100vw;
  96. min-height: 100vh;
  97. background-color: #f2f2f2;
  98. .placeholder {
  99. height: 30rpx;
  100. }
  101. .add {
  102. margin-bottom: 30rpx;
  103. display: flex;
  104. width: 750rpx;
  105. height: 110rpx;
  106. background-color: #fff;
  107. .icon {
  108. display: flex;
  109. justify-content: center;
  110. align-items: center;
  111. width: 88rpx;
  112. img {
  113. width: 50rpx;
  114. height: 50rpx;
  115. }
  116. }
  117. .title {
  118. line-height: 110rpx;
  119. font-size: 30rpx;
  120. font-weight: 400;
  121. color: #0082fc;
  122. }
  123. }
  124. .rules {
  125. width: 750rpx;
  126. .box {
  127. padding: 0 30rpx;
  128. margin-bottom: 20rpx;
  129. height: 348rpx;
  130. background-color: #fff;
  131. .box_title {
  132. display: flex;
  133. height: 90rpx;
  134. .icon {
  135. flex: 1;
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. img {
  140. width: 35rpx;
  141. height: 35rpx;
  142. }
  143. }
  144. .msg {
  145. flex: 10;
  146. line-height: 90rpx;
  147. font-size: 30rpx;
  148. font-weight: 400;
  149. }
  150. .right {
  151. flex: 1;
  152. display: flex;
  153. justify-content: center;
  154. align-items: center;
  155. img {
  156. width: 16rpx;
  157. height: 25rpx;
  158. }
  159. }
  160. }
  161. .box_info {
  162. display: flex;
  163. margin: 15rpx 0;
  164. height: 44rpx;
  165. font-size: 30rpx;
  166. font-weight: 400;
  167. color: #808080;
  168. overflow: hidden;
  169. white-space: nowrap;
  170. text-overflow: ellipsis;
  171. span {
  172. margin-right: 10rpx;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. </style>