editRules.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="container">
  3. <!-- 每一个选项区域 -->
  4. <view class="box">
  5. <view class="name">
  6. 规则名称:
  7. </view>
  8. <view class="val" @click="goPageRuleName">
  9. <view class="ele" v-if="ruleName=='未设置'">
  10. {{ruleName}}
  11. </view>
  12. <view class="ele black" v-else>
  13. {{ruleName}}
  14. </view>
  15. <view class="right">
  16. <img src="../../static/right.png">
  17. </view>
  18. </view>
  19. </view>
  20. <view class="box">
  21. <view class="name">
  22. 考 勤 组:
  23. </view>
  24. <view class="val" @click="goPageGroup">
  25. <view class="ele" v-if="group=='未设置'">
  26. {{group}}
  27. </view>
  28. <view class="ele black" v-else>
  29. {{group}}
  30. </view>
  31. <view class="right">
  32. <img src="../../static/right.png">
  33. </view>
  34. </view>
  35. </view>
  36. <view class="box">
  37. <view class="name">
  38. 打卡时间:
  39. </view>
  40. <view class="val" @click="goPagePunchTime">
  41. <view class="ele" v-if="time=='未设置'">
  42. {{time}}
  43. </view>
  44. <view class="ele black" v-else>
  45. <span>{{time}}</span>
  46. <span v-for="(item,index) in periods" :key="index">
  47. {{format_time(item.beginTime)}}-{{format_time(item.endTime)}}
  48. </span>
  49. </view>
  50. <view class="right">
  51. <img src="../../static/right.png">
  52. </view>
  53. </view>
  54. </view>
  55. <view class="box">
  56. <view class="name">
  57. 打卡地点:
  58. </view>
  59. <view class="val" @click="goPagePunchLocation">
  60. <view class="ele" v-if="place=='未设置'">
  61. {{place}}
  62. </view>
  63. <view class="ele black" v-else>
  64. {{place}}
  65. </view>
  66. <view class="right">
  67. <img src="../../static/right.png">
  68. </view>
  69. </view>
  70. </view>
  71. <view class="box">
  72. <view class="name">
  73. 提前通知:
  74. </view>
  75. <picker :value="index" :range="array" @change="changeSelect">
  76. <view class="val">
  77. <view class="ele" v-if="value=='未设置'">
  78. {{value}}
  79. </view>
  80. <view class="ele black" v-else>
  81. {{value}}分钟
  82. </view>
  83. <view class="right">
  84. <img src="../../static/right.png">
  85. </view>
  86. </view>
  87. </picker>
  88. </view>
  89. <!-- 确认按钮区域 -->
  90. <view class="button" @click="handleConfirm">
  91. 确认
  92. </view>
  93. <!-- 删除按钮区域 -->
  94. <view class="button2" @click="handleDelete">
  95. 删除
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. export default {
  101. data() {
  102. return {
  103. info: {},
  104. // 规则名称
  105. ruleName: "未设置",
  106. // 考勤组
  107. group: "未设置",
  108. // 打卡时间
  109. time: "未设置",
  110. // 打卡地点
  111. place: "未设置",
  112. // 提前通知
  113. value: "未设置",
  114. // 提前通知选项
  115. array: ['5分钟', '10分钟', '15分钟', '20分钟'],
  116. periods: [],
  117. index: 0,
  118. };
  119. },
  120. onLoad(option) {
  121. this.info = JSON.parse(option.info)
  122. console.log(this.info);
  123. this.ruleName = this.info.name
  124. this.group = this.info.groups
  125. this.time = this.info.temList
  126. this.place = this.info.locations
  127. this.value = this.info.noticeTime
  128. this.periods = this.info.periods
  129. uni.$on('update', (data) => {
  130. this.ruleName = data
  131. })
  132. },
  133. onUnload() {
  134. uni.$off('update')
  135. },
  136. methods: {
  137. // 点击确认按钮回调
  138. handleConfirm() {
  139. uni.showModal({
  140. title: '提示',
  141. content: '确定修改吗?',
  142. success: function(res) {
  143. if (res.confirm) {
  144. console.log('用户点击确定');
  145. } else if (res.cancel) {
  146. console.log('用户点击取消');
  147. }
  148. }
  149. });
  150. },
  151. // 点击删除按钮回调
  152. handleDelete() {
  153. uni.showModal({
  154. title: '提示',
  155. content: '确定删除吗?',
  156. success: function(res) {
  157. if (res.confirm) {
  158. console.log('用户点击确定');
  159. } else if (res.cancel) {
  160. console.log('用户点击取消');
  161. }
  162. }
  163. });
  164. },
  165. // 提前通知选择框点击回调
  166. changeSelect(e) {
  167. let index = e.detail.value
  168. this.value = this.array[index]
  169. },
  170. // 点击规则名称跳转回调
  171. goPageRuleName() {
  172. uni.navigateTo({
  173. url: "/pages/ruleName/ruleName"
  174. })
  175. },
  176. // 点击考勤组跳转回调
  177. goPageGroup() {
  178. uni.navigateTo({
  179. url: `/pages/group/group?flag=2`
  180. })
  181. },
  182. // 点击打卡时间跳转回调
  183. goPagePunchTime() {
  184. uni.navigateTo({
  185. url: "/pages/punchTime/punchTime"
  186. })
  187. },
  188. // 点击打卡地点跳转回调
  189. goPagePunchLocation() {
  190. uni.navigateTo({
  191. url: "/pages/punchLocation/punchLocation"
  192. })
  193. },
  194. // 格式化时间
  195. format_time(timestamp) {
  196. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  197. var date = new Date(timestamp);
  198. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  199. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  200. let strDate = h + m;
  201. return strDate;
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. .container {
  208. height: 100vh;
  209. background-color: #fff;
  210. .box {
  211. display: flex;
  212. align-items: center;
  213. margin: 0 30rpx;
  214. width: 690rpx;
  215. height: 90rpx;
  216. font-size: 30rpx;
  217. border-bottom: 1rpx solid #CCCCCC;
  218. background-color: #fff;
  219. .name {
  220. flex: 1;
  221. }
  222. .val {
  223. flex: 3;
  224. display: flex;
  225. align-items: center;
  226. .ele {
  227. display: inline-block;
  228. width: 460rpx;
  229. text-align: end;
  230. color: #A6A6A6;
  231. overflow: hidden;
  232. white-space: nowrap;
  233. text-overflow: ellipsis;
  234. span {
  235. margin-right: 10rpx;
  236. }
  237. }
  238. .black {
  239. color: #000;
  240. }
  241. .right {
  242. margin-left: 20rpx;
  243. width: 40rpx;
  244. display: inline-flex;
  245. justify-content: center;
  246. align-items: center;
  247. img {
  248. width: 16rpx;
  249. height: 25rpx;
  250. }
  251. }
  252. }
  253. }
  254. .button {
  255. margin: auto;
  256. margin-top: 52rpx;
  257. width: 690rpx;
  258. height: 80rpx;
  259. line-height: 80rpx;
  260. text-align: center;
  261. font-size: 32rpx;
  262. font-weight: 500;
  263. color: #fff;
  264. border-radius: 16rpx;
  265. background-color: #3396FB;
  266. }
  267. .button2 {
  268. margin: auto;
  269. margin-top: 30rpx;
  270. width: 690rpx;
  271. height: 80rpx;
  272. line-height: 80rpx;
  273. text-align: center;
  274. font-size: 32rpx;
  275. font-weight: 500;
  276. color: #FF5733;
  277. border-radius: 16rpx;
  278. background-color: #fff;
  279. }
  280. }
  281. </style>