index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="库存查询" @clickLeft="back"></uni-nav-bar>
  4. <view class="top-wrapper">
  5. <uni-section>
  6. <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="form.keyWord" placeholder="请输入编码/名称">
  7. </uni-easyinput>
  8. </uni-section>
  9. <view style="display: flex;">
  10. <button class="search_btn" @click="search">搜索</button>
  11. <view class="more_search">
  12. <image src="~@/static/moreSearch.svg" mode="" @click="handlScreen"></image>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="mainBox">
  17. <view class="scroll_box">
  18. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  19. <uni-table border stripe emptyText="暂无更多数据">
  20. <uni-tr style="width: 100%;">
  21. <uni-th align="center">序号</uni-th>
  22. <uni-th align="center">名称</uni-th>
  23. <uni-th align="center">数量</uni-th>
  24. <uni-th align="center">重量</uni-th>
  25. </uni-tr>
  26. <!-- 表格数据行 -->
  27. <uni-tr v-for="(item, index) in listData" :key="index" style="width: 100%;">
  28. <uni-td width="50">
  29. <view @click="goDetails(item)">{{index+Number(1)}}</view>
  30. </uni-td>
  31. <uni-td>
  32. <view class="ellipsis" @click="goDetails(item)">
  33. {{ item.categoryCode }}({{ item.categoryName }})
  34. </view>
  35. </uni-td>
  36. <uni-td>
  37. <view @click="goDetails(item)">{{ item.measureQuantity }} {{ item.measureUnit }}</view>
  38. </uni-td>
  39. <uni-td>
  40. <view @click="goDetails(item)">{{ item.weight }}{{ item.weightUnit }}</view>
  41. </uni-td>
  42. </uni-tr>
  43. </uni-table>
  44. </scroll-view>
  45. </view>
  46. </view>
  47. <screen ref="screen" @succeed="cabScreen" :dimension="form.dimension" :categoryLevelId="form.categoryLevelId"
  48. :warehouseId="form.warehouseId"></screen>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. getProductList,
  54. getBatchList,
  55. getPackingList
  56. } from '@/api/warehouseManagement'
  57. import screen from './components/screen'
  58. export default {
  59. components: {
  60. screen
  61. },
  62. data() {
  63. return {
  64. page: 1,
  65. size: 20,
  66. isEnd: true,
  67. listData: [],
  68. form: {
  69. keyWord: '',
  70. // 列表维度
  71. dimension: 1,
  72. /* 资产类型 */
  73. categoryLevelId: '',
  74. /* 所属仓库 */
  75. warehouseId: ''
  76. },
  77. timerId: null,
  78. dict: {
  79. code: {
  80. 1: '生产设备',
  81. 2: '舟皿',
  82. 3: '物料',
  83. 5: '周转车',
  84. 6: '模具',
  85. 7: '备品备件'
  86. }
  87. },
  88. status: 'loading'
  89. }
  90. },
  91. onLoad() {},
  92. onShow() {},
  93. //加载更多
  94. onReachBottom() {
  95. console.log('加载更多')
  96. if (this.isEnd) {
  97. return
  98. }
  99. this.getMoreLists()
  100. },
  101. created() {
  102. this.getData()
  103. },
  104. computed: {
  105. tableHeader() {
  106. if (this.form.dimension == 1) {
  107. // 物品
  108. return [{
  109. label: '牌号',
  110. prop: 'brandNum'
  111. },
  112. {
  113. label: '型号',
  114. prop: 'categoryModel'
  115. },
  116. {
  117. label: '规格',
  118. prop: 'specification'
  119. },
  120. {
  121. label: '重量',
  122. prop: 'weight'
  123. },
  124. {
  125. label: '重量单位',
  126. prop: 'weightUnit'
  127. }
  128. ]
  129. } else if (this.form.dimension == 2) {
  130. // 批次
  131. return [{
  132. label: '牌号',
  133. prop: 'brandNum'
  134. },
  135. {
  136. label: '型号',
  137. prop: 'categoryModel'
  138. },
  139. {
  140. label: '规格',
  141. prop: 'specification'
  142. },
  143. {
  144. label: '批次号',
  145. prop: 'batchNo'
  146. },
  147. {
  148. label: '重量',
  149. prop: 'weight'
  150. },
  151. {
  152. label: '重量单位',
  153. prop: 'weightUnit'
  154. }
  155. ]
  156. } else {
  157. // 包装
  158. return [{
  159. label: '牌号',
  160. prop: 'brandNum'
  161. },
  162. {
  163. label: '型号',
  164. prop: 'categoryModel'
  165. },
  166. {
  167. label: '规格',
  168. prop: 'specification'
  169. },
  170. {
  171. label: '批次号',
  172. prop: 'batchNo'
  173. },
  174. {
  175. label: '重量',
  176. prop: 'weight'
  177. },
  178. {
  179. label: '重量单位',
  180. prop: 'weightUnit'
  181. },
  182. {
  183. label: '包装编码',
  184. prop: 'packageNo'
  185. },
  186. {
  187. label: '包装数量',
  188. prop: 'packingQuantity'
  189. },
  190. {
  191. label: '包装单位',
  192. prop: 'packingUnit'
  193. },
  194. {
  195. label: '仓库',
  196. prop: 'warehouseName'
  197. }
  198. ]
  199. }
  200. switch (+this.form.categoryLevelId) {
  201. case 3:
  202. return [{
  203. label: '牌号',
  204. prop: 'brandNum'
  205. }]
  206. case 8:
  207. return [{
  208. label: '型号',
  209. prop: 'modelType'
  210. },
  211. {
  212. label: '规格',
  213. prop: 'specification'
  214. }
  215. ]
  216. case 4:
  217. return [{
  218. label: '牌号',
  219. prop: 'brandNum'
  220. },
  221. {
  222. label: '型号',
  223. prop: 'modelType'
  224. }
  225. ]
  226. case 5: //'周转车'
  227. return [{
  228. label: '规格',
  229. prop: 'specification'
  230. },
  231. {
  232. label: '材质',
  233. prop: 'texture',
  234. formatter(row) {
  235. const extendField = JSON.parse(row.extendField)
  236. return extendField.texture
  237. }
  238. }
  239. // {
  240. // label: '长宽高',
  241. // prop: '',
  242. // formatter (row) {
  243. // const extendField = JSON.parse(row.extendField)
  244. // return `${extendField.length}*${extendField.width}*${extendField.high}`
  245. // }
  246. // }
  247. ]
  248. case 2: //'舟皿'
  249. return [{
  250. label: '规格',
  251. prop: 'specification'
  252. },
  253. {
  254. label: '型号',
  255. prop: 'modelType'
  256. }
  257. // {
  258. // label: '长宽高',
  259. // prop: '',
  260. // formatter (row) {
  261. // const extendField = JSON.parse(row.extendField)
  262. // return `${extendField.length}*${extendField.width}*${extendField.high}`
  263. // }
  264. // }
  265. ]
  266. case 1: //'设备'
  267. return [{
  268. label: '型号',
  269. prop: 'modelType'
  270. },
  271. {
  272. label: '规格',
  273. prop: 'specification'
  274. }
  275. ]
  276. case 6: //'模具'
  277. return [{
  278. label: '牌号',
  279. prop: 'brandNum'
  280. },
  281. {
  282. label: '型号',
  283. prop: 'modelType'
  284. }
  285. // {
  286. // label: '收缩系数',
  287. // prop: '',
  288. // formatter (row) {
  289. // const extendField = JSON.parse(row.extendField)
  290. // return extendField.shrinkageCoefficient
  291. // }
  292. // }
  293. ]
  294. case 7: //'备品备件'
  295. return [{
  296. label: '规格',
  297. prop: 'specification'
  298. },
  299. {
  300. label: '型号',
  301. prop: 'modelType'
  302. }
  303. ]
  304. }
  305. return []
  306. }
  307. },
  308. methods: {
  309. lower() {
  310. console.log('加载更多')
  311. if (this.isEnd) {
  312. return
  313. }
  314. this.getMoreLists()
  315. },
  316. expand(index, isOpen) {
  317. this.$set(this.listData[index], 'open', isOpen)
  318. console.log(this.listData[index])
  319. },
  320. //筛选
  321. getData() {
  322. // console.log('this.selectedDime-----------', this.selectedDime)
  323. // const dimension = this.$refs.refSeavch.dimension
  324. // console.log('this.dimension-----------', dimension)
  325. // const treeId = this.$parent.$parent.$parent.current.id
  326. // if (this.form.dimension == 1) {
  327. // // 物品维度
  328. // const data = storageApi.getProductList({
  329. // ...where,
  330. // ...order,
  331. // pageNum: page,
  332. // size: limit
  333. // })
  334. // return data
  335. // } else if (this.form.dimension == 2) {
  336. // // 批次维度
  337. // const params = {
  338. // categoryLevelId: treeId,
  339. // ...where,
  340. // ...order
  341. // }
  342. // const data = storageApi.getBatchList({
  343. // ...params,
  344. // pageNum: page,
  345. // size: limit
  346. // })
  347. // return data
  348. // } else {
  349. // // 包装维度
  350. // let params = {
  351. // categoryLevelId: this.form.code,
  352. // ...where,
  353. // ...order
  354. // }
  355. // const data = storageApi.getPackingList({
  356. // ...params,
  357. // pageNum: page,
  358. // size: limit
  359. // })
  360. // return data
  361. // }
  362. let par = JSON.parse(JSON.stringify(this.form))
  363. par.pageNum = this.page
  364. par.size = this.size
  365. // par = this.URLSearchParams(par)
  366. console.log(par)
  367. uni.showLoading({
  368. title: '加载中'
  369. })
  370. if (this.form.dimension == 1) {
  371. getProductList(par)
  372. .then(res => {
  373. console.log('res----', res)
  374. this.listData = [...this.listData, ...res.list]
  375. let pages = res.count
  376. console.log(this.page)
  377. console.log(pages)
  378. if (this.listData.length < pages) {
  379. this.isEnd = false
  380. this.status = 'loading'
  381. } else {
  382. this.isEnd = true
  383. this.status = 'nomore'
  384. }
  385. })
  386. .finally(() => {
  387. uni.hideLoading()
  388. })
  389. } else if (this.form.dimension == 2) {
  390. getBatchList(par)
  391. .then(res => {
  392. console.log('res----', res)
  393. this.listData = [...this.listData, ...res.list]
  394. let pages = res.count
  395. if (this.listData.length < pages) {
  396. this.isEnd = false
  397. this.status = 'loading'
  398. } else {
  399. this.isEnd = true
  400. this.status = 'nomore'
  401. }
  402. })
  403. .finally(() => {
  404. uni.hideLoading()
  405. })
  406. } else {
  407. getPackingList(par)
  408. .then(res => {
  409. console.log('res----', res)
  410. this.listData = [...this.listData, ...res.list]
  411. let pages = res.count
  412. if (this.listData.length < pages) {
  413. this.isEnd = false
  414. this.status = 'loading'
  415. } else {
  416. this.isEnd = true
  417. this.status = 'nomore'
  418. }
  419. })
  420. .finally(() => {
  421. uni.hideLoading()
  422. })
  423. }
  424. // get(this.apiUrl + '/InventoryBook/select/getPage?' + par).then(res => {
  425. // if (res.success) {
  426. // this.listData = [...this.listData, ...res.data.records]
  427. // let pages = res.data.pages
  428. // if (page < pages) {
  429. // isEnd = false
  430. // } else {
  431. // isEnd = true
  432. // this.status = 'nomore'
  433. // }
  434. // }
  435. // })
  436. },
  437. handlScreen() {
  438. this.$refs.screen.open()
  439. },
  440. cabScreen(data) {
  441. console.log('data---', data)
  442. for (let key of Object.keys(data)) {
  443. this.form[key] = data[key]
  444. }
  445. this.page = 1
  446. this.listData = []
  447. this.search()
  448. },
  449. goDetails(item) {
  450. console.log(item, 'eeeee')
  451. // // 物料维度
  452. // if (this.form.dimension == 1) {
  453. // let par = {
  454. // info: encodeURIComponent(JSON.stringify(item)),
  455. // dimension: this.form.dimension,
  456. // code: item.assetType
  457. // }
  458. // par = this.URLSearchParams(par)
  459. // uni.navigateTo({
  460. // url: '/pages/warehouse/inventory/details/details?' + par
  461. // })
  462. // }
  463. // 批次维度
  464. // if (this.form.dimension == 2) {
  465. let par = {
  466. dimension: this.form.dimension,
  467. categoryCode: item.categoryCode,
  468. categoryId: item.categoryId,
  469. info: encodeURIComponent(JSON.stringify(item))
  470. }
  471. par = this.URLSearchParams(par)
  472. uni.navigateTo({
  473. url: '/pages/warehouse/inventory/batch/batch?' + par
  474. })
  475. // }
  476. },
  477. // inputChange() {
  478. // // 清除timer对应的延时器
  479. // clearTimeout(this.timerId)
  480. // // 重新启动一个延时器,并把timerId赋值给this.timer
  481. // this.timerId = setTimeout(() => {
  482. // // 如果500毫秒内,没有触发新的输入事件,则为搜索关键词赋值
  483. // this.search()
  484. // }, 500)
  485. // },
  486. search() {
  487. this.listData = []
  488. this.getData()
  489. },
  490. getMoreLists() {
  491. this.page++
  492. this.getData()
  493. }
  494. }
  495. }
  496. </script>
  497. <style lang="scss" scoped>
  498. .mainBox {
  499. height: 100vh;
  500. width: 100%;
  501. display: flex;
  502. flex-direction: column;
  503. }
  504. .uni-easyinput__placeholder-class {
  505. font-size: 28rpx;
  506. }
  507. /deep/.uni-table {
  508. min-width: 100vw !important;
  509. font-size: 28rpx;
  510. .uni-table-td,
  511. .uni-table-th {
  512. padding: 10rpx !important;
  513. text-align: center !important;
  514. font-size: 28rpx;
  515. color: #000000;
  516. }
  517. }
  518. .ellipsis {
  519. overflow: hidden;
  520. text-overflow: ellipsis;
  521. white-space: nowrap;
  522. max-width: 160px;
  523. }
  524. /* 当屏幕宽度小于600px时,调整最大宽度 */
  525. @media (max-width: 600px) {
  526. .ellipsis {
  527. max-width: 140px;
  528. /* 小屏幕下更小的最大宽度 */
  529. }
  530. }
  531. .top-wrapper {
  532. display: flex;
  533. height: 88rpx;
  534. align-items: center;
  535. justify-content: space-between;
  536. padding: 20rpx;
  537. /deep/.uni-section {
  538. margin-top: 0px;
  539. }
  540. /deep/.uni-section-header {
  541. padding: 0px;
  542. }
  543. .search_btn {
  544. width: 120rpx;
  545. height: 70rpx;
  546. line-height: 70rpx;
  547. background: $theme-color;
  548. font-size: 28rpx;
  549. color: #fff;
  550. }
  551. .menu_icon {
  552. width: 44rpx;
  553. height: 44rpx;
  554. margin-left: 14rpx;
  555. }
  556. .more_search {
  557. display: flex;
  558. align-items: center;
  559. height: 70rpx;
  560. line-height: 70rpx;
  561. }
  562. /deep/.u-input {
  563. border: 1rpx solid #ccc;
  564. .u-input__content__field-wrapper__field {
  565. height: 40rpx !important;
  566. }
  567. }
  568. image {
  569. width: 52rpx;
  570. height: 52rpx;
  571. margin-left: 10rpx;
  572. }
  573. }
  574. .scroll_box {
  575. flex: 1;
  576. overflow: scroll;
  577. .scroll-Y {
  578. height: 100%;
  579. }
  580. }
  581. </style>