selectEnterType.vue 9.5 KB

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