outassembleOperate.vue 15 KB

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