set.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view class="set">
  3. <!-- 年级区域 -->
  4. <view class="box">
  5. 年级
  6. <!-- <picker @change="bindPickerChange" :value="gradeCurrentIndex" :range="gradeArray">
  7. <view class="box_select">
  8. {{ gradeArray[gradeCurrentIndex] }}
  9. <img class="img" src="@/static/images/bottom.png" alt="" />
  10. </view>
  11. </picker> -->
  12. <view class="box_select">{{ configInfo.gradeName }}</view>
  13. </view>
  14. <!-- 班级区域 -->
  15. <view class="box">
  16. 班级
  17. <!-- <picker @change="bindPickerChange" :value="classCurrentIndex" :range="classArray">
  18. <view class="box_select">
  19. {{ classArray[classCurrentIndex] }}
  20. <img class="img" src="@/static/images/bottom.png" alt="" />
  21. </view>
  22. </picker> -->
  23. <view class="box_select">{{ configInfo.className }}</view>
  24. </view>
  25. <!-- 设置区域 -->
  26. <view class="setBox">
  27. <view class="title">
  28. <view class="circle"></view>
  29. 小程序设置
  30. </view>
  31. <!-- 小程序是否需要审核 -->
  32. <checkbox-group class="checkbox_group">
  33. <label class="checkbox" v-for="item in checkItems" :key="item.value" @click="checkboxChange(checkItems, item)">
  34. <view>
  35. <checkbox color="#3464FF" :value="item.value" :checked="item.checked" />
  36. </view>
  37. <view>{{ item.name }}</view>
  38. </label>
  39. </checkbox-group>
  40. <!-- 小程序是否需要推送 -->
  41. <checkbox-group class="checkbox_group">
  42. <label class="checkbox" v-for="item in pushItems" :key="item.value" @click="checkboxChange(pushItems, item)">
  43. <view>
  44. <checkbox color="#3464FF" :value="item.value" :checked="item.checked" />
  45. </view>
  46. <view>{{ item.name }}</view>
  47. </label>
  48. </checkbox-group>
  49. <!-- 小程序是否需要核销区域 -->
  50. <checkbox-group class="checkbox_group">
  51. <label class="checkbox" v-for="item in cancelItems" :key="item.value" @click="checkboxChange(cancelItems, item)">
  52. <view>
  53. <checkbox color="#3464FF" :value="item.value" :checked="item.checked" />
  54. </view>
  55. <view>{{ item.name }}</view>
  56. </label>
  57. </checkbox-group>
  58. <view class="title">
  59. <view class="circle"></view>
  60. 大屏设置
  61. </view>
  62. <!-- 大屏是否需要审核 -->
  63. <checkbox-group class="checkbox_group">
  64. <label class="checkbox" v-for="item in checkItems_screen" :key="item.value" @click="checkboxChange(checkItems_screen, item)">
  65. <view>
  66. <checkbox color="#3464FF" :value="item.value" :checked="item.checked" />
  67. </view>
  68. <view>{{ item.name }}</view>
  69. </label>
  70. </checkbox-group>
  71. <!-- 大屏是否需要推送 -->
  72. <checkbox-group class="checkbox_group">
  73. <label class="checkbox" v-for="item in pushItems_screen" :key="item.value" @click="checkboxChange(pushItems_screen, item)">
  74. <view>
  75. <checkbox color="#3464FF" :value="item.value" :checked="item.checked" />
  76. </view>
  77. <view>{{ item.name }}</view>
  78. </label>
  79. </checkbox-group>
  80. <!-- 大屏是否需要核销区域 -->
  81. <checkbox-group class="checkbox_group">
  82. <label class="checkbox" v-for="item in cancelItems_screen" :key="item.value" @click="checkboxChange(cancelItems_screen, item)">
  83. <view>
  84. <checkbox color="#3464FF" :value="item.value" :checked="item.checked" />
  85. </view>
  86. <view>{{ item.name }}</view>
  87. </label>
  88. </checkbox-group>
  89. <view class="title">
  90. <view class="circle"></view>
  91. 门禁车闸设置
  92. </view>
  93. <!-- 门禁车闸是否需要联动区域 -->
  94. <checkbox-group class="checkbox_group">
  95. <label class="checkbox" v-for="item in doorItems" :key="item.value" @click="checkboxChange(doorItems, item)">
  96. <view>
  97. <checkbox color="#3464FF" :value="item.value" :checked="item.checked" />
  98. </view>
  99. <view>{{ item.name }}</view>
  100. </label>
  101. </checkbox-group>
  102. </view>
  103. <!-- 按钮区域 -->
  104. <view class="btns">
  105. <view class="btn cancel" @click="handleCancle">取消</view>
  106. <view class="btn save" @click="handleSave">保存</view>
  107. </view>
  108. </view>
  109. </template>
  110. <script setup>
  111. import { ref, nextTick } from 'vue'
  112. import backlogVue from '../backlog/backlog.vue'
  113. import { onLoad } from '@dcloudio/uni-app'
  114. import { myRequest } from '../../utils/api'
  115. // 年级数组
  116. // const gradeArray = ref(['2022', '2023', '2024', '2025'])
  117. // 当前选择的年级索引
  118. // const gradeCurrentIndex = ref(0)
  119. // 班级数组
  120. // const classArray = ref(['1班', '2班', '3班', '4班'])
  121. // 当前选择的班级索引
  122. // const classCurrentIndex = ref(0)
  123. // 小程序审核数组
  124. const checkItems = ref([
  125. {
  126. value: 1,
  127. name: '需要审核',
  128. checked: false
  129. },
  130. {
  131. value: 4,
  132. name: '不需要审核',
  133. checked: false
  134. }
  135. ])
  136. // 小程序推送数组
  137. const pushItems = ref([
  138. {
  139. value: 5,
  140. name: '需要推送',
  141. checked: false
  142. },
  143. {
  144. value: 3,
  145. name: '不需要推送',
  146. checked: false
  147. }
  148. ])
  149. // 小程序核销数组
  150. const cancelItems = ref([
  151. {
  152. value: 6,
  153. name: '需要核销',
  154. checked: false
  155. },
  156. {
  157. value: 9,
  158. name: '不需要核销',
  159. checked: false
  160. }
  161. ])
  162. // 大屏审核数组
  163. const checkItems_screen = ref([
  164. {
  165. value: 1,
  166. name: '需要审核',
  167. checked: false
  168. },
  169. {
  170. value: 4,
  171. name: '不需要审核',
  172. checked: false
  173. }
  174. ])
  175. // 大屏推送数组
  176. const pushItems_screen = ref([
  177. {
  178. value: 5,
  179. name: '需要推送',
  180. checked: false
  181. },
  182. {
  183. value: 3,
  184. name: '不需要推送',
  185. checked: false
  186. }
  187. ])
  188. // 大屏核销数组
  189. const cancelItems_screen = ref([
  190. {
  191. value: 6,
  192. name: '需要核销',
  193. checked: false
  194. },
  195. {
  196. value: 9,
  197. name: '不需要核销',
  198. checked: false
  199. }
  200. ])
  201. // 门禁车闸数组
  202. const doorItems = ref([
  203. {
  204. value: 0,
  205. name: '需要联动',
  206. checked: false
  207. },
  208. {
  209. value: 1,
  210. name: '不需要联动',
  211. checked: false
  212. }
  213. ])
  214. // 配置信息
  215. const configInfo = ref({})
  216. onLoad((options) => {
  217. configInfo.value = JSON.parse(options.info)
  218. // console.log(configInfo.value)
  219. handleMatch(checkItems.value, configInfo.value.appAuditConfig)
  220. handleMatch(pushItems.value, configInfo.value.appPushConfig)
  221. handleMatch(cancelItems.value, configInfo.value.appCancelConfig)
  222. handleMatch(checkItems_screen.value, configInfo.value.screenAuditConfig)
  223. handleMatch(pushItems_screen.value, configInfo.value.screenPushConfig)
  224. handleMatch(cancelItems_screen.value, configInfo.value.screenCancelConfig)
  225. handleMatch(doorItems.value, configInfo.value.accessConfig)
  226. })
  227. // 勾选时的回调
  228. const checkboxChange = (list, item) => {
  229. list.forEach((ele) => {
  230. ele.checked = false
  231. })
  232. nextTick(() => {
  233. item.checked = true
  234. })
  235. }
  236. // 取消按钮回调
  237. const handleCancle = () => {
  238. uni.navigateBack(1)
  239. }
  240. // 保存按钮回调
  241. const handleSave = async () => {
  242. let appAuditConfig = handleMatchValue(checkItems.value)
  243. let appPushConfig = handleMatchValue(pushItems.value)
  244. let appCancelConfig = handleMatchValue(cancelItems.value)
  245. let screenAuditConfig = handleMatchValue(checkItems_screen.value)
  246. let screenPushConfig = handleMatchValue(pushItems_screen.value)
  247. let screenCancelConfig = handleMatchValue(cancelItems_screen.value)
  248. let accessConfig = handleMatchValue(doorItems.value)
  249. const res = await myRequest({
  250. url: '/wanzai/api/smartVisitorParentsConfig/update',
  251. method: 'post',
  252. data: {
  253. id: configInfo.value.id,
  254. classId: configInfo.value.classId,
  255. appAuditConfig,
  256. appPushConfig,
  257. appCancelConfig,
  258. screenAuditConfig,
  259. screenPushConfig,
  260. screenCancelConfig,
  261. accessConfig
  262. }
  263. })
  264. // console.log(res)
  265. if (res.code == 200) {
  266. uni.showToast({
  267. title: res.message,
  268. icon: 'none',
  269. duration: 2000
  270. })
  271. setTimeout(() => {
  272. uni.redirectTo({
  273. url: '/pagesReservation/backlog/backlog'
  274. })
  275. }, 2000)
  276. }
  277. }
  278. // 匹配出哪个是勾选上的
  279. const handleMatch = (list, v) => {
  280. list.forEach((ele) => {
  281. if (ele.value == v) {
  282. ele.checked = true
  283. }
  284. })
  285. }
  286. // 匹配出当前勾选上的值
  287. const handleMatchValue = (list) => {
  288. let Obj = list.find((ele) => ele.checked)
  289. return Obj.value
  290. }
  291. </script>
  292. <style lang="scss" scoped>
  293. .set {
  294. box-sizing: border-box;
  295. padding: 30rpx 20rpx 150rpx;
  296. min-height: 100vh;
  297. background-color: #f1f6fe;
  298. .box {
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. margin-bottom: 20rpx;
  303. height: 90rpx;
  304. font-size: 28rpx;
  305. .box_select {
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: center;
  309. padding: 0 20rpx;
  310. box-sizing: border-box;
  311. width: 628rpx;
  312. height: 90rpx;
  313. border-radius: 15rpx;
  314. background-color: #fff;
  315. .img {
  316. width: 33rpx;
  317. height: 33rpx;
  318. }
  319. }
  320. }
  321. .setBox {
  322. box-sizing: border-box;
  323. padding: 0 30rpx;
  324. width: 710rpx;
  325. height: 847rpx;
  326. background-color: #fff;
  327. .title {
  328. display: flex;
  329. align-items: center;
  330. height: 90rpx;
  331. font-size: 28rpx;
  332. font-weight: bold;
  333. .circle {
  334. margin-right: 20rpx;
  335. width: 20rpx;
  336. height: 20rpx;
  337. border-radius: 50%;
  338. background-color: #3464ff;
  339. }
  340. }
  341. .checkbox_group {
  342. display: flex;
  343. align-items: center;
  344. margin-bottom: 35rpx;
  345. .checkbox {
  346. display: flex;
  347. align-items: center;
  348. margin-right: 70rpx;
  349. }
  350. }
  351. }
  352. .btns {
  353. display: flex;
  354. justify-content: space-around;
  355. align-items: center;
  356. margin-top: 100rpx;
  357. height: 100rpx;
  358. .btn {
  359. display: flex;
  360. justify-content: center;
  361. align-items: center;
  362. width: 297rpx;
  363. height: 100rpx;
  364. font-size: 32rpx;
  365. border-radius: 8rpx;
  366. }
  367. .cancel {
  368. color: #0061ff;
  369. border: 2rpx solid #0061ff;
  370. }
  371. .save {
  372. color: #fff;
  373. background-color: #0061ff;
  374. }
  375. }
  376. }
  377. </style>