inventory.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="inventory">
  3. <view class="top">
  4. <text class="text" @click="showDrawer()">
  5. 筛选
  6. </text>
  7. <uni-drawer ref="showRight" mode="right" :width="340">
  8. <view class="close">
  9. <view class="par">
  10. <text class="tad">
  11. 仓库
  12. </text>
  13. <view class="th">
  14. <view class="td" :class="warehouseIndex == i ? 'active' : ''" v-for="(v,i) in warehouse"
  15. :key="i" @click="change(v,i,0)">
  16. {{v.name}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="par">
  21. <text class="tad">
  22. 品牌
  23. </text>
  24. <view class="th">
  25. <view class="td" :class="brandIndex == i ? 'active' : ''" v-for="(v,i) in brand" :key="i"
  26. @click="change(v,i,1)">
  27. {{v}}
  28. </view>
  29. </view>
  30. </view>
  31. <view class="par">
  32. <text class="tad">
  33. 是否转基因
  34. </text>
  35. <view class="th">
  36. <view class="td" :class="geneIndex == i ? 'active' : ''" v-for="(v,i) in gene" :key="i"
  37. @click="change(v,i,2)">
  38. {{v == -1 ? '全部' : v == 0 ? '转基因' : v== 1 ? '非转基因' : '其他'}}
  39. </view>
  40. </view>
  41. </view>
  42. <view class="par">
  43. <text class="tad">
  44. 等级
  45. </text>
  46. <view class="th">
  47. <view class="td" :class="levelIndex == i ? 'active' : ''" v-for="(v,i) in level" :key="i"
  48. @click="change(v,i,3)">
  49. {{v}}
  50. </view>
  51. </view>
  52. </view>
  53. <view class="par">
  54. <text class="tad">
  55. 容量
  56. </text>
  57. <view class="th">
  58. <view class="td" :class="capacityIndex == i ? 'active' : ''" v-for="(v,i) in capacity"
  59. :key="i" @click="change(v,i,4)">
  60. {{v}}
  61. </view>
  62. </view>
  63. </view>
  64. <view class="btn">
  65. <view class="" @click="reset()">
  66. 重置
  67. </view>
  68. <view class="" @click="confirm()">
  69. 确定
  70. </view>
  71. </view>
  72. </view>
  73. </uni-drawer>
  74. </view>
  75. <view class="main">
  76. <view class="tab" v-for="(v,i) in data" :key="i">
  77. <view class="name">
  78. {{v.name}}
  79. </view>
  80. <view class="">
  81. {{v.warehouseStock}}瓶
  82. </view>
  83. </view>
  84. </view>
  85. <view class="bom">
  86. 合计: {{sum}}瓶
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. mapState
  93. } from 'vuex'
  94. import {
  95. stock
  96. } from '../../api/inventory.js'
  97. import {
  98. stockSearch
  99. } from '../../api/statistics.js'
  100. export default {
  101. data() {
  102. return {
  103. showRight: false,
  104. showLeft: false,
  105. data: '',
  106. sum: 0,
  107. brandIndex: 0,
  108. capacityIndex: 0,
  109. geneIndex: 0,
  110. levelIndex: 0,
  111. warehouseIndex: 0,
  112. brand: [],
  113. capacity: [],
  114. gene: [],
  115. level: [],
  116. warehouse: [],
  117. brandName: '',
  118. capacityName: '',
  119. geneName: '',
  120. levelName: '',
  121. warehouseName: ''
  122. };
  123. },
  124. computed: {
  125. ...mapState({
  126. user: store => store.user
  127. })
  128. },
  129. onLoad(options) {
  130. this.name = options.name
  131. if (this.name) {
  132. uni.setNavigationBarTitle({
  133. title: this.name
  134. });
  135. }
  136. },
  137. mounted() {
  138. this.getScreen()
  139. this.getData()
  140. },
  141. methods: {
  142. async getData() {
  143. uni.showLoading({
  144. title: '加载中'
  145. });
  146. const res = await stock({
  147. code: this.warehouseName,
  148. brand: this.brandName,
  149. gene: this.geneName,
  150. level: this.levelName,
  151. capacity: this.capacityName,
  152. accessToken: uni.getStorageSync('tokenInfo'),
  153. account: uni.getStorageSync('account')
  154. })
  155. uni.hideLoading();
  156. this.data = res.data.list
  157. let that = this
  158. res.data.list.forEach(v => {
  159. that.sum += v.warehouseStock
  160. })
  161. },
  162. async getScreen() {
  163. const res = await stockSearch({})
  164. this.warehouse = res.data.data.warehouse
  165. this.warehouse.unshift({
  166. name: "全部仓库",
  167. code: 'ck00'
  168. })
  169. this.brand = res.data.data.brand
  170. this.brand.unshift("全部品牌")
  171. this.level = res.data.data.level
  172. this.level.unshift("全部等级")
  173. this.capacity = res.data.data.capacity
  174. this.capacity.unshift("全部容量")
  175. this.gene = res.data.data.gene
  176. this.gene.unshift(-1)
  177. },
  178. // 打开窗口
  179. showDrawer(e) {
  180. this.$refs.showRight.open()
  181. },
  182. // 关闭窗口
  183. closeDrawer(e) {
  184. this.$refs.showRight.close()
  185. },
  186. change(v, i, num) {
  187. if (num === 0) {
  188. this.warehouseIndex = i
  189. if (i == 0) {
  190. this.warehouseName = ''
  191. } else {
  192. this.warehouseName = v.code
  193. }
  194. } else if (num === 1) {
  195. this.brandIndex = i
  196. if (i == 0) {
  197. this.brandName = ''
  198. } else {
  199. this.brandName = v
  200. }
  201. } else if (num === 2) {
  202. this.geneIndex = i
  203. if (i == 0) {
  204. this.geneName = ''
  205. } else {
  206. this.geneName = v
  207. }
  208. } else if (num === 3) {
  209. this.levelIndex = i
  210. if (i == 0) {
  211. this.levelName = ''
  212. } else {
  213. this.levelName = v
  214. }
  215. } else if (num === 4) {
  216. this.capacityIndex = i
  217. if (i == 0) {
  218. this.capacityName = ''
  219. } else {
  220. this.capacityName = v
  221. }
  222. }
  223. },
  224. // 筛选重置
  225. reset() {
  226. this.brandIndex = 0
  227. this.capacityIndex = 0
  228. this.geneIndex = 0
  229. this.levelIndex = 0
  230. this.warehouseIndex = 0
  231. this.brandName = ''
  232. this.capacityName = ''
  233. this.geneName = ''
  234. this.levelName = ''
  235. this.warehouseName = ''
  236. },
  237. // 筛选确定
  238. confirm() {
  239. this.getData()
  240. this.closeDrawer()
  241. },
  242. }
  243. }
  244. </script>
  245. <style lang="scss">
  246. .inventory {
  247. height: 100%;
  248. display: flex;
  249. flex-direction: column;
  250. justify-content: space-between;
  251. .top {
  252. height: 100rpx;
  253. line-height: 100rpx;
  254. text-align: right;
  255. background-color: #e40315;
  256. .text {
  257. padding: 30rpx;
  258. color: #fff;
  259. }
  260. .close {
  261. height: 100%;
  262. display: flex;
  263. flex-direction: column;
  264. justify-content: space-between;
  265. .par {
  266. text-align: left;
  267. padding: 20rpx;
  268. .th {
  269. display: flex;
  270. flex-wrap: wrap;
  271. .td {
  272. background-color: #eff3f6;
  273. height: 50rpx;
  274. line-height: 50rpx;
  275. padding: 0 20rpx;
  276. border-radius: 4px;
  277. margin: 0 10rpx 10rpx 0;
  278. }
  279. .active {
  280. background-color: #e40315;
  281. color: #fff;
  282. }
  283. }
  284. }
  285. .btn {
  286. height: 80rpx;
  287. padding: 10rpx;
  288. display: flex;
  289. margin-bottom: 20rpx;
  290. view {
  291. height: 100%;
  292. flex: 1;
  293. background-color: #e40315;
  294. border-right: 2rpx solid #fff;
  295. text-align: center;
  296. color: #fff;
  297. line-height: 80rpx;
  298. }
  299. }
  300. }
  301. }
  302. .main {
  303. flex: 1;
  304. overflow-y: scroll;
  305. padding: 0 20rpx;
  306. .tab {
  307. padding: 15rpx 0;
  308. border-bottom: 1rpx solid #e3e3e3;
  309. .name {
  310. margin-bottom: 20rpx;
  311. }
  312. }
  313. }
  314. .bom {
  315. height: 120rpx;
  316. border-top: 10rpx solid #f1f1f1;
  317. text-align: center;
  318. line-height: 120rpx;
  319. color: #e40315;
  320. font-size: 26rpx;
  321. }
  322. }
  323. </style>