index.vue 14 KB

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