outstoreOperate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view style="padding-left: 2px;padding-right: 2px;">
  3. <!-- <view style="flex-direction: row;display: flex;padding: 1px;margin-top: 5px;">
  4. <text style="align-self: center;font-size: 35rpx;color: darkslategray;">出库任务单号:</text>
  5. <text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{outTaskDtlMd.outTaskNo}}</text>
  6. </view> -->
  7. <view style="flex-direction: row;display: flex;margin-top: 5px;">
  8. <text style="align-self: center;font-size: 35rpx;color: darkslategray;">生产令号:</text>
  9. <text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{outTaskDtlMd.bomNo}}</text>
  10. </view>
  11. <view style="flex-direction: row;display: flex;">
  12. <text style="align-self: center;font-size: 35rpx;color: darkslategray;">物料号:</text>
  13. <text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{outTaskDtlMd.materialCode}}</text>
  14. </view>
  15. <view style="flex-direction: row;display: flex;">
  16. <text style="align-self: center;font-size: 35rpx;color: darkslategray;">物料名称:</text>
  17. <text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{outTaskDtlMd.materialName}}</text>
  18. </view>
  19. <view style="flex-direction: row;display: flex;">
  20. <text style="align-self: center;font-size: 35rpx;color: darkslategray;">规格型号/图号:</text>
  21. <text style="align-self: center;font-size: 35rpx;word-wrap: break-word;width: 200px;font-weight: bold;">{{outTaskDtlMd.materialSpec}}</text>
  22. </view>
  23. <view style="flex-direction: row;flex-direction: row;display: flex;">
  24. <text style="align-self: center;font-size: 35rpx;color: darkslategray;width: 260rpx;">需求数量:</text>
  25. <text style="align-self: center;font-size: 50rpx;font-weight: bold;color: blue;">{{outTaskDtlMd.qty - outTaskDtlMd.outQty}}</text>
  26. </view>
  27. <view style="flex-direction: row;display: flex;padding: 1px;">
  28. <text style="align-self: center;font-size: 35rpx;color: #0000ff;font-weight: bold;width: 260rpx;">扫码-物料号:</text>
  29. <input class="uni-input" style="font-size: 40rpx;font-weight: bold;" v-model="scanMaterialCode" :focus="foucusIndex === 0" @confirm="foucusChange0" @focus="getFoucus(0)"/>
  30. <!-- <uni-easyinput style="background:#FFF;margin-right: 5px;font-size: 80rpx;" v-model="scanMaterialCode" :errorMessage="isMaterialCodeErr" :focus="foucusIndex === 0" @confirm="foucusChange0" @input="input"></uni-easyinput> -->
  31. </view>
  32. <view style="flex-direction: row;display: flex;padding: 1px;">
  33. <text style="align-self: center;font-size: 35rpx;color: #0000ff;font-weight: bold;width: 260rpx;">扫码-BN/SN码:</text>
  34. <input class="uni-input" style="font-size: 40rpx;font-weight: bold;" v-model="scanBnSnCode" :focus="foucusIndex === 1" @confirm="foucusChange1" @focus="getFoucus(1)"/>
  35. </view>
  36. <view style="flex-direction: row;display: flex;padding: 1px;">
  37. <text style="align-self: center;font-size: 35rpx;color: #0000ff;font-weight: bold;width: 260rpx;">出库数量:</text>
  38. <input class="uni-input" type="number" style="font-size: 40rpx;font-weight: bold;color: red;" v-model="outNum" :focus="foucusIndex === 2" @confirm="foucusChange2" @focus="getFoucus(2)"/>
  39. </view>
  40. <view class="my-tips-view">{{tipMsg}}</view>
  41. <button type="primary" style="margin-top: 5px;" @click="resetData">重置</button>
  42. <button type="primary" style="margin-top: 15px;" @click="submitResult">出库结果提交</button>
  43. <!-- 提示信息弹窗 -->
  44. <!-- <view>
  45. <uni-popup ref="message" type="message">
  46. <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
  47. </uni-popup>
  48. </view> -->
  49. <view>
  50. <!-- 普通弹窗 -->
  51. <uni-popup ref="popup" background-color="#fff" @change="change" :mask-click="isMaskClick" @maskClick="maskClickFun">
  52. <view class="popup-content" style="flex-direction: column;display: flex;">
  53. <text class="text" style="color: red;font-weight: bold;">{{popTitleMsg}}</text>
  54. <text style="color: #333;font-size: 16px;margin-top: 15px;">{{popMsg}}</text>
  55. </view>
  56. </uni-popup>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. outTaskDtlMd: {},
  65. scanMaterialCode: '',
  66. scanBnSnCode: '',
  67. outNum: 0,
  68. foucusIndex: 0,
  69. tipMsg: '等待扫码确认物料号......',
  70. popTitleMsg: '请重新扫码!!',
  71. popMsg: '',
  72. isMaskClick: true,
  73. stockQty: 0
  74. }
  75. },
  76. onUnload() {
  77. },
  78. onLoad() {
  79. uni.$once('sendCheckedDeliverDtlData', (data) => {
  80. this.outTaskDtlMd = data
  81. })
  82. this.foucusIndex = 0
  83. },
  84. methods: {
  85. maskClickFun() {
  86. if(this.foucusIndex === 0 && (this.scanMaterialCode !== this.outTaskDtlMd.materialCode)) {
  87. this.scanMaterialCode = ''
  88. }
  89. else if(this.foucusIndex === 1 && (this.scanMaterialCode !== this.outTaskDtlMd.materialCode)) {
  90. if(this.isEmptyStr(this.scanMaterialCode)) {
  91. this.scanBnSnCode = ''
  92. this.foucusIndex = 0
  93. }
  94. else if(this.isEmptyStr(this.scanBnSnCode)) {
  95. this.foucusIndex = 1
  96. }
  97. else {
  98. this.scanBnSnCode = ''
  99. this.scanMaterialCode = ''
  100. this.resetFoucus(0)
  101. }
  102. }
  103. },
  104. change(e) {
  105. if(e.show) {
  106. }
  107. else {
  108. this.resetFoucus(this.foucusIndex)
  109. }
  110. },
  111. input(e) {
  112. if(e !== this.outTaskDtlMd.materialCode) {
  113. this.isMaterialCodeErr = true;
  114. }
  115. else {
  116. this.isMaterialCodeErr = false;
  117. }
  118. },
  119. async submitResult() {
  120. if(this.outNum <= 0) {
  121. this.popTitleMsg = '错误提示!!'
  122. this.popMsg = '出库数量不能为0'
  123. this.$refs.popup.open('center')
  124. this.foucusIndex = 2
  125. return;
  126. }
  127. if(this.stockQty <= 0) {
  128. this.popTitleMsg = '错误提示!!'
  129. this.popMsg = '库存数量为:0,无法出库'
  130. this.$refs.popup.open('center')
  131. return;
  132. }
  133. if((this.outTaskDtlMd.qty - this.outTaskDtlMd.outQty) < this.outNum) {
  134. this.popTitleMsg = '错误提示!!'
  135. this.popMsg = `出库数量【${this.outNum}】大于需求数量【${this.outTaskDtlMd.qty - this.outTaskDtlMd.outQty}】,无法出库`
  136. this.$refs.popup.open('center')
  137. return;
  138. }
  139. if(this.stockQty < this.outNum) {
  140. this.popTitleMsg = '错误提示!!'
  141. this.popMsg = `出库数量【${this.outNum}】大于库存数量【${this.stockQty}】,无法出库`
  142. this.$refs.popup.open('center')
  143. return;
  144. }
  145. let tmpMd = this.outTaskDtlMd;
  146. tmpMd.outStoreQty = this.outNum;
  147. tmpMd.OutNum = this.outNum;
  148. tmpMd.BnSnCode = this.scanBnSnCode;
  149. let parm = {
  150. url : '/business/OutOutstoreRecord/AddOutstoreRecord',
  151. data: tmpMd,
  152. method: 'POST',
  153. isHaveToken : true
  154. }
  155. let retData = await getApp().RequestData(parm)
  156. if(retData.isSuccess) {
  157. if(retData.data.code == 200) {
  158. uni.navigateBack({
  159. url: '/pages/Outstore/outstoreDtl',
  160. success: () => {
  161. uni.$emit('addOutstoreData',tmpMd);
  162. }
  163. });
  164. console.log(retData.data)
  165. }
  166. else {
  167. // console.log(retData.data)
  168. uni.showToast({
  169. title: '接口错误!' + retData.data.msg,
  170. icon: 'none',
  171. duration: 1500,
  172. mask:true,
  173. })
  174. }
  175. }
  176. else {
  177. // console.log(retData)
  178. uni.showToast({
  179. title: '接口异常!' + retData.retMsg,
  180. icon: 'none',
  181. duration: 1500,
  182. mask:true,
  183. })
  184. }
  185. },
  186. isEmptyStr(s) {
  187. if (s == undefined || s === '') {
  188. return true
  189. }
  190. return false
  191. },
  192. foucusChange0(event) {
  193. if(this.isEmptyStr(this.scanMaterialCode)) {
  194. this.popTitleMsg = '请重新扫码!!'
  195. this.popMsg = '物料号不能为空'
  196. this.$refs.popup.open('center')
  197. return;
  198. }
  199. if(this.scanMaterialCode !== this.outTaskDtlMd.materialSpec) {
  200. this.popTitleMsg = '请重新扫码!!'
  201. this.popMsg = '物料号扫码确认错误'
  202. this.$refs.popup.open('center')
  203. return
  204. }
  205. let str = event.detail.value
  206. if(str.length !== 0) {
  207. this.foucusIndex = 1
  208. }
  209. else {
  210. this.resetFoucus(0)
  211. }
  212. this.tipMsg = "等待扫码 BN/SN码......"
  213. },
  214. foucusChange1(event) {
  215. if(this.isEmptyStr(this.scanMaterialCode)) {
  216. this.popTitleMsg = '请重新扫码!!'
  217. this.popMsg = '物料号不能为空'
  218. this.$refs.popup.open('center')
  219. return;
  220. }
  221. if(this.isEmptyStr(this.scanBnSnCode)) {
  222. this.popTitleMsg = '请重新扫码!!'
  223. this.popMsg = 'BN/SN码不能为空'
  224. this.$refs.popup.open('center')
  225. //this.resetFoucus(1)
  226. return
  227. }
  228. if(this.scanMaterialCode !== this.outTaskDtlMd.materialSpec) {
  229. this.popTitleMsg = '请重新扫码!!'
  230. this.popMsg = '物料号扫码确认错误'
  231. this.$refs.popup.open('center')
  232. return
  233. }
  234. // let str = event.detail.value
  235. // if(str.length !== 0) {
  236. // this.foucusIndex = 2
  237. // }
  238. this.tipMsg = "正在查询库存数据......"
  239. this.isMaskClick = false;
  240. this.popTitleMsg = '提示'
  241. this.popMsg = '正在查询库存数据......'
  242. this.$refs.popup.open('center')
  243. // let that = this
  244. let parm = {
  245. url : '/business/StkBalanceDtl/GetStkBalanceDtlList',
  246. data: {
  247. BomNo: this.outTaskDtlMd.bomNo,
  248. MaterialCode: this.scanMaterialCode,
  249. BnSnCode: this.scanBnSnCode,
  250. },
  251. method: 'GET',
  252. isHaveToken : true
  253. }
  254. getApp().RequestData(parm).then((res)=>{
  255. let retData = res;
  256. if(retData.isSuccess) {
  257. if(retData.data.code == 200) {
  258. if(retData.data.data.length === 0) {
  259. this.stockQty = 0
  260. setTimeout(() => {
  261. this.tipMsg = '库存数量为:' + this.stockQty
  262. this.$refs.popup.close()
  263. this.isMaskClick = true
  264. this.scanBnSnCode = ''
  265. // this.foucusIndex = 2
  266. this.resetFoucus(1)
  267. }, 2000)
  268. }
  269. else {
  270. this.stockQty = retData.data.data
  271. setTimeout(() => {
  272. this.tipMsg = '库存数量为:' + this.stockQty
  273. this.$refs.popup.close()
  274. this.isMaskClick = true
  275. // this.foucusIndex = 2
  276. this.resetFoucus(2)
  277. }, 2000)
  278. }
  279. }
  280. else {
  281. this.stockQty = 0
  282. this.tipMsg = '获取库存数量发生错误!!'
  283. this.$refs.popup.close()
  284. this.isMaskClick = true;
  285. this.scanBnSnCode = ''
  286. // this.foucusIndex = 1
  287. this.resetFoucus(1)
  288. }
  289. }
  290. else {
  291. this.stockQty = 0
  292. this.tipMsg = '获取库存数量发生错误!!'
  293. this.$refs.popup.close()
  294. this.isMaskClick = true;
  295. this.scanBnSnCode = ''
  296. // this.foucusIndex = 1
  297. this.resetFoucus(1)
  298. }
  299. });
  300. },
  301. foucusChange2(event) {
  302. if(this.outNum <= 0) {
  303. this.popTitleMsg = '错误提示!!'
  304. this.popMsg = '出库数量不能为0'
  305. this.$refs.popup.open('center')
  306. this.foucusIndex = 2
  307. return;
  308. }
  309. let str = event.detail.value
  310. if(str.length !== 0) {
  311. this.foucusIndex = 3
  312. }
  313. this.submitResult()
  314. },
  315. resetData() {
  316. this.resetFoucus(0)
  317. this.scanBnSnCode = ''
  318. this.scanMaterialCode = ''
  319. this.outNum = 0
  320. this.stockQty = 0
  321. this.tipMsg = '等待扫码确认物料号......'
  322. },
  323. isEmptyStr(s) {
  324. if (s == undefined || s === '') {
  325. return true
  326. }
  327. return false
  328. },
  329. resetFoucus(index) {
  330. this.foucusIndex = 3
  331. setTimeout(() => {
  332. this.foucusIndex = index;
  333. }, 5)
  334. },
  335. getFoucus(index) {
  336. this.foucusIndex = index
  337. }
  338. }
  339. }
  340. </script>
  341. <style lang="scss">
  342. @import '@/common/uni-nvue.css';
  343. .my-tips-view {
  344. margin-top: 5px;
  345. text-align: center;
  346. color: #aa007f;
  347. font-size: 20px;
  348. font-weight: bold;
  349. }
  350. .popup-content {
  351. // @include flex;
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. padding: 15px;
  356. // height: 50px;
  357. background-color: #fff;
  358. }
  359. .text {
  360. font-size: 22px;
  361. color: #333;
  362. }
  363. </style>