outassembleOperate.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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. if(this.isEmptyStr(this.imageSrc)) {
  134. this.popTitleMsg = '请重新扫码!!'
  135. this.popMsg = '图片不能为空'
  136. this.$refs.popup.open('center')
  137. this.foucusIndex = 3
  138. return
  139. }
  140. uni.showLoading({
  141. title: "正在提交数据...",
  142. mask: true,
  143. })
  144. let tmpMd = this.sapBomDtlMd;
  145. tmpMd.assembleNum = Number(this.assembleNum);
  146. tmpMd.BnSnCode = this.scanBnSnCode;
  147. // console.log(tmpMd)
  148. let userMsg = uni.getStorageSync('userInfo')
  149. uni.uploadFile({
  150. url: getApp().globalData.baseUrl + '/business/OutAssembleRecord/AddOutAssembleRecordForFile',
  151. filePath: this.imageSrc,
  152. fileType: 'image',
  153. header: { //自定义请求头信息
  154. Authorization: 'Bearer ' + userMsg.tokenStr + ''
  155. },
  156. formData: tmpMd,
  157. name: 'AssembleData',
  158. success: (res) => {
  159. let retMd = JSON.parse(res.data)
  160. if(retMd.code == 200) {
  161. uni.navigateBack({
  162. url: '/pages/Outstore/outassembleDtl',
  163. success: () => {
  164. uni.hideLoading()
  165. uni.$emit('addAssembleDtlData',tmpMd);
  166. }
  167. });
  168. }
  169. else {
  170. uni.hideLoading()
  171. this.popTitleMsg = '请重新扫码!!'
  172. this.popMsg = `新增装配数据失败:【${retMd.msg}】`
  173. this.$refs.popup.open('center')
  174. }
  175. },
  176. fail: (err) => {
  177. uni.hideLoading()
  178. this.popTitleMsg = '请重新扫码!!'
  179. this.popMsg = `新增装配数据失败:【${err}】`
  180. this.$refs.popup.open('center')
  181. }
  182. });
  183. },
  184. isEmptyStr(s) {
  185. if (s == undefined || s === '') {
  186. return true
  187. }
  188. return false
  189. },
  190. foucusChange0(event) {
  191. if(this.isEmptyStr(this.scanMaterialCode)) {
  192. this.popTitleMsg = '请重新扫码!!'
  193. this.popMsg = '物料号不能为空'
  194. this.$refs.popup.open('center')
  195. this.foucusIndex = 0
  196. return;
  197. }
  198. if(this.scanMaterialCode !== this.sapBomDtlMd.materialSpec) {
  199. this.popTitleMsg = '请重新扫码!!'
  200. let tmpMatCode = this.scanMaterialCode
  201. this.popMsg = `物料号:【${tmpMatCode}】扫码确认错误`
  202. this.$refs.popup.open('center')
  203. this.scanMaterialCode = ''
  204. this.foucusIndex = 0
  205. return
  206. }
  207. this.tipMsg = "等待扫码 BN/SN码......"
  208. this.foucusIndex = 1
  209. },
  210. foucusChange1(event) {
  211. if(this.isEmptyStr(this.scanMaterialCode)) {
  212. this.popTitleMsg = '请重新扫码!!'
  213. this.popMsg = '物料号不能为空'
  214. this.$refs.popup.open('center')
  215. this.foucusIndex = 0
  216. return;
  217. }
  218. if(this.scanMaterialCode !== this.sapBomDtlMd.materialSpec) {
  219. this.popTitleMsg = '请重新扫码!!'
  220. let tmpMatCode = this.scanMaterialCode
  221. this.popMsg = `物料号:【${tmpMatCode}】扫码确认错误`
  222. this.$refs.popup.open('center')
  223. this.scanMaterialCode = ''
  224. this.foucusIndex = 0
  225. return
  226. }
  227. if(this.isEmptyStr(this.scanBnSnCode)) {
  228. this.popTitleMsg = '请重新扫码!!'
  229. this.popMsg = 'BN/SN码不能为空'
  230. this.$refs.popup.open('center')
  231. this.foucusIndex = 1
  232. //this.resetFoucus(1)
  233. return
  234. }
  235. this.tipMsg = "正在查询已出库数据......"
  236. this.isMaskClick = false;
  237. this.popTitleMsg = '提示'
  238. let showMsg = '正在查询已出库数据......'
  239. this.popMsg = showMsg
  240. this.$refs.popup.open('center')
  241. let parm = {
  242. url : '/business/StkBalanceDtl/GetStkBalanceDtlList',
  243. data: {
  244. BomNo: this.sapBomDtlMd.bomNo,
  245. MaterialCode: this.scanMaterialCode,
  246. BnSnCode: this.scanBnSnCode,
  247. IsForAssemble: true,
  248. },
  249. method: 'GET',
  250. isHaveToken : true
  251. }
  252. getApp().RequestData(parm).then((res)=>{
  253. let retData = res;
  254. if(retData.isSuccess) {
  255. if(retData.data.code == 200) {
  256. if(retData.data.data.length === 0) {
  257. this.outTaskQty = 0
  258. setTimeout(() => {
  259. this.tipMsg = '已出库数量为:' + this.outTaskQty
  260. this.$refs.popup.close()
  261. this.isMaskClick = true
  262. this.scanBnSnCode = ''
  263. // this.foucusIndex = 2
  264. this.resetFoucus(1)
  265. }, 1000)
  266. }
  267. else {
  268. this.outTaskQty = retData.data.data
  269. if(this.outTaskQty > 0) {
  270. setTimeout(() => {
  271. this.tipMsg = '已出库数量为:' + this.outTaskQty
  272. this.$refs.popup.close()
  273. this.isMaskClick = true
  274. // this.foucusIndex = 2
  275. this.resetFoucus(2)
  276. }, 1000)
  277. }
  278. else {
  279. showMsg = '已出库数量为:' + this.outTaskQty
  280. setTimeout(() => {
  281. this.popMsg = showMsg
  282. }, 1000)
  283. setTimeout(() => {
  284. this.tipMsg = '已出库数量为:' + this.outTaskQty
  285. this.$refs.popup.close()
  286. this.isMaskClick = true
  287. this.scanBnSnCode = ''
  288. // this.foucusIndex = 2
  289. this.resetFoucus(1)
  290. }, 2000)
  291. }
  292. }
  293. }
  294. else {
  295. this.outTaskQty = 0
  296. this.tipMsg = '获取已出库数量发生错误!!'
  297. this.$refs.popup.close()
  298. this.isMaskClick = true;
  299. this.scanBnSnCode = ''
  300. // this.foucusIndex = 1
  301. this.resetFoucus(1)
  302. }
  303. }
  304. else {
  305. this.outTaskQty = 0
  306. this.tipMsg = '获取已出库数量发生错误!!'
  307. this.$refs.popup.close()
  308. this.isMaskClick = true;
  309. this.scanBnSnCode = ''
  310. // this.foucusIndex = 1
  311. this.resetFoucus(1)
  312. }
  313. });
  314. },
  315. foucusChange2(event) {
  316. this.myVerify()
  317. this.foucusIndex = 3
  318. },
  319. myVerify() {
  320. if(this.isEmptyStr(this.scanMaterialCode)) {
  321. this.popTitleMsg = '请重新扫码!!'
  322. this.popMsg = '物料号不能为空'
  323. this.$refs.popup.open('center')
  324. this.foucusIndex = 0
  325. return;
  326. }
  327. if(this.scanMaterialCode !== this.sapBomDtlMd.materialSpec) {
  328. this.popTitleMsg = '请重新扫码!!'
  329. let tmpMatCode = this.scanMaterialCode
  330. this.popMsg = `物料号:【${tmpMatCode}】扫码确认错误`
  331. this.$refs.popup.open('center')
  332. this.scanMaterialCode = ''
  333. this.foucusIndex = 0
  334. return
  335. }
  336. if(this.isEmptyStr(this.scanBnSnCode)) {
  337. this.popTitleMsg = '请重新扫码!!'
  338. this.popMsg = 'BN/SN码不能为空'
  339. this.$refs.popup.open('center')
  340. this.foucusIndex = 1
  341. return
  342. }
  343. if(this.assembleNum <= 0) {
  344. this.popTitleMsg = '错误提示!!'
  345. this.popMsg = '输入的装配数量不能为0'
  346. this.$refs.popup.open('center')
  347. this.foucusIndex = 2
  348. return;
  349. }
  350. if(this.outTaskQty <= 0) {
  351. this.popTitleMsg = '错误提示!!'
  352. this.popMsg = '已出库数量为:0,无法进行装配'
  353. this.$refs.popup.open('center')
  354. return;
  355. }
  356. if((this.sapBomDtlMd.qty - this.sapBomDtlMd.outQty) < this.assembleNum) {
  357. this.popTitleMsg = '错误提示!!'
  358. this.popMsg = `输入的装配数量【${this.assembleNum}】大于需求数量【${this.sapBomDtlMd.qty - this.sapBomDtlMd.outQty}】,无法进行装配`
  359. this.$refs.popup.open('center')
  360. return;
  361. }
  362. if(this.outTaskQty < this.assembleNum) {
  363. this.popTitleMsg = '错误提示!!'
  364. this.popMsg = `输入的装配数量【${this.assembleNum}】大于已出库数量【${this.outTaskQty}】,无法进行装配`
  365. this.$refs.popup.open('center')
  366. return;
  367. }
  368. },
  369. resetData() {
  370. this.resetFoucus(0)
  371. this.scanBnSnCode = ''
  372. this.scanMaterialCode = ''
  373. this.assembleNum = 0
  374. this.outTaskQty = 0
  375. this.tipMsg = '等待扫码确认物料号......'
  376. this.imageSrc = ''
  377. this.previewImagePath = []
  378. },
  379. isEmptyStr(s) {
  380. if (s == undefined || s === '') {
  381. return true
  382. }
  383. return false
  384. },
  385. resetFoucus(index) {
  386. this.foucusIndex = 3
  387. setTimeout(() => {
  388. this.foucusIndex = index;
  389. }, 5)
  390. },
  391. getFoucus(index) {
  392. this.foucusIndex = index
  393. },
  394. chooseImage() {
  395. uni.chooseImage({
  396. count: 1,
  397. sizeType: ['compressed'],
  398. sourceType: ['camera'],
  399. success: (res) => {
  400. // console.log(res.tempFilePaths)
  401. // console.log('chooseImage success, temp path is', res.tempFilePaths[0])
  402. var imageSrc = res.tempFilePaths[0]
  403. this.previewImagePath = res.tempFilePaths
  404. this.imageSrc = imageSrc
  405. // console.log(` 11【${this.previewImagePath}】`)
  406. // console.log(` 22【${this.imageSrc}】`)
  407. },
  408. fail: (err) => {
  409. // console.log('chooseImage fail', err)
  410. }
  411. })
  412. },
  413. previewImage11() {
  414. // ToDo: 暂未实现 从后端获取图片并预览大图 孙亚龙 20230613
  415. // 预览图片
  416. uni.previewImage({
  417. urls: this.previewImagePath
  418. });
  419. }
  420. }
  421. }
  422. </script>
  423. <style lang="scss">
  424. @import '@/common/uni-nvue.css';
  425. .my-tips-view {
  426. margin-top: 5px;
  427. text-align: center;
  428. color: #aa007f;
  429. font-size: 20px;
  430. font-weight: bold;
  431. }
  432. .popup-content {
  433. // @include flex;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. padding: 15px;
  438. // height: 50px;
  439. background-color: #fff;
  440. }
  441. .text {
  442. font-size: 22px;
  443. color: #333;
  444. }
  445. .image {
  446. width: 100%;
  447. height: 100%;
  448. }
  449. .demo {
  450. // padding: 5rpx;
  451. margin-left: 8px;
  452. width: 245px;
  453. height: 210px;
  454. // border: 1px solid green;
  455. background-color: #fff;
  456. }
  457. .uni-hello-addfile:active {
  458. background-color: aliceblue;
  459. }
  460. .uni-hello-addfile {
  461. font-size: 45rpx;
  462. color: black;
  463. font-weight: bold;
  464. }
  465. </style>