goOut.vue 6.0 KB

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