punchTime.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="container">
  3. <!-- 头部添加打卡时间区域 -->
  4. <view class="add">
  5. <view class="icon" @click="handleAdd">
  6. <img src="../../static/add.png">
  7. </view>
  8. <view class="title" @click="handleAdd">
  9. 添加打卡时间
  10. </view>
  11. <view class="none"></view>
  12. </view>
  13. <!-- 打卡时间列表 -->
  14. <view class="list">
  15. <uni-swipe-action>
  16. <!-- 每一个时间段区域 -->
  17. <uni-swipe-action-item :auto-close="true" :right-options="options" @click="onClick(index)"
  18. v-for="(item,index) in list" :key="index">
  19. <view class="box" @click="handleEdit(item)">
  20. <view class="left">
  21. <view class="week">
  22. <view class="key">
  23. 星期
  24. </view>
  25. <view class="value">
  26. {{item.selectedWeeks}}
  27. </view>
  28. </view>
  29. <view class="week">
  30. <view class="key">
  31. 时段
  32. </view>
  33. <view class="value">
  34. <span v-for="(item_time,index_time) in item.list" :key="index_time">
  35. {{item_time.startTime}}-{{item_time.endTime}}
  36. </span>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="right">
  41. <img src="../../static/right.png">
  42. </view>
  43. </view>
  44. </uni-swipe-action-item>
  45. </uni-swipe-action>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. list: [
  54. // {
  55. // id: 1,
  56. // week: "周一,周二,周三,周四,周五,周六,周日",
  57. // time: "09:00-17:00、20:00-21:00、22:00-23:00"
  58. // },
  59. // {
  60. // id: 2,
  61. // week: "周一,周二,周三,周四,周五,周六,周日",
  62. // time: "09:00-17:00"
  63. // },
  64. // {
  65. // id: 3,
  66. // week: "周一,周二,周三,周四,周五,周六,周日",
  67. // time: "12:00-17:00"
  68. // },
  69. // {
  70. // id: 4,
  71. // week: "周一,周二,周三,周四,周五,周六,周日",
  72. // time: "09:00-17:00、20:00-21:00、22:00-23:00"
  73. // },
  74. ],
  75. options: [{
  76. text: '删除',
  77. style: {
  78. backgroundColor: '#D43030'
  79. }
  80. }],
  81. }
  82. },
  83. onShow() {
  84. let ruleTime = uni.getStorageSync("ruleTime")
  85. if (ruleTime) {
  86. this.list = ruleTime
  87. }
  88. },
  89. methods: {
  90. // 点击添加打卡时间回调 跳转到添加页面
  91. handleAdd() {
  92. uni.navigateTo({
  93. url: `/pages/setPunchTime/setPunchTime?flag=1`
  94. })
  95. },
  96. // 点击每一个时间段回调 跳转到编辑页面
  97. handleEdit(item) {
  98. let info = JSON.stringify(item)
  99. uni.navigateTo({
  100. url: `/pages/setPunchTime/setPunchTime?flag=2&info=${info}`
  101. })
  102. },
  103. // 点击右侧删除按钮回调
  104. onClick(index) {
  105. // console.log(index);
  106. uni.showModal({
  107. title: '提示',
  108. content: '确定删除该打卡时间吗?',
  109. success: (res) => {
  110. if (res.confirm) {
  111. uni.showToast({
  112. title: "删除成功",
  113. icon: 'success'
  114. })
  115. this.list.splice(index, 1)
  116. uni.setStorageSync("ruleTime", this.list)
  117. } else if (res.cancel) {}
  118. }
  119. });
  120. },
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .container {
  126. padding-top: 20rpx;
  127. .add {
  128. display: flex;
  129. margin: 0 auto;
  130. width: 690rpx;
  131. height: 87rpx;
  132. line-height: 87rpx;
  133. border-radius: 14rpx;
  134. background-color: #fff;
  135. .icon {
  136. flex: 1;
  137. display: flex;
  138. justify-content: center;
  139. align-items: center;
  140. img {
  141. width: 36rpx;
  142. height: 36rpx;
  143. }
  144. }
  145. .title {
  146. flex: 3;
  147. font-size: 30rpx;
  148. color: #0082FC;
  149. }
  150. .none {
  151. flex: 5;
  152. }
  153. }
  154. .list {
  155. margin-top: 20rpx;
  156. padding-bottom: 30rpx;
  157. .box {
  158. display: flex;
  159. margin: 0 auto;
  160. margin-bottom: 20rpx;
  161. width: 690rpx;
  162. height: 132rpx;
  163. border-radius: 14rpx;
  164. background-color: #fff;
  165. .left {
  166. flex: 5;
  167. display: flex;
  168. flex-direction: column;
  169. margin-left: 17rpx;
  170. .week {
  171. flex: 1;
  172. display: flex;
  173. align-items: center;
  174. font-size: 24rpx;
  175. .key {
  176. flex: 1;
  177. margin-left: 8rpx;
  178. color: #A6A6A6;
  179. }
  180. .value {
  181. flex: 5;
  182. overflow: hidden;
  183. white-space: nowrap;
  184. text-overflow: ellipsis;
  185. }
  186. }
  187. }
  188. .right {
  189. flex: 2;
  190. display: flex;
  191. justify-content: flex-end;
  192. align-items: center;
  193. img {
  194. margin-right: 20rpx;
  195. width: 20rpx;
  196. height: 30rpx;
  197. }
  198. }
  199. }
  200. }
  201. }
  202. // 解决左滑区域突出问题
  203. ::v-deep .uni-swipe_button-group {
  204. margin-bottom: 20rpx;
  205. }
  206. </style>