outassembleOperate.vue 15 KB

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