group.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  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="请输入考勤组名称" v-model="group_name">
  66. </view>
  67. <view class="scope" @click="handleChoose">
  68. <view class="notes" v-if="!group_scope">
  69. 请选择考勤组范围
  70. </view>
  71. <view class="notes2" v-else>
  72. {{group_scope}}
  73. </view>
  74. <view class="icon">
  75. <img src="./imgs/bottom.png">
  76. </view>
  77. </view>
  78. <view class="num">
  79. <view class="count">
  80. <view class="icon">
  81. <img src="./imgs/people.png">
  82. </view>
  83. <view class="info">
  84. 680人
  85. </view>
  86. </view>
  87. <view class="input">
  88. <input type="number" placeholder="请输入打卡人数" v-model="group_num">
  89. </view>
  90. </view>
  91. </view>
  92. <view class="foot">
  93. <view class="left" @click="handleCancel">
  94. 取消
  95. </view>
  96. <view class="right" @click="handleSave">
  97. 保存
  98. </view>
  99. </view>
  100. </view>
  101. </uni-popup>
  102. <!-- 选择考勤组范围区域 -->
  103. <tki-tree ref="tkitree" multiple :range="range" rangeKey="name" confirmColor="#3396FB" @confirm="treeConfirm"
  104. @cancel="treeCancel" />
  105. </view>
  106. </template>
  107. <script>
  108. import tkiTree from "@/components/tki-tree/tki-tree.vue"
  109. export default {
  110. components: {
  111. tkiTree
  112. },
  113. data() {
  114. return {
  115. group_name: "",
  116. group_scope: "",
  117. group_num: "",
  118. flag: null,
  119. checkStatus: false,
  120. searchValue: "",
  121. options: [{
  122. text: '删除',
  123. style: {
  124. backgroundColor: '#D43030'
  125. }
  126. }],
  127. list: [{
  128. id: 1,
  129. title: "全体学生",
  130. num: 56,
  131. checked: false,
  132. textArr: [{
  133. "name": "墨轩湖校区",
  134. "id": "1",
  135. "open": false,
  136. "children": [{
  137. "name": "学生",
  138. "id": "1-1",
  139. "open": false,
  140. "children": [{
  141. "name": "计算机专业",
  142. "id": "1-1-1",
  143. "open": false,
  144. "children": [{
  145. "name": "陈志斌",
  146. "id": "1-1-1-1",
  147. "open": false,
  148. "children": [],
  149. },
  150. {
  151. "name": "华志杰",
  152. "id": "1-1-1-2",
  153. "open": false,
  154. "children": [],
  155. },
  156. {
  157. "name": "刘子麟",
  158. "id": "1-1-1-3",
  159. "open": false,
  160. "children": [],
  161. },
  162. ],
  163. },
  164. {
  165. "name": "文法分院",
  166. "id": "1-1-2",
  167. "open": false,
  168. "children": [],
  169. },
  170. ]
  171. },
  172. {
  173. "name": "老师",
  174. "id": "1-2",
  175. "open": false,
  176. "children": [{
  177. "name": "辅导员",
  178. "id": "1-2-1",
  179. "open": false,
  180. "children": [],
  181. }]
  182. }
  183. ]
  184. }, ],
  185. },
  186. {
  187. id: 2,
  188. title: "后勤人员",
  189. num: 36,
  190. checked: false,
  191. textArr: [{
  192. "name": "黄家湖校区",
  193. "id": "1",
  194. "open": false,
  195. "children": [{
  196. "name": "商户",
  197. "id": "1-1",
  198. "open": false,
  199. "children": [{
  200. "name": "食堂",
  201. "id": "1-1-1",
  202. "open": false,
  203. "children": [{
  204. "name": "饭",
  205. "id": "1-1-1-1",
  206. "open": false,
  207. "children": [],
  208. },
  209. {
  210. "name": "水",
  211. "id": "1-1-1-2",
  212. "open": false,
  213. "children": [],
  214. },
  215. {
  216. "name": "零食",
  217. "id": "1-1-1-3",
  218. "open": false,
  219. "children": [],
  220. },
  221. ],
  222. },
  223. {
  224. "name": "商业街",
  225. "id": "1-1-2",
  226. "open": false,
  227. "children": [],
  228. },
  229. ]
  230. },
  231. {
  232. "name": "清洁工",
  233. "id": "1-2",
  234. "open": false,
  235. "children": [{
  236. "name": "园丁",
  237. "id": "1-2-1",
  238. "open": false,
  239. "children": [],
  240. }]
  241. }
  242. ]
  243. }, ],
  244. },
  245. ],
  246. range: [{
  247. id: 1,
  248. name: '北京市',
  249. children: [{
  250. id: 11,
  251. name: '市辖区',
  252. children: [{
  253. id: 111,
  254. name: '西城区',
  255. children: [{
  256. id: 1111,
  257. name: '南河沿大街',
  258. children: [{
  259. id: 11111,
  260. name: '紫金宫饭店',
  261. // checked: true
  262. }, ]
  263. }, ]
  264. },
  265. {
  266. id: 112,
  267. name: '东城区',
  268. },
  269. {
  270. id: 113,
  271. name: '朝阳区',
  272. },
  273. {
  274. id: 114,
  275. name: '丰台区',
  276. }
  277. ]
  278. }, ]
  279. },
  280. {
  281. id: 2,
  282. name: '河北省',
  283. children: [{
  284. id: 21,
  285. name: '石家庄市',
  286. },
  287. {
  288. id: 22,
  289. name: '唐山市',
  290. },
  291. {
  292. id: 23,
  293. name: '秦皇岛市',
  294. },
  295. ]
  296. },
  297. {
  298. id: 3,
  299. name: '山东省',
  300. children: [{
  301. id: 31,
  302. name: '济南市',
  303. children: [{
  304. id: 311,
  305. name: '历下区',
  306. children: [{
  307. id: 3131,
  308. name: '解放路街道办事处',
  309. }, ]
  310. },
  311. {
  312. id: 312,
  313. name: '槐荫区',
  314. },
  315. {
  316. id: 313,
  317. name: '天桥区',
  318. },
  319. {
  320. id: 314,
  321. name: '历城区',
  322. },
  323. {
  324. id: 315,
  325. name: '长清区',
  326. }
  327. ]
  328. },
  329. {
  330. id: 32,
  331. name: '青岛市',
  332. },
  333. {
  334. id: 33,
  335. name: '临沂市',
  336. children: [{
  337. id: 331,
  338. name: '兰山区',
  339. children: [{
  340. id: 3331,
  341. name: '金雀山街道',
  342. }, ]
  343. },
  344. {
  345. id: 332,
  346. name: '河东区',
  347. },
  348. {
  349. id: 333,
  350. name: '罗庄区',
  351. children: [{
  352. id: 3331,
  353. name: '盛庄街道',
  354. }, ]
  355. }
  356. ]
  357. },
  358. {
  359. id: 34,
  360. name: '日照市',
  361. },
  362. {
  363. id: 35,
  364. name: '淄博市',
  365. },
  366. {
  367. id: 36,
  368. name: '枣庄市',
  369. },
  370. {
  371. id: 37,
  372. name: '东营市',
  373. },
  374. {
  375. id: 38,
  376. name: '潍坊市',
  377. },
  378. {
  379. id: 39,
  380. name: '烟台市',
  381. },
  382. {
  383. id: 40,
  384. name: '济宁市',
  385. },
  386. {
  387. id: 41,
  388. name: '泰安市',
  389. },
  390. {
  391. id: 42,
  392. name: '威海市',
  393. },
  394. {
  395. id: 43,
  396. name: '滨州市',
  397. },
  398. {
  399. id: 44,
  400. name: '菏泽市',
  401. },
  402. ]
  403. }
  404. ]
  405. };
  406. },
  407. onLoad(options) {
  408. this.flag = options.flag
  409. if (this.flag == 1) {
  410. this.checkStatus = true
  411. }
  412. },
  413. methods: {
  414. // 考勤组选择框确定回调事件
  415. treeConfirm(e) {
  416. // console.log(e)
  417. let temList = []
  418. e.forEach((ele) => {
  419. temList.push(ele.name)
  420. })
  421. this.group_scope = temList.join(",")
  422. },
  423. // 考勤组选择框取消回调事件
  424. treeCancel(e) {
  425. console.log(e)
  426. console.log("取消");
  427. },
  428. // 点击选择考勤组选择框回调
  429. handleChoose() {
  430. this.$refs.tkitree._show()
  431. },
  432. handleChange(item) {
  433. console.log(item);
  434. item.checked = !item.checked
  435. },
  436. // 点击弹窗保存按钮回调
  437. handleSave() {
  438. if (!this.group_name) {
  439. uni.showToast({
  440. title: "请输入考勤组名称",
  441. icon: "none"
  442. })
  443. return
  444. }
  445. if (!this.group_scope) {
  446. uni.showToast({
  447. title: "请选择考勤组范围",
  448. icon: "none"
  449. })
  450. return
  451. }
  452. if (!this.group_num) {
  453. uni.showToast({
  454. title: "请输入打卡人数",
  455. icon: "none"
  456. })
  457. return
  458. }
  459. this.$refs.popup.close()
  460. },
  461. // 点击弹窗取消按钮回调
  462. handleCancel() {
  463. this.$refs.popup.close()
  464. },
  465. // 点击新增考勤组按钮回调
  466. handleAdd() {
  467. this.$refs.popup.open()
  468. },
  469. // 点击关联考勤组按钮回调
  470. handleRelevancy() {
  471. console.log(456);
  472. },
  473. // 点击树状节点回调
  474. nodechange(ref) {
  475. this.$nextTick(() => {
  476. setTimeout(() => {
  477. this.$refs[ref][0].resize()
  478. }, 200)
  479. })
  480. },
  481. // 点击右侧删除按钮回调
  482. onClick(id) {
  483. console.log(id);
  484. uni.showModal({
  485. title: '提示',
  486. content: '确定删除该考勤组吗?',
  487. success: function(res) {
  488. if (res.confirm) {
  489. console.log('用户点击确定');
  490. uni.showToast({
  491. title: "删除成功",
  492. icon: 'success'
  493. })
  494. } else if (res.cancel) {
  495. console.log('用户点击取消');
  496. }
  497. }
  498. });
  499. },
  500. // 搜索框失焦回调
  501. blur(res) {
  502. uni.showToast({
  503. title: '搜索:' + res.value,
  504. icon: 'none'
  505. })
  506. },
  507. // 搜索框输入时的回调
  508. input(res) {
  509. console.log('----input:', res)
  510. },
  511. // 清除搜索框内容时的回调
  512. clear(res) {
  513. uni.showToast({
  514. title: 'clear事件,清除值为:' + res.value,
  515. icon: 'none'
  516. })
  517. },
  518. }
  519. }
  520. </script>
  521. <style lang="scss" scoped>
  522. .container {
  523. padding-top: 20rpx;
  524. .search {
  525. box-sizing: border-box;
  526. padding: 0 30rpx;
  527. width: 750rpx;
  528. height: 90rpx;
  529. border-radius: 170rpx;
  530. background-color: #fff;
  531. }
  532. .add {
  533. margin-top: 20rpx;
  534. display: flex;
  535. align-items: center;
  536. width: 750rpx;
  537. height: 110rpx;
  538. background-color: #fff;
  539. .icon {
  540. margin: 0 20rpx 0 30rpx;
  541. width: 36rpx;
  542. height: 36rpx;
  543. img {
  544. width: 100%;
  545. height: 100%;
  546. }
  547. }
  548. .title {
  549. font-size: 30rpx;
  550. color: #0082FC;
  551. }
  552. }
  553. .group {
  554. margin-top: 20rpx;
  555. background-color: #F2F2F2;
  556. .group_item {
  557. margin-bottom: 20rpx;
  558. width: 750rpx;
  559. background-color: #fff;
  560. .collapse_title {
  561. display: flex;
  562. align-items: center;
  563. height: 79rpx;
  564. .collapse_check {
  565. margin-left: 30rpx;
  566. }
  567. .collapse_info {
  568. margin-left: 10rpx;
  569. font-size: 28rpx;
  570. font-weight: 600;
  571. }
  572. }
  573. .content {
  574. padding-bottom: 50rpx;
  575. .num {
  576. margin-left: 30rpx;
  577. height: 50rpx;
  578. font-size: 24rpx;
  579. color: #808080;
  580. }
  581. .tree {}
  582. }
  583. }
  584. }
  585. .popup_box {
  586. width: 630rpx;
  587. height: 610rpx;
  588. border-radius: 33rpx;
  589. background-color: #fff;
  590. .header {
  591. width: 630rpx;
  592. height: 97rpx;
  593. line-height: 97rpx;
  594. text-align: center;
  595. font-size: 32rpx;
  596. font-weight: 500;
  597. border-bottom: 1rpx solid #E6E6E6;
  598. }
  599. .body {
  600. display: flex;
  601. flex-direction: column;
  602. align-items: center;
  603. width: 630rpx;
  604. height: 414rpx;
  605. border-bottom: 1rpx solid #E6E6E6;
  606. .name {
  607. margin-top: 42rpx;
  608. width: 570rpx;
  609. height: 80rpx;
  610. border-radius: 10rpx;
  611. border: 1rpx solid #ccc;
  612. input {
  613. padding: 0 24rpx;
  614. width: 90%;
  615. height: 100%;
  616. font-size: 28rpx;
  617. }
  618. }
  619. .scope {
  620. display: flex;
  621. align-items: center;
  622. margin-top: 32rpx;
  623. width: 570rpx;
  624. height: 80rpx;
  625. border-radius: 10rpx;
  626. border: 1rpx solid #ccc;
  627. .notes {
  628. padding-left: 24rpx;
  629. flex: 5;
  630. font-size: 28rpx;
  631. color: #808080;
  632. }
  633. .notes2 {
  634. padding-left: 24rpx;
  635. flex: 5;
  636. font-size: 28rpx;
  637. }
  638. .icon {
  639. flex: 1;
  640. display: flex;
  641. justify-content: center;
  642. align-items: center;
  643. img {
  644. width: 25rpx;
  645. height: 20rpx;
  646. }
  647. }
  648. }
  649. .num {
  650. display: flex;
  651. align-items: center;
  652. margin-top: 32rpx;
  653. width: 570rpx;
  654. height: 80rpx;
  655. border-radius: 10rpx;
  656. border: 1rpx solid #ccc;
  657. .count {
  658. flex: 2;
  659. display: flex;
  660. align-items: center;
  661. height: 50rpx;
  662. border-right: 1rpx solid #A6A6A6;
  663. .icon {
  664. flex: 1;
  665. display: flex;
  666. justify-content: center;
  667. align-items: center;
  668. img {
  669. width: 30rpx;
  670. height: 30rpx;
  671. }
  672. }
  673. .info {
  674. flex: 2;
  675. font-size: 28rpx;
  676. }
  677. }
  678. .input {
  679. flex: 4;
  680. input {
  681. padding: 0 45rpx;
  682. width: 80%;
  683. font-size: 28rpx;
  684. }
  685. }
  686. }
  687. }
  688. .foot {
  689. display: flex;
  690. justify-content: space-evenly;
  691. width: 630rpx;
  692. height: 99rpx;
  693. line-height: 99rpx;
  694. font-size: 28rpx;
  695. .left {
  696. flex: 1;
  697. text-align: center;
  698. border-right: 1rpx solid #CCC;
  699. }
  700. .right {
  701. flex: 1;
  702. text-align: center;
  703. color: #2A82E4;
  704. }
  705. }
  706. }
  707. }
  708. // 解决输入框不居中问题
  709. ::v-deep .uni-searchbar {
  710. padding: 10rpx;
  711. }
  712. // 解决左滑区域突出问题
  713. ::v-deep .uni-swipe_button-group {
  714. margin-bottom: 20rpx;
  715. }
  716. // 清除树状组件下边框
  717. ::v-deep .uni-collapse-item__wrap-content.uni-collapse-item--border {
  718. border-bottom: none;
  719. }
  720. </style>