selectUser.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择" @clickLeft="backAdd">
  4. <!--右菜单-->
  5. <template slot="right">
  6. <u-button type="success" size="small" class="u-reset-button" @click="$refs.treePicker._show()"
  7. text="选择部门"></u-button>
  8. </template>
  9. </uni-nav-bar>
  10. <view class="searchBox">
  11. <input v-model="searchVal" placeholder="请输入名称" class="searchInput" />
  12. <u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" data-icon="Search" class="searchBtn">
  13. <view class="iconfont icon-sousuo"></view>
  14. <view class="text">搜索</view>
  15. </u-button>
  16. </view>
  17. <view class="wrapper">
  18. <u-list @scrolltolower="scrolltolower" class="listContent">
  19. <checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
  20. <label>
  21. <view class="listBox">
  22. <view class="listBox-sel">
  23. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  24. :checked="item.checked" />
  25. </view>
  26. <view class="listBox-con">
  27. <view class="listBox-top">
  28. <view class="listBox-name">
  29. {{ item.name }}
  30. </view>
  31. </view>
  32. <view class="listBox-bottom">
  33. <view>工号:{{ item.jobNumber }}</view>
  34. <view>账号:{{ item.loginName }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </label>
  39. </checkbox-group>
  40. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  41. </u-list>
  42. </view>
  43. <view class="footer">
  44. <view class="bottom" v-if="this.isAll==1">
  45. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  46. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  47. </checkbox>
  48. </view>
  49. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  50. <view class="selBtn">选择( {{ checkListLen }} )</view>
  51. </u-button>
  52. </view>
  53. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择部门"
  54. :localdata="classificationList" valueKey="id" textKey="name" />
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. listOrganizations,
  60. getUserPage
  61. } from '@/api/myTicket/index.js'
  62. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  63. export default {
  64. components: {
  65. baTreePicker
  66. },
  67. data() {
  68. return {
  69. page: 1,
  70. size: 20,
  71. isEnd: true,
  72. searchVal: '',
  73. pickTabIndex: 1,
  74. popupShow: false, //右侧搜索窗
  75. typeIndex: 1,
  76. listData: [], //列表数据
  77. classificationList: [], //分类数据
  78. seletedAll: false, //全选状态,
  79. isAll: ''
  80. }
  81. },
  82. //选择的列表长度
  83. computed: {
  84. checkListLen() {
  85. return this.listData.filter(el => el.checked).length
  86. },
  87. },
  88. onLoad({
  89. isAll
  90. }) {
  91. this.isAll = isAll //1多选 2单选
  92. this.getClassify()
  93. },
  94. onShow() {},
  95. methods: {
  96. scrolltolower() {
  97. if (this.isEnd) {
  98. return
  99. }
  100. // 显示加载图标
  101. uni.showLoading({
  102. title: '数据加载中'
  103. })
  104. //获取更多数据
  105. this.page++
  106. this.getList()
  107. },
  108. //列表数据
  109. async getList() {
  110. this.isEnd = false
  111. this._getClassifyList()
  112. },
  113. async _getClassifyList() {
  114. uni.showLoading({
  115. title: '数据加载中'
  116. })
  117. const params = {
  118. pageNum: 1,
  119. size:100,
  120. name: this.searchVal,
  121. groupId: this.categoryLevelId
  122. }
  123. getUserPage(params).then(res => {
  124. uni.hideLoading()
  125. if (this.page == 1) {
  126. this.listData = []
  127. }
  128. this.listData = this.listData.concat(res.list)
  129. this.isEnd = this.listData.length >= res.count
  130. })
  131. },
  132. confirm([id]) {
  133. this.categoryLevelId = id
  134. this.page = 1
  135. this.getList()
  136. },
  137. async getClassify() {
  138. listOrganizations(1).then(res => {
  139. this.classificationList = res
  140. this.page = 1
  141. this.getList()
  142. });
  143. },
  144. doSearch() {
  145. this.page = 1
  146. this.getList()
  147. },
  148. //勾选
  149. selectVal(e, val, index) {
  150. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  151. if (this.isAll != 1) {
  152. this.listData.forEach((item, i) => {
  153. if (item.id != val.id) {
  154. this.$set(this.listData[i], 'checked', false)
  155. }
  156. })
  157. } else {
  158. this.seletedAll = !this.listData.some(item => !item.checked)
  159. }
  160. },
  161. //全选按钮
  162. _seletedAll() {
  163. if (!this.seletedAll) {
  164. this.seletedAll = true
  165. this.listData.map(item => {
  166. this.$set(item, 'checked', true)
  167. })
  168. } else {
  169. this.seletedAll = false
  170. this.listData.map(item => {
  171. this.$set(item, 'checked', false)
  172. })
  173. }
  174. },
  175. //跳转回添加页面
  176. jumpAdd() {
  177. uni.$emit(
  178. 'setUserInfo',
  179. this.listData.filter(item => item.checked)
  180. )
  181. uni.navigateBack()
  182. },
  183. //返回添加页
  184. backAdd() {
  185. uni.navigateBack()
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .mainBox {
  192. height: 100vh;
  193. display: flex;
  194. flex-direction: column;
  195. .wrapper {
  196. flex: 1;
  197. overflow: hidden;
  198. }
  199. .searchBox {
  200. padding: 10rpx 0;
  201. box-sizing: border-box;
  202. background-color: #dedede;
  203. height: 90rpx;
  204. width: 100%;
  205. line-height: 90rpx;
  206. display: flex;
  207. justify-content: space-around;
  208. align-items: center;
  209. input {
  210. height: 78rpx;
  211. width: 65%;
  212. background: #f9f9f9 !important;
  213. margin: 0 10rpx;
  214. padding: 0 10rpx;
  215. box-sizing: border-box;
  216. border-radius: 5rpx;
  217. }
  218. .searchBtn {
  219. height: 80rpx;
  220. background: #f9f9f9 !important;
  221. color: #676767;
  222. font-size: 28rpx;
  223. padding: 0 42rpx;
  224. box-sizing: border-box;
  225. outline: none;
  226. border: none;
  227. width: 260rpx;
  228. .icon-sousuo {
  229. font-size: 22px;
  230. }
  231. .text {
  232. font-size: 16px;
  233. margin-left: 10px;
  234. }
  235. }
  236. }
  237. .tab-title {
  238. position: fixed;
  239. top: 190rpx;
  240. z-index: 99;
  241. width: 100%;
  242. display: flex;
  243. justify-content: space-between;
  244. align-items: center;
  245. height: $tab-height;
  246. line-height: $tab-height;
  247. background-color: #ffffff;
  248. border-bottom: 2rpx solid #f2f2f2;
  249. box-sizing: border-box;
  250. .tab-item {
  251. width: 25%;
  252. text-align: center;
  253. font-size: 32rpx;
  254. color: $uni-text-color-grey;
  255. }
  256. .tab-item.active {
  257. color: $j-primary-border-green;
  258. border-bottom: 1px solid $j-primary-border-green;
  259. font-weight: bold;
  260. }
  261. .tab-item.filter {
  262. flex: 1;
  263. padding: 0px 30rpx;
  264. .uni-icons {
  265. display: flex;
  266. padding-top: 5px;
  267. }
  268. }
  269. .screenIcon {
  270. display: flex;
  271. width: 80px;
  272. justify-content: center;
  273. .screenText {
  274. font-size: 32rpx;
  275. color: $uni-text-color-grey;
  276. }
  277. }
  278. }
  279. .listContent {
  280. height: 100% !important;
  281. .listBox {
  282. display: flex;
  283. // height: 180rpx;
  284. padding: 20rpx 0;
  285. border-bottom: 2rpx solid #e5e5e5;
  286. .listBox-sel {
  287. height: 90rpx;
  288. width: 80rpx;
  289. // line-height: 90rpx;
  290. text-align: center;
  291. checkbox {
  292. transform: scale(1.2);
  293. }
  294. }
  295. .listBox-con {
  296. width: 100%;
  297. // display: flex;
  298. // flex-wrap: wrap;
  299. // justify-content: space-between;
  300. align-items: center;
  301. padding: 0 18rpx 0 0;
  302. .listBox-top {
  303. width: 100%;
  304. display: flex;
  305. justify-content: space-between;
  306. padding-bottom: 10rpx;
  307. .listBox-name,
  308. .listBox-code {
  309. display: inline-block;
  310. font-size: $uni-font-size-sm;
  311. font-weight: bold;
  312. }
  313. }
  314. .listBox-bottom {
  315. width: 100%;
  316. display: flex;
  317. justify-content: space-between;
  318. font-size: $uni-font-size-sm;
  319. flex-wrap: wrap;
  320. >view {
  321. width: 50%;
  322. overflow: hidden;
  323. white-space: nowrap;
  324. text-overflow: ellipsis;
  325. }
  326. }
  327. }
  328. }
  329. .noDate {
  330. height: 100%;
  331. }
  332. }
  333. //底部按钮
  334. .footer {
  335. height: 90rpx;
  336. position: relative;
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. bottom: 0;
  341. width: 100%;
  342. height: 100rpx;
  343. border-top: 1rpx solid #eeecec;
  344. background-color: #ffffff;
  345. z-index: 999;
  346. .bottom {
  347. margin-left: 10rpx;
  348. }
  349. .u-reset-button {
  350. position: absolute;
  351. right: 10rpx;
  352. top: 20rpx;
  353. width: 150rpx;
  354. }
  355. }
  356. }
  357. </style>