editRules.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. id: ""
  119. };
  120. },
  121. onLoad(option) {
  122. uni.$on('updateRuleName', (data) => {
  123. this.ruleName = data
  124. })
  125. uni.$on('updateGroup', (data) => {
  126. let temList = []
  127. data.forEach((ele) => {
  128. temList.push(ele.name)
  129. })
  130. this.group = temList.join(",")
  131. })
  132. this.info = JSON.parse(option.info)
  133. console.log(this.info);
  134. if (this.info) {
  135. this.ruleName = this.info.name
  136. this.group = this.info.groups
  137. this.time = this.info.temList
  138. this.place = this.info.locations
  139. this.value = this.info.noticeTime
  140. this.periods = this.info.periods
  141. this.id = this.info.id
  142. let ruleTime = []
  143. ruleTime.push({
  144. selectedWeeks: this.time,
  145. list: this.periods
  146. })
  147. uni.setStorageSync("ruleTime", ruleTime)
  148. }
  149. },
  150. methods: {
  151. // 点击确认按钮回调
  152. handleConfirm() {
  153. uni.showModal({
  154. title: '提示',
  155. content: '确定修改吗?',
  156. success: (res) => {
  157. if (res.confirm) {
  158. console.log('用户点击确定');
  159. } else if (res.cancel) {}
  160. }
  161. });
  162. },
  163. // 点击删除按钮回调
  164. handleDelete() {
  165. uni.showModal({
  166. title: '提示',
  167. content: '确定删除吗?',
  168. success: async (res) => {
  169. if (res.confirm) {
  170. let res = await this.$myRequest({
  171. url: "/attendance/api/settings/rule/delete",
  172. method: "delete",
  173. data: {
  174. ids: [this.id]
  175. }
  176. })
  177. // console.log(res);
  178. if (res.code == 200) {
  179. uni.showToast({
  180. title: "删除成功"
  181. })
  182. setTimeout(() => {
  183. uni.navigateBack({
  184. delta: 1
  185. })
  186. }, 1500)
  187. }
  188. } else if (res.cancel) {}
  189. }
  190. });
  191. },
  192. // 提前通知选择框点击回调
  193. changeSelect(e) {
  194. let index = e.detail.value
  195. this.value = this.array[index]
  196. },
  197. // 点击规则名称跳转回调
  198. goPageRuleName() {
  199. uni.navigateTo({
  200. url: `/pages/ruleName/ruleName?flag=1`
  201. })
  202. },
  203. // 点击考勤组跳转回调
  204. goPageGroup() {
  205. uni.navigateTo({
  206. url: `/pages/group/group?flag=2&type=edit`
  207. })
  208. },
  209. // 点击打卡时间跳转回调
  210. goPagePunchTime() {
  211. uni.navigateTo({
  212. url: "/pages/punchTime/punchTime"
  213. })
  214. },
  215. // 点击打卡地点跳转回调
  216. goPagePunchLocation() {
  217. uni.navigateTo({
  218. url: "/pages/punchLocation/punchLocation"
  219. })
  220. },
  221. // 格式化时间
  222. format_time(timestamp) {
  223. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  224. var date = new Date(timestamp);
  225. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  226. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  227. let strDate = h + m;
  228. return strDate;
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. .container {
  235. height: 100vh;
  236. background-color: #fff;
  237. .box {
  238. display: flex;
  239. align-items: center;
  240. margin: 0 30rpx;
  241. width: 690rpx;
  242. height: 90rpx;
  243. font-size: 30rpx;
  244. border-bottom: 1rpx solid #CCCCCC;
  245. background-color: #fff;
  246. .name {
  247. flex: 1;
  248. }
  249. .val {
  250. flex: 3;
  251. display: flex;
  252. align-items: center;
  253. .ele {
  254. display: inline-block;
  255. width: 460rpx;
  256. text-align: end;
  257. color: #A6A6A6;
  258. overflow: hidden;
  259. white-space: nowrap;
  260. text-overflow: ellipsis;
  261. span {
  262. margin-right: 10rpx;
  263. }
  264. }
  265. .black {
  266. color: #000;
  267. }
  268. .right {
  269. margin-left: 20rpx;
  270. width: 40rpx;
  271. display: inline-flex;
  272. justify-content: center;
  273. align-items: center;
  274. img {
  275. width: 16rpx;
  276. height: 25rpx;
  277. }
  278. }
  279. }
  280. }
  281. .button {
  282. margin: auto;
  283. margin-top: 52rpx;
  284. width: 690rpx;
  285. height: 80rpx;
  286. line-height: 80rpx;
  287. text-align: center;
  288. font-size: 32rpx;
  289. font-weight: 500;
  290. color: #fff;
  291. border-radius: 16rpx;
  292. background-color: #3396FB;
  293. }
  294. .button2 {
  295. margin: auto;
  296. margin-top: 30rpx;
  297. width: 690rpx;
  298. height: 80rpx;
  299. line-height: 80rpx;
  300. text-align: center;
  301. font-size: 32rpx;
  302. font-weight: 500;
  303. color: #FF5733;
  304. border-radius: 16rpx;
  305. background-color: #fff;
  306. }
  307. }
  308. </style>