replenishmentManagement.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <template>
  2. <view>
  3. <view class="container">
  4. <u-navbar titleStyle="fontSize:36rpx;" :autoBack="true" bgColor="#fff" :placeholder="true"
  5. title="补货管理"></u-navbar>
  6. <view style="background-color: #fff;">
  7. <view class="flex align-center box">
  8. <!-- <view class="flex flex-direction align-center" @tap="startReplenishment()">
  9. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/replenish/bh.png" mode="widthFix"></image>
  10. <view class="">开始补货</view>
  11. </view> -->
  12. <!-- <view class="flex flex-direction align-center" @tap="commodityList()">
  13. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/replenish/qd.png" mode="widthFix"></image>
  14. <view class="">商品清单</view>
  15. </view> -->
  16. <view class="flex justify-between align-center" @tap="replenishmentRecord()">
  17. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/replenish/jl.png"
  18. mode="widthFix"></image>
  19. <!-- <image src="../../static/favicon.ico" mode=""></image> -->
  20. <view class="menu-name">补货记录</view>
  21. </view>
  22. <view class="flex justify-between align-center" @tap='inventoryManagement()'>
  23. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/replenish/kc.png"
  24. mode="widthFix"></image>
  25. <!-- <image src="../../static/favicon.ico" mode=""></image> -->
  26. <view class="menu-name">库存管理</view>
  27. </view>
  28. </view>
  29. <!-- <view class="tips">
  30. 补货说明补货说明补货说明
  31. </view> -->
  32. <!-- 设备列表 -->
  33. <view class="search">
  34. <u-search animation placeholder="请输入设备名称" bgColor="#F6F8FB" :clearabled="true" v-model="keyword"
  35. :showAction="false" @search="search"></u-search>
  36. </view>
  37. <!-- <view class="tab-list">
  38. <u-tabs :list="tabList" @click="tabChange" :current="current" :scrollable="false" bgColor="#fff"
  39. lineColor="#2C6FF3"></u-tabs>
  40. </view> -->
  41. <view class="tab-wrap">
  42. <view class="tab">
  43. <u-tabs :list="tabList" :activeStyle="{color: '#333',fontWeight: 'bold',fontSize:'36rpx'}"
  44. :inactiveStyle="{fontSize:'32rpx'}" :scrollable="false" :current="current"
  45. @click="tabChange" lineColor="#2C6FF3">
  46. </u-tabs>
  47. </view>
  48. </view>
  49. </view>
  50. <scroll-view class="scrollview" :scroll-with-animation="true" scroll-y lower-threshold="100"
  51. @scrolltolower="scrolltolower" :style="{height:fullHeight}">
  52. <view class="content">
  53. <view class="xy-card" v-for="(item,index) in list" :key="item.deviceId"
  54. @click="replenish(item.deviceId,item.deviceName)">
  55. <view class="title flex justify-between">
  56. <view class="flex">
  57. <view>
  58. <view class="device-name" v-if="item.deviceName">
  59. {{item.deviceName}}<text>({{item.deviceId}})</text>
  60. </view>
  61. <view class="device-name" v-else>
  62. {{item.deviceId}}
  63. </view>
  64. </view>
  65. <view style="margin-left: 22rpx; margin-top: 8rpx;" v-if="item.deviceTypeName">
  66. <view class="busy-state on">{{item.deviceTypeName}}</view>
  67. </view>
  68. <view style="margin-left: 22rpx; margin-top: 8rpx;">
  69. <view v-if="item.busyState==1" class="busy-state on">运营中</view>
  70. <view v-else class="busy-state off">已停运</view>
  71. </view>
  72. </view>
  73. <view class="flex status">
  74. <view style="margin-left: 24rpx;color: #FF0000;" v-if="item.goodsIdStockOutCount>0">
  75. 缺货
  76. </view>
  77. <view style="margin-left: 24rpx;color: green;" v-else>
  78. 正常
  79. </view>
  80. </view>
  81. </view>
  82. <view class="t-content flex flex-direction" v-if="current==0">
  83. <view class="c-item-t">
  84. <view class="c-item">
  85. <view>剩余库存:</view>
  86. <view>{{item.stockSum||0}}</view>
  87. </view>
  88. <view class="c-item">
  89. <view>补后库存:</view>
  90. <view>{{item.fillCountSum||0}}</view>
  91. </view>
  92. </view>
  93. <view class="c-item-t">
  94. <view class="c-item">
  95. <view>在售商品种类:</view>
  96. <view>{{item.goodsIdCount||0}}</view>
  97. </view>
  98. <view class="c-item" v-if="item.goodsIdStockOutCount>0">
  99. <view>缺货商品种类:</view>
  100. <view style="color: red;font-weight: bold;">{{item.goodsIdStockOutCount||0}}</view>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="t-content flex flex-direction" v-else>
  105. <view class="c-item-t">
  106. <view class="c-item">
  107. <view>剩余库存:</view>
  108. <view>{{item.stockSum||0}}</view>
  109. </view>
  110. <view class="c-item">
  111. <view>补后库存:</view>
  112. <view>{{item.fillCountSum||0}}</view>
  113. </view>
  114. </view>
  115. <view class="c-item-t">
  116. <view class="c-item">
  117. <view>缺货商品种类:</view>
  118. <view style="color: red;font-weight: bold;">{{item.goodsIdStockOutCount||0}}</view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. <u-loadmore :status="status" v-if="list.length>=1" />
  124. </view>
  125. <view class="empty" v-if="list.length==0">
  126. <u-empty text="没有设备!"></u-empty>
  127. </view>
  128. </scroll-view>
  129. <!-- <view class="scan" @click="startReplenishment">
  130. <view class="scan-icon-bot">
  131. <u-icon name="scan" color="#2C6FF3" size="60"></u-icon>
  132. </view>
  133. <view>扫码补货</view>
  134. </view> -->
  135. <view class="btn">
  136. <xbutton size="large" @click="startReplenishment">
  137. <view class="btn-wrap flex align-center">
  138. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/replenish/rep-scan.png" mode=""></image>
  139. 扫码补货
  140. </view>
  141. </xbutton>
  142. </view>
  143. </view>
  144. </view>
  145. </template>
  146. <script>
  147. import {
  148. deviceDetail,
  149. searchPage,
  150. isMerc
  151. } from '@/api/device/device.js'
  152. import {
  153. deviceStockList,
  154. deviceStockOutList
  155. } from '@/api/replenishment/replenishment.js'
  156. export default {
  157. data() {
  158. return {
  159. page: 1,
  160. size: 10,
  161. status: 'loadmore',
  162. current: 0,
  163. tabList: [{
  164. name: '全部',
  165. value: ''
  166. },
  167. {
  168. name: '缺货',
  169. value: 1
  170. }
  171. ],
  172. list: [],
  173. keyword: '',
  174. fullHeight:0
  175. }
  176. },
  177. onPullDownRefresh() {
  178. this.reset()
  179. if (this.current == 0) {
  180. this.getList1().then(res => {
  181. uni.stopPullDownRefresh();
  182. })
  183. } else {
  184. this.getList2().then(res => {
  185. uni.stopPullDownRefresh();
  186. })
  187. }
  188. },
  189. onShow() {
  190. this.search()
  191. },
  192. onLoad() {
  193. let _this = this;
  194. const query = uni.createSelectorQuery().in(this);
  195. query.select(".scrollview").boundingClientRect((data) => {
  196. uni.getSystemInfo({
  197. success(res) {
  198. // 针对iPhone X等机型底部安全距离做适配
  199. const model = res.model;
  200. const modelInclude = [
  201. "iPhone X",
  202. 'iPhone XR',
  203. "iPhone XS",
  204. "iPhone XS MAX",
  205. "iPhone 12/13 mini",
  206. "iPhone 12/13 (Pro)",
  207. "iPhone 12/13 Pro Max",
  208. "iPhone 14 Pro Max"
  209. ];
  210. let safeDistance = modelInclude.includes(model)
  211. //动态设置商品区域高度
  212. console.log(res.windowHeight, data.top)
  213. if (safeDistance) {
  214. _this.fullHeight = res.windowHeight - data.top - 40 + 'px';
  215. } else {
  216. _this.fullHeight = res.windowHeight - data.top + 'px';
  217. }
  218. },
  219. });
  220. }).exec();
  221. },
  222. methods: {
  223. startReplenishment() {
  224. uni.scanCode({
  225. success: (res) => {
  226. let deviceId = res.result.split('=')[1];
  227. if (deviceId) {
  228. this.hasDevice(deviceId).then(res => {
  229. this.$tab.navigateTo(
  230. `/pages/replenish/replenishmentHomePage?id=${deviceId}`)
  231. }).catch(err => {
  232. if (err.indeOf('com.netflix') == -1) {
  233. this.$modal.msg('err')
  234. } else {
  235. this.$modal.msg('网络繁忙,请重试!')
  236. }
  237. })
  238. } else {
  239. this.$modal.msg('该二维码无效~')
  240. }
  241. }
  242. });
  243. },
  244. hasDevice(id) {
  245. return new Promise((resolve, reject) => {
  246. isMerc({
  247. deviceId: id
  248. }).then(res => {
  249. console.log(res)
  250. resolve(res)
  251. }).catch(err => {
  252. reject(err)
  253. })
  254. })
  255. },
  256. commodityList() {
  257. this.$tab.navigateTo('../commodity/commoditylist')
  258. },
  259. replenishmentRecord() {
  260. this.$tab.navigateTo('replenishmentRecord')
  261. },
  262. inventoryManagement() {
  263. this.$tab.navigateTo('/pages/replenish/invSearch')
  264. },
  265. tabChange(e) {
  266. this.current = e.index
  267. this.reset()
  268. this.getList()
  269. },
  270. getList() {
  271. if (this.current == 0) {
  272. this.getList1()
  273. } else {
  274. this.getList2()
  275. }
  276. },
  277. reset() {
  278. this.status == 'loadmore'
  279. this.page = 1;
  280. this.list = [];
  281. },
  282. getList1() {
  283. return new Promise((resolve, reject) => {
  284. deviceStockList({
  285. page: {
  286. current: this.page,
  287. size: this.size
  288. },
  289. keyword: this.keyword,
  290. }).then(res => {
  291. let data = res.data.records;
  292. if (data.length < 10) {
  293. this.status = "nomore"
  294. } else {
  295. this.status = "loadmore"
  296. }
  297. this.list = this.list.concat(data)
  298. resolve(data)
  299. }).catch(err => {
  300. reject(err)
  301. })
  302. })
  303. },
  304. getList2() {
  305. return new Promise((resolve, reject) => {
  306. deviceStockOutList({
  307. page: {
  308. current: this.page,
  309. size: this.size
  310. },
  311. keyword: this.keyword,
  312. }).then(res => {
  313. let data = res.data.records;
  314. if (data.length < 10) {
  315. this.status = "nomore"
  316. } else {
  317. this.status = "loadmore"
  318. }
  319. this.list = this.list.concat(data)
  320. resolve(data)
  321. }).catch(err => {
  322. reject(err)
  323. })
  324. })
  325. },
  326. search() {
  327. this.reset()
  328. this.getList()
  329. },
  330. scanDevice() {
  331. uni.scanCode({
  332. success: (res) => {
  333. let deviceId = res.result.split('=')[1];
  334. if (deviceId) {
  335. this.keyword = deviceId;
  336. this.getList()
  337. } else {
  338. this.$modal.msg('该二维码无效~')
  339. }
  340. }
  341. });
  342. },
  343. replenish(id, name) {
  344. this.$tab.navigateTo(`/pages/replenish/replenishmentHomePage?id=${id}&&deviceName=${name}`)
  345. },
  346. //触底加载更多
  347. scrolltolower() {
  348. if (this.status == 'nomore') return
  349. this.page++
  350. this.getList()
  351. },
  352. }
  353. }
  354. </script>
  355. <style scoped lang="scss">
  356. .container {
  357. // padding-top: 120rpx;
  358. image {
  359. width: 50rpx;
  360. height: 50rpx;
  361. }
  362. .box {
  363. padding: 38rpx 12rpx 14rpx;
  364. background: #fff;
  365. font-size: 28rpx;
  366. font-weight: 500;
  367. color: #777777;
  368. line-height: 62rpx;
  369. >view {
  370. background: #F7F7F7;
  371. border-radius: 10rpx;
  372. margin-right: 20rpx;
  373. padding: 0 12rpx;
  374. }
  375. image {
  376. width: 34rpx;
  377. height: 34rpx;
  378. margin-right: 15rpx;
  379. }
  380. }
  381. .tips {
  382. width: 724rpx;
  383. padding: 10rpx 24rpx;
  384. font-size: 28rpx;
  385. line-height: 40rpx;
  386. font-weight: 500;
  387. color: #333333;
  388. background: #F0FFFC;
  389. border: 2rpx dashed #61D8BE;
  390. border-radius: 14rpx;
  391. margin-left: 13rpx;
  392. }
  393. .search {
  394. padding: 0rpx 13rpx 24rpx;
  395. background-color: #fff;
  396. position: relative;
  397. margin-top: 14rpx;
  398. .scan-icon {
  399. position: absolute;
  400. right: 36rpx;
  401. top: 50%;
  402. transform: translateY(-50%);
  403. z-index: 2;
  404. }
  405. }
  406. .scan {
  407. width: 100%;
  408. position: fixed;
  409. bottom: 0;
  410. display: flex;
  411. flex-direction: column;
  412. justify-content: center;
  413. align-items: center;
  414. background-color: #fff;
  415. box-shadow: 0 2rpx 10rpx 0 rgba(0, 0, 0, 0.1);
  416. .scan-icon-bot {
  417. width: 60px;
  418. }
  419. >view:nth-child(2) {
  420. font-size: 24rpx;
  421. color: #999;
  422. }
  423. }
  424. .tab-wrap {
  425. background-color: #fff;
  426. .tab {
  427. width: 40%;
  428. margin-left: -12rpx;
  429. }
  430. }
  431. .content {
  432. margin: 0 13rpx;
  433. padding-bottom: 60rpx;
  434. overflow: hidden;
  435. .xy-card {
  436. margin-top: 20rpx;
  437. padding: 32rpx;
  438. }
  439. }
  440. .title {
  441. font-size: 28rpx;
  442. font-weight: bold;
  443. line-height: 50rpx;
  444. .device-name {
  445. font-size: 28rpx;
  446. font-weight: bold;
  447. color: #333;
  448. max-width: 180rpx;
  449. >text {
  450. font-size: 24rpx;
  451. color: #666;
  452. font-weight: normal;
  453. }
  454. }
  455. }
  456. .t-content {
  457. margin-top: 12rpx;
  458. .c-item-t {
  459. display: flex;
  460. justify-content: flex-start;
  461. margin-top: 12rpx;
  462. .c-item {
  463. width: 50%;
  464. display: flex;
  465. justify-content: flex-start;
  466. align-items: flex-end;
  467. }
  468. }
  469. }
  470. .busy-state {
  471. font-size: 24rpx;
  472. height: 38rpx;
  473. padding: 0 16rpx;
  474. line-height: 38rpx;
  475. background: #F4F8FF;
  476. border-radius: 8rpx;
  477. text-align: center;
  478. font-weight: normal;
  479. &.on {
  480. color: #2C6FF3;
  481. }
  482. &.off {
  483. color: #666;
  484. }
  485. }
  486. .status {
  487. font-weight: normal;
  488. }
  489. .empty {
  490. margin-top: 50rpx;
  491. }
  492. .btn{
  493. width:724rpx;
  494. position: fixed;
  495. left: 13rpx;
  496. bottom:calc(24rpx + env(safe-area-inset-bottom) / 2);
  497. border-radius: 88rpx;
  498. overflow: hidden;
  499. .btn-wrap{
  500. text-align: center;
  501. font-size: 36rpx;
  502. font-weight: 500;
  503. >image{
  504. width:42rpx;
  505. height: 42rpx;
  506. margin-right: 20rpx;
  507. }
  508. }
  509. }
  510. }
  511. </style>