index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="p-content">
  3. <view class="p-head" v-if="baseData">
  4. <view>
  5. <view>
  6. <text>店内调出单号:</text>
  7. <text style="color: crimson;">{{baseData.storeCallOutNo}}</text>
  8. </view>
  9. <view>
  10. <button :disabled="loading" size="mini" type="primary" @click="submitForm"> 出库 <text class="iconfont icon-icon-test43"></text></button>
  11. </view>
  12. </view>
  13. <view>
  14. <view>条形码:</view>
  15. <view>
  16. <input
  17. @blur="pickFun(true)"
  18. @change="curProductIndex = 0"
  19. style="width: 100%;text-align: left;"
  20. class="uni-input"
  21. placeholder="扫描或输入条形码"
  22. border="surround"
  23. v-model="code">
  24. </view>
  25. </view>
  26. <view>
  27. <view>产品编码:</view>
  28. <view>
  29. <input
  30. @blur="pickFun(true)"
  31. @change="curProductIndex = 0"
  32. style="width: 100%;text-align: left;"
  33. class="uni-input"
  34. placeholder="请输入产品编码"
  35. border="surround"
  36. v-model="productCode">
  37. </view>
  38. </view>
  39. <view style="justify-content: flex-start;flex-wrap: wrap;">
  40. <view>已拣款数: <text style="color: red;">{{baseData.pickCategory||0}}</text>/{{baseData.productTotalCategory}}</view>
  41. <view>已拣数量: <text style="color: red;">{{baseData.pickQty||0}}</text>/{{baseData.productTotalQty}}</view>
  42. </view>
  43. </view>
  44. <view class="p-body">
  45. <uni-table style="width: 100%;" border emptyText="暂无数据" :loading="loading1" >
  46. <!-- 表头行 -->
  47. <uni-tr>
  48. <uni-td align="center">产品编码</uni-td>
  49. <uni-td align="center">产品分类</uni-td>
  50. <uni-td align="center">已拣/总数</uni-td>
  51. <uni-td align="center">拣货</uni-td>
  52. </uni-tr>
  53. <!-- 表格数据行 -->
  54. <uni-tr
  55. v-for="item in detailList"
  56. :key="item.id"
  57. :checkedRow="hasCheck(item)">
  58. <uni-td width="30%" align="center">
  59. <view @click="copyText(item.productCode)">{{item.productCode}}</view>
  60. </uni-td>
  61. <uni-td width="30%" align="center">{{item.productTypeName3||'--'}}</uni-td>
  62. <uni-td width="25%" align="center"><text style="color: red;">{{item.pickQty||0}}</text>/{{item.outQty}}</uni-td>
  63. <uni-td width="15%" align="center">
  64. <view style="display: flex;justify-content: center;">
  65. <u-icon v-if="item.pickFlag==0" name="close-circle-fill" color="red" size="22"></u-icon>
  66. <u-icon v-if="item.pickFlag==1" name="checkmark-circle-fill" color="green" size="22"></u-icon>
  67. <u-icon v-if="item.pickFlag==2" name="info-circle-fill" color="#ffaa00" size="22"></u-icon>
  68. </view>
  69. </uni-td>
  70. </uni-tr>
  71. </uni-table>
  72. </view>
  73. <view class="p-footer">
  74. <button :disabled="loading" size="mini" type="warn" @click="pickFun(false)"> <text class="iconfont icon-reduce-btn"> 减 </text></button>
  75. <button :disabled="loading" size="mini" type="primary" @click="pickFun(true)"> <text class="iconfont icon-add-btn"> 加 </text></button>
  76. </view>
  77. <scanCode></scanCode>
  78. <u-modal :show="showModal" :title="msg.title" :confirmText="msg.confirmText" showCancelButton :content='msg.content' @cancel="showModal=false" @confirm="confirmModal"></u-modal>
  79. </view>
  80. </template>
  81. <script>
  82. import scanCode from '@/libs/scan-code.vue';
  83. import { storeCallOutDetail, storeCallOutDetailList, storeCallOutPick, storeCallOutOut } from '@/config/api.js'
  84. import { playAudio } from '@/libs/tools.js'
  85. import clipboard from "@/js_sdk/dc-clipboard/clipboard.js"
  86. export default {
  87. components: { scanCode },
  88. data() {
  89. return {
  90. loading: false,
  91. loading1: false,
  92. baseData: null,
  93. showModal: false,
  94. msg:{title:'提示',content:''},
  95. detailList:[],
  96. code:'',
  97. productCode: '',
  98. storeCallOutSn: null,
  99. storeCallOutId: null,
  100. curProductIndex: 0,
  101. curProductArr: [],
  102. };
  103. },
  104. onLoad(opts) {
  105. var _this = this
  106. this.storeCallOutSn = opts.storeCallOutSn
  107. this.storeCallOutId = opts.id
  108. this.getDetail()
  109. this.getDetailList()
  110. uni.$on('scancodedate', function(content) {
  111. console.log("扫描到的内容为:", content)
  112. _this.code = content||''
  113. _this.curProductIndex = 0
  114. _this.pickFun(true)
  115. })
  116. },
  117. onUnload() {
  118. uni.$off('scancodedate')
  119. },
  120. onShow() {
  121. this.hideKeyborder()
  122. },
  123. methods: {
  124. hideKeyborder(){
  125. uni.hideKeyboard()
  126. },
  127. // 复制
  128. copyText(text){
  129. clipboard.setText(text);
  130. uni.showToast({
  131. icon: 'none',
  132. title: '编码已复制成功'
  133. })
  134. },
  135. hasCheck(item){
  136. const curProduct = this.curProductArr[this.curProductIndex]
  137. return curProduct&&(item.productCode == curProduct.productCode)
  138. },
  139. getCurProduct(){
  140. const curProduct = this.detailList.filter(item => item.productQrCode == this.code || item.productCode == this.productCode)
  141. console.log(curProduct)
  142. this.curProductArr = curProduct || []
  143. },
  144. pickFun(flag){
  145. this.getCurProduct()
  146. this.addQty(flag)
  147. },
  148. addQty(flag){
  149. console.log(this.curProductArr, this.curProductIndex)
  150. const curProduct = this.curProductArr[this.curProductIndex]
  151. console.log(curProduct)
  152. if(curProduct){
  153. this.loading = true
  154. // 加
  155. if(flag){
  156. // 如果不是拣货完成
  157. if(curProduct.pickFlag != 1){
  158. this.queryProduct((curProduct.pickQty||0)+1,curProduct)
  159. }else{
  160. // 当前商品拣货完,判断是否有其它仓库同样商品
  161. // 切换到下一个商品
  162. if(this.curProductIndex<this.curProductArr.length-1){
  163. this.curProductIndex = this.curProductIndex + 1
  164. this.pickFun(flag)
  165. }else{
  166. this.loading = false
  167. uni.$u.toast("此商品已全部拣货")
  168. playAudio('warn')
  169. }
  170. }
  171. }else{
  172. // 减
  173. // 如果状态不是未拣货
  174. if(curProduct.pickFlag != 0){
  175. this.queryProduct((curProduct.pickQty||0)-1,curProduct)
  176. }else{
  177. // 判断是否有它仓库同样商品
  178. // 切换到上一个商品
  179. if(this.curProductIndex){
  180. this.curProductIndex = this.curProductIndex - 1
  181. this.pickFun(flag)
  182. }else{
  183. this.loading = false
  184. uni.$u.toast("没有可以减的商品了")
  185. playAudio('warn')
  186. }
  187. }
  188. }
  189. }else{
  190. this.curProductIndex = 0
  191. if(this.code == '' && this.productCode == ''){
  192. uni.$u.toast("请扫描条形码或输入编码")
  193. }else{
  194. uni.$u.toast("此商品不存在")
  195. }
  196. playAudio('warn')
  197. }
  198. },
  199. //拣货
  200. queryProduct(pickQty, curProduct){
  201. // console.log(curProduct)
  202. this.loading = true
  203. const params = {
  204. storeCallOutSn: this.storeCallOutSn,
  205. id: curProduct.id,
  206. pickQty: pickQty
  207. }
  208. // console.log(params)
  209. storeCallOutPick(params).then(res => {
  210. console.log(res)
  211. if(res.status == 200){
  212. if(res.data){
  213. this.getDetail()
  214. this.getDetailList()
  215. }else{
  216. uni.$u.toast("此商品不存在")
  217. playAudio('error')
  218. }
  219. }
  220. this.loading = false
  221. })
  222. },
  223. // 详情
  224. getDetail(){
  225. storeCallOutDetail({sn: this.storeCallOutSn}).then(res => {
  226. // console.log(res,'详情')
  227. if(res.status == 200){
  228. this.baseData = res.data
  229. }
  230. })
  231. },
  232. // 产品明细列表
  233. getDetailList(){
  234. storeCallOutDetailList({pageNo:1,pageSize:1000,storeCallOutSn:this.storeCallOutSn}).then(res => {
  235. console.log(res)
  236. if(res.status == 200){
  237. this.detailList = res.data.list
  238. this.getCurProduct()
  239. }
  240. })
  241. },
  242. confirmModal(e){
  243. this.toOut()
  244. },
  245. // 提交
  246. submitForm(){
  247. if(this.baseData.pickQty != this.baseData.productTotalQty){
  248. this.showModal = true
  249. this.msg = {
  250. title: '提示',
  251. content: '确定未完成拣货出库吗?',
  252. confirmText: '确定出库'
  253. }
  254. }else{
  255. this.toOut()
  256. }
  257. },
  258. // 出库
  259. async toOut(){
  260. const ret = await storeCallOutOut({storeCallOutSn: this.storeCallOutSn})
  261. if(ret.status == 200){
  262. this.$store.state.vuex_isRefash = true
  263. uni.navigateBack()
  264. }
  265. }
  266. },
  267. }
  268. </script>
  269. <style lang="scss">
  270. .p-content{
  271. .p-head{
  272. font-size: 32upx;
  273. color: $uni-text-color;
  274. >view{
  275. display: flex;
  276. align-items: center;
  277. padding: 10upx 20upx;
  278. border-bottom: 1px solid #eee;
  279. justify-content: space-between;
  280. > view{
  281. display: flex;
  282. padding: 0 10upx;
  283. align-items: center;
  284. }
  285. }
  286. .uni-input{
  287. border: 1px solid #eee;
  288. width: 150upx;
  289. text-align: center;
  290. padding: 8upx;
  291. }
  292. }
  293. .p-body{
  294. overflow: auto;
  295. flex-grow: 1;
  296. height: 50%;
  297. }
  298. .p-footer{
  299. padding:20upx 30upx;
  300. display: flex;
  301. > button{
  302. width: 30%;
  303. }
  304. }
  305. }
  306. </style>