show.vue 8.8 KB

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