selectPBom.vue 9.8 KB

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