selectEnterType.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. }
  102. },
  103. //选择的列表长度
  104. computed: {
  105. tableHeader() {
  106. return tableHeader(+this.warehousingType)
  107. },
  108. checkListLen() {
  109. console.log(
  110. 'this.listData.filter(el => el.checked)---',
  111. this.listData.filter(el => el.checked)
  112. )
  113. return this.listData.filter(el => el.checked).length
  114. },
  115. curTab() {
  116. return warehousingType.find(i => i.id == this.warehousingType) || {}
  117. }
  118. },
  119. onLoad({
  120. assetType
  121. }) {
  122. this.assetType = assetType
  123. },
  124. //触底刷新
  125. // onReachBottom: function () {
  126. // if (this.isEnd) {
  127. // return
  128. // }
  129. // // 显示加载图标
  130. // uni.showLoading({
  131. // title: '数据加载中'
  132. // })
  133. // //获取更多数据
  134. // this.page++
  135. // this.getList()
  136. // },
  137. onShow() {
  138. this.getClassify()
  139. },
  140. methods: {
  141. scrolltolower() {
  142. if (this.isEnd) {
  143. return
  144. }
  145. // 显示加载图标
  146. uni.showLoading({
  147. title: '数据加载中'
  148. })
  149. //获取更多数据
  150. this.page++
  151. this.getList()
  152. },
  153. //列表数据
  154. async getList() {
  155. this.isEnd = false
  156. this._getClassifyList()
  157. },
  158. async _getClassifyList() {
  159. uni.showLoading({
  160. title: '数据加载中'
  161. })
  162. const params = {
  163. pageNum: this.page,
  164. size: this.size,
  165. searchKey: this.searchVal,
  166. categoryLevelId: this.categoryLevelId
  167. }
  168. getCategoryList(params).then(res => {
  169. uni.hideLoading()
  170. if (this.page == 1) {
  171. this.listData = []
  172. }
  173. this.listData = this.listData.concat(res.list)
  174. this.isEnd = this.listData.length >= res.count
  175. })
  176. },
  177. confirm([id]) {
  178. console.log('id----------', id)
  179. this.categoryLevelId = id
  180. this.page = 1
  181. this.getList()
  182. },
  183. async getClassify() {
  184. getTreeByIds({
  185. ids: this.assetType
  186. }).then(res => {
  187. console.log('res--------', res)
  188. this.classificationList = res
  189. this.page = 1
  190. this.getList()
  191. })
  192. },
  193. doSearch() {
  194. this.page = 1
  195. this.getList()
  196. },
  197. //勾选
  198. selectVal(e, val, index) {
  199. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  200. // this.listData[index].checked = !this.listData[index].checked
  201. this.seletedAll = !this.listData.some(item => !item.checked)
  202. },
  203. //全选按钮
  204. _seletedAll() {
  205. if (!this.seletedAll) {
  206. this.seletedAll = true
  207. this.listData.map(item => {
  208. this.$set(item, 'checked', true)
  209. })
  210. } else {
  211. this.seletedAll = false
  212. //this.checkListLen = 0;
  213. this.listData.map(item => {
  214. this.$set(item, 'checked', false)
  215. })
  216. }
  217. },
  218. //跳转回添加页面
  219. jumpAdd() {
  220. uni.$emit(
  221. 'setSelectList',
  222. this.listData.filter(item => item.checked)
  223. )
  224. console.log(
  225. this.listData.filter(item => item.checked),
  226. '222'
  227. )
  228. uni.navigateBack()
  229. },
  230. //返回添加页
  231. backAdd() {
  232. uni.navigateBack()
  233. }
  234. }
  235. }
  236. </script>
  237. <style lang="scss" scoped>
  238. .mainBox {
  239. height: 100vh;
  240. display: flex;
  241. flex-direction: column;
  242. .wrapper {
  243. flex: 1;
  244. overflow: hidden;
  245. }
  246. .top-wrapper {
  247. display: flex;
  248. height: 88rpx;
  249. align-items: center;
  250. justify-content: space-between;
  251. padding: 20rpx;
  252. /deep/.uni-section {
  253. margin-top: 0px;
  254. }
  255. /deep/.uni-section-header {
  256. padding: 0px;
  257. }
  258. .search_btn {
  259. width: 120rpx;
  260. height: 70rpx;
  261. line-height: 70rpx;
  262. background: $theme-color;
  263. font-size: 28rpx;
  264. color: #fff;
  265. }
  266. .menu_icon {
  267. width: 44rpx;
  268. height: 44rpx;
  269. margin-left: 14rpx;
  270. }
  271. .more_search {
  272. display: flex;
  273. align-items: center;
  274. height: 70rpx;
  275. line-height: 70rpx;
  276. }
  277. /deep/.u-input {
  278. border: 1rpx solid #ccc;
  279. .u-input__content__field-wrapper__field {
  280. height: 40rpx !important;
  281. }
  282. }
  283. image {
  284. width: 52rpx;
  285. height: 52rpx;
  286. margin-left: 10rpx;
  287. }
  288. }
  289. .tab-title {
  290. position: fixed;
  291. top: 190rpx;
  292. z-index: 99;
  293. width: 100%;
  294. display: flex;
  295. justify-content: space-between;
  296. align-items: center;
  297. height: $tab-height;
  298. line-height: $tab-height;
  299. background-color: #ffffff;
  300. border-bottom: 2rpx solid #f2f2f2;
  301. box-sizing: border-box;
  302. .tab-item {
  303. width: 25%;
  304. text-align: center;
  305. font-size: 32rpx;
  306. color: $uni-text-color-grey;
  307. }
  308. .tab-item.active {
  309. color: $j-primary-border-green;
  310. border-bottom: 1px solid $j-primary-border-green;
  311. font-weight: bold;
  312. }
  313. .tab-item.filter {
  314. flex: 1;
  315. padding: 0px 30rpx;
  316. .uni-icons {
  317. display: flex;
  318. padding-top: 5px;
  319. }
  320. }
  321. .screenIcon {
  322. display: flex;
  323. width: 80px;
  324. justify-content: center;
  325. .screenText {
  326. font-size: 32rpx;
  327. color: $uni-text-color-grey;
  328. }
  329. }
  330. }
  331. .listContent {
  332. height: 100% !important;
  333. .listBox {
  334. display: flex;
  335. // height: 180rpx;
  336. padding: 20rpx 0;
  337. border-top: 2rpx solid #e5e5e5;
  338. .listBox-sel {
  339. height: 90rpx;
  340. width: 80rpx;
  341. // line-height: 90rpx;
  342. text-align: center;
  343. checkbox {
  344. transform: scale(1.2);
  345. }
  346. }
  347. .listBox-con {
  348. width: 100%;
  349. // display: flex;
  350. // flex-wrap: wrap;
  351. // justify-content: space-between;
  352. align-items: center;
  353. padding: 0 18rpx 0 0;
  354. .listBox-top {
  355. width: 100%;
  356. display: flex;
  357. justify-content: space-between;
  358. padding-bottom: 10rpx;
  359. .listBox-name,
  360. .listBox-code {
  361. display: inline-block;
  362. font-size: $uni-font-size-sm;
  363. font-weight: bold;
  364. }
  365. }
  366. .listBox-bottom {
  367. width: 100%;
  368. display: flex;
  369. justify-content: space-between;
  370. font-size: $uni-font-size-sm;
  371. flex-wrap: wrap;
  372. >view {
  373. width: 50%;
  374. overflow: hidden;
  375. white-space: nowrap;
  376. text-overflow: ellipsis;
  377. }
  378. }
  379. }
  380. }
  381. .noDate {
  382. height: 100%;
  383. }
  384. }
  385. //底部按钮
  386. .footer {
  387. height: 90rpx;
  388. position: relative;
  389. display: flex;
  390. justify-content: space-between;
  391. align-items: center;
  392. bottom: 0;
  393. width: 100%;
  394. height: 100rpx;
  395. border-top: 1rpx solid #eeecec;
  396. background-color: #ffffff;
  397. z-index: 999;
  398. .bottom {
  399. margin-left: 10rpx;
  400. }
  401. .u-reset-button {
  402. position: absolute;
  403. right: 10rpx;
  404. top: 20rpx;
  405. width: 150rpx;
  406. }
  407. }
  408. }
  409. </style>