punchTime.vue 4.1 KB

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