inOut.vue 5.6 KB

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