show.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view>
  3. <uni-section title="">
  4. <view class="example">
  5. <uni-forms ref="form" :modelValue="item" labelWidth="80px" :rules="rules">
  6. <uni-forms-item label="装箱单号" name="FBillNo">
  7. <uni-easyinput v-model="item['FENCHASENUM.LT']" disabled>
  8. </uni-easyinput>
  9. </uni-forms-item>
  10. <uni-forms-item label="新装箱单号" name="Mdd">
  11. <uni-easyinput v-model="item['NewFENCHASENUM.LT']" @confirm="search">
  12. </uni-easyinput>
  13. </uni-forms-item>
  14. <uni-forms-item label="物料编码" name="Ch">
  15. <uni-easyinput v-model="item['FMaterialId.fnumber']" disabled />
  16. </uni-forms-item>
  17. <uni-forms-item label="实际作业数量" name="FActualQty">
  18. <uni-easyinput type="number" v-model="item.FActualQty" placeholder="实际作业数量" />
  19. </uni-forms-item>
  20. <uni-forms-item label="剩余数量">
  21. <uni-easyinput disabled v-model="remainingQuantity" placeholder="" />
  22. </uni-forms-item>
  23. <uni-forms-item label="即时库存数量" name="FInventoryQty">
  24. <uni-easyinput disabled v-model="item.FInventoryQty" placeholder="即时库存数量" />
  25. </uni-forms-item>
  26. <uni-forms-item label="生产车间" name="FWorkShopId.fname">
  27. <uni-easyinput disabled v-model="item['FWorkShopId.fname']" />
  28. </uni-forms-item>
  29. </uni-forms>
  30. <button type="primary" @click="submit()">确认</button>
  31. </view>
  32. </uni-section>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. getInfoByBarcode,
  38. getStockInfo
  39. } from '../../api/production_replenishment';
  40. import {
  41. playVoice,
  42. audioUrls
  43. } from '@/utils/audio.js'
  44. import modal from '../../plugins/modal';
  45. export default {
  46. onLoad(option) {
  47. const item = JSON.parse(decodeURIComponent(option.item))
  48. const index = JSON.parse(decodeURIComponent(option.index))
  49. console.log(item)
  50. console.log(index)
  51. this.item = item
  52. this.index = index
  53. },
  54. data() {
  55. return {
  56. item: {},
  57. index: '',
  58. isReplace: false,
  59. rules: {
  60. FActualQty: {
  61. rules: [{
  62. required: true,
  63. errorMessage: '请输入实发数量',
  64. },
  65. ]
  66. },
  67. },
  68. };
  69. },
  70. computed: {
  71. remainingQuantity() {
  72. console.log(this.item["FInventoryQty"] - this.item["FActualQty"])
  73. return Math.round((this.item["FInventoryQty"] - this.item["FActualQty"]) * 100) / 100;
  74. }
  75. },
  76. methods: {
  77. async search() {
  78. if (this.item['NewFENCHASENUM.LT'] == "") {
  79. uni.showToast({
  80. title: '请扫描条码',
  81. icon: 'none',
  82. duration: 3000
  83. })
  84. return
  85. }
  86. const data = {
  87. "parameters": [{
  88. "FormId": "LT_BD_MtlLotCodeMap",
  89. "FieldKeys": "FEntity_FSEQ,FMaterialId,FMaterialId.fnumber,FLot.FNumber,FLot,",
  90. "FilterString": [{
  91. "Left": "",
  92. "FieldName": "FNumber",
  93. "Compare": "67",
  94. // "Value": "T23091000852",
  95. "Value": this.item['NewFENCHASENUM.LT'],
  96. "Right": "",
  97. "Logic": 0
  98. }],
  99. "OrderString": "FEntity_FSEQ DESC",
  100. }]
  101. }
  102. this.$modal.loading('替换中,请耐心等待...');
  103. const firstResponse = await getInfoByBarcode(JSON.stringify(data))
  104. console.log(firstResponse)
  105. if (firstResponse.length === 0) {
  106. console.log("dafafadf")
  107. uni.showToast({
  108. title: '请确认条码有效!',
  109. duration: 2000,
  110. icon: 'none'
  111. });
  112. return; // 停止保存操作
  113. }
  114. if (firstResponse[0]["FMaterialId.fnumber"] != this.item["FMaterialId.fnumber"]) {
  115. console.log("dafafadf")
  116. uni.showToast({
  117. title: '编码与原物料编码不一致,请重新替换装箱单号',
  118. duration: 3000,
  119. icon: 'none'
  120. });
  121. playVoice(audioUrls.failVoiceUrl)
  122. return; // 停止保存操作
  123. }
  124. const data2 = {
  125. "parameters": [{
  126. "FormId": "STK_Inventory",
  127. "FieldKeys": "FAuxPropId.FF101501,FAuxPropId.FF101501.FDATAVALUE,FStockLocId.FF102029.fname,FBaseQty",
  128. "FilterString": [{
  129. "Left": "",
  130. "FieldName": "FMaterialId.FNumber",
  131. "Compare": "67",
  132. // "Value": "CAW04044-1611088-1",
  133. "Value": firstResponse[0]["FMaterialId.fnumber"],
  134. "Right": "",
  135. "Logic": 0
  136. },
  137. {
  138. "Left": "",
  139. "FieldName": "FLot.FNumber",
  140. "Compare": "67",
  141. // "Value": "智能工厂-智能1220/20230821&T23091000852&无&23122000002",
  142. "Value": firstResponse[0]["FLot.FNumber"],
  143. "Right": "",
  144. "Logic": 0
  145. },
  146. {
  147. "Left": "",
  148. "FieldName": "FBaseQty",
  149. "Compare": "21",
  150. "Value": "0",
  151. "Right": "",
  152. "Logic": 0
  153. }
  154. ],
  155. "OrderString": "",
  156. }]
  157. }
  158. const secondResponse = await getStockInfo(JSON.stringify(data2))
  159. if (secondResponse.length > 1) {
  160. this.handleError("即时库存存在多个仓位,不允许选择!")
  161. this.$modal.closeLoading()
  162. this.item['NewFENCHASENUM.LT'] = ""
  163. return
  164. }
  165. console.log("原item", this.item)
  166. this.item['FInventoryQty'] = secondResponse[0]["FBaseQty"]
  167. this.item['Flot.FNumber'] = firstResponse[0]["FLot.FNumber"]
  168. this.item['FAuxPropId.FF101501.FDATAVALUE'] = secondResponse[0]["FAuxPropId.FF101501.FDATAVALUE"]
  169. this.item['FStockLocId.FF102029.fname'] = secondResponse[0]["FStockLocId.FF102029.fname"]
  170. this.item['smzt'] = 1
  171. console.log("替换后item", this.item)
  172. console.log(secondResponse)
  173. this.isReplace = true
  174. this.$modal.closeLoading()
  175. uni.showToast({
  176. title: '替换成功',
  177. icon: 'none',
  178. duration: 3000
  179. })
  180. playVoice(audioUrls.successVoiceUrl)
  181. },
  182. submit() {
  183. this.$refs.form.validate().then(res => {
  184. if (this.item["FActualQty"] < 0) {
  185. uni.showToast({
  186. title: '实发数量不能小于0',
  187. icon: 'none',
  188. duration: 3000
  189. })
  190. return
  191. }
  192. console.log(typeof this.item["NewFENCHASENUM.LT"])
  193. if ((typeof this.item["NewFENCHASENUM.LT"] != "undefined" && this.item["NewFENCHASENUM.LT"] !=
  194. "") && this.isReplace == false) {
  195. uni.showToast({
  196. title: '装箱单号未替换',
  197. icon: 'none',
  198. duration: 3000
  199. })
  200. return
  201. }
  202. console.log(this.item)
  203. this.item["index"] = this.index
  204. let self = this
  205. uni.navigateBack({
  206. success: function() {
  207. // 传递数据给上一页
  208. uni.$emit('item', self.item);
  209. }
  210. });
  211. }).catch(err => {
  212. console.log(err);
  213. })
  214. },
  215. handleError(error) {
  216. playVoice(audioUrls.failVoiceUrl)
  217. console.error('操作失败:', error);
  218. modal.confirm(error).then(res => {
  219. if (res) {
  220. } else {
  221. // 用户点击取消,不执行任何操作
  222. }
  223. })
  224. // uni.showToast({
  225. // title: error.message || '操作失败',
  226. // duration: 3000,
  227. // icon: "none"
  228. // });
  229. // playVoice(audioUrls.failVoiceUrl)
  230. // console.error('操作失败:', error);
  231. },
  232. }
  233. };
  234. </script>
  235. <style>
  236. /deep/ .is-disabled {
  237. background-color: #ffffff !important;
  238. color: #0d0d0d !important;
  239. }
  240. .example {
  241. padding-left: 10px;
  242. padding-right: 10px;
  243. background-color: #fff;
  244. }
  245. .segmented-control {
  246. margin-bottom: 15px;
  247. }
  248. .button-group {
  249. margin-top: 15px;
  250. display: flex;
  251. justify-content: space-around;
  252. }
  253. .form-item {
  254. display: flex;
  255. align-items: center;
  256. }
  257. .button {
  258. display: flex;
  259. align-items: center;
  260. height: 35px;
  261. margin-left: 10px;
  262. }
  263. </style>