index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. if (this.form.dimension == 1) {
  400. getProductList(par).then(res => {
  401. console.log('res----', res)
  402. this.listData = [...this.listData, ...res.list]
  403. let pages = res.count
  404. console.log(this.page)
  405. console.log(pages)
  406. if (this.listData.length < pages) {
  407. this.isEnd = false
  408. this.status = 'loading'
  409. } else {
  410. this.isEnd = true
  411. this.status = 'nomore'
  412. }
  413. })
  414. } else if (this.form.dimension == 2) {
  415. getBatchList(par).then(res => {
  416. console.log('res----', res)
  417. this.listData = [...this.listData, ...res.list]
  418. let pages = res.count
  419. if (this.listData.length < pages) {
  420. this.isEnd = false
  421. this.status = 'loading'
  422. } else {
  423. this.isEnd = true
  424. this.status = 'nomore'
  425. }
  426. })
  427. } else {
  428. getPackingList(par).then(res => {
  429. console.log('res----', res)
  430. this.listData = [...this.listData, ...res.list]
  431. let pages = res.count
  432. if (this.listData.length < pages) {
  433. this.isEnd = false
  434. this.status = 'loading'
  435. } else {
  436. this.isEnd = true
  437. this.status = 'nomore'
  438. }
  439. })
  440. }
  441. // get(this.apiUrl + '/InventoryBook/select/getPage?' + par).then(res => {
  442. // if (res.success) {
  443. // this.listData = [...this.listData, ...res.data.records]
  444. // let pages = res.data.pages
  445. // if (page < pages) {
  446. // isEnd = false
  447. // } else {
  448. // isEnd = true
  449. // this.status = 'nomore'
  450. // }
  451. // }
  452. // })
  453. },
  454. handlScreen() {
  455. this.$refs.screen.open()
  456. },
  457. cabScreen(data) {
  458. console.log('data---', data)
  459. for (let key of Object.keys(data)) {
  460. this.form[key] = data[key]
  461. }
  462. this.page = 1
  463. this.listData = []
  464. this.search()
  465. },
  466. goDetails(item) {
  467. // // 物料维度
  468. // if (this.form.dimension == 1) {
  469. // let par = {
  470. // info: encodeURIComponent(JSON.stringify(item)),
  471. // dimension: this.form.dimension,
  472. // code: item.assetType
  473. // }
  474. // par = this.URLSearchParams(par)
  475. // uni.navigateTo({
  476. // url: '/pages/warehouse/inventory/details/details?' + par
  477. // })
  478. // }
  479. // 批次维度
  480. // if (this.form.dimension == 2) {
  481. let par = {
  482. dimension: this.form.dimension,
  483. categoryCode: item.categoryCode,
  484. categoryId: item.categoryId,
  485. info: encodeURIComponent(JSON.stringify(item))
  486. }
  487. par = this.URLSearchParams(par)
  488. uni.navigateTo({
  489. url: '/pages/warehouse/inventory/batch/batch?' + par
  490. })
  491. // }
  492. },
  493. inputChange() {
  494. // 清除timer对应的延时器
  495. clearTimeout(this.timerId)
  496. // 重新启动一个延时器,并把timerId赋值给this.timer
  497. this.timerId = setTimeout(() => {
  498. // 如果500毫秒内,没有触发新的输入事件,则为搜索关键词赋值
  499. this.search()
  500. }, 500)
  501. },
  502. search() {
  503. this.listData = []
  504. this.getData()
  505. },
  506. getMoreLists() {
  507. this.page++
  508. this.getData()
  509. }
  510. }
  511. }
  512. </script>
  513. <style lang="scss" scoped>
  514. .mainBox {
  515. height: 100vh;
  516. width: 100%;
  517. display: flex;
  518. flex-direction: column;
  519. }
  520. .search-bar {
  521. height: 100rpx;
  522. display: flex;
  523. align-items: center;
  524. justify-content: space-between;
  525. .screen {
  526. display: flex;
  527. align-items: center;
  528. margin-right: 20rpx;
  529. .text {
  530. line-height: 1;
  531. }
  532. .image {
  533. width: 40rpx;
  534. height: 40rpx;
  535. }
  536. }
  537. .uni-search-bar {
  538. flex: 1;
  539. }
  540. }
  541. .scroll_box {
  542. flex: 1;
  543. overflow: scroll;
  544. .scroll-Y {
  545. height: 100%;
  546. .list-wrap {
  547. .item {
  548. .title {
  549. display: flex;
  550. align-items: center;
  551. padding: 20rpx;
  552. border-bottom: 1px solid #333333;
  553. font-size: 28rpx;
  554. .s1 {
  555. flex: 1;
  556. }
  557. }
  558. .main {
  559. padding: 0 50rpx;
  560. background-color: #fcfcfc;
  561. transition: all 0.3s linear;
  562. overflow: hidden;
  563. .main-item {
  564. display: flex;
  565. justify-content: space-between;
  566. font-size: 28rpx;
  567. color: #aaaaaa;
  568. padding: 20rpx 0;
  569. & + .main-item {
  570. border-top: 1px dashed #aaaaaa;
  571. }
  572. }
  573. }
  574. .open {
  575. height: auto;
  576. }
  577. .close {
  578. height: 0;
  579. }
  580. .ckxq {
  581. font-size: 28rpx;
  582. color: #70b603;
  583. background-color: #f1fbe2;
  584. padding: 20rpx;
  585. text-align: center;
  586. }
  587. }
  588. }
  589. }
  590. }
  591. </style>