group.vue 11 KB

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