addRules.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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.selectedWeeks}}</span>
  46. <span v-for="(item,index) in time.list" :key="index">
  47. {{item.startTime}}-{{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. </view>
  94. </template>
  95. <script>
  96. export default {
  97. data() {
  98. return {
  99. // 规则名称
  100. ruleName: "未设置",
  101. // 考勤组
  102. group: "未设置",
  103. // 打卡时间
  104. time: "未设置",
  105. // 打卡地点
  106. place: "未设置",
  107. // 提前通知
  108. value: "未设置",
  109. array: ['5分钟', '10分钟', '15分钟', '20分钟'],
  110. index: 0,
  111. };
  112. },
  113. onLoad() {
  114. uni.$on('updatePunchTime', (data) => {
  115. this.time = data
  116. })
  117. },
  118. onShow() {
  119. let ruleName = uni.getStorageSync("ruleName")
  120. if (ruleName) {
  121. this.ruleName = ruleName
  122. }
  123. let ruleGroup = uni.getStorageSync("ruleGroup")
  124. if (ruleGroup) {
  125. this.group = ruleGroup.join(",")
  126. }
  127. let temPlace = uni.getStorageSync("chooseList")
  128. if (temPlace) {
  129. let temList = []
  130. temPlace.forEach((ele) => {
  131. temList.push(ele.title)
  132. })
  133. this.place = temList.join(",")
  134. }
  135. },
  136. methods: {
  137. // 点击确认按钮回调
  138. handleConfirm() {
  139. if (this.ruleName == '未设置') {
  140. uni.showToast({
  141. title: "请设置规则名称",
  142. icon: 'none'
  143. })
  144. return
  145. }
  146. if (this.group == '未设置') {
  147. uni.showToast({
  148. title: "请设置考勤组",
  149. icon: 'none'
  150. })
  151. return
  152. }
  153. if (this.time == '未设置') {
  154. uni.showToast({
  155. title: "请设置打卡时间",
  156. icon: 'none'
  157. })
  158. return
  159. }
  160. if (this.place == '未设置') {
  161. uni.showToast({
  162. title: "请设置打卡地点",
  163. icon: 'none'
  164. })
  165. return
  166. }
  167. if (this.value == '未设置') {
  168. uni.showToast({
  169. title: "请设置提前通知时间",
  170. icon: 'none'
  171. })
  172. return
  173. }
  174. uni.showModal({
  175. title: '提示',
  176. content: '确定新增吗?',
  177. success: function(res) {
  178. if (res.confirm) {
  179. console.log('用户点击确定');
  180. } else if (res.cancel) {
  181. console.log('用户点击取消');
  182. }
  183. }
  184. });
  185. },
  186. // 提前通知选择框点击回调
  187. changeSelect(e) {
  188. let index = e.detail.value
  189. this.value = this.array[index]
  190. },
  191. // 点击规则名称跳转回调
  192. goPageRuleName() {
  193. uni.navigateTo({
  194. url: "/pages/ruleName/ruleName"
  195. })
  196. },
  197. // 点击考勤组跳转回调
  198. goPageGroup() {
  199. uni.navigateTo({
  200. url: `/pages/group/group?flag=2`
  201. })
  202. },
  203. // 点击打卡时间跳转回调
  204. goPagePunchTime() {
  205. uni.navigateTo({
  206. url: "/pages/punchTime/punchTime"
  207. })
  208. },
  209. // 点击打卡地点跳转回调
  210. goPagePunchLocation() {
  211. uni.navigateTo({
  212. url: "/pages/punchLocation/punchLocation"
  213. })
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .container {
  220. height: 100vh;
  221. background-color: #fff;
  222. .box {
  223. display: flex;
  224. align-items: center;
  225. margin: 0 30rpx;
  226. width: 690rpx;
  227. height: 90rpx;
  228. font-size: 30rpx;
  229. border-bottom: 1rpx solid #CCCCCC;
  230. .name {
  231. flex: 1;
  232. }
  233. .val {
  234. flex: 3;
  235. display: flex;
  236. align-items: center;
  237. .ele {
  238. margin-right: 20rpx;
  239. display: inline-block;
  240. width: 460rpx;
  241. text-align: end;
  242. color: #A6A6A6;
  243. overflow: hidden;
  244. white-space: nowrap;
  245. text-overflow: ellipsis;
  246. span {
  247. margin-right: 10rpx;
  248. }
  249. }
  250. .black {
  251. color: #000;
  252. }
  253. .right {
  254. width: 40rpx;
  255. display: inline-flex;
  256. justify-content: center;
  257. align-items: center;
  258. img {
  259. width: 16rpx;
  260. height: 25rpx;
  261. }
  262. }
  263. }
  264. }
  265. .button {
  266. margin: auto;
  267. margin-top: 52rpx;
  268. width: 690rpx;
  269. height: 80rpx;
  270. line-height: 80rpx;
  271. text-align: center;
  272. font-size: 32rpx;
  273. font-weight: 500;
  274. color: #fff;
  275. border-radius: 16rpx;
  276. background-color: #3396FB;
  277. }
  278. }
  279. </style>