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