setPunchTime.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="container">
  3. <!-- 选择星期区域 -->
  4. <view class="week_title">
  5. 选择星期
  6. </view>
  7. <view class="week">
  8. <jlk-week :value="selectedWeeks" @change="changeWeek"></jlk-week>
  9. </view>
  10. <!-- 选择打卡时间段区域 -->
  11. <view class="time_list">
  12. <view class="title">
  13. 选择打卡时间段
  14. </view>
  15. <view class="add" @click="handleAddTime">
  16. 添加时段
  17. </view>
  18. </view>
  19. <view class="list">
  20. <uni-swipe-action>
  21. <!-- 每一个时间段区域 -->
  22. <uni-swipe-action-item :auto-close="true" :right-options="options" @click="onClick(item.id)"
  23. v-for="(item,index) in list" :key="index">
  24. <view class="item">
  25. <view class="item_box">
  26. <picker mode="time" :value="item.startTime" @change="bindTimeChange($event,1,item)">
  27. <view class="uni-input">
  28. <view class="input_time">
  29. {{item.startTime}}
  30. </view>
  31. <view class="input_icon">
  32. <img src="../../static/time.png">
  33. </view>
  34. </view>
  35. </picker>
  36. </view>
  37. --
  38. <view class="item_box">
  39. <picker mode="time" :value="item.endTime" @change="bindTimeChange($event,2,item)">
  40. <view class="uni-input">
  41. <view class="input_time">
  42. {{item.endTime}}
  43. </view>
  44. <view class="input_icon">
  45. <img src="../../static/time.png">
  46. </view>
  47. </view>
  48. </picker>
  49. </view>
  50. </view>
  51. </uni-swipe-action-item>
  52. </uni-swipe-action>
  53. <!-- <view class="edit">
  54. 编辑
  55. </view> -->
  56. </view>
  57. <!-- switch区域 -->
  58. <view class="switch">
  59. <view class="switch_title">
  60. 除去法定节假日
  61. </view>
  62. <view class="switch_button">
  63. <switch color="#2A82E4" @change="switchChange" />
  64. </view>
  65. </view>
  66. <view class="button">
  67. 保存
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import JlkWeek from '@/uni_modules/jlk-week/components/jlk-week/jlk-week.vue';
  73. export default {
  74. components: {
  75. JlkWeek
  76. },
  77. data() {
  78. return {
  79. selectedWeeks: [],
  80. list: [{
  81. startTime: "00:00",
  82. endTime: "00:00",
  83. },
  84. {
  85. startTime: "00:00",
  86. endTime: "00:00",
  87. },
  88. ],
  89. info: {},
  90. options: [{
  91. text: '删除',
  92. style: {
  93. backgroundColor: '#D43030'
  94. }
  95. }],
  96. }
  97. },
  98. onLoad(options) {
  99. if (options.flag == 1) {
  100. uni.setNavigationBarTitle({
  101. title: '添加打卡时间'
  102. });
  103. } else {
  104. uni.setNavigationBarTitle({
  105. title: '编辑打卡时间'
  106. });
  107. this.selectedWeeks = [0, 1]
  108. // this.info=JSON.parse(options.info)
  109. // console.log(this.info);
  110. // let temList=this.info.time.split("、")
  111. // console.log(temList);
  112. }
  113. },
  114. methods: {
  115. changeWeek(value) {
  116. console.log(value);
  117. this.selectedWeeks = value
  118. },
  119. bindTimeChange(e, val, item) {
  120. console.log(e);
  121. console.log(val);
  122. console.log(item);
  123. if (val == 1) {
  124. item.startTime = e.detail.value
  125. } else {
  126. item.endTime = e.detail.value
  127. }
  128. },
  129. handleAddTime() {
  130. this.list.push({
  131. startTime: "00:00",
  132. endTime: "00:00",
  133. })
  134. },
  135. switchChange(e) {
  136. console.log('switch1 发生 change 事件,携带值为', e.detail.value)
  137. },
  138. // 点击右侧删除按钮回调
  139. onClick(id) {
  140. console.log(id);
  141. uni.showModal({
  142. title: '提示',
  143. content: '确定删除该打卡时间段吗?',
  144. success: function(res) {
  145. if (res.confirm) {
  146. console.log('用户点击确定');
  147. uni.showToast({
  148. title: "删除成功",
  149. icon: 'success'
  150. })
  151. } else if (res.cancel) {
  152. console.log('用户点击取消');
  153. }
  154. }
  155. });
  156. },
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .container {
  162. padding-top: 33rpx;
  163. .week_title {
  164. margin-left: 35rpx;
  165. font-size: 34rpx;
  166. font-weight: 500;
  167. }
  168. .week {
  169. margin: 0 auto;
  170. margin-top: 12rpx;
  171. width: 690rpx;
  172. height: 107rpx;
  173. border-radius: 10rpx;
  174. background-color: #fff;
  175. }
  176. .time_list {
  177. display: flex;
  178. align-items: center;
  179. margin: 0 auto;
  180. margin-top: 32rpx;
  181. width: 690rpx;
  182. height: 60rpx;
  183. font-weight: 500;
  184. .title {
  185. flex: 4;
  186. font-size: 34rpx;
  187. }
  188. .add {
  189. flex: 1;
  190. text-align: end;
  191. font-size: 24rpx;
  192. color: #3396FB;
  193. }
  194. }
  195. .list {
  196. margin: 0 auto;
  197. margin-top: 13rpx;
  198. padding-top: 20rpx;
  199. padding-bottom: 20rpx;
  200. width: 690rpx;
  201. border-radius: 10rpx;
  202. background-color: #fff;
  203. .item {
  204. display: flex;
  205. justify-content: space-between;
  206. margin: 0 20rpx 20rpx 20rpx;
  207. width: 650rpx;
  208. height: 60rpx;
  209. .item_box {
  210. width: 291rpx;
  211. height: 60rpx;
  212. border-radius: 8rpx;
  213. border: 1rpx solid #CCCCCC;
  214. .uni-input {
  215. display: flex;
  216. align-items: center;
  217. width: 291rpx;
  218. height: 60rpx;
  219. .input_time {
  220. flex: 2;
  221. margin-left: 34rpx;
  222. font-size: 28rpx;
  223. color: #707070;
  224. }
  225. .input_icon {
  226. flex: 1;
  227. display: flex;
  228. justify-content: center;
  229. align-items: center;
  230. img {
  231. width: 26rpx;
  232. height: 26rpx;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. // .edit {
  239. // margin-left: 20rpx;
  240. // padding-top: 10rpx;
  241. // width: 70rpx;
  242. // height: 60rpx;
  243. // color: #3396FB;
  244. // font-size: 24rpx;
  245. // font-weight: 500;
  246. // }
  247. }
  248. .switch {
  249. box-sizing: border-box;
  250. display: flex;
  251. align-items: center;
  252. margin: 0 auto;
  253. margin-top: 20rpx;
  254. padding: 0 20rpx;
  255. width: 690rpx;
  256. height: 86rpx;
  257. border-radius: 10rpx;
  258. background: #FFFFFF;
  259. .switch_title {
  260. flex: 5;
  261. font-size: 34rpx;
  262. font-weight: 500;
  263. }
  264. .switch_button {
  265. flex: 1;
  266. }
  267. }
  268. .button {
  269. margin: 0 auto;
  270. margin-top: 50rpx;
  271. width: 690rpx;
  272. height: 80rpx;
  273. line-height: 80rpx;
  274. text-align: center;
  275. color: #fff;
  276. font-size: 32rpx;
  277. border-radius: 16rpx;
  278. background-color: #3396FB;
  279. }
  280. }
  281. // 选择星期区域圆角效果
  282. ::v-deep .weeks-outer {
  283. border-radius: 10rpx;
  284. }
  285. // 解决左滑区域突出问题
  286. ::v-deep .uni-swipe_button-group {
  287. margin-bottom: 20rpx;
  288. }
  289. </style>