index.vue 4.5 KB

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