invSearch.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="库存管理"></u-navbar>
  5. <view class="tab-wrap">
  6. <view class="tab">
  7. <u-tabs :list="tabList" :activeStyle="{color: '#333',fontWeight: 'bold',fontSize:'36rpx'}"
  8. :inactiveStyle="{fontSize:'32rpx'}" :scrollable="false" :current="current" @click="tabClick"
  9. lineColor="#2C6FF3">
  10. </u-tabs>
  11. </view>
  12. </view>
  13. <view class="flex align-center justify-end screen-container">
  14. <view style="margin-right: 24rpx;" @click="sortClick">{{sortName}}</view>
  15. <view class="flex align-center justify-center" @tap="screen">
  16. <view class="" style="font-size: 28rpx;font-weight: 500;color: #333333;">筛选</view>
  17. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/screen.png"
  18. style="width: 32rpx;height: 32rpx;margin-left: 12rpx;" mode="widthFix"></image>
  19. </view>
  20. </view>
  21. <scroll-view class="scrollview" :scroll-with-animation="true" scroll-y lower-threshold="100"
  22. @scrolltolower="scrolltolower" :style="{height:fullHeight}">
  23. <view v-if="list.length>0">
  24. <block v-for="(item,index) in list" :key="index">
  25. <view class="equipment-container" @click="details(item)">
  26. <view class="flex align-center justify-between">
  27. <view class="title" v-if="current==1">
  28. <view v-if="item.deviceName">{{item.deviceName}}<text>({{item.deviceId}})</text></view>
  29. <view v-else>{{item.deviceId}}</view>
  30. </view>
  31. <view class="title" v-else>{{item.goodsName}}</view>
  32. <view>
  33. <u-icon name="arrow-right" size="14"></u-icon>
  34. </view>
  35. </view>
  36. <view class="order-detail-item">
  37. <view>缺货:</view>{{item.lackSum}}
  38. </view>
  39. <view class="order-detail-item">
  40. <view>库存:</view>{{item.stockSum}}
  41. </view>
  42. <view class="order-detail-item">
  43. <view>容量:</view>{{item.capacitySum}}
  44. </view>
  45. <view class="order-detail-item percent">
  46. <view>缺货占比:</view>{{item.percent}}%
  47. </view>
  48. </view>
  49. </block>
  50. </view>
  51. <view v-else class='empty'>
  52. <u-empty mode="data" text="数据为空"></u-empty>
  53. </view>
  54. </scroll-view>
  55. <xpopup :show="screenShow" @close="close" @confirm="sure" :showBtn="true" title="筛选">
  56. <view class="popup-container">
  57. <view class="pop-item-name">
  58. 机器名称/机器编号:
  59. </view>
  60. <view class='martop'>
  61. <u-checkbox-group v-model="searchQuery.deviceIdList" placement="row" @change="checkboxChange">
  62. <u-checkbox :customStyle="{marginBottom: '8px',marginRight: '12px'}"
  63. v-for="(item, index) in checkboxList" :key="item.id" :label="item.name" :name="item.id">
  64. </u-checkbox>
  65. </u-checkbox-group>
  66. </view>
  67. <view class="pop-item-name" style="margin-top: 30rpx;">
  68. 商品名称:
  69. </view>
  70. <view class='martop'>
  71. <u--input placeholder="商品名称" v-model="searchQuery.goodsName" border="surround"></u--input>
  72. </view>
  73. </view>
  74. </xpopup>
  75. <u-action-sheet :show="actionSheetShow" :actions="actions" :title="title" @close="actionSheetShow = false"
  76. @select="actionsheetSelect($event)"></u-action-sheet>
  77. </view>
  78. </template>
  79. <script>
  80. import {
  81. stockByDevice, //按设备分组
  82. stockByGoods, // 按商品分组
  83. } from '@/api/replenishment/replenishment.js'
  84. export default {
  85. data() {
  86. return {
  87. sortName: '缺货率从多到少',
  88. searchQuery: {
  89. deviceIdList: [],
  90. goodsName: null
  91. },
  92. screenShow: false,
  93. list: [],
  94. loadmoreStatus: 'loadmore',
  95. fullHeight: 0,
  96. tabList: [{
  97. name: '商品'
  98. },
  99. {
  100. name: '机器'
  101. }
  102. ],
  103. current: 0,
  104. actionSheetShow: false,
  105. actions: [{
  106. type: '1',
  107. name: '缺货率从多到少'
  108. },
  109. {
  110. type: '2',
  111. name: '缺货率从少到多'
  112. },
  113. {
  114. type: '3',
  115. name: '缺货数从多到少'
  116. },
  117. {
  118. type: '4',
  119. name: '缺货数从少到多'
  120. }
  121. ],
  122. checkboxList: [],
  123. }
  124. },
  125. onLoad() {
  126. let _this = this;
  127. const query = uni.createSelectorQuery().in(this);
  128. query.select(".scrollview").boundingClientRect((data) => {
  129. uni.getSystemInfo({
  130. success(res) {
  131. // 针对iPhone X等机型底部安全距离做适配
  132. const model = res.model;
  133. const modelInclude = [
  134. "iPhone X",
  135. 'iPhone XR',
  136. "iPhone XS",
  137. "iPhone XS MAX",
  138. "iPhone 12/13 mini",
  139. "iPhone 12/13 (Pro)",
  140. "iPhone 12/13 Pro Max",
  141. "iPhone 14 Pro Max"
  142. ];
  143. let safeDistance = modelInclude.includes(model)
  144. //动态设置商品区域高度
  145. console.log(res.windowHeight, data.top)
  146. if (safeDistance) {
  147. _this.fullHeight = res.windowHeight - data.top - 40 + 'px';
  148. } else {
  149. _this.fullHeight = res.windowHeight - data.top + 'px';
  150. }
  151. },
  152. });
  153. }).exec();
  154. this.search()
  155. this.getDeviceList()
  156. },
  157. methods: {
  158. search() {
  159. let params = {
  160. "deviceIdList": this.searchQuery.deviceIdList,
  161. "goodsName": this.searchQuery.goodsName,
  162. "orderBy": '',
  163. "orderByKey": '',
  164. }
  165. switch (this.sortName) {
  166. case '缺货率从多到少':
  167. params.orderBy = 'desc';
  168. params.orderByKey = 'percent'
  169. break;
  170. case '缺货率从少到多':
  171. params.orderBy = 'asc';
  172. params.orderByKey = 'percent'
  173. break;
  174. case '缺货数从多到少':
  175. params.orderBy = 'desc';
  176. params.orderByKey = 'lackSum'
  177. break;
  178. case '缺货数从少到多':
  179. params.orderBy = 'asc';
  180. params.orderByKey = 'lackSum'
  181. break;
  182. default:
  183. break;
  184. }
  185. if (this.current == 0) { //商品
  186. this.getListA(params)
  187. } else { //机器
  188. this.getListB(params)
  189. }
  190. },
  191. getDeviceList(){
  192. deviceList().then(res => {
  193. this.checkboxList=res.data
  194. })
  195. },
  196. //按商品分组
  197. getListA(params) {
  198. stockByGoods(params).then(res => {
  199. if (res.code == 200) {
  200. if (res.data && res.data.length > 0) {
  201. this.list = res.data
  202. } else {
  203. this.list = []
  204. }
  205. } else {
  206. this.list = []
  207. }
  208. })
  209. },
  210. //按设备分组
  211. getListB(params) {
  212. stockByDevice(params).then(res => {
  213. if (res.code == 200) {
  214. if (res.data && res.data.length > 0) {
  215. this.list = res.data
  216. } else {
  217. this.list = []
  218. }
  219. } else {
  220. this.list = []
  221. }
  222. })
  223. },
  224. //点击筛选
  225. screen() {
  226. this.screenShow = true
  227. },
  228. close() {
  229. this.screenShow = false
  230. },
  231. confirm(e) {
  232. this.show = false
  233. this.search()
  234. },
  235. sortClick() {
  236. this.actionSheetShow = true;
  237. },
  238. actionsheetSelect(e) {
  239. this.sortName = e.name
  240. },
  241. checkboxChange(e) {
  242. this.searchQuery.deviceIdList = e
  243. },
  244. sure() {
  245. this.close()
  246. this.search()
  247. },
  248. // 时间选择
  249. timeSubmit(e) {
  250. this.searchQuery.orderDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
  251. this.timeShow = false
  252. this.reset()
  253. this.getpage()
  254. //改为分页接口获取 this.getCountData()
  255. },
  256. tabClick(e) {
  257. this.current = e.index
  258. this.search()
  259. },
  260. details(item) {
  261. let id = this.current == 0 ? item.goodsId : item.deviceId;
  262. let title = this.current == 0 ? item.goodsName : item.deviceName ? item.deviceName : item.deviceId;
  263. this.$tab.navigateTo(`/pages/replenish/invSearchDetail?type=${this.current}&id=${id}&title=${title}`)
  264. },
  265. }
  266. }
  267. </script>
  268. <style scoped lang="scss">
  269. .container {
  270. .empty {
  271. margin-top: 40%;
  272. }
  273. .martop {
  274. margin-top: 20rpx;
  275. }
  276. .search {
  277. padding: 24rpx 13rpx;
  278. background-color: #fff;
  279. }
  280. .tab-wrap {
  281. background-color: #fff;
  282. .tab {
  283. // width: 40%;
  284. }
  285. }
  286. .marleft {
  287. margin-left: 10rpx;
  288. }
  289. .scrollview {
  290. overflow: hidden;
  291. }
  292. .screen-container {
  293. background-color: #fff;
  294. padding: 30rpx 13rpx;
  295. >view:nth-child(1) {
  296. font-size: 28rpx;
  297. font-weight: 500;
  298. }
  299. }
  300. .equipment-container {
  301. margin: 13rpx 13rpx 0;
  302. padding: 12rpx 20rpx 24rpx;
  303. border-radius: 14rpx;
  304. background-color: #fff;
  305. box-shadow: 0px 0px 10rpx 0px rgba(174, 201, 255, 0.2);
  306. position: relative;
  307. .sb-box {
  308. padding: 24rpx 18rpx;
  309. background-color: #f5f8fb;
  310. border-radius: 8rpx;
  311. margin-top: 12rpx;
  312. }
  313. .title {
  314. height: 60rpx;
  315. line-height: 60rpx;
  316. font-size: 32rpx;
  317. font-weight: bold;
  318. color: #333;
  319. >text {
  320. font-size: 24rpx;
  321. color: #333;
  322. }
  323. }
  324. .order-detail-item {
  325. font-size: 28rpx;
  326. margin-top: 12rpx;
  327. color: #777;
  328. >view {
  329. display: inline-block;
  330. width: 170rpx;
  331. }
  332. }
  333. .percent {
  334. position: absolute;
  335. right: 40rpx;
  336. bottom: 20rpx;
  337. line-height: 140rpx;
  338. color: red;
  339. >view {
  340. color: #777;
  341. }
  342. }
  343. }
  344. .popup-container {
  345. padding: 20rpx;
  346. }
  347. }
  348. </style>