index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
  3. <view class="edit-price rd-t-40rpx" v-if="goodsInfo.attr_value">
  4. <view class="title">{{goodsInfo.spec_type?'批量修改库存':'修改库存'}}
  5. <view class="close acea-row row-center-wrapper" @tap="closeDrawer">
  6. <text class="iconfont icon-ic_close"></text>
  7. </view>
  8. </view>
  9. <view class="list">
  10. <view class="item acea-row row-between-wrapper" v-if="!goodsInfo.spec_type">
  11. <view>剩余库存</view>
  12. <view class="stock">{{goodsInfo.attr_value.stock}}</view>
  13. </view>
  14. <view class="item acea-row row-between-wrapper pr-20">
  15. <view>修改库存</view>
  16. <view class="acea-row row-middle">
  17. <view class="itemn acea-row row-middle" :class="current == index?'on':''" v-for="(item, index) in navList" :key="index" @click="navTap(index)">
  18. <text class="iconfont" :class="current == index?'icon-ic_Selected':'icon-ic_unselect'"></text>
  19. <text>{{item}}</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="item acea-row row-between-wrapper">
  24. <view>库存</view>
  25. <input type="number" placeholder="请填写库存" placeholder-class="placeholder" v-model="currentStock" @input="stockTap"/>
  26. </view>
  27. </view>
  28. <view v-if="goodsInfo.spec_type" class="bnt acea-row row-center-wrapper" @tap="defineSpec">确定</view>
  29. <view v-else class="bnt acea-row row-center-wrapper" @tap="define">保存</view>
  30. </view>
  31. </base-drawer>
  32. </template>
  33. <script>
  34. import {
  35. postStoreUpdateAttrs
  36. } from "@/api/admin";
  37. export default {
  38. props:{
  39. visible: {
  40. type: Boolean,
  41. default: false,
  42. },
  43. goodsInfo: {
  44. type: Object,
  45. default: () => {}
  46. }
  47. },
  48. data: function() {
  49. return {
  50. navList:['入库','出库'],
  51. current:0,
  52. currentStock:0
  53. };
  54. },
  55. mounted() {
  56. },
  57. methods:{
  58. navTap(index){
  59. this.current = index
  60. },
  61. stockTap(e){
  62. this.currentStock = parseInt(e.detail.value);
  63. },
  64. defineSpec(){
  65. if(this.currentStock<=0){
  66. this.$util.Tips({
  67. title: '请填写库存'
  68. });
  69. return
  70. }
  71. let data = {
  72. currentStock:this.currentStock,
  73. current: this.current
  74. }
  75. this.$emit('successChange',data);
  76. },
  77. define(){
  78. if(this.currentStock<=0){
  79. this.$util.Tips({
  80. title: '请填写库存'
  81. });
  82. return
  83. }
  84. let data = {
  85. attr_value:[]
  86. }
  87. let obj = {
  88. product_id:this.goodsInfo.attr_value.product_id,
  89. unique:this.goodsInfo.attr_value.unique,
  90. stock: this.current? parseInt(this.goodsInfo.attr_value.stock)-this.currentStock : this.currentStock + parseInt(this.goodsInfo.attr_value.stock)
  91. }
  92. data.type = 'stock';
  93. data.attr_value.push(obj)
  94. postStoreUpdateAttrs(this.goodsInfo.id,data).then(res=>{
  95. this.$util.Tips({
  96. title: res.msg
  97. });
  98. this.current = 0;
  99. this.currentStock = 0;
  100. this.$emit('successChange');
  101. }).catch(err=>{
  102. this.$util.Tips({
  103. title: err
  104. });
  105. })
  106. },
  107. closeDrawer() {
  108. this.$emit('closeDrawer');
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .edit-price{
  115. background-color: #fff;
  116. padding-bottom: 60rpx;
  117. .title{
  118. text-align: center;
  119. height: 108rpx;
  120. line-height: 108rpx;
  121. font-size: 32rpx;
  122. font-family: PingFang SC, PingFang SC;
  123. font-weight: 600;
  124. color: #333333;
  125. position: relative;
  126. padding: 0 30rpx;
  127. .close{
  128. width: 36rpx;
  129. height: 36rpx;
  130. line-height: 36rpx;
  131. background: #EEEEEE;
  132. border-radius: 50%;
  133. position: absolute;
  134. right: 30rpx;
  135. top:38rpx;
  136. .iconfont {
  137. font-weight: 300;
  138. font-size: 20rpx;
  139. }
  140. }
  141. }
  142. .list{
  143. padding: 0 10rpx 0 30rpx;
  144. .item{
  145. font-size: 28rpx;
  146. font-family: PingFang SC, PingFang SC;
  147. font-weight: 400;
  148. color: #333333;
  149. height: 72rpx;
  150. margin-bottom: 32rpx;
  151. box-sizing: border-box;
  152. .stock{
  153. color: #999;
  154. padding-right: 20rpx;
  155. }
  156. .itemn{
  157. margin-left: 50rpx;
  158. color: #999999;
  159. .iconfont {
  160. margin-top: 4rpx;
  161. color: #CCCCCC;
  162. margin-right: 14rpx;
  163. }
  164. &.on {
  165. color: #333333;
  166. .iconfont {
  167. color: #2A7EFB;
  168. }
  169. }
  170. }
  171. input {
  172. text-align: right;
  173. font-size: 28rpx;
  174. height: 100%;
  175. padding-right: 20rpx;
  176. }
  177. .placeholder{
  178. font-size: 28rpx;
  179. padding-right: 20rpx;
  180. }
  181. }
  182. }
  183. .bnt{
  184. font-size: 26rpx;
  185. font-family: PingFang SC, PingFang SC;
  186. font-weight: 500;
  187. color: #FFFFFF;
  188. width: 710rpx;
  189. height: 72rpx;
  190. background: #2A7EFB;
  191. border-radius: 50rpx;
  192. margin: 72rpx auto 0 auto;
  193. }
  194. }
  195. </style>