selectEnterType.vue 9.7 KB

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