creatOrder.vue 9.1 KB

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