sendStock.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="app-content">
  3. <view class="billing_box_bg">
  4. <view class="input-wrap">
  5. <text style="margin-right:15upx;font-size:38upx;">库存:{{stock}}扎</text>
  6. <text style="margin-right:20upx;font-size:38upx;">批发价:¥{{ price }}</text>
  7. <button class="admin-button-com middle blue" @click="setSon()">新增子花材</button>
  8. </view>
  9. <view class="scroll-middle_bx">
  10. <block>
  11. <view class="item_list_bx" style="width: 100%">
  12. <view v-for="(sonItem,xjIndex) in sonItemList" :key="xjIndex">
  13. <view>
  14. <view class="item-cmd_bx">
  15. <view class="img_bx" style="background:#eeeeee">
  16. <image :src="sonItem.cover"></image>
  17. </view>
  18. <view class="cmd-info_bx">
  19. <view class="tit">{{ sonItem.name || "" }}</view>
  20. <view class="kc">剩 {{sonItem.stock ? parseFloat(sonItem.stock) : 0}}</view>
  21. <view class="num-open_bx">
  22. <view class="open-bx">
  23. <button class="admin-button-com mini-btn blue del-button" @click="delItem(sonItem)">删除</button>
  24. <input class="hy-ok-price" placeholder-style="color:#CCCCCC" v-model="sonItem.sendHyPrice" type="number" placeholder="会员价" />
  25. <input class="add-ok-stock" placeholder-style="color:#CCCCCC" @input="stockToggle(sonItem)" v-model="sonItem.sendSonStock" type="digit" placeholder="库存数量" />
  26. <input class="ls-ok-price" placeholder-style="color:#CCCCCC" v-model="sonItem.sendLsPrice" type="digit" placeholder="零售价" />
  27. <input class="pf-ok-price" placeholder-style="color:#CCCCCC" @input="linkChange(sonItem)" v-model="sonItem.sendPfPrice" type="digit" placeholder="批发价" />
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </block>
  36. </view>
  37. <div class="app-footer footer-button">
  38. <button class="admin-button-com big default" @click="goBack()"
  39. style="margin-left:58upx;padding:30upx 55upx 30upx 55upx;">返回</button>
  40. <button class="admin-button-com big blue" @click="toSend()"
  41. style="margin-left:58upx;padding:30upx 65upx; 30upx 65upx;" >分配</button>
  42. </div>
  43. <view v-if="remain>=0" style="width:200upx;position:fixed;bottom:40upx;left:15upx;z-index:99999;font-size:32upx;">
  44. 还剩{{ remain }}
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  51. import { mapGetters } from "vuex";
  52. import { getSonList,delMsItem,sendStockFn } from "@/api/item"
  53. export default {
  54. name: "sendStock",
  55. components: {
  56. AppWrapperEmpty,
  57. },
  58. mixins: [],
  59. data() {
  60. return {
  61. sonItemList:[],
  62. stock:0,
  63. price:0,
  64. remain:0
  65. };
  66. },
  67. onShow(){
  68. this.init()
  69. },
  70. onLoad(){
  71. this.price = this.option.price ? parseFloat(this.option.price) : 0
  72. this.stock = this.option.stock ? parseFloat(this.option.stock) : 0
  73. this.remain = this.stock
  74. },
  75. methods: {
  76. stockToggle(item){
  77. let totalNum = 0
  78. if (!this.$util.isEmpty(this.sonItemList)){
  79. this.sonItemList.forEach((item,idx,arr) => {
  80. if(Number(item.sendSonStock)>0){
  81. totalNum = totalNum + Number(item.sendSonStock)
  82. }
  83. })
  84. }
  85. let remain = Number(this.stock) - Number(totalNum)
  86. remain = parseFloat(remain.toFixed(2))
  87. this.remain = remain
  88. },
  89. linkChange(item){
  90. let skMore = item.skMore ? parseFloat(item.skMore) : 0
  91. let hjAddPrice = item.hjAddPrice ? parseFloat(item.hjAddPrice) : 0
  92. let addPrice = item.addPrice ? parseFloat(item.addPrice) : 0
  93. if(Number(item.sendPfPrice)>0){
  94. let lsDiff = Number(skMore) - Number(addPrice)
  95. let lsPrice = Number(item.sendPfPrice) + Number(lsDiff)
  96. lsPrice = parseFloat(lsPrice.toFixed(2))
  97. item.sendLsPrice = lsPrice
  98. let hyDiff = Number(addPrice) - Number(hjAddPrice)
  99. let hyPrice = Number(item.sendPfPrice) - Number(hyDiff)
  100. hyPrice = parseFloat(hyPrice.toFixed(2))
  101. item.sendHyPrice = hyPrice
  102. }else{
  103. item.sendLsPrice = ''
  104. item.sendHyPrice = ''
  105. }
  106. },
  107. delItem(item){
  108. let that = this
  109. let motherId = this.option.id ? this.option.id : 0
  110. this.$util.confirmModal({content:'确认删除?'},() => {
  111. delMsItem({motherId:motherId,id:item.id}).then(res=>{
  112. if(res.code == 1){
  113. that.init()
  114. }
  115. })
  116. })
  117. },
  118. setSon(){
  119. let productId = this.option.id ? this.option.id : 0
  120. this.$util.pageTo({url:'/admin/changePrice/setSon?id='+productId})
  121. },
  122. goBack(){
  123. uni.navigateBack({});
  124. },
  125. toSend(){
  126. let that = this
  127. if (this.$util.isEmpty(this.sonItemList)){
  128. this.$msg('没有花材')
  129. return false
  130. }
  131. let hasErr = false
  132. let errText = ''
  133. let productList = []
  134. for (const item of this.sonItemList) {
  135. if(Number(item.sendSonStock)>0){
  136. if(Number(item.sendHyPrice)<=0){
  137. hasErr = true
  138. errText = '请填写 '+item.name+' 会员价'
  139. break
  140. }
  141. if(Number(item.sendLsPrice)<=0){
  142. hasErr = true
  143. errText = '请填写 '+item.name+' 零售价'
  144. break
  145. }
  146. if(Number(item.sendPfPrice)<=0){
  147. hasErr = true
  148. errText = '请填写 '+item.name+' 批发价'
  149. break
  150. }
  151. let groupItem = {id:item.id,stock:item.sendSonStock,lsPrice:item.sendLsPrice,pfPrice:item.sendPfPrice,hyPrice:item.sendHyPrice}
  152. productList.push(groupItem)
  153. }else{
  154. if(Number(item.sendPfPrice)>0){
  155. hasErr = true
  156. errText = '请填写 '+item.name+' 数量'
  157. break
  158. }
  159. }
  160. }
  161. if(hasErr == true){
  162. that.$msg(errText)
  163. return false
  164. }
  165. if (this.$util.isEmpty(productList)){
  166. this.$msg('请填写数量和价格')
  167. return false
  168. }
  169. console.log(productList)
  170. console.log('---------')
  171. let jsonProduct = JSON.stringify(productList)
  172. let params = {product:jsonProduct}
  173. this.$util.confirmModal({content:'确认分配?'},() => {
  174. sendStockFn(params).then(res=>{
  175. if(res.code == 1){
  176. that.$msg('分配成功')
  177. setTimeout(function(){
  178. //that.goBack()
  179. },1200)
  180. }
  181. })
  182. })
  183. },
  184. init(){
  185. let productId = this.option.id ? this.option.id : 0
  186. getSonList({motherId:productId}).then(res => {
  187. this.sonItemList = res.data.list
  188. })
  189. }
  190. }
  191. };
  192. </script>
  193. <style lang="scss" scoped>
  194. .billing_box_bg {
  195. height: 100%;
  196. display: flex;
  197. background: white;
  198. flex-direction: column;
  199. .input-wrap {
  200. font-size:30upx;
  201. display: flex;
  202. padding: 22upx 20upx 22upx 30upx;
  203. .search-bar {
  204. flex: 1;
  205. }
  206. .city-select {
  207. display: flex;
  208. flex-shrink: 0;
  209. align-items: center;
  210. margin-right: 15upx;
  211. margin-left: 45upx;
  212. background-color: #ffff;
  213. .iconfont {
  214. margin-left: 20upx;
  215. font-size: 30upx;
  216. }
  217. }
  218. }
  219. .scroll-middle_bx {
  220. margin-bottom:110upx;
  221. }
  222. .tab-view {
  223. height: 100%;
  224. width: 170upx;
  225. flex-shrink: 0;
  226. background-color: #f0f2f6;
  227. .tab-bar-item {
  228. position: relative;
  229. width: 170upx;
  230. height: 90upx;
  231. box-sizing: border-box;
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. font-size: 26upx;
  236. color: #444;
  237. font-weight: 400;
  238. .tag {
  239. display: flex;
  240. padding: 0 20upx;
  241. align-items: center;
  242. position: absolute;
  243. right: 0;
  244. top: 0;
  245. height: 32upx;
  246. background: #ff2842;
  247. border-radius: 16upx;
  248. color: #fff;
  249. font-size: 20upx;
  250. }
  251. &:last-child{
  252. margin-bottom: 110upx;
  253. }
  254. }
  255. .active {
  256. position: relative;
  257. color: $mainColor;
  258. font-size: 26upx;
  259. background: #fff;
  260. }
  261. .active::before {
  262. content: "";
  263. position: absolute;
  264. border-left: 8upx solid $mainColor;
  265. height: 100%;
  266. left: 0;
  267. }
  268. }
  269. .right-box {
  270. height: 100%;
  271. flex: 1;
  272. box-sizing: border-box;
  273. }
  274. .item_list_bx {
  275. padding: 10upx 40upx;
  276. }
  277. .item_list_title {
  278. margin-bottom: 20upx;
  279. font-size: 24upx;
  280. font-weight: 600;
  281. color: #666666;
  282. }
  283. .select-cmd_bx {
  284. & .kc {
  285. color: #999999;
  286. font-size: 28upx;
  287. font-weight: 400;
  288. margin-bottom: 60upx;
  289. text-align: center;
  290. margin-top: 10upx;
  291. }
  292. & .num_bx {
  293. display: flex;
  294. align-items: center;
  295. margin-bottom: 80upx;
  296. & > input {
  297. width: 212upx;
  298. height: 80upx;
  299. border: 1upx solid #dddddd;
  300. border-radius: 4upx;
  301. text-align: center;
  302. margin-right: 24upx;
  303. }
  304. }
  305. }
  306. }
  307. .item-cmd_bx {
  308. position: relative;
  309. margin-bottom: 20upx;
  310. height:190upx;
  311. .img_bx {
  312. height: 160upx;
  313. width: 160upx;
  314. position: absolute;
  315. left: 0upx;
  316. top: 0upx;
  317. image{
  318. width: 100%;
  319. height: 100%;
  320. }
  321. }
  322. .cmd-info_bx {
  323. position: relative;
  324. padding-left: 177upx;
  325. &.active{
  326. &:before{
  327. content: ' ';
  328. height: 22upx;
  329. width: 22upx;
  330. border-width: 2upx 2upx 0 0;
  331. border-color: #b2b2b2;
  332. border-style: solid;
  333. -webkit-transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  334. transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  335. position: absolute;
  336. top: 50%;
  337. margin-top: -12upx;
  338. right: 30upx;
  339. }
  340. }
  341. & .tit {
  342. font-size: 30upx;
  343. font-weight: 700;
  344. color: #333333;
  345. }
  346. & .kc {
  347. color: #999999;
  348. font-size: 26upx;
  349. padding: 13upx 0 13upx;
  350. }
  351. & .num-open_bx {
  352. display: flex;
  353. align-items: center;
  354. & .price {
  355. font-size: 28upx;
  356. color: #999999;
  357. flex: 1;
  358. }
  359. & .open-bx {
  360. color: #333333;
  361. position: relative;
  362. .del-button{
  363. position: absolute;
  364. left:20upx;
  365. top:15upx;
  366. width:100upx;
  367. }
  368. .hy-ok-price{
  369. width: 160upx;
  370. height: 60upx;
  371. line-height: 60upx;
  372. text-align: center;
  373. background: #ffffff;
  374. border: 1upx solid #b4b4b4;
  375. border-radius: 4upx;
  376. font-size: 30upx;
  377. color:#777777;
  378. position: absolute;
  379. left:180upx;
  380. top:15upx;
  381. }
  382. .add-ok-stock{
  383. width: 160upx;
  384. height: 60upx;
  385. line-height: 60upx;
  386. text-align: center;
  387. background: #ffffff;
  388. border: 1upx solid #3385FF;
  389. border-radius: 4upx;
  390. font-size: 30upx;
  391. color:#3385FF;
  392. position: absolute;
  393. left:180upx;
  394. top:-58upx;
  395. }
  396. .ls-ok-price{
  397. width: 160upx;
  398. height: 60upx;
  399. line-height: 60upx;
  400. text-align: center;
  401. background: #ffffff;
  402. border: 1upx solid #b4b4b4;
  403. border-radius: 4upx;
  404. font-size: 30upx;
  405. color:#777777;
  406. position: absolute;
  407. left:350upx;
  408. top:15upx;
  409. }
  410. .pf-ok-price{
  411. width: 160upx;
  412. height: 60upx;
  413. line-height: 60upx;
  414. text-align: center;
  415. background: #ffffff;
  416. border: 1upx solid #b4b4b4;
  417. border-radius: 4upx;
  418. font-size: 30upx;
  419. color:#777777;
  420. position: absolute;
  421. left:350upx;
  422. top:-58upx;
  423. }
  424. }
  425. }
  426. }
  427. }
  428. .footer-button{
  429. height:120upx;
  430. }
  431. </style>