ns-goods-sku.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="ns-record">
  3. <view class="title">
  4. 价格库存
  5. <text class="iconfont iconguanbi1" @click="close"></text>
  6. </view>
  7. <view class="table">
  8. <view class="table-th">
  9. <view class="table-td" style="min-width: 35%;max-width: 35%;">规格名称</view>
  10. <view class="table-td">统一售价</view>
  11. <view class="table-td" v-if="is_unify_price == 0">独立售价</view>
  12. <view class="table-td">库存</view>
  13. </view>
  14. <scroll-view scroll-y="true" class="table-tb">
  15. <view class="table-tr" v-for="(item, index) in sku_list" :key="index">
  16. <view class="table-td" style="min-width: 35%;max-width: 35%;">{{ item.spec_name ? item.spec_name : item.goods_name }}</view>
  17. <view class="table-td">{{ item.discount_price }}</view>
  18. <view class="table-td input-wrap" v-if="is_unify_price == 0">
  19. <input class="input" v-model="item.store_price" type="digit" />
  20. <view class="unit">元</view>
  21. </view>
  22. <view class="table-td input-wrap">
  23. <block v-if="storeInfo.stock_type == 'store'">
  24. <input class="input" v-model="item.stock" type="digit" />
  25. <view class="unit">{{ item.unit }}</view>
  26. </block>
  27. <view v-else>{{ item.stock }}</view>
  28. </view>
  29. </view>
  30. </scroll-view>
  31. <view class="pop-bottom"><button class="primary-btn" @click="save()">确定</button></view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. goods_sku_list: [],
  40. flag: true,
  41. store: null
  42. };
  43. },
  44. props: {
  45. goods_id: {
  46. type: Number,
  47. default: () => {
  48. return 0;
  49. }
  50. },
  51. sku_list: {
  52. type: Array,
  53. default: () => {
  54. return [];
  55. }
  56. },
  57. is_unify_price: {
  58. type: Number,
  59. default: () => {
  60. return 0;
  61. }
  62. }
  63. },
  64. mounted() {},
  65. created() {
  66. this.getGoodsSku();
  67. },
  68. methods: {
  69. getGoodsSku() {
  70. this.goods_sku_list = [];
  71. Object.keys(this.sku_list).forEach(key => {
  72. let data = this.sku_list[key];
  73. let obj = {
  74. sku_id: data.sku_id,
  75. price: data.store_price ? data.store_price : data.discount_price
  76. };
  77. if (this.storeInfo && this.storeInfo.stock_type == 'store') {
  78. obj.stock = data.stock;
  79. }
  80. this.goods_sku_list.push(obj);
  81. });
  82. },
  83. save() {
  84. this.getGoodsSku();
  85. if (!this.flag) return false;
  86. this.flag = false;
  87. uni.showLoading({
  88. title: '请求处理中'
  89. });
  90. this.$api.sendRequest({
  91. url: '/cashier/storeapi/goods/editgoods',
  92. data: {
  93. goods_sku_list: JSON.stringify(this.goods_sku_list)
  94. },
  95. success: res => {
  96. uni.hideLoading();
  97. this.$util.showToast({
  98. title: res.message
  99. });
  100. if (res.code >= 0) {
  101. this.$root.$refs.goodsListTable.load();
  102. this.close();
  103. } else {
  104. this.flag = true;
  105. }
  106. }
  107. });
  108. },
  109. // 弹窗关闭
  110. close() {
  111. this.$emit('close');
  112. }
  113. }
  114. };
  115. </script>
  116. <style lang="scss" scoped>
  117. .ns-record {
  118. width: 100%;
  119. height: 100%;
  120. background: #ffffff;
  121. border-radius: 0.04rem;
  122. min-height: 2rem;
  123. padding-bottom: 0.6rem;
  124. .title {
  125. width: 100%;
  126. height: 0.5rem;
  127. border-bottom: 0.01rem solid #e6e6e6;
  128. font-size: 0.16rem;
  129. line-height: 0.5rem;
  130. text-align: center;
  131. position: relative;
  132. font-weight: bold;
  133. .iconguanbi1 {
  134. font-size: 0.2rem;
  135. position: absolute;
  136. top: 50%;
  137. right: 0.15rem;
  138. transform: translateY(-50%);
  139. font-weight: 500;
  140. }
  141. }
  142. .selectbox {
  143. width: 100%;
  144. display: flex;
  145. flex-wrap: wrap;
  146. padding: 0.15rem;
  147. box-sizing: border-box;
  148. .item-select1 {
  149. display: flex;
  150. align-items: center;
  151. margin-bottom: 0.2rem;
  152. margin-right: 0.4rem;
  153. .slect1-left {
  154. min-width: 1rem;
  155. text-align: right;
  156. }
  157. .slect1-right {
  158. width: 2.1rem;
  159. height: 0.3rem;
  160. display: flex;
  161. align-items: center;
  162. padding-right: 0.15rem;
  163. box-sizing: border-box;
  164. margin-left: 0.1rem;
  165. border: 0.01rem solid #e6e6e6;
  166. padding-left: 0.15rem;
  167. .uni-input {
  168. width: 1.7rem;
  169. height: 100%;
  170. display: flex;
  171. align-items: center;
  172. justify-content: space-between;
  173. text-overflow: ellipsis;
  174. overflow: hidden;
  175. white-space: nowrap;
  176. .iconxiala {
  177. font-size: 0.18rem;
  178. }
  179. }
  180. }
  181. .slect1-right2 {
  182. width: 80%;
  183. display: flex;
  184. align-items: center;
  185. margin-left: 0.1rem;
  186. text {
  187. margin: 0 0.15rem;
  188. }
  189. }
  190. }
  191. }
  192. .table {
  193. width: 100%;
  194. height: 4rem;
  195. padding: 0.15rem;
  196. box-sizing: border-box;
  197. .table-th {
  198. width: 100%;
  199. height: 0.5rem;
  200. display: flex;
  201. align-items: center;
  202. justify-content: space-between;
  203. background: #f7f8fa;
  204. box-sizing: border-box;
  205. }
  206. .table-td {
  207. display: flex;
  208. flex: 1;
  209. padding: 0 0.15rem;
  210. }
  211. .table-tb {
  212. width: 100%;
  213. height: calc(100% - 0.5rem);
  214. .table-tr {
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. width: 100%;
  219. height: 0.5rem;
  220. box-sizing: border-box;
  221. border-bottom: 0.01rem solid #e6e6e6;
  222. }
  223. }
  224. }
  225. }
  226. /deep/ .uni-date-single {
  227. height: 0.3rem;
  228. }
  229. .input-wrap {
  230. height: 100%;
  231. line-height: 0.5rem;
  232. text-overflow: ellipsis;
  233. overflow: hidden;
  234. white-space: nowrap;
  235. font-size: 0.14rem;
  236. display: flex;
  237. align-items: center;
  238. .input {
  239. width: 0.7rem;
  240. height: 0.35rem;
  241. border: 0.01rem solid #e6e6e6;
  242. padding: 0 0.1rem;
  243. border-top-left-radius: 0.03rem;
  244. border-bottom-left-radius: 0.03rem;
  245. }
  246. .unit {
  247. background-color: #eee;
  248. height: 0.35rem;
  249. width: 0.35rem;
  250. text-align: center;
  251. line-height: 0.35rem;
  252. border: 0.01rem solid #e6e6e6;
  253. border-left: 0;
  254. border-top-right-radius: 0.03rem;
  255. border-bottom-right-radius: 0.03rem;
  256. }
  257. }
  258. .save {
  259. height: 0.3rem;
  260. line-height: 0.3rem;
  261. }
  262. .pagination {
  263. width: 100%;
  264. margin-top: 0.2rem;
  265. }
  266. .pop-bottom {
  267. padding: 0.1rem;
  268. height: 0.65rem;
  269. border-top: 0.01rem solid #eee;
  270. button {
  271. width: 1rem;
  272. }
  273. }
  274. </style>