creatOrder.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view class="content flex flex_column">
  3. <u-navbar back-text="待补货产品" :border-bottom="false">
  4. <view slot='right' style="padding: 0 30upx;" 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="#999" 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" :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. }
  125. },
  126. onNavigationBarButtonTap(e) {
  127. if(e.index == 0){
  128. this.toChooseProduct()
  129. }
  130. },
  131. onLoad(opts) {
  132. const _this = this
  133. this.nowData = JSON.parse(decodeURIComponent(opts.data));
  134. uni.$on("chooseDbhProduct",function(data){
  135. _this.chooseList = _this.chooseList.concat(data).sort(function(a,b){
  136. return (a.shelfPlaceCode+'').localeCompare(b.shelfPlaceCode+'');
  137. });
  138. })
  139. },
  140. computed: {
  141. totalCategory () {
  142. return this.chooseList.length
  143. },
  144. totalQty () {
  145. let ret = 0
  146. this.chooseList.map(item => {
  147. ret = ret + item.replenishQty
  148. })
  149. return ret
  150. },
  151. chooseKey(){
  152. let ret = []
  153. this.chooseList.map(item => {
  154. ret.push(item.id)
  155. })
  156. return ret
  157. }
  158. },
  159. methods: {
  160. toChooseProduct(){
  161. this.nowData.chooseKey = this.chooseKey
  162. uni.navigateTo({
  163. url: "/pages/soldOut/chooseProduct?data="+encodeURIComponent(JSON.stringify(this.nowData))
  164. })
  165. },
  166. // 创建补货单
  167. creatOrder(data){
  168. uni.showLoading({
  169. title:"正在保存.."
  170. })
  171. stockCheckSave({
  172. shelfSn: this.nowData.shelfSn,
  173. totalCategory: this.nowData.totalCategory,
  174. totalStockQty: this.nowData.totalStockQty,
  175. totalFreezeQty: this.nowData.totalFreezeQty
  176. }).then(res => {
  177. if(res.status == 200){
  178. this.detail = res.data || null
  179. this.stockCheckSn = res.data.stockCheckSn
  180. }else{
  181. uni.hideLoading()
  182. }
  183. })
  184. },
  185. numsChange(item){
  186. this.chooseList.splice()
  187. },
  188. // 删除购物车产品
  189. delDetail(item,i){
  190. console.log(item.id,i)
  191. const index = this.chooseList.findIndex(k => k.id == item.id)
  192. this.chooseList.splice(index,1)
  193. // 全部清空
  194. if(this.chooseList.length==0){
  195. this.clearChoose()
  196. }
  197. },
  198. // 空列表
  199. clearDetail(){
  200. const _this = this
  201. clzConfirm({
  202. title: '提示',
  203. content: '确认要清空列表吗?',
  204. success (ret) {
  205. if (ret.confirm || ret.index == 0) {
  206. _this.clearChoose()
  207. }
  208. }
  209. })
  210. },
  211. // 清空已选数据
  212. clearChoose(){
  213. this.chooseList = []
  214. },
  215. // 提交
  216. submitOrder(){
  217. if(this.totalCategory){
  218. this.handleSave()
  219. }else{
  220. uni.showToast({
  221. icon: 'none',
  222. title: '请先选择产品'
  223. })
  224. }
  225. },
  226. handleSave () {
  227. const data = this.chooseList
  228. const dataList = []
  229. data.map(item => {
  230. dataList.push({
  231. shelfPlaceSn: item.shelfPlaceSn,
  232. shelfPlaceCode: item.shelfPlaceCode,
  233. productSn: item.productSn,
  234. productCode: item.productCode,
  235. qty: item.replenishQty
  236. })
  237. })
  238. this.showLoading("正在提交...")
  239. // 开始提交
  240. saveMainAndDetail({
  241. shelfSn: this.nowData.shelfSn,
  242. dealerSn: this.nowData.dealerSn,
  243. detailList: dataList
  244. }).then(res => {
  245. if (res.status == 200) {
  246. this.toashMsg(res.message)
  247. uni.redirectTo({ url: "/pages/replenishmentManage/outWarehousing?sn="+res.data.replenishBillSn })
  248. }
  249. uni.hideLoading()
  250. })
  251. },
  252. }
  253. }
  254. </script>
  255. <style lang="less">
  256. .content{
  257. height: 100vh;
  258. width: 100%;
  259. background: #fff;
  260. .footer-bar{
  261. background-color: #f8f8f8;
  262. padding: 20upx;
  263. .active{
  264. background-color: #0485F6;
  265. }
  266. .f-left{
  267. color: #666;
  268. flex-grow: 1;
  269. > view{
  270. text{
  271. color: red;
  272. margin: 0 5rpx;
  273. }
  274. }
  275. }
  276. .f-btns{
  277. button{
  278. width: 200upx;
  279. }
  280. }
  281. }
  282. .nodata{
  283. padding: 150rpx 50rpx;
  284. text-align: center;
  285. display: flex;
  286. flex-direction: column;
  287. justify-content: center;
  288. align-items: center;
  289. color: #999;
  290. > view{
  291. position: relative;
  292. padding: 10upx 0;
  293. text{
  294. color: #00aaff;
  295. margin-left: 10rpx;
  296. }
  297. }
  298. }
  299. .searchBar{
  300. padding: 0 0.8rem 0.3rem;
  301. .p-title{
  302. padding: 0 15rpx;
  303. display: flex;
  304. align-items: center;
  305. color: #222;
  306. font-size: 30rpx;
  307. > text{
  308. display: block;
  309. height: 30rpx;
  310. width: 6rpx;
  311. background: #0485F6;
  312. margin-right: 10rpx;
  313. border-radius: 10rpx;
  314. }
  315. .shelfName{
  316. flex-grow: 1;
  317. font-weight: bold;
  318. width: 80%;
  319. > view{
  320. overflow: hidden;
  321. white-space: nowrap;
  322. text-overflow: ellipsis;
  323. }
  324. }
  325. .btns{
  326. width:100rpx;
  327. text-align: right;
  328. font-size: 28rpx;
  329. color: #0485F6;
  330. }
  331. }
  332. }
  333. // 购物车
  334. .cpb_cart-box{
  335. flex-grow: 1;
  336. width: 100%;
  337. overflow: auto;
  338. .cpb_cart-list{
  339. padding: 20rpx 0;
  340. overflow: auto;
  341. flex-grow: 1;
  342. > view{
  343. margin-bottom: 20rpx;
  344. }
  345. .nav-right-item{
  346. padding: 0 30upx;
  347. &:last-child{
  348. border-bottom:2rpx solid #eee;
  349. }
  350. }
  351. .item-name{
  352. font-size: 28rpx;
  353. text{
  354. background: rgba(3, 54, 146, 0.15);
  355. color: #1c588a;
  356. border-radius: 1em;
  357. font-size: 26rpx;
  358. padding: 0 0.5em;
  359. margin-right: 10upx;
  360. }
  361. margin-top: 10upx;
  362. }
  363. .item-info{
  364. padding-left: 0.8em;
  365. flex-grow: 1;
  366. }
  367. .item-detail{
  368. .item-detail-info{
  369. padding: 10upx 0 4upx;
  370. font-size: 24upx;
  371. .pnums{
  372. margin-right: 10rpx;
  373. color: #333;
  374. }
  375. .pnums1{
  376. margin-right: 10rpx;
  377. color: red;
  378. }
  379. > view{
  380. padding-bottom: 10rpx;
  381. align-items: center;
  382. .item-detail-text{
  383. color: #999;
  384. margin-left: 20upx;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. }
  391. }
  392. </style>