index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="库存查询" @clickLeft="back">
  4. </uni-nav-bar>
  5. <view class="search-bar">
  6. <uni-search-bar class="uni-search-bar" @confirm="search" v-model="form.key" @input="search" cancelButton="none"
  7. placeholder="编码/名称">
  8. </uni-search-bar>
  9. <view class="screen" @click="handlScreen">
  10. <text class="text">筛选</text>
  11. <image class="image" src="~@/static/moreSearch.svg" mode=""></image>
  12. </view>
  13. </view>
  14. <view class="list-wrap">
  15. <view class="item" v-for="(item, index) in listData" @click="goDetails(item)" :key="index">
  16. <view class="title" v-if="form.dimension == 1">
  17. <view class="s1"> {{ item.assetCode }} ({{ item.assetName }}) </view>
  18. <view class="s2" :class="{
  19. 'text-danger': item.realInventoryNum < item.safeStock
  20. }">
  21. {{ item.realInventoryNum }} {{ item.unit }}
  22. </view>
  23. </view>
  24. <view class="title" v-if="form.dimension == 2">
  25. <view class="s1">
  26. {{ item.batchNum }}
  27. </view>
  28. <view class="s1"> {{ item.assetCode }} ({{ item.assetName }}) </view>
  29. <view class="s2" :class="{
  30. 'text-danger': item.realInventoryNum < item.safeStock
  31. }">
  32. {{ item.realInventoryNum }} {{ item.unit }}
  33. </view>
  34. </view>
  35. <view class="main">
  36. <view class="main-item" v-if="form.dimension == 2">
  37. <view class="s1"> 批次号 </view>
  38. <view class="s2">
  39. {{ item.batchNum }}
  40. </view>
  41. </view>
  42. <view class="main-item" v-for="(itm, index) in tableHeader" :key="index">
  43. <view class="s1"> {{ itm.label }} </view>
  44. <view class="s2" v-if="itm.formatter">{{
  45. itm.formatter(item)
  46. }}</view>
  47. <view class="s2" v-else>{{ item[itm.prop] }}</view>
  48. </view>
  49. <view class="main-item">
  50. <view class="s1"> 分类 </view>
  51. <view class="s2">
  52. {{ item.classificationUrl }}
  53. </view>
  54. </view>
  55. </view>
  56. <view class="ckxq"> 查看详情 </view>
  57. </view>
  58. </view>
  59. <u-loadmore fontSize="32" iconSize="36" :status="status" style="margin-top: 20rpx" />
  60. <screen ref="screen" @succeed="cabScreen" :dimension="form.dimension" :code="form.code"
  61. :warehouseId="form.warehouseId"></screen>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. post,
  67. get
  68. } from '@/utils/api.js'
  69. let [page, size, isEnd] = [1, 10, true]
  70. import screen from './components/screen'
  71. export default {
  72. components: {
  73. screen
  74. },
  75. data() {
  76. return {
  77. listData: [],
  78. form: {
  79. key: '',
  80. // 列表维度
  81. dimension: 1,
  82. /* 资产类型 */
  83. code: '',
  84. /* 所属仓库 */
  85. warehouseId: ''
  86. },
  87. dict: {
  88. code: {
  89. 1: '生产设备',
  90. 2: '舟皿',
  91. 3: '物料',
  92. 5: '周转车',
  93. 6: '模具',
  94. 7: '备品备件'
  95. }
  96. },
  97. status: 'loading'
  98. }
  99. },
  100. onLoad() {},
  101. onShow() {},
  102. //加载更多
  103. onReachBottom() {
  104. console.log('加载更多')
  105. if (isEnd) {
  106. return
  107. }
  108. this.getMoreLists()
  109. },
  110. created() {
  111. // this.getData()
  112. },
  113. computed: {
  114. tableHeader() {
  115. switch (+this.form.code) {
  116. case 3:
  117. return [{
  118. label: '牌号',
  119. prop: 'brandNum'
  120. }]
  121. case 8:
  122. return [{
  123. label: '型号',
  124. prop: 'modelType'
  125. },
  126. {
  127. label: '规格',
  128. prop: 'specification'
  129. }
  130. ]
  131. case 4:
  132. return [{
  133. label: '牌号',
  134. prop: 'brandNum'
  135. },
  136. {
  137. label: '型号',
  138. prop: 'modelType'
  139. }
  140. ]
  141. case 5: //'周转车'
  142. return [{
  143. label: '规格',
  144. prop: 'specification'
  145. },
  146. {
  147. label: '材质',
  148. prop: 'texture',
  149. formatter(row) {
  150. const extendField = JSON.parse(row.extendField)
  151. return extendField.texture
  152. }
  153. }
  154. // {
  155. // label: '长宽高',
  156. // prop: '',
  157. // formatter (row) {
  158. // const extendField = JSON.parse(row.extendField)
  159. // return `${extendField.length}*${extendField.width}*${extendField.high}`
  160. // }
  161. // }
  162. ]
  163. case 2: //'舟皿'
  164. return [{
  165. label: '规格',
  166. prop: 'specification'
  167. },
  168. {
  169. label: '型号',
  170. prop: 'modelType'
  171. }
  172. // {
  173. // label: '长宽高',
  174. // prop: '',
  175. // formatter (row) {
  176. // const extendField = JSON.parse(row.extendField)
  177. // return `${extendField.length}*${extendField.width}*${extendField.high}`
  178. // }
  179. // }
  180. ]
  181. case 1: //'设备'
  182. return [{
  183. label: '型号',
  184. prop: 'modelType'
  185. },
  186. {
  187. label: '规格',
  188. prop: 'specification'
  189. }
  190. ]
  191. case 6: //'模具'
  192. return [{
  193. label: '牌号',
  194. prop: 'brandNum'
  195. },
  196. {
  197. label: '型号',
  198. prop: 'modelType'
  199. }
  200. // {
  201. // label: '收缩系数',
  202. // prop: '',
  203. // formatter (row) {
  204. // const extendField = JSON.parse(row.extendField)
  205. // return extendField.shrinkageCoefficient
  206. // }
  207. // }
  208. ]
  209. case 7: //'备品备件'
  210. return [{
  211. label: '规格',
  212. prop: 'specification'
  213. },
  214. {
  215. label: '型号',
  216. prop: 'modelType'
  217. }
  218. ]
  219. }
  220. return []
  221. }
  222. },
  223. methods: {
  224. //筛选
  225. getData() {
  226. let par = JSON.parse(JSON.stringify(this.form))
  227. par.page = page
  228. par.size = size
  229. par = this.URLSearchParams(par)
  230. console.log(par)
  231. get(this.apiUrl + '/InventoryBook/select/getPage?' + par).then(res => {
  232. if (res.success) {
  233. this.listData = [...this.listData, ...res.data.records]
  234. let pages = res.data.pages
  235. if (page < pages) {
  236. isEnd = false
  237. } else {
  238. isEnd = true
  239. this.status = 'nomore'
  240. }
  241. }
  242. })
  243. },
  244. handlScreen() {
  245. this.$refs.screen.open()
  246. },
  247. cabScreen(data) {
  248. for (let key of Object.keys(data)) {
  249. this.form[key] = data[key]
  250. }
  251. page = 1
  252. this.listData = []
  253. this.search()
  254. },
  255. goDetails(item) {
  256. // // 物料维度
  257. // if (this.form.dimension == 1) {
  258. // let par = {
  259. // info: encodeURIComponent(JSON.stringify(item)),
  260. // dimension: this.form.dimension,
  261. // code: item.assetType
  262. // }
  263. // par = this.URLSearchParams(par)
  264. // uni.navigateTo({
  265. // url: '/pages/warehouse/inventory/details/details?' + par
  266. // })
  267. // }
  268. // 批次维度
  269. // if (this.form.dimension == 2) {
  270. let par = {
  271. dimension: this.form.dimension,
  272. batchNum: item.batchNum,
  273. inventoryCode: item.assetCode,
  274. info: encodeURIComponent(JSON.stringify(item)),
  275. code: item.assetType,
  276. }
  277. par = this.URLSearchParams(par)
  278. uni.navigateTo({
  279. url: '/pages/warehouse/inventory/batch/batch?' + par
  280. })
  281. // }
  282. },
  283. search() {
  284. this.listData = []
  285. this.getData()
  286. },
  287. getMoreLists() {
  288. page++
  289. this.getData()
  290. }
  291. }
  292. }
  293. </script>
  294. <style lang="scss" scoped>
  295. .search-bar {
  296. display: flex;
  297. align-items: center;
  298. justify-content: space-between;
  299. .screen {
  300. display: flex;
  301. align-items: center;
  302. margin-right: 20rpx;
  303. .text {
  304. line-height: 1;
  305. }
  306. .image {
  307. width: 40rpx;
  308. height: 40rpx;
  309. }
  310. }
  311. .uni-search-bar {
  312. flex: 1;
  313. }
  314. }
  315. .list-wrap {
  316. .item {
  317. .title {
  318. display: flex;
  319. justify-content: space-between;
  320. padding: 20rpx;
  321. border-bottom: 1px solid #333333;
  322. font-size: 28rpx;
  323. }
  324. .main {
  325. padding: 0 50rpx;
  326. background-color: #fcfcfc;
  327. .main-item {
  328. display: flex;
  329. justify-content: space-between;
  330. font-size: 28rpx;
  331. color: #aaaaaa;
  332. padding: 20rpx 0;
  333. &+.main-item {
  334. border-top: 1px dashed #aaaaaa;
  335. }
  336. }
  337. }
  338. .ckxq {
  339. font-size: 28rpx;
  340. color: #70b603;
  341. background-color: #f1fbe2;
  342. padding: 20rpx;
  343. text-align: center;
  344. }
  345. }
  346. }
  347. </style>