selectUser.vue 8.5 KB

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