show.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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="inputFENCHASENUM" 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="inputMaterial" disabled />
  16. </uni-forms-item>
  17. <uni-forms-item label="实际作业数量" :name="fieldName">
  18. <uni-easyinput type="number" v-model="inputValue" placeholder="实际作业数量" />
  19. </uni-forms-item>
  20. <uni-forms-item label="剩余数量" v-if="showRemainingQuantity">
  21. <uni-easyinput disabled v-model="remainingQuantity" placeholder="" />
  22. </uni-forms-item>
  23. <uni-forms-item label="即时库存数量" name="FInventoryQty" v-if="showFInventoryQty">
  24. <uni-easyinput disabled v-model="InventoryQtyValue" placeholder="即时库存数量" />
  25. </uni-forms-item>
  26. <uni-forms-item label="生产车间" name="FWorkShopId.fname" v-if="showWorkShop">
  27. <uni-easyinput disabled v-model="item['FWorkShopId.fname']" />
  28. </uni-forms-item>
  29. <uni-forms-item label="仓位" name="FStockLocId.FF102029.fname" v-if="showLocation">
  30. <uni-easyinput disabled v-model="item['FStockLocId.FF102029.fname']" />
  31. </uni-forms-item>
  32. <uni-forms-item label="采购员" name="FPURCHASERID.fname" v-if="formId === 'PUR_MRB'">
  33. <uni-easyinput disabled v-model="item['FPURCHASERID.fname']" />
  34. </uni-forms-item>
  35. </uni-forms>
  36. <button type="primary" @click="submit()">确认</button>
  37. </view>
  38. </uni-section>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. getInfoByBarcode,
  44. getStockInfo
  45. } from '../../api/production_replenishment';
  46. import {
  47. playVoice,
  48. audioUrls
  49. } from '@/utils/audio.js'
  50. import modal from '../../uni_modules/uview-ui/libs/config/props/modal';
  51. export default {
  52. onLoad(option) {
  53. this.formId = uni.getStorageSync("formId")
  54. const item = JSON.parse(decodeURIComponent(option.item))
  55. const index = JSON.parse(decodeURIComponent(option.index))
  56. console.log(item)
  57. console.log(index)
  58. this.item = item
  59. this.index = index
  60. },
  61. data() {
  62. return {
  63. formId: '',
  64. item: {},
  65. index: '',
  66. isReplace: false,
  67. rules: {
  68. FActualQty: {
  69. rules: [{
  70. required: true,
  71. errorMessage: '请输入实发数量',
  72. },
  73. ]
  74. },
  75. FQty: {
  76. rules: [{
  77. required: true,
  78. errorMessage: '请输入实发数量',
  79. }, {
  80. validateFunction: function(rule, value, data, callback) {
  81. if (value < 0) {
  82. callback('实际作业数量不能小于0')
  83. }
  84. return true
  85. }
  86. }
  87. ]
  88. },
  89. FRMREALQTY: {
  90. rules: [{
  91. required: true,
  92. errorMessage: '请输入实际作业数量',
  93. }, {
  94. validateFunction: function(rule, value, data, callback) {
  95. if (value < 0) {
  96. callback('实际作业数量不能小于0')
  97. }
  98. return true
  99. }
  100. }
  101. ]
  102. },
  103. FRealQty: {
  104. rules: [{
  105. required: true,
  106. errorMessage: '请输入实际作业数量',
  107. }, {
  108. validateFunction: function(rule, value, data, callback) {
  109. if (value < 0) {
  110. callback('实际作业数量不能小于0')
  111. }
  112. return true
  113. }
  114. }
  115. ]
  116. },
  117. FSumActualQty: {
  118. rules: [{
  119. required: true,
  120. errorMessage: '请输入实际作业数量',
  121. }, {
  122. validateFunction: function(rule, value, data, callback) {
  123. if (value < 0) {
  124. callback('实际作业数量不能小于0')
  125. }
  126. return true
  127. }
  128. }
  129. ]
  130. },
  131. },
  132. };
  133. },
  134. computed: {
  135. remainingQuantity() {
  136. console.log(this.item["FInventoryQty"] - this.item["FActualQty"])
  137. if (this.formId === 'LT_PRD_PMCWorkBench' || this.formId === 'SP_PickMtrl') {
  138. return Math.round((this.item["FInventoryQty"] - this.item["FActualQty"]) * 100) / 100;
  139. }
  140. if (this.formId === 'STK_MisDelivery' || this.formId === 'STK_OEMInStockRETURN') {
  141. return Math.round((this.item["FInventoryQty"] - this.item["FQty"]) * 100) / 100;
  142. }
  143. if (this.formId === 'SAL_OUTSTOCK') {
  144. return Math.round((this.item["FInventoryQty.LT"] - this.item["FRealQty"]) * 100) / 100;
  145. }
  146. },
  147. fieldName() {
  148. if (this.formId === 'LT_PRD_PMCWorkBench' || (this.formId === 'SP_PickMtrl' && uni.getStorageSync(
  149. "fbillType") !== "B")) {
  150. return 'FActualQty';
  151. } else if (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") == "B") {
  152. return 'FSumActualQty';
  153. } else if (this.formId === 'STK_MisDelivery') {
  154. return 'FQty';
  155. } else if (this.formId === 'PUR_MRB') {
  156. return 'FRMREALQTY';
  157. } else if (this.formId === 'SAL_OUTSTOCK') {
  158. return 'FRealQty';
  159. } else {
  160. return 'FQty';
  161. }
  162. },
  163. inputFENCHASENUM: {
  164. get() {
  165. if (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") == "B") {
  166. return this.item["FSumEnchaseNum.LT"];
  167. } else {
  168. return this.item["FENCHASENUM.LT"];
  169. }
  170. },
  171. set(value) {
  172. if (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") == "B") {
  173. this.item["FSumEnchaseNum.LT"] = value;
  174. } else {
  175. this.item["FENCHASENUM.LT"] = value;
  176. }
  177. }
  178. },
  179. inputMaterial: {
  180. get() {
  181. if (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") == "B") {
  182. return this.item["FSumMaterialId.fnumber"];
  183. } else {
  184. return this.item["FMaterialId.fnumber"];
  185. }
  186. },
  187. set(value) {
  188. if (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") == "B") {
  189. this.item["FSumMaterialId.fnumber"] = value;
  190. } else {
  191. this.item["FMaterialId.fnumber"] = value;
  192. }
  193. }
  194. },
  195. inputValue: {
  196. get() {
  197. if (this.formId === 'LT_PRD_PMCWorkBench' || (this.formId === 'SP_PickMtrl' && uni.getStorageSync(
  198. "fbillType") !== "B")) {
  199. return this.item.FActualQty;
  200. } else if (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") == "B") {
  201. return this.item.FSumActualQty;
  202. } else if (this.formId === 'STK_MisDelivery') {
  203. return this.item.FQty;
  204. } else if (this.formId === 'PUR_MRB') {
  205. return this.item.FRMREALQTY;
  206. } else if (this.formId === 'SAL_OUTSTOCK') {
  207. return this.item.FRealQty;
  208. } else {
  209. return this.item.FQty;
  210. }
  211. },
  212. set(value) {
  213. if (this.formId === 'LT_PRD_PMCWorkBench' || (this.formId === 'SP_PickMtrl' && uni.getStorageSync(
  214. "fbillType") !== "B")) {
  215. this.item.FActualQty = value;
  216. } else if (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") == "B") {
  217. return this.item.FSumActualQty = value;
  218. } else if (this.formId === 'STK_MisDelivery' || this.formId === 'STK_OEMInStockRETURN') {
  219. this.item.FQty = value;
  220. } else if (this.formId === 'PUR_MRB') {
  221. this.item.FRMREALQTY = value;
  222. } else if (this.formId === 'SAL_OUTSTOCK') {
  223. this.item.FRealQty = value;
  224. }
  225. }
  226. },
  227. InventoryQtyValue: {
  228. get() {
  229. switch (this.formId) {
  230. case 'SAL_OUTSTOCK':
  231. return this.item["FInventoryQty.LT"];
  232. default:
  233. return this.item.FInventoryQty;
  234. }
  235. },
  236. set(value) {
  237. switch (this.formId) {
  238. // case 'LT_PRD_PMCWorkBench':
  239. // case 'SP_PickMtrl':
  240. // this.item.FActualQty = value;
  241. // break;
  242. // case 'STK_MisDelivery':
  243. // case 'STK_OEMInStockRETURN':
  244. // this.item.FQty = value;
  245. // break;
  246. // case 'PUR_MRB':
  247. // this.item.FRMREALQTY = value;
  248. // break;
  249. // case 'SAL_OUTSTOCK':
  250. // this.item.FRealQty = value;
  251. // break;
  252. case 'SAL_OUTSTOCK':
  253. return this.item["FInventoryQty.LT"] = value;
  254. default:
  255. return this.item.FInventoryQty = value;
  256. }
  257. }
  258. },
  259. showRemainingQuantity() {
  260. return this.formId !== 'PUR_MRB' && (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") !=
  261. "B")
  262. },
  263. showFInventoryQty() {
  264. return this.formId !== 'PUR_MRB' && (this.formId === 'SP_PickMtrl' && uni.getStorageSync("fbillType") !=
  265. "B")
  266. },
  267. showWorkShop() {
  268. return this.formId !== 'PUR_MRB' && this.formId !== 'SAL_OUTSTOCK' && this.formId !==
  269. 'STK_OEMInStockRETURN'
  270. },
  271. showLocation() {
  272. return this.formId === 'PUR_MRB' || this.formId === 'STK_OEMInStockRETURN'
  273. },
  274. },
  275. methods: {
  276. async search() {
  277. if (this.item['NewFENCHASENUM.LT'] == "") {
  278. uni.showToast({
  279. title: '请扫描条码',
  280. icon: 'none',
  281. duration: 3000
  282. })
  283. return
  284. }
  285. const data = {
  286. "parameters": [{
  287. "FormId": "LT_BD_MtlLotCodeMap",
  288. "FieldKeys": "FEntity_FSEQ,FMaterialId,FMaterialId.fnumber,FLot.FNumber,FLot,",
  289. "FilterString": [{
  290. "Left": "",
  291. "FieldName": "FNumber",
  292. "Compare": "67",
  293. // "Value": "T23091000852",
  294. "Value": this.item['NewFENCHASENUM.LT'],
  295. "Right": "",
  296. "Logic": 0
  297. }],
  298. "OrderString": "FEntity_FSEQ DESC",
  299. }]
  300. }
  301. this.$modal.loading('替换中,请耐心等待...');
  302. const firstResponse = await getInfoByBarcode(JSON.stringify(data))
  303. console.log(firstResponse)
  304. if (firstResponse.length === 0) {
  305. console.log("dafafadf")
  306. uni.showToast({
  307. title: '请确认条码有效!',
  308. duration: 2000,
  309. icon: 'none'
  310. });
  311. return; // 停止保存操作
  312. }
  313. if (firstResponse[0]["FMaterialId.fnumber"] != (this.item["FMaterialId.fnumber"]||this.item["FSumMaterialId.fnumber"])) {
  314. console.log("dafafadf")
  315. uni.showToast({
  316. title: '编码与原物料编码不一致,请重新替换装箱单号',
  317. duration: 3000,
  318. icon: 'none'
  319. });
  320. playVoice(audioUrls.failVoiceUrl)
  321. return; // 停止保存操作
  322. }
  323. const data2 = {
  324. "parameters": [{
  325. "FormId": "STK_Inventory",
  326. "FieldKeys": "FAuxPropId.FF101501,FAuxPropId.FF101501.FDATAVALUE,FStockLocId.FF102029.fname,FBaseQty",
  327. "FilterString": [{
  328. "Left": "",
  329. "FieldName": "FMaterialId.FNumber",
  330. "Compare": "67",
  331. // "Value": "CAW04044-1611088-1",
  332. "Value": firstResponse[0]["FMaterialId.fnumber"],
  333. "Right": "",
  334. "Logic": 0
  335. },
  336. {
  337. "Left": "",
  338. "FieldName": "FLot.FNumber",
  339. "Compare": "67",
  340. // "Value": "智能工厂-智能1220/20230821&T23091000852&无&23122000002",
  341. "Value": firstResponse[0]["FLot.FNumber"],
  342. "Right": "",
  343. "Logic": 0
  344. },
  345. {
  346. "Left": "",
  347. "FieldName": "FBaseQty",
  348. "Compare": "21",
  349. "Value": "0",
  350. "Right": "",
  351. "Logic": 0
  352. }
  353. ],
  354. "OrderString": "",
  355. }]
  356. }
  357. const secondResponse = await getStockInfo(JSON.stringify(data2))
  358. if (secondResponse.length > 1) {
  359. this.handleError("即时库存存在多个仓位,不允许选择!")
  360. this.$modal.closeLoading()
  361. this.item['NewFENCHASENUM.LT'] = ""
  362. return
  363. }
  364. console.log("原item", this.item)
  365. if (this.formId === 'SAL_OUTSTOCK') {
  366. this.item['FInventoryQty.LT'] = secondResponse[0]["FBaseQty"]
  367. } else {
  368. this.item['FInventoryQty'] = secondResponse[0]["FBaseQty"]
  369. }
  370. let lotFieldName = this.item.hasOwnProperty('FSumLot.FNumber') ? 'FSumLot.FNumber' : 'Flot.FNumber';
  371. let FAuxPropIdFieldName = this.item.hasOwnProperty('FSumAuxPropId.FF101501.FNumber') ? 'FSumAuxPropId.FF101501.FNumber' : 'FAuxPropId.FF101501.FDATAVALUE';
  372. let FStockLocIdFieldName = this.item.hasOwnProperty('FSumStockLocId.FF102029.fname') ? 'FSumStockLocId.FF102029.fname' : 'FStockLocId.FF102029.fname';
  373. this.item[lotFieldName] = firstResponse[0]["FLot.FNumber"];
  374. this.item[FAuxPropIdFieldName] = secondResponse[0]["FAuxPropId.FF101501.FDATAVALUE"]
  375. this.item[FStockLocIdFieldName] = secondResponse[0]["FStockLocId.FF102029.fname"]
  376. this.item['smzt'] = 1
  377. console.log("替换后item", this.item)
  378. console.log(secondResponse)
  379. this.isReplace = true
  380. this.$modal.closeLoading()
  381. uni.showToast({
  382. title: '替换成功',
  383. icon: 'none',
  384. duration: 3000
  385. })
  386. playVoice(audioUrls.successVoiceUrl)
  387. },
  388. handleError(error) {
  389. playVoice(audioUrls.failVoiceUrl)
  390. console.error('操作失败:', error);
  391. modal.confirm(error).then(res => {
  392. if (res) {} else {}
  393. })
  394. },
  395. submit() {
  396. this.$refs.form.validate().then(res => {
  397. if (this.item["FActualQty"] < 0) {
  398. uni.showToast({
  399. title: '实发数量不能小于0',
  400. icon: 'none',
  401. duration: 3000
  402. })
  403. return
  404. }
  405. console.log(typeof this.item["NewFENCHASENUM.LT"])
  406. if ((typeof this.item["NewFENCHASENUM.LT"] != "undefined" && this.item["NewFENCHASENUM.LT"] !=
  407. "") && this.isReplace == false) {
  408. uni.showToast({
  409. title: '装箱单号未替换',
  410. icon: 'none',
  411. duration: 3000
  412. })
  413. return
  414. }
  415. console.log(this.item)
  416. this.item["index"] = this.index
  417. let self = this
  418. uni.navigateBack({
  419. success: function() {
  420. // 传递数据给上一页
  421. uni.$emit('item', self.item);
  422. }
  423. });
  424. }).catch(err => {
  425. console.log(err);
  426. })
  427. },
  428. }
  429. };
  430. </script>
  431. <style>
  432. /deep/ .is-disabled {
  433. background-color: #ffffff !important;
  434. color: #0d0d0d !important;
  435. }
  436. .example {
  437. padding-left: 10px;
  438. padding-right: 10px;
  439. background-color: #fff;
  440. }
  441. .segmented-control {
  442. margin-bottom: 15px;
  443. }
  444. .button-group {
  445. margin-top: 15px;
  446. display: flex;
  447. justify-content: space-around;
  448. }
  449. .form-item {
  450. display: flex;
  451. align-items: center;
  452. }
  453. .button {
  454. display: flex;
  455. align-items: center;
  456. height: 35px;
  457. margin-left: 10px;
  458. }
  459. </style>