selectProduce.vue 9.0 KB

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