creatOrder.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view class="content flex flex_column">
  3. <u-navbar back-text="待补货产品" :border-bottom="false" :background="{backgroundColor: $config('primaryColor')}" back-icon-color="#fff" :back-text-style="{ color: '#fff' }">
  4. <view slot='right' style="padding: 0 30upx;color: #ffffff;" v-if="chooseList.length" @click="toChooseProduct">
  5. <u-icon name="chuangjiandingdan" custom-prefix="iscm-icon"></u-icon>
  6. <text style="margin-left: 6rpx;">选择产品</text>
  7. </view>
  8. </u-navbar>
  9. <view class="searchBar">
  10. <view class="p-title flex align_center">
  11. <text></text>
  12. <view class="shelfName">
  13. <view>{{nowData.shelfName}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 已选配件 购物车 -->
  18. <div class="cpb_cart-box">
  19. <div class="cpb_cart-list">
  20. <view
  21. v-for="(item, index) in chooseList"
  22. :key="'cpb_'+item.id"
  23. >
  24. <view class="nav-right-item flex align_center">
  25. <view class="uni-col-1" @click="delDetail(item,index)">
  26. <u-icon name="close-circle" color="#ff5500" size="35"></u-icon>
  27. </view>
  28. <view class="uni-col-9 flex">
  29. <view class="item-imgs">
  30. <u-image :src="item.productImageUrl?item.productImageUrl:`../../static/${$config('themePath')}/def_img@2x.png`" width="120" height="120" border-radius="10"></u-image>
  31. </view>
  32. <view class="item-info">
  33. <view class="item-name">
  34. <text>{{item.shelfPlaceCode}}</text>
  35. {{item.productCode}}
  36. </view>
  37. <view class="item-name">
  38. {{item.productName}}
  39. </view>
  40. <view class="item-detail">
  41. <view class="item-detail-info align_center flex justify_between">
  42. <view></view>
  43. <view class="flex justify_end">
  44. <view class="item-detail-text">
  45. 最大库容:<text class="pnums">{{item.maxQty||0}}</text>
  46. 货架库存:<text class="pnums">{{item.qty||0}}</text>
  47. 门店库存:<text class="pnums">{{item.qplsStockQty||0}}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="nav-right-item">
  56. <view class="item-detail">
  57. <view class="item-detail-info">
  58. <view class="flex justify_between">
  59. <view class="item-detail-text flex">
  60. <view v-if="item.replenishBillQty">补货在途:<text class="pnums1">{{item.replenishBillQty||0}}</text></view>
  61. <view v-if="item.recallBillQty">调回在途:<text class="pnums1">{{item.recallBillQty||0}}</text></view>
  62. </view>
  63. <view class="item-detail-text">
  64. 补货数量:
  65. <u-number-box
  66. v-model="item.replenishQty"
  67. :index="'cart_'+item.id"
  68. :min="1"
  69. @change="numsChange(item)"
  70. :max="999999"></u-number-box>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view v-if="chooseList.length==0">
  78. <view class="nodata">
  79. <view>
  80. <u-image :src="`../../static/${$config('themePath')}/def_no_data@3x.png`" width="180" height="180" border-radius="10"></u-image>
  81. </view>
  82. <view class="flex">
  83. 暂无产品,请点击
  84. <view>
  85. <text @click="toChooseProduct">选择产品</text>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </div>
  91. </div>
  92. <!-- 底部栏 -->
  93. <view class="footer-bar flex align_center justify_between">
  94. <view class="f-left flex align_center">
  95. <view>
  96. 已选<text>{{totalCategory}}</text>款/<text>{{totalQty}}</text>件
  97. </view>
  98. <view v-if="chooseList.length" style="padding-left: 20upx;">
  99. <text @click="clearDetail">清空列表</text>
  100. </view>
  101. </view>
  102. <view class="f-btns">
  103. <u-button size="medium" @click="submitOrder" :loading="loading" :custom-style="customBtnStyle" shape="circle" type="primary" hover-class="none" >创建补货单</u-button>
  104. </view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import { queryProductListForReplenish } from '@/api/shelf'
  110. import { saveMainAndDetail } from '@/api/shelfReplenish'
  111. import { clzConfirm } from '@/libs/tools'
  112. export default {
  113. data() {
  114. return {
  115. nowData:null,
  116. detail:null,
  117. customBtnStyle: { // 自定义按钮样式
  118. borderColor: this.$config('primaryColor'),
  119. backgroundColor: this.$config('primaryColor'),
  120. color: '#fff'
  121. },
  122. chooseList: [],
  123. tempData: null,
  124. loading: false
  125. }
  126. },
  127. onNavigationBarButtonTap(e) {
  128. if(e.index == 0){
  129. this.toChooseProduct()
  130. }
  131. },
  132. onLoad(opts) {
  133. const _this = this
  134. this.nowData = JSON.parse(decodeURIComponent(opts.data));
  135. // 首次选中产品
  136. this.chooseList = this.$store.state.vuex_tempData || []
  137. uni.$on("chooseDbhProduct",function(data){
  138. _this.chooseList = _this.chooseList.concat(data).sort(function(a,b){
  139. return (a.shelfPlaceCode+'').localeCompare(b.shelfPlaceCode+'');
  140. });
  141. })
  142. },
  143. computed: {
  144. totalCategory () {
  145. return this.chooseList.length
  146. },
  147. totalQty () {
  148. let ret = 0
  149. this.chooseList.map(item => {
  150. ret = ret + item.replenishQty
  151. })
  152. return ret
  153. },
  154. chooseKey(){
  155. let ret = []
  156. this.chooseList.map(item => {
  157. ret.push(item.id)
  158. })
  159. return ret
  160. }
  161. },
  162. methods: {
  163. toChooseProduct(){
  164. this.nowData.chooseKey = this.chooseKey
  165. uni.navigateTo({
  166. url: "/pages/soldOut/chooseProduct?data="+encodeURIComponent(JSON.stringify(this.nowData))
  167. })
  168. },
  169. // 创建补货单
  170. creatOrder(data){
  171. uni.showLoading({
  172. title:"正在保存.."
  173. })
  174. stockCheckSave({
  175. shelfSn: this.nowData.shelfSn,
  176. totalCategory: this.nowData.totalCategory,
  177. totalStockQty: this.nowData.totalStockQty,
  178. totalFreezeQty: this.nowData.totalFreezeQty
  179. }).then(res => {
  180. if(res.status == 200){
  181. this.detail = res.data || null
  182. this.stockCheckSn = res.data.stockCheckSn
  183. }else{
  184. uni.hideLoading()
  185. }
  186. })
  187. },
  188. numsChange(item){
  189. this.chooseList.splice()
  190. },
  191. // 删除购物车产品
  192. delDetail(item,i){
  193. console.log(item.id,i)
  194. const index = this.chooseList.findIndex(k => k.id == item.id)
  195. this.chooseList.splice(index,1)
  196. // 全部清空
  197. if(this.chooseList.length==0){
  198. this.clearChoose()
  199. }
  200. },
  201. // 空列表
  202. clearDetail(){
  203. const _this = this
  204. clzConfirm({
  205. title: '提示',
  206. content: '确认要清空列表吗?',
  207. success (ret) {
  208. if (ret.confirm || ret.index == 0) {
  209. _this.clearChoose()
  210. }
  211. }
  212. })
  213. },
  214. // 清空已选数据
  215. clearChoose(){
  216. this.chooseList = []
  217. },
  218. // 提交
  219. submitOrder(){
  220. if(this.totalCategory){
  221. this.handleSave()
  222. }else{
  223. uni.showToast({
  224. icon: 'none',
  225. title: '请先选择产品'
  226. })
  227. }
  228. },
  229. handleSave () {
  230. const data = this.chooseList
  231. const dataList = []
  232. data.map(item => {
  233. dataList.push({
  234. shelfPlaceSn: item.shelfPlaceSn,
  235. shelfPlaceCode: item.shelfPlaceCode,
  236. productSn: item.productSn,
  237. productCode: item.productCode,
  238. qty: item.replenishQty
  239. })
  240. })
  241. this.showLoading("正在提交...")
  242. this.loading = true
  243. // 开始提交
  244. saveMainAndDetail({
  245. shelfSn: this.nowData.shelfSn,
  246. dealerSn: this.nowData.dealerSn,
  247. detailList: dataList
  248. }).then(res => {
  249. uni.hideLoading()
  250. if (res.status == 200) {
  251. this.toashMsg(res.message)
  252. uni.redirectTo({ url: "/pages/replenishmentManage/outWarehousing?sn="+res.data.replenishBillSn })
  253. }
  254. this.loading = false
  255. })
  256. },
  257. }
  258. }
  259. </script>
  260. <style lang="less">
  261. .content{
  262. height: 100vh;
  263. width: 100%;
  264. background: #fff;
  265. .footer-bar{
  266. background-color: #f8f8f8;
  267. padding: 20upx;
  268. .active{
  269. background-color: #0485F6;
  270. }
  271. .f-left{
  272. color: #666;
  273. flex-grow: 1;
  274. > view{
  275. text{
  276. color: red;
  277. margin: 0 5rpx;
  278. }
  279. }
  280. }
  281. .f-btns{
  282. button{
  283. width: 200upx;
  284. }
  285. }
  286. }
  287. .nodata{
  288. padding: 150rpx 50rpx;
  289. text-align: center;
  290. display: flex;
  291. flex-direction: column;
  292. justify-content: center;
  293. align-items: center;
  294. color: #999;
  295. > view{
  296. position: relative;
  297. padding: 10upx 0;
  298. text{
  299. color: #00aaff;
  300. margin-left: 10rpx;
  301. }
  302. }
  303. }
  304. .searchBar{
  305. padding: 0.3rem 0.8rem;
  306. .p-title{
  307. padding: 0 15rpx;
  308. display: flex;
  309. align-items: center;
  310. color: #222;
  311. font-size: 30rpx;
  312. > text{
  313. display: block;
  314. height: 30rpx;
  315. width: 6rpx;
  316. background: #0485F6;
  317. margin-right: 10rpx;
  318. border-radius: 10rpx;
  319. }
  320. .shelfName{
  321. flex-grow: 1;
  322. font-weight: bold;
  323. width: 80%;
  324. > view{
  325. overflow: hidden;
  326. white-space: nowrap;
  327. text-overflow: ellipsis;
  328. }
  329. }
  330. .btns{
  331. width:100rpx;
  332. text-align: right;
  333. font-size: 28rpx;
  334. color: #0485F6;
  335. }
  336. }
  337. }
  338. // 购物车
  339. .cpb_cart-box{
  340. flex-grow: 1;
  341. width: 100%;
  342. overflow: auto;
  343. .cpb_cart-list{
  344. padding: 20rpx 0;
  345. overflow: auto;
  346. flex-grow: 1;
  347. > view{
  348. margin-bottom: 20rpx;
  349. }
  350. .nav-right-item{
  351. padding: 0 30upx;
  352. &:last-child{
  353. border-bottom:2rpx solid #eee;
  354. }
  355. }
  356. .item-name{
  357. font-size: 28rpx;
  358. text{
  359. background: rgba(3, 54, 146, 0.15);
  360. color: #1c588a;
  361. border-radius: 1em;
  362. font-size: 26rpx;
  363. padding: 0 0.5em;
  364. margin-right: 10upx;
  365. }
  366. margin-top: 10upx;
  367. }
  368. .item-info{
  369. padding-left: 0.8em;
  370. flex-grow: 1;
  371. }
  372. .item-detail{
  373. .item-detail-info{
  374. padding: 10upx 0 4upx;
  375. font-size: 24upx;
  376. .pnums{
  377. margin-right: 10rpx;
  378. color: #333;
  379. }
  380. .pnums1{
  381. margin-right: 10rpx;
  382. color: red;
  383. }
  384. > view{
  385. padding-bottom: 10rpx;
  386. align-items: center;
  387. .item-detail-text{
  388. color: #999;
  389. margin-left: 20upx;
  390. }
  391. }
  392. }
  393. }
  394. }
  395. }
  396. }
  397. </style>