index.vue 13 KB

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