creatOrder.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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" :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. // 首次选中产品
  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. // 开始提交
  242. saveMainAndDetail({
  243. shelfSn: this.nowData.shelfSn,
  244. dealerSn: this.nowData.dealerSn,
  245. detailList: dataList
  246. }).then(res => {
  247. if (res.status == 200) {
  248. this.toashMsg(res.message)
  249. uni.redirectTo({ url: "/pages/replenishmentManage/outWarehousing?sn="+res.data.replenishBillSn })
  250. }
  251. uni.hideLoading()
  252. })
  253. },
  254. }
  255. }
  256. </script>
  257. <style lang="less">
  258. .content{
  259. height: 100vh;
  260. width: 100%;
  261. background: #fff;
  262. .footer-bar{
  263. background-color: #f8f8f8;
  264. padding: 20upx;
  265. .active{
  266. background-color: #0485F6;
  267. }
  268. .f-left{
  269. color: #666;
  270. flex-grow: 1;
  271. > view{
  272. text{
  273. color: red;
  274. margin: 0 5rpx;
  275. }
  276. }
  277. }
  278. .f-btns{
  279. button{
  280. width: 200upx;
  281. }
  282. }
  283. }
  284. .nodata{
  285. padding: 150rpx 50rpx;
  286. text-align: center;
  287. display: flex;
  288. flex-direction: column;
  289. justify-content: center;
  290. align-items: center;
  291. color: #999;
  292. > view{
  293. position: relative;
  294. padding: 10upx 0;
  295. text{
  296. color: #00aaff;
  297. margin-left: 10rpx;
  298. }
  299. }
  300. }
  301. .searchBar{
  302. padding: 0.3rem 0.8rem;
  303. .p-title{
  304. padding: 0 15rpx;
  305. display: flex;
  306. align-items: center;
  307. color: #222;
  308. font-size: 30rpx;
  309. > text{
  310. display: block;
  311. height: 30rpx;
  312. width: 6rpx;
  313. background: #0485F6;
  314. margin-right: 10rpx;
  315. border-radius: 10rpx;
  316. }
  317. .shelfName{
  318. flex-grow: 1;
  319. font-weight: bold;
  320. width: 80%;
  321. > view{
  322. overflow: hidden;
  323. white-space: nowrap;
  324. text-overflow: ellipsis;
  325. }
  326. }
  327. .btns{
  328. width:100rpx;
  329. text-align: right;
  330. font-size: 28rpx;
  331. color: #0485F6;
  332. }
  333. }
  334. }
  335. // 购物车
  336. .cpb_cart-box{
  337. flex-grow: 1;
  338. width: 100%;
  339. overflow: auto;
  340. .cpb_cart-list{
  341. padding: 20rpx 0;
  342. overflow: auto;
  343. flex-grow: 1;
  344. > view{
  345. margin-bottom: 20rpx;
  346. }
  347. .nav-right-item{
  348. padding: 0 30upx;
  349. &:last-child{
  350. border-bottom:2rpx solid #eee;
  351. }
  352. }
  353. .item-name{
  354. font-size: 28rpx;
  355. text{
  356. background: rgba(3, 54, 146, 0.15);
  357. color: #1c588a;
  358. border-radius: 1em;
  359. font-size: 26rpx;
  360. padding: 0 0.5em;
  361. margin-right: 10upx;
  362. }
  363. margin-top: 10upx;
  364. }
  365. .item-info{
  366. padding-left: 0.8em;
  367. flex-grow: 1;
  368. }
  369. .item-detail{
  370. .item-detail-info{
  371. padding: 10upx 0 4upx;
  372. font-size: 24upx;
  373. .pnums{
  374. margin-right: 10rpx;
  375. color: #333;
  376. }
  377. .pnums1{
  378. margin-right: 10rpx;
  379. color: red;
  380. }
  381. > view{
  382. padding-bottom: 10rpx;
  383. align-items: center;
  384. .item-detail-text{
  385. color: #999;
  386. margin-left: 20upx;
  387. }
  388. }
  389. }
  390. }
  391. }
  392. }
  393. }
  394. </style>