group.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <view class="container">
  3. <!-- 头部搜索栏区域 -->
  4. <view class="search">
  5. <uni-search-bar placeholder="请输入搜索内容" cancelButton="none" v-model="searchValue" @input="input"
  6. @clear="clear" @blur="blur">
  7. </uni-search-bar>
  8. </view>
  9. <!-- 新增考勤组区域 -->
  10. <view class="add">
  11. <view class="icon" @click="handleAdd">
  12. <img src="../../static/add.png">
  13. </view>
  14. <view class="title" @click="handleAdd">
  15. 新增考勤组
  16. </view>
  17. </view>
  18. <!--考勤组列表区域 -->
  19. <view class="group">
  20. <uni-swipe-action>
  21. <!-- 每一个考勤组区域 -->
  22. <uni-swipe-action-item :auto-close="true" :right-options="options" @click="onClick(item.id)"
  23. v-for="item in list" :key="item.id">
  24. <view class="group_item">
  25. <uni-collapse :ref="item.id+'collapse'">
  26. <uni-collapse-item :title="item.title" open>
  27. <view class="content">
  28. <view class="num">
  29. 随机人数:{{item.num}}人
  30. </view>
  31. <!-- 树状结构区域 -->
  32. <view class="tree">
  33. <dropDown :node="item.textArr" @nodechange="nodechange(item.id+'collapse')">
  34. </dropDown>
  35. </view>
  36. </view>
  37. </uni-collapse-item>
  38. </uni-collapse>
  39. </view>
  40. </uni-swipe-action-item>
  41. </uni-swipe-action>
  42. </view>
  43. <!-- 新增考勤组弹窗区域 -->
  44. <uni-popup ref="popup" :is-mask-click="false">
  45. <view class="popup_box">
  46. <view class="header">
  47. 新增考勤组
  48. </view>
  49. <view class="body">
  50. <view class="name">
  51. <input type="text" placeholder="请输入考勤组名称">
  52. </view>
  53. <view class="scope">
  54. <view class="notes">
  55. 请选择考勤组范围
  56. </view>
  57. <view class="icon">
  58. <img src="./imgs/bottom.png">
  59. </view>
  60. </view>
  61. <view class="num">
  62. <view class="count">
  63. <view class="icon">
  64. <img src="./imgs/people.png">
  65. </view>
  66. <view class="info">
  67. 680人
  68. </view>
  69. </view>
  70. <view class="input">
  71. <input type="text" placeholder="请输入打卡人数">
  72. </view>
  73. </view>
  74. </view>
  75. <view class="foot">
  76. <view class="left" @click="handleCancel">
  77. 取消
  78. </view>
  79. <view class="right" @click="handleSave">
  80. 保存
  81. </view>
  82. </view>
  83. </view>
  84. </uni-popup>
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. data() {
  90. return {
  91. searchValue: "",
  92. options: [{
  93. text: '删除',
  94. style: {
  95. backgroundColor: '#D43030'
  96. }
  97. }],
  98. list: [{
  99. id: 1,
  100. title: "全体学生",
  101. num: 56,
  102. textArr: [{
  103. "name": "墨轩湖校区",
  104. "id": "1",
  105. "open": false,
  106. "children": [{
  107. "name": "学生",
  108. "id": "1-1",
  109. "open": false,
  110. "children": [{
  111. "name": "计算机专业",
  112. "id": "1-1-1",
  113. "open": false,
  114. "children": [{
  115. "name": "陈志斌",
  116. "id": "1-1-1-1",
  117. "open": false,
  118. "children": [],
  119. },
  120. {
  121. "name": "华志杰",
  122. "id": "1-1-1-2",
  123. "open": false,
  124. "children": [],
  125. },
  126. {
  127. "name": "刘子麟",
  128. "id": "1-1-1-3",
  129. "open": false,
  130. "children": [],
  131. },
  132. ],
  133. },
  134. {
  135. "name": "文法分院",
  136. "id": "1-1-2",
  137. "open": false,
  138. "children": [],
  139. },
  140. ]
  141. },
  142. {
  143. "name": "老师",
  144. "id": "1-2",
  145. "open": false,
  146. "children": [{
  147. "name": "辅导员",
  148. "id": "1-2-1",
  149. "open": false,
  150. "children": [],
  151. }]
  152. }
  153. ]
  154. }, ],
  155. },
  156. {
  157. id: 2,
  158. title: "后勤人员",
  159. num: 36,
  160. textArr: [{
  161. "name": "黄家湖校区",
  162. "id": "1",
  163. "open": false,
  164. "children": [{
  165. "name": "商户",
  166. "id": "1-1",
  167. "open": false,
  168. "children": [{
  169. "name": "食堂",
  170. "id": "1-1-1",
  171. "open": false,
  172. "children": [{
  173. "name": "饭",
  174. "id": "1-1-1-1",
  175. "open": false,
  176. "children": [],
  177. },
  178. {
  179. "name": "水",
  180. "id": "1-1-1-2",
  181. "open": false,
  182. "children": [],
  183. },
  184. {
  185. "name": "零食",
  186. "id": "1-1-1-3",
  187. "open": false,
  188. "children": [],
  189. },
  190. ],
  191. },
  192. {
  193. "name": "商业街",
  194. "id": "1-1-2",
  195. "open": false,
  196. "children": [],
  197. },
  198. ]
  199. },
  200. {
  201. "name": "清洁工",
  202. "id": "1-2",
  203. "open": false,
  204. "children": [{
  205. "name": "园丁",
  206. "id": "1-2-1",
  207. "open": false,
  208. "children": [],
  209. }]
  210. }
  211. ]
  212. }, ],
  213. },
  214. ]
  215. };
  216. },
  217. onLoad() {
  218. // this.$refs.popup.open()
  219. },
  220. methods: {
  221. // 点击弹窗保存按钮回调
  222. handleSave() {
  223. this.$refs.popup.close()
  224. },
  225. // 点击弹窗取消按钮回调
  226. handleCancel() {
  227. this.$refs.popup.close()
  228. },
  229. // 点击新增考勤组按钮回调
  230. handleAdd() {
  231. console.log(123);
  232. this.$refs.popup.open()
  233. },
  234. // 点击树状节点回调
  235. nodechange(ref) {
  236. this.$nextTick(() => {
  237. setTimeout(() => {
  238. this.$refs[ref][0].resize()
  239. }, 200)
  240. })
  241. },
  242. // 点击右侧删除按钮回调
  243. onClick(id) {
  244. console.log(id);
  245. uni.showModal({
  246. title: '提示',
  247. content: '确定删除该考勤组吗?',
  248. success: function(res) {
  249. if (res.confirm) {
  250. console.log('用户点击确定');
  251. uni.showToast({
  252. title: "删除成功",
  253. icon: 'success'
  254. })
  255. } else if (res.cancel) {
  256. console.log('用户点击取消');
  257. }
  258. }
  259. });
  260. },
  261. // 搜索框失焦回调
  262. blur(res) {
  263. uni.showToast({
  264. title: '搜索:' + res.value,
  265. icon: 'none'
  266. })
  267. },
  268. // 搜索框输入时的回调
  269. input(res) {
  270. console.log('----input:', res)
  271. },
  272. // 清除搜索框内容时的回调
  273. clear(res) {
  274. uni.showToast({
  275. title: 'clear事件,清除值为:' + res.value,
  276. icon: 'none'
  277. })
  278. },
  279. }
  280. }
  281. </script>
  282. <style lang="scss" scoped>
  283. .container {
  284. padding-top: 20rpx;
  285. .search {
  286. box-sizing: border-box;
  287. padding: 0 30rpx;
  288. width: 750rpx;
  289. height: 90rpx;
  290. border-radius: 170rpx;
  291. background-color: #fff;
  292. }
  293. .add {
  294. margin-top: 20rpx;
  295. display: flex;
  296. align-items: center;
  297. width: 750rpx;
  298. height: 110rpx;
  299. background-color: #fff;
  300. .icon {
  301. margin: 0 20rpx 0 30rpx;
  302. width: 36rpx;
  303. height: 36rpx;
  304. img {
  305. width: 100%;
  306. height: 100%;
  307. }
  308. }
  309. .title {
  310. font-size: 30rpx;
  311. color: #0082FC;
  312. }
  313. }
  314. .group {
  315. margin-top: 20rpx;
  316. background-color: #F2F2F2;
  317. .group_item {
  318. margin-bottom: 20rpx;
  319. width: 750rpx;
  320. background-color: #fff;
  321. .content {
  322. padding-bottom: 50rpx;
  323. .num {
  324. margin-left: 30rpx;
  325. height: 50rpx;
  326. font-size: 24rpx;
  327. color: #808080;
  328. }
  329. .tree {}
  330. }
  331. }
  332. }
  333. .popup_box {
  334. width: 630rpx;
  335. height: 610rpx;
  336. border-radius: 33rpx;
  337. background-color: #fff;
  338. .header {
  339. width: 630rpx;
  340. height: 97rpx;
  341. line-height: 97rpx;
  342. text-align: center;
  343. font-size: 32rpx;
  344. font-weight: 500;
  345. border-bottom: 1rpx solid #E6E6E6;
  346. }
  347. .body {
  348. display: flex;
  349. flex-direction: column;
  350. align-items: center;
  351. width: 630rpx;
  352. height: 414rpx;
  353. border-bottom: 1rpx solid #E6E6E6;
  354. .name {
  355. margin-top: 42rpx;
  356. width: 570rpx;
  357. height: 80rpx;
  358. border-radius: 10rpx;
  359. border: 1rpx solid #ccc;
  360. input {
  361. padding: 0 24rpx;
  362. width: 90%;
  363. height: 100%;
  364. font-size: 28rpx;
  365. color: #B3B3B3;
  366. }
  367. }
  368. .scope {
  369. display: flex;
  370. align-items: center;
  371. margin-top: 32rpx;
  372. width: 570rpx;
  373. height: 80rpx;
  374. border-radius: 10rpx;
  375. border: 1rpx solid #ccc;
  376. .notes {
  377. padding-left: 24rpx;
  378. flex: 5;
  379. font-size: 28rpx;
  380. color: #808080;
  381. }
  382. .icon {
  383. flex: 1;
  384. display: flex;
  385. justify-content: center;
  386. align-items: center;
  387. img {
  388. width: 25rpx;
  389. height: 20rpx;
  390. }
  391. }
  392. }
  393. .num {
  394. display: flex;
  395. align-items: center;
  396. margin-top: 32rpx;
  397. width: 570rpx;
  398. height: 80rpx;
  399. border-radius: 10rpx;
  400. border: 1rpx solid #ccc;
  401. .count {
  402. flex: 2;
  403. display: flex;
  404. align-items: center;
  405. height: 50rpx;
  406. border-right: 1rpx solid #A6A6A6;
  407. .icon {
  408. flex: 1;
  409. display: flex;
  410. justify-content: center;
  411. align-items: center;
  412. img {
  413. width: 30rpx;
  414. height: 30rpx;
  415. }
  416. }
  417. .info {
  418. flex: 2;
  419. font-size: 28rpx;
  420. }
  421. }
  422. .input {
  423. flex: 4;
  424. input {
  425. padding: 0 45rpx;
  426. width: 80%;
  427. height: 100%;
  428. font-size: 28rpx;
  429. }
  430. }
  431. }
  432. }
  433. .foot {
  434. display: flex;
  435. justify-content: space-evenly;
  436. align-items: center;
  437. width: 630rpx;
  438. height: 99rpx;
  439. font-size: 28rpx;
  440. .left {
  441. flex: 1;
  442. text-align: center;
  443. border-right: 1rpx solid #CCC;
  444. }
  445. .right {
  446. flex: 1;
  447. text-align: center;
  448. color: #2A82E4;
  449. }
  450. }
  451. }
  452. }
  453. // 解决输入框不居中问题
  454. ::v-deep .uni-searchbar {
  455. padding: 10rpx;
  456. }
  457. // 解决左滑区域突出问题
  458. ::v-deep .uni-swipe_button-group {
  459. margin-bottom: 20rpx;
  460. }
  461. // 清除树状组件下边框
  462. ::v-deep .uni-collapse-item__wrap-content.uni-collapse-item--border {
  463. border-bottom: none;
  464. }
  465. </style>