withdrawal.vue 5.8 KB

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