outstoreOperate.vue 12 KB

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