index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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">{{storeNum?'修改价格/库存':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">
  11. <view>售价</view>
  12. <input type="number" :placeholder="'请填写售价'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.price" />
  13. </view>
  14. <view class="item acea-row row-between-wrapper">
  15. <view>成本价</view>
  16. <input type="number" :placeholder="'请填写成本价'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.cost" />
  17. </view>
  18. <view class="item acea-row row-between-wrapper">
  19. <view>原价</view>
  20. <input type="number" :placeholder="'请填写原价'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.ot_price" />
  21. </view>
  22. <view v-if="storeNum" class="item acea-row row-between-wrapper">
  23. <view>库存</view>
  24. <input type="number" :placeholder="'请填写库存'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.stock" />
  25. </view>
  26. </view>
  27. <view v-if="goodsInfo.spec_type" class="bnt acea-row row-center-wrapper" @tap="defineSpec">确定</view>
  28. <view v-else class="bnt acea-row row-center-wrapper" @tap="define">保存</view>
  29. </view>
  30. </base-drawer>
  31. </template>
  32. <script>
  33. import {
  34. postUpdateAttrs,
  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. storeNum: {
  48. type: Number,
  49. default: 0
  50. }
  51. },
  52. data: function() {
  53. return {
  54. tips:''
  55. };
  56. },
  57. mounted() {
  58. this.tips = this.goodsInfo.spec_type?'(可为空)':''
  59. },
  60. methods:{
  61. defineSpec(){
  62. let info = this.goodsInfo.attr_value;
  63. let obj = info.cost || info.price || info.ot_price;
  64. if((this.storeNum && (obj || info.stock)) || (!this.storeNum && obj)){
  65. this.$emit('successChange',info);
  66. }else{
  67. this.$util.Tips({
  68. title: '修改类容至少填写一项'
  69. });
  70. }
  71. },
  72. define(){
  73. let data = {
  74. attr_value:[]
  75. }
  76. if(!this.storeNum){
  77. delete this.goodsInfo.attr_value.stock;
  78. data.type = 'price';
  79. }
  80. data.attr_value.push(this.goodsInfo.attr_value);
  81. let funApi = '';
  82. if(this.storeNum){
  83. funApi = postUpdateAttrs;
  84. }else{
  85. funApi = postStoreUpdateAttrs;
  86. }
  87. funApi(this.goodsInfo.id,data).then(res=>{
  88. this.$util.Tips({
  89. title: res.msg
  90. });
  91. this.$emit('successChange');
  92. }).catch(err=>{
  93. this.$util.Tips({
  94. title: err
  95. });
  96. })
  97. },
  98. closeDrawer() {
  99. this.$emit('closeDrawer');
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .edit-price{
  106. background-color: #fff;
  107. padding-bottom: 60rpx;
  108. .title{
  109. text-align: center;
  110. height: 108rpx;
  111. line-height: 108rpx;
  112. font-size: 32rpx;
  113. font-family: PingFang SC, PingFang SC;
  114. font-weight: 600;
  115. color: #333333;
  116. position: relative;
  117. padding: 0 30rpx;
  118. .close{
  119. width: 36rpx;
  120. height: 36rpx;
  121. line-height: 36rpx;
  122. background: #EEEEEE;
  123. border-radius: 50%;
  124. position: absolute;
  125. right: 30rpx;
  126. top:38rpx;
  127. .iconfont {
  128. font-weight: 300;
  129. font-size: 20rpx;
  130. }
  131. }
  132. }
  133. .list{
  134. padding: 0 10rpx 0 30rpx;
  135. .item{
  136. font-size: 28rpx;
  137. font-family: PingFang SC, PingFang SC;
  138. font-weight: 400;
  139. color: #333333;
  140. height: 72rpx;
  141. margin-bottom: 32rpx;
  142. box-sizing: border-box;
  143. input {
  144. text-align: right;
  145. font-size: 28rpx;
  146. height: 100%;
  147. padding-right: 20rpx;
  148. }
  149. .placeholder{
  150. font-size: 28rpx;
  151. padding-right: 20rpx;
  152. }
  153. }
  154. }
  155. .bnt{
  156. font-size: 26rpx;
  157. font-family: PingFang SC, PingFang SC;
  158. font-weight: 500;
  159. color: #FFFFFF;
  160. width: 710rpx;
  161. height: 72rpx;
  162. background: #2A7EFB;
  163. border-radius: 50rpx;
  164. margin: 72rpx auto 0 auto;
  165. }
  166. }
  167. </style>