comManage.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" :title="title"></u-navbar>
  5. <view class="content">
  6. <!-- <view class="search">
  7. <u-search animation placeholder="商品搜索" v-model="keyword" :showAction="false" search="search"></u-search>
  8. </view> -->
  9. <view class="list" v-if="commList&&commList.length>0">
  10. <view class="thumb-box" v-for="(item, index) in commList" :key="item.id"
  11. @click.stop="commItemSelect(item)">
  12. <view>
  13. <image class="select-img"
  14. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/selected.png"
  15. mode="widthFix" v-show="item.checked"></image>
  16. <image class="select-img"
  17. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/select.png"
  18. mode="widthFix" v-show="!item.checked"></image>
  19. </view>
  20. <view class="check-content">
  21. <view class="comm-img">
  22. <u--image width="130rpx" height="130rpx" :src="item.cover" mode="aspectFit"
  23. :lazy-load="true"></u--image>
  24. </view>
  25. <view class="comm-main">
  26. <view>
  27. {{item.name}}
  28. </view>
  29. <view>
  30. 条形码:{{item.barcode}}
  31. </view>
  32. <view>
  33. 商品ID:{{item.id}}
  34. </view>
  35. <view>
  36. 商品SKUID:{{item.skuId}}
  37. </view>
  38. <!-- <view class="c-cx">
  39. 促销活动:
  40. </view> -->
  41. <view class="c-pri">
  42. 价格:<text>¥{{$xy.delMoney(item.price)}}</text>
  43. <view @click.stop="edit(item)">修改</view>
  44. </view>
  45. </view>
  46. <view class="status" v-if="item.name">
  47. <view class="s-name">
  48. 在售/补后
  49. </view>
  50. <view class="s-num">
  51. {{item.stock}}/{{item.fillCount}}
  52. </view>
  53. </view>
  54. <view class="status" v-else>
  55. 补货时请移除
  56. </view>
  57. <!-- <view class="sale" v-if="item.name">
  58. <view>
  59. 今日销售额
  60. </view>
  61. <view>
  62. ¥<text>{{item.todaySalesMoney||0}}</text>
  63. </view>
  64. </view>
  65. <view class="sale" v-else>
  66. 已删除商品
  67. </view> -->
  68. </view>
  69. </view>
  70. <u-loadmore :status="status" v-if="commList.length>=1" />
  71. </view>
  72. <view class="empty" v-else>
  73. <u-empty></u-empty>
  74. </view>
  75. </view>
  76. <view class="refresh" @click="search">
  77. 刷新
  78. </view>
  79. <view class="btn safe-bottom">
  80. <xbutton width="340rpx" size="large" @click="del">删除商品</xbutton>
  81. <xbutton width="340rpx" size="large" @click="add">增加商品</xbutton>
  82. </view>
  83. <xpopup :show="editPriceShow" @close="editPriceClose" @confirm="submit" :showBtn="true" title="修改价格">
  84. <view class="pop-content">
  85. <u--input placeholder="请输入内容" type="digit" border="surround" v-model="price"></u--input>
  86. </view>
  87. </xpopup>
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. goodsList
  93. } from '@/api/device/device.js'
  94. import {
  95. delGoods
  96. } from "@/api/replenishment/replenishment.js"
  97. import {
  98. changePrice
  99. } from '@/api/commodity/goodsMode.js'
  100. export default {
  101. data() {
  102. return {
  103. keyword: '',
  104. commList: [],
  105. id: null, //设备id
  106. page: 1,
  107. size: 10,
  108. editPriceShow: false,
  109. price: 0,
  110. goodsId: null,
  111. deviceName: null,
  112. title: null
  113. }
  114. },
  115. onLoad(o) {
  116. if (o.id) {
  117. this.id = o.id;
  118. this.deviceName = o.deviceName;
  119. this.title = '商品列表-' + this.deviceName
  120. }
  121. },
  122. onShow() {
  123. this.reset()
  124. this.getList()
  125. },
  126. methods: {
  127. search(val) {
  128. this.reset()
  129. this.getList()
  130. },
  131. // 商品选中状态改变
  132. commItemSelect(e) {
  133. if (e.name == '未知商品' || e.name == '非友好购物商品') {
  134. this.$modal.msg('预设商品不能删除!!!')
  135. return
  136. }
  137. e.checked = !e.checked;
  138. },
  139. edit(item) {
  140. this.goodsId = item.id;
  141. this.editPriceShow = true;
  142. this.price = (Number(item.price) / 100).toFixed(2)
  143. },
  144. //删除商品
  145. del() {
  146. let delComList = [];
  147. this.commList.forEach(i => {
  148. if (i.checked) {
  149. delComList.push(i.goodsId)
  150. }
  151. })
  152. if (delComList.length == 0) {
  153. this.$modal.msg('请选择需要删除的商品~')
  154. return
  155. }
  156. uni.showModal({
  157. title: '提示',
  158. content: '是否确认删除',
  159. success: res => {
  160. if (res.confirm) {
  161. delGoods({
  162. deviceId: this.id,
  163. goodsIds: delComList
  164. }).then(res => {
  165. this.$modal.confirm('删除成功,请拿走货架上当前商品。').then(resolve => {
  166. console.log('确认拿走~')
  167. })
  168. this.reset()
  169. this.getList()
  170. })
  171. } else if (res.cancel) {
  172. console.log('用户点击取消');
  173. }
  174. }
  175. });
  176. },
  177. add() {
  178. this.$tab.navigateTo(`/pages/equipment/addCom?id=${this.id}`)
  179. },
  180. reset() {
  181. this.status == 'loadmore'
  182. this.page = 1;
  183. this.commList = [];
  184. },
  185. getList() {
  186. goodsList({
  187. page: {
  188. current: this.page,
  189. size: this.size
  190. },
  191. deviceId: this.id
  192. }).then(res => {
  193. let data = res.data.records;
  194. for (let i = 0; i < data.length; i++) {
  195. let item = data[i];
  196. item.checked = false;
  197. }
  198. if (data.length < 10) {
  199. this.status = "nomore"
  200. } else {
  201. this.status = "loadmore"
  202. }
  203. this.commList = this.commList.concat(data)
  204. })
  205. },
  206. onReachBottom() {
  207. if (this.status == 'nomore') return
  208. this.page++
  209. this.getList()
  210. },
  211. editPriceClose() {
  212. this.editPriceShow = false;
  213. },
  214. submit() {
  215. if (this.price) {
  216. changePrice({
  217. id: this.goodsId,
  218. price: Number(this.price) * 100
  219. }).then(res => {
  220. if (res.code == 200) {
  221. this.$modal.msg('修改成功~')
  222. this.reset()
  223. this.getList()
  224. }
  225. }).catch(err => {})
  226. } else {
  227. this.$modal.msg('商品价格不能为空!')
  228. }
  229. this.editPriceClose()
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .container {
  236. .content {
  237. padding-bottom: 88rpx;
  238. .search {
  239. padding: 24rpx 24rpx;
  240. background-color: #fff;
  241. }
  242. .list {
  243. width: 100%;
  244. padding: 12rpx 24rpx;
  245. .thumb-box {
  246. margin-bottom: 12rpx;
  247. border-bottom: 1rpx solid #f4f4f4;
  248. display: flex;
  249. flex-flow: row nowrap;
  250. padding: 12rpx 12rpx;
  251. align-items: center;
  252. background-color: #fff;
  253. border-radius: 12rpx;
  254. }
  255. .select-img {
  256. width: 40rpx;
  257. height: 40rpx;
  258. }
  259. .check-content {
  260. width: 100%;
  261. display: flex;
  262. flex-direction: row;
  263. align-items: center;
  264. padding-left: 12rpx;
  265. position: relative;
  266. .comm-img {
  267. width: 130rpx;
  268. height: 130rpx;
  269. display: flex;
  270. flex-direction: row;
  271. align-items: center;
  272. justify-content: space-around;
  273. image {
  274. width: 100%;
  275. }
  276. }
  277. .comm-main {
  278. box-sizing: border-box;
  279. padding-left: 18rpx;
  280. color: #999;
  281. >view {
  282. padding: 8rpx 0;
  283. width: 330rpx;
  284. }
  285. >view:nth-child(1) {
  286. font-size: 28rpx;
  287. font-weight: bold;
  288. color: #333;
  289. padding: 12rpx 0 8rpx 0;
  290. }
  291. >view:nth-child(2) {
  292. width: 450rpx;
  293. font-size: 26rpx;
  294. }
  295. >view:nth-child(3) {
  296. width: 450rpx;
  297. font-size: 26rpx;
  298. }
  299. >view:nth-child(4) {
  300. width: 450rpx;
  301. font-size: 26rpx;
  302. padding: 0;
  303. line-height: 40rpx;
  304. }
  305. >.c-cx {
  306. font-size: 26rpx;
  307. }
  308. >.c-pri {
  309. font-size: 26rpx;
  310. text {
  311. font-weight: bold;
  312. color: red;
  313. font-size: 30rpx;
  314. }
  315. >view {
  316. display: inline-block;
  317. font-size: 26rpx;
  318. color: #2C6FF3;
  319. text-decoration: underline;
  320. margin-left: 12rpx;
  321. }
  322. }
  323. }
  324. .status {
  325. width: 120rpx;
  326. height: 120rpx;
  327. box-sizing: border-box;
  328. border-radius: 120rpx;
  329. // border: 6rpx solid #2C6FF3;
  330. text-align: center;
  331. display: flex;
  332. flex-flow: column;
  333. justify-content: space-around;
  334. align-items: center;
  335. position: absolute;
  336. right: 12rpx;
  337. top: -12rpx;
  338. .s-name {
  339. font-size: 24rpx;
  340. padding-top: 16rpx;
  341. font-weight: bold;
  342. }
  343. .s-num {
  344. font-size: 28rpx;
  345. padding-bottom: 20rpx;
  346. }
  347. }
  348. .sale {
  349. position: absolute;
  350. right: 12rpx;
  351. bottom: 12rpx;
  352. text-align: center;
  353. color: #999;
  354. >view:nth-child(1) {
  355. font-size: 24rpx;
  356. }
  357. >view:nth-child(2) {
  358. font-size: 32rpx;
  359. color: #2C6FF3;
  360. font-weight: bold;
  361. }
  362. }
  363. }
  364. }
  365. }
  366. .empty {
  367. position: absolute;
  368. left: 50%;
  369. top: 50%;
  370. transform: translate(-50%, -50%);
  371. }
  372. .refresh {
  373. width: 80rpx;
  374. height: 80rpx;
  375. border-radius: 80rpx;
  376. text-align: center;
  377. line-height: 80rpx;
  378. position: fixed;
  379. right: 24rpx;
  380. bottom: 230rpx;
  381. background-color: #999;
  382. color: #fff;
  383. opacity: .8;
  384. }
  385. .btn {
  386. width: 100%;
  387. position: fixed;
  388. bottom: 24rpx;
  389. left: 0;
  390. display: flex;
  391. flex-flow: row nowrap;
  392. justify-content: space-between;
  393. padding: 0 24rpx;
  394. .cu-btn {
  395. background-color: #2C6FF3;
  396. color: #fff;
  397. width: 48%;
  398. }
  399. }
  400. .pop-content {
  401. padding: 24rpx;
  402. }
  403. }
  404. </style>