outassembleOperate.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view style="padding-left: 2px;padding-right: 2px;">
  3. <view style="flex-direction: row;display: flex;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;">{{sapBomDtlMd.materialCode}}</text>
  6. </view>
  7. <view style="flex-direction: row;display: flex;">
  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;">{{sapBomDtlMd.materialName}}</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;">{{sapBomDtlMd.materialSpec}}</text>
  14. </view>
  15. <view style="flex-direction: row;flex-direction: row;display: flex;">
  16. <text style="align-self: center;font-size: 35rpx;color: darkslategray;width: 260rpx;">需求数量:</text>
  17. <text style="align-self: center;font-size: 50rpx;font-weight: bold;color: blue;">{{sapBomDtlMd.qty - sapBomDtlMd.assembleQty}}</text>
  18. </view>
  19. <view style="flex-direction: row;display: flex;padding: 1px;">
  20. <text style="align-self: center;font-size: 35rpx;color: #0000ff;font-weight: bold;width: 260rpx;">扫码-物料号:</text>
  21. <input class="uni-input" style="font-size: 40rpx;font-weight: bold;" v-model="scanMaterialCode" :focus="foucusIndex === 0" @confirm="foucusChange0" @focus="getFoucus(0)"/>
  22. <!-- <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> -->
  23. </view>
  24. <view style="flex-direction: row;display: flex;padding: 1px;">
  25. <text style="align-self: center;font-size: 35rpx;color: #0000ff;font-weight: bold;width: 260rpx;">扫码-BN/SN码:</text>
  26. <input class="uni-input" style="font-size: 40rpx;font-weight: bold;" v-model="scanBnSnCode" :focus="foucusIndex === 1" @confirm="foucusChange1" @focus="getFoucus(1)"/>
  27. </view>
  28. <view style="flex-direction: row;display: flex;padding: 1px;">
  29. <text style="align-self: center;font-size: 35rpx;color: #0000ff;font-weight: bold;width: 260rpx;">装配数量:</text>
  30. <input class="uni-input" type="number" style="font-size: 40rpx;font-weight: bold;color: red;" v-model="assembleNum" :focus="foucusIndex === 2" @confirm="foucusChange2" @focus="getFoucus(2)"/>
  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;">实物图片:</text>
  34. <view class="demo">
  35. <block v-if="imageSrc">
  36. <image :src="imageSrc" class="image" mode="scaleToFill" @click="previewImage11()"></image>
  37. </block>
  38. <block v-else>
  39. <view class="uni-hello-addfile" @click="chooseImage">+ 选择图片</view>
  40. </block>
  41. </view>
  42. </view>
  43. <view class="my-tips-view">{{tipMsg}}</view>
  44. <button type="primary" style="margin-top: 5px;" @click="resetData">重置</button>
  45. <button type="primary" style="margin-top: 5px; margin-bottom: 10px;" @click="submitResult">装配结果提交</button>
  46. <!-- 提示信息弹窗 -->
  47. <!-- <view>
  48. <uni-popup ref="message" type="message">
  49. <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
  50. </uni-popup>
  51. </view> -->
  52. <view>
  53. <!-- 普通弹窗 -->
  54. <uni-popup ref="popup" background-color="#fff" @change="change" :mask-click="isMaskClick" @maskClick="maskClickFun">
  55. <view class="popup-content" style="flex-direction: column;display: flex;">
  56. <text class="text" style="color: red;font-weight: bold;">{{popTitleMsg}}</text>
  57. <text style="color: #333;font-size: 16px;margin-top: 15px;">{{popMsg}}</text>
  58. </view>
  59. </uni-popup>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. sapBomDtlMd: {},
  68. scanMaterialCode: '',
  69. scanBnSnCode: '',
  70. assembleNum: 0,
  71. foucusIndex: 0,
  72. tipMsg: '等待扫码确认物料号......',
  73. popTitleMsg: '请重新扫码!!',
  74. popMsg: '',
  75. isMaskClick: true,
  76. imageSrc: '',
  77. previewImagePath: [],
  78. outTaskQty: 0
  79. }
  80. },
  81. onUnload() {
  82. },
  83. onLoad() {
  84. uni.$once('sendCheckedDeliverDtlData', (data) => {
  85. this.sapBomDtlMd = data
  86. })
  87. this.foucusIndex = 0
  88. },
  89. methods: {
  90. maskClickFun() {
  91. // if(this.foucusIndex === 0 && (this.scanMaterialCode !== this.sapBomDtlMd.materialCode)) {
  92. // this.scanMaterialCode = ''
  93. // }
  94. // else if(this.foucusIndex === 1 && (this.scanMaterialCode !== this.sapBomDtlMd.materialCode)) {
  95. // if(this.isEmptyStr(this.scanMaterialCode)) {
  96. // this.scanBnSnCode = ''
  97. // this.foucusIndex = 0
  98. // }
  99. // else if(this.isEmptyStr(this.scanBnSnCode)) {
  100. // this.foucusIndex = 1
  101. // }
  102. // else {
  103. // this.scanBnSnCode = ''
  104. // this.scanMaterialCode = ''
  105. // this.resetFoucus(0)
  106. // }
  107. // }
  108. // else if(this.foucusIndex === 2 && this.isEmptyStr(this.scanMaterialCode)) {
  109. // this.foucusIndex = 0
  110. // }
  111. // else if(this.foucusIndex === 2 && this.isEmptyStr(this.scanBnSnCode)&& !this.isEmptyStr(this.scanMaterialCode)) {
  112. // this.foucusIndex = 1
  113. // }
  114. // console.log(this.foucusIndex)
  115. },
  116. change(e) {
  117. if(e.show) {
  118. }
  119. else {
  120. this.resetFoucus(this.foucusIndex)
  121. }
  122. },
  123. input(e) {
  124. if(e !== this.sapBomDtlMd.materialCode) {
  125. this.isMaterialCodeErr = true;
  126. }
  127. else {
  128. this.isMaterialCodeErr = false;
  129. }
  130. },
  131. submitResult() {
  132. this.myVerify();
  133. let tmpMd = this.sapBomDtlMd;
  134. tmpMd.assembleNum = this.assembleNum;
  135. tmpMd.BnSnCode = this.scanBnSnCode;
  136. // console.log(tmpMd)
  137. let userMsg = uni.getStorageSync('userInfo')
  138. uni.uploadFile({
  139. url: getApp().globalData.baseUrl + '/business/OutAssembleRecord/AddOutAssembleRecordForFile',
  140. filePath: this.imageSrc,
  141. fileType: 'image',
  142. header: { //自定义请求头信息
  143. Authorization: 'Bearer ' + userMsg.tokenStr + ''
  144. },
  145. formData: tmpMd,
  146. name: 'AssembleData',
  147. success: (res) => {
  148. let retMd = JSON.parse(res.data)
  149. if(retMd.code == 200) {
  150. uni.navigateBack({
  151. url: '/pages/Outstore/outassembleDtl',
  152. success: () => {
  153. uni.$emit('addAssembleDtlData',tmpMd);
  154. }
  155. });
  156. }
  157. else {
  158. this.popTitleMsg = '请重新扫码!!'
  159. this.popMsg = `新增装配数据失败:【${retMd.msg}】`
  160. this.$refs.popup.open('center')
  161. }
  162. },
  163. fail: (err) => {
  164. this.popTitleMsg = '请重新扫码!!'
  165. this.popMsg = `新增装配数据失败:【${err}】`
  166. this.$refs.popup.open('center')
  167. }
  168. });
  169. },
  170. isEmptyStr(s) {
  171. if (s == undefined || s === '') {
  172. return true
  173. }
  174. return false
  175. },
  176. foucusChange0(event) {
  177. if(this.isEmptyStr(this.scanMaterialCode)) {
  178. this.popTitleMsg = '请重新扫码!!'
  179. this.popMsg = '物料号不能为空'
  180. this.$refs.popup.open('center')
  181. this.foucusIndex = 0
  182. return;
  183. }
  184. if(this.scanMaterialCode !== this.sapBomDtlMd.materialCode) {
  185. this.popTitleMsg = '请重新扫码!!'
  186. let tmpMatCode = this.scanMaterialCode
  187. this.popMsg = `物料号:【${tmpMatCode}】扫码确认错误`
  188. this.$refs.popup.open('center')
  189. this.scanMaterialCode = ''
  190. this.foucusIndex = 0
  191. return
  192. }
  193. this.tipMsg = "等待扫码 BN/SN码......"
  194. this.foucusIndex = 1
  195. },
  196. foucusChange1(event) {
  197. if(this.isEmptyStr(this.scanMaterialCode)) {
  198. this.popTitleMsg = '请重新扫码!!'
  199. this.popMsg = '物料号不能为空'
  200. this.$refs.popup.open('center')
  201. this.foucusIndex = 0
  202. return;
  203. }
  204. if(this.scanMaterialCode !== this.sapBomDtlMd.materialCode) {
  205. this.popTitleMsg = '请重新扫码!!'
  206. let tmpMatCode = this.scanMaterialCode
  207. this.popMsg = `物料号:【${tmpMatCode}】扫码确认错误`
  208. this.$refs.popup.open('center')
  209. this.scanMaterialCode = ''
  210. this.foucusIndex = 0
  211. return
  212. }
  213. if(this.isEmptyStr(this.scanBnSnCode)) {
  214. this.popTitleMsg = '请重新扫码!!'
  215. this.popMsg = 'BN/SN码不能为空'
  216. this.$refs.popup.open('center')
  217. this.foucusIndex = 1
  218. //this.resetFoucus(1)
  219. return
  220. }
  221. this.tipMsg = "正在查询已出库数据......"
  222. this.isMaskClick = false;
  223. this.popTitleMsg = '提示'
  224. let showMsg = '正在查询已出库数据......'
  225. this.popMsg = showMsg
  226. this.$refs.popup.open('center')
  227. let parm = {
  228. url : '/business/StkBalanceDtl/GetStkBalanceDtlList',
  229. data: {
  230. BomNo: this.sapBomDtlMd.bomNo,
  231. MaterialCode: this.scanMaterialCode,
  232. BnSnCode: this.scanBnSnCode,
  233. IsForAssemble: true,
  234. },
  235. method: 'GET',
  236. isHaveToken : true
  237. }
  238. getApp().RequestData(parm).then((res)=>{
  239. let retData = res;
  240. if(retData.isSuccess) {
  241. if(retData.data.code == 200) {
  242. if(retData.data.data.length === 0) {
  243. this.outTaskQty = 0
  244. setTimeout(() => {
  245. this.tipMsg = '已出库数量为:' + this.outTaskQty
  246. this.$refs.popup.close()
  247. this.isMaskClick = true
  248. this.scanBnSnCode = ''
  249. // this.foucusIndex = 2
  250. this.resetFoucus(1)
  251. }, 2000)
  252. }
  253. else {
  254. this.outTaskQty = retData.data.data
  255. if(this.outTaskQty > 0) {
  256. setTimeout(() => {
  257. this.tipMsg = '已出库数量为:' + this.outTaskQty
  258. this.$refs.popup.close()
  259. this.isMaskClick = true
  260. // this.foucusIndex = 2
  261. this.resetFoucus(2)
  262. }, 2000)
  263. }
  264. else {
  265. showMsg = '已出库数量为:' + this.outTaskQty
  266. setTimeout(() => {
  267. this.popMsg = showMsg
  268. }, 1000)
  269. setTimeout(() => {
  270. this.tipMsg = '已出库数量为:' + this.outTaskQty
  271. this.$refs.popup.close()
  272. this.isMaskClick = true
  273. this.scanBnSnCode = ''
  274. // this.foucusIndex = 2
  275. this.resetFoucus(1)
  276. }, 2000)
  277. }
  278. }
  279. }
  280. else {
  281. this.outTaskQty = 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.outTaskQty = 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. this.myVerify()
  303. this.foucusIndex = 3
  304. },
  305. myVerify() {
  306. if(this.isEmptyStr(this.scanMaterialCode)) {
  307. this.popTitleMsg = '请重新扫码!!'
  308. this.popMsg = '物料号不能为空'
  309. this.$refs.popup.open('center')
  310. this.foucusIndex = 0
  311. return;
  312. }
  313. if(this.scanMaterialCode !== this.sapBomDtlMd.materialCode) {
  314. this.popTitleMsg = '请重新扫码!!'
  315. let tmpMatCode = this.scanMaterialCode
  316. this.popMsg = `物料号:【${tmpMatCode}】扫码确认错误`
  317. this.$refs.popup.open('center')
  318. this.scanMaterialCode = ''
  319. this.foucusIndex = 0
  320. return
  321. }
  322. if(this.isEmptyStr(this.scanBnSnCode)) {
  323. this.popTitleMsg = '请重新扫码!!'
  324. this.popMsg = 'BN/SN码不能为空'
  325. this.$refs.popup.open('center')
  326. this.foucusIndex = 1
  327. return
  328. }
  329. if(this.assembleNum <= 0) {
  330. this.popTitleMsg = '错误提示!!'
  331. this.popMsg = '输入的装配数量不能为0'
  332. this.$refs.popup.open('center')
  333. this.foucusIndex = 2
  334. return;
  335. }
  336. if(this.outTaskQty <= 0) {
  337. this.popTitleMsg = '错误提示!!'
  338. this.popMsg = '已出库数量为:0,无法进行装配'
  339. this.$refs.popup.open('center')
  340. return;
  341. }
  342. if((this.sapBomDtlMd.qty - this.sapBomDtlMd.outQty) < this.assembleNum) {
  343. this.popTitleMsg = '错误提示!!'
  344. this.popMsg = `输入的装配数量【${this.assembleNum}】大于需求数量【${this.sapBomDtlMd.qty - this.sapBomDtlMd.outQty}】,无法进行装配`
  345. this.$refs.popup.open('center')
  346. return;
  347. }
  348. if(this.outTaskQty < this.assembleNum) {
  349. this.popTitleMsg = '错误提示!!'
  350. this.popMsg = `输入的装配数量【${this.assembleNum}】大于已出库数量【${this.outTaskQty}】,无法进行装配`
  351. this.$refs.popup.open('center')
  352. return;
  353. }
  354. },
  355. resetData() {
  356. this.resetFoucus(0)
  357. this.scanBnSnCode = ''
  358. this.scanMaterialCode = ''
  359. this.assembleNum = 0
  360. this.outTaskQty = 0
  361. this.tipMsg = '等待扫码确认物料号......'
  362. this.imageSrc = ''
  363. this.previewImagePath = []
  364. },
  365. isEmptyStr(s) {
  366. if (s == undefined || s === '') {
  367. return true
  368. }
  369. return false
  370. },
  371. resetFoucus(index) {
  372. this.foucusIndex = 3
  373. setTimeout(() => {
  374. this.foucusIndex = index;
  375. }, 5)
  376. },
  377. getFoucus(index) {
  378. this.foucusIndex = index
  379. },
  380. chooseImage() {
  381. uni.chooseImage({
  382. count: 1,
  383. sizeType: ['compressed'],
  384. sourceType: ['camera'],
  385. success: (res) => {
  386. // console.log(res.tempFilePaths)
  387. // console.log('chooseImage success, temp path is', res.tempFilePaths[0])
  388. var imageSrc = res.tempFilePaths[0]
  389. this.previewImagePath = res.tempFilePaths
  390. this.imageSrc = imageSrc
  391. // console.log(` 11【${this.previewImagePath}】`)
  392. // console.log(` 22【${this.imageSrc}】`)
  393. },
  394. fail: (err) => {
  395. // console.log('chooseImage fail', err)
  396. }
  397. })
  398. },
  399. previewImage11() {
  400. // ToDo: 暂未实现 从后端获取图片并预览大图 孙亚龙
  401. // 预览图片
  402. uni.previewImage({
  403. urls: this.previewImagePath
  404. });
  405. }
  406. }
  407. }
  408. </script>
  409. <style lang="scss">
  410. @import '@/common/uni-nvue.css';
  411. .my-tips-view {
  412. margin-top: 5px;
  413. text-align: center;
  414. color: #aa007f;
  415. font-size: 20px;
  416. font-weight: bold;
  417. }
  418. .popup-content {
  419. // @include flex;
  420. display: flex;
  421. align-items: center;
  422. justify-content: center;
  423. padding: 15px;
  424. // height: 50px;
  425. background-color: #fff;
  426. }
  427. .text {
  428. font-size: 22px;
  429. color: #333;
  430. }
  431. .image {
  432. width: 100%;
  433. height: 100%;
  434. }
  435. .demo {
  436. // padding: 5rpx;
  437. margin-left: 8px;
  438. width: 245px;
  439. height: 210px;
  440. // border: 1px solid green;
  441. background-color: #fff;
  442. }
  443. .uni-hello-addfile:active {
  444. background-color: aliceblue;
  445. }
  446. .uni-hello-addfile {
  447. font-size: 45rpx;
  448. color: black;
  449. font-weight: bold;
  450. }
  451. </style>