goIn.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view class="goIn">
  3. <view class="" style="padding-bottom:300rpx">
  4. <view class="dtl" v-if="isScanCode">
  5. <view class="">
  6. 二维码编号:{{dtlData.qrCode}}
  7. </view>
  8. <view class="">
  9. 物料编码:{{dtlData.materialCode}}
  10. </view>
  11. <view class="">
  12. 物料名称:{{dtlData.materialName}}
  13. </view>
  14. <view class="">
  15. 绑定数量:{{dtlData.quantity}}
  16. </view>
  17. <view class="">
  18. 绑定时间:{{dtlData.createTime}}
  19. </view>
  20. <view class="">
  21. 供应商:{{dtlData.supplierName}}
  22. </view>
  23. <view class="">
  24. 合同编号:{{dtlData.purchaseBillNo}} <span style="margin-left: 20rpx;">批次号:{{dtlData.batchNo}}</span>
  25. </view>
  26. </view>
  27. <view class="commons-title">
  28. 入库明细
  29. </view>
  30. <view class="addQrcode-list" v-for="(i,index) in qrCodeList" :key="i,index">
  31. <view class="fl" @click="toRouter(index)">
  32. <view class="code">
  33. <view class="">
  34. 二维码编号:{{i.qrCode}}
  35. </view>
  36. <view class="" style="margin-top: 20rpx;">
  37. 绑定数量:{{i.quantity}}
  38. </view>
  39. </view>
  40. </view>
  41. <view class="fr">
  42. <uni-icons type="trash-filled" color="red" size="30" @click="delelte(index)"></uni-icons>
  43. </view>
  44. </view>
  45. <button size="mini" type="default" style="width: 500rpx;margin: 30rpx auto;display: block;"
  46. @click="scanCode(true)">
  47. 扫码添加
  48. </button>
  49. </view>
  50. <view class="submit-box">
  51. <view class="" style="line-height: 80rpx;text-align: center;">
  52. 合计:{{quantitytol}} | {{qrCodeList.length}}件
  53. </view>
  54. <picker @change="bindPickerChange" :range="stockHouseData" range-key="name">
  55. <button style="background: #0066CC;color:#fff;margin-bottom: 30rpx;">提交</button>
  56. </picker>
  57. </view>
  58. <uni-popup ref="popup" background-color="#fff" :is-mask-click="false">
  59. <view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
  60. <view class="popup-input-warp">
  61. <view class="commons-title">
  62. 扫码入库
  63. </view>
  64. <view class="" style="margin: 20rpx;">
  65. 请选择入库类型
  66. </view>
  67. <button
  68. v-if="userData.roleKey == 'storekeeper' || userData.roleKey == ' supervisor' || userData.roleKey == 'admin'"
  69. style="background: #0066CC;color:#fff;margin-bottom: 30rpx;" @click="scanCode">到货入库</button>
  70. <button @click="toWithdrawal">退仓</button>
  71. </view>
  72. </view>
  73. </uni-popup>
  74. </view>
  75. </template>
  76. <script>
  77. import {
  78. getInfo
  79. } from "@/util/api.js";
  80. import Vue from 'vue'
  81. export default {
  82. data() {
  83. return {
  84. listData: [],
  85. formData: {
  86. number: 0,
  87. quantity: 0,
  88. },
  89. req: {
  90. qrCodeList: [],
  91. stockHouseId: null,
  92. },
  93. btnType: 1,
  94. isScanCode: false,
  95. userData: {},
  96. dtlData: null,
  97. qrCodeList:[],
  98. index: 0,
  99. stockHouseData:[],
  100. quantitytol:0,
  101. }
  102. },
  103. onLoad(option) {
  104. const v = this
  105. this.$refs.popup.open('bottom')
  106. v.userData = Vue.prototype.$userInfo
  107. v.$post('/wx/common/getStockHouse',{}).then(res=>{
  108. v.stockHouseData = res.data
  109. })
  110. },
  111. methods: {
  112. toWithdrawal(){
  113. const v = this
  114. uni.navigateTo({
  115. url: '/pages/goIn/withdrawal'
  116. })
  117. },
  118. delelte(index){
  119. const v = this
  120. uni.showModal({
  121. title:"提示",
  122. content:"你确定删除此信息么?",
  123. success(res) {
  124. if(res.confirm){
  125. v.quantitytol = v.quantitytol - v.qrCodeList[index].quantity
  126. v.qrCodeList.splice(index,1)
  127. }
  128. }
  129. })
  130. },
  131. bindPickerChange(e){
  132. const v = this
  133. if(v.qrCodeList.length == 0){
  134. uni.showToast({
  135. icon: "error",
  136. title: '请添加物料信息',
  137. duration: 2000
  138. });
  139. return
  140. }
  141. v.req.qrCodeList = []
  142. v.req.stockHouseId = v.stockHouseData[e.detail.value].id
  143. for (var i = 0; i < v.qrCodeList.length; i++) {
  144. v.req.qrCodeList.push(v.qrCodeList[i].qrCode)
  145. }
  146. v.$post('/wx/codeScanIn/addWarehousingInfo',v.req).then(res=>{
  147. if(res.code == 200){
  148. uni.showToast({
  149. title:'入库成功,跳转中!'
  150. })
  151. setTimeout(()=>{
  152. wx.reLaunch({
  153. url: '/pages/home'
  154. })
  155. },1000)
  156. }
  157. console.log(res)
  158. })
  159. console.log(v.req)
  160. },
  161. scanCode(_isReload) {
  162. const v = this
  163. uni.scanCode({
  164. onlyFromCamera: true,
  165. success: function(res) {
  166. uni.showToast({
  167. icon: "loading",
  168. title: '加载中',
  169. duration: 1500
  170. });
  171. v.$post('/wx/common/gerMaterialInfoByQrcode', {
  172. qrCode: res.result
  173. }).then(res => {
  174. if(res.data.stockHouseId){
  175. uni.showToast({
  176. icon:'none',
  177. title: '此物料已入库',
  178. duration: 2000
  179. });
  180. return
  181. }
  182. if (v.dtlData) {
  183. for (var i = 0; i < v.qrCodeList.length; i++) {
  184. if(v.qrCodeList[i].qrCode == res.data.qrCode){
  185. uni.showToast({
  186. icon:'none',
  187. title: '此二维码已扫描',
  188. duration: 2000
  189. });
  190. return
  191. }
  192. }
  193. if(v.dtlData.purchaseBillNo != res.data.purchaseBillNo){
  194. uni.showToast({
  195. icon:'none',
  196. title: '合同不一致!',
  197. duration: 2000
  198. });
  199. return
  200. }
  201. if(v.dtlData.materialCode != res.data.materialCode){
  202. uni.showToast({
  203. icon:'none',
  204. title: '物料编码不一致!',
  205. duration: 2000
  206. });
  207. return
  208. }
  209. if(v.dtlData.batchNo != res.data.batchNo){
  210. uni.showToast({
  211. icon:'none',
  212. title: '批次不一致!',
  213. duration: 2000
  214. });
  215. return
  216. }
  217. } else {
  218. v.dtlData = res.data
  219. }
  220. v.quantitytol = res.data.quantity + v.quantitytol
  221. v.qrCodeList.push(res.data)
  222. v.isScanCode = true
  223. v.$refs.popup.close()
  224. if(_isReload){
  225. v.scanCode(_isReload)
  226. }
  227. })
  228. }
  229. });
  230. },
  231. },
  232. }
  233. </script>
  234. <style lang="less">
  235. .popup-input-warp {
  236. padding: 30rpx 40rpx;
  237. }
  238. .submit-box {
  239. position: fixed;
  240. left: 0;
  241. right: 0;
  242. bottom: 0;
  243. padding: 0 30rpx;
  244. background: #fff;
  245. }
  246. .dtl {
  247. padding: 30rpx;
  248. border-bottom: 1rpx solid #dcdcdc;
  249. font-size: 26rpx;
  250. line-height: 40rpx;
  251. }
  252. .addQrcode-list {
  253. height: 80rpx;
  254. display: flex;
  255. justify-content: space-between;
  256. padding: 15rpx;
  257. border-bottom: 1rpx solid #dcdcdc;
  258. font-size: 24rpx;
  259. .fl {
  260. display: flex;
  261. .code {
  262. margin-right: 20rpx;
  263. }
  264. }
  265. .fr {
  266. line-height: 80rpx;
  267. }
  268. }
  269. </style>