creatOrder.vue 9.5 KB

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