index.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  1. <template>
  2. <view>
  3. <view class="sticky-box">
  4. <view class="button-group" v-if="isCreate === false">
  5. <button type="default" @click="reset">取消</button>
  6. <!-- <button type="default" @click="navigateToSummary">统计</button> -->
  7. <button type="default" @click="navigateToSearch">查询</button>
  8. <button type="default" @click="navigateToStage">暂存</button>
  9. <button type="default" @click="navigateToSearch">提交</button>
  10. </view>
  11. <view class="button-group" v-else>
  12. <button type="default" @click="reset">取消</button>
  13. <button type="default" @click="submit">提交</button>
  14. </view>
  15. <uni-easyinput prefixIcon="search" :focus="isFocus" v-model="searchValue" @blur="isFocus = false"
  16. @confirm="getIsCreate()" @clear="clear" :placeholder="isCreate ? '请扫描条形码' : '请扫描拼件单号'">
  17. </uni-easyinput>
  18. </view>
  19. <view>
  20. <u-picker :show="showPicker" :columns="depotList" keyName="FStockLocId.FF102029.FName" @confirm="pickDepot"
  21. title="仓位选择"></u-picker>
  22. </view>
  23. <view class="table-container" style="height: 100vh;">
  24. <scroll-view class="table-content" :style="{'height': clientHeight + 'px'}" scroll-x scroll-y
  25. :scroll-into-view="scrollItem">
  26. <!-- 表头-正常-->
  27. <view class="table-header" v-if="!isCreate">
  28. <view class="table-cell">操作</view>
  29. <view class="table-cell">扫描状态</view>
  30. <view class="table-cell">调出仓位</view>
  31. <view class="table-cellwl">物料编码</view>
  32. <view class="table-cell1">装箱单号</view>
  33. <view class="table-cell1">调拨数量</view>
  34. <view class="table-cell1">箱号</view>
  35. <view class="table-cell1">等级</view>
  36. <view class="table-cellph">批号</view>
  37. <view class="table-cell2">总件数</view>
  38. <view class="table-cell">备注</view>
  39. <view class="table-cell2">仓位原件数</view>
  40. <view class="table-cell">发货件数</view>
  41. <view class="table-cell3">单据编号</view>
  42. <view class="table-cell">仓管员</view>
  43. </view>
  44. <!-- 表头-生成-->
  45. <view class="table-header" v-else>
  46. <view class="table-cell">操作</view>
  47. <view class="table-cell2">条形码</view>
  48. <view class="table-cell2">调出仓位</view>
  49. <view class="table-cell2">调入仓位</view>
  50. </view>
  51. <view v-if="!isCreate">
  52. <view class="table-row" v-for="(item, index) in indexList" :key="index" :id="'scrollItem-' + index"
  53. :style="getStyle(item.smzt)">
  54. <view class="table-cell">
  55. <button type="default" size="mini" @click="edit(item,index)">编辑</button>
  56. </view>
  57. <view class="table-cell">{{ item.smzt? '已扫描' : '未扫描' }}</view>
  58. <view class="table-cell">{{ item["FSrcStockLocId.FF102029.FName"] }}</view>
  59. <view class="table-cellwl" :style="getStyle(item.smzt)">{{ item["FMaterialId.FNumber"] }}</view>
  60. <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FENCHASENUM.LT"] }}</view>
  61. <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FQty"] }}</view>
  62. <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FBOXNO.LT"] }}</view>
  63. <view class="table-cell1" :style="getStyle(item.smzt)">
  64. {{ item["FAuxPropId.FF101501.FDataValue"] }}
  65. </view>
  66. <view class="table-cellph" :style="getStyle(item.smzt)">{{ item["FLot.FNumber"] }}</view>
  67. <view class="table-cell2" :style="getStyle(item.smzt)">{{ item["rowCount"] }}</view>
  68. <view class="table-cell" :style="getStyle(item.smzt)">{{ item["FNoteEntry"] }}</view>
  69. <view class="table-cell2" :style="getStyle(item.smzt)">{{ item["quantity"] }}</view>
  70. <view class="table-cell" :style="getStyle(item.smzt)">{{ item["rowCount"] }}</view>
  71. <view class="table-cell3" :style="getStyle(item.smzt)">{{ item["FBillNo"] }}</view>
  72. <view class="table-cell" :style="getStyle(item.smzt)">{{ item["FStockerId.FName"] }}</view>
  73. </view>
  74. </view>
  75. <view v-else>
  76. <view class="table-row" v-for="(item) in indexList" :key="item.FCMKBarCode"
  77. :id="'scrollItem-' + item.index">
  78. <view class="table-cell">
  79. <button type="default" size="mini" @click="edit(item,item.index)">编辑</button>
  80. </view>
  81. <view class="table-cell2">{{ item["FCMKBarCode"] }}</view>
  82. <view class="table-cell2">{{ item["FStockLocId.FF102029.FName"] }}</view>
  83. <view class="table-cell2">{{ item["FDestStockLocId.FF102029.FNumber"] }}</view>
  84. </view>
  85. </view>
  86. </scroll-view>
  87. </view>
  88. <view style="height: 200px;touch-action: none;"></view>
  89. <view class="card-bottom" style="">
  90. <view style="margin: 0 auto;">
  91. <!-- <view class="input-select">
  92. <uni-data-select v-model="loginForm.acctID" :localdata="range" @change="change"
  93. :clear="false"></uni-data-select>
  94. </view> -->
  95. <view v-if="!isCreate"
  96. style="display: flex;flex-direction: row;margin-top: 8px;font-size: 12px;margin-right: 15px;margin-bottom: 8px;">
  97. <view style="margin-right: 15px;">源单明细:{{ indexList.length }}</view>
  98. <view style="margin-right: 15px;">已扫描:{{ indexListLength }}</view>
  99. <!-- <view>剩余件数:{{ balance }}</view> -->
  100. </view>
  101. <view v-else
  102. style="display: flex;flex-direction: row;margin-top: 8px;font-size: 12px;margin-right: 15px;margin-bottom: 8px;">
  103. <view style="margin-right: 15px;">已扫描:{{ indexListLength }}</view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import {
  111. audit,
  112. getInventoryList,
  113. save,
  114. submit,
  115. getBillList
  116. } from '../../api/production_replenishment';
  117. import modal from '../../plugins/modal';
  118. import {
  119. playVoice,
  120. audioUrls,
  121. playSequentially
  122. } from '../../utils/audio2';
  123. import {
  124. getAuditParam,
  125. getSaveParam,
  126. getSubmitParam
  127. } from '../../utils/params';
  128. import submitHelper from '@/utils/commonSubmitHelper.js'; // 确保路径正确
  129. import {
  130. executeSql
  131. } from '../../utils/database';
  132. import {
  133. createInventoryQueryRequest,
  134. getFLotFNumber,
  135. getInventory
  136. } from '@/utils/transferparams.js';
  137. export default {
  138. onShow() {
  139. const res = uni.getSystemInfo({
  140. success: (res => {
  141. console.log(res.windowHeight)
  142. if (res.windowHeight < 600) {
  143. this.clientHeight = 580
  144. } else {
  145. this.clientHeight = res.windowHeight - 150;
  146. }
  147. console.log(res.windowHeight)
  148. console.log(this.clientHeight)
  149. // console.log(getApp().globalData.navHeight)
  150. })
  151. });
  152. this.$nextTick(() => {
  153. this.searchValue = ''
  154. this.isFocus = true;
  155. })
  156. },
  157. computed: {
  158. //已扫描数量
  159. indexListLength() {
  160. console.log("执行了计算属性")
  161. console.log(this.indexList.filter(obj => obj.smzt === 1).length)
  162. return this.indexList.filter(obj => obj.smzt === 1).length
  163. },
  164. //剩余数量
  165. indexList2Length() {
  166. let arr1 = this.indexList.filter((item, index, self) => {
  167. return item.smzt == 0
  168. })
  169. console.log(arr1)
  170. return arr1.length
  171. },
  172. //正操作仓位未扫描数量
  173. indexList3Length() {
  174. return this.indexList.filter(item =>
  175. item["FSrcStockLocId.FF102029.FName"] == this.Location && item['smzt'] != 1
  176. ).length
  177. },
  178. showWorkCenter() {
  179. return this.formId !== 'PUR_MRB';
  180. },
  181. showRemark() {
  182. return this.formId !== 'PUR_MRB';
  183. },
  184. showApplicant() {
  185. return this.formId !== 'PUR_MRB';
  186. }
  187. },
  188. mounted() {
  189. // 页面加载完成后滚动到目标数据位置
  190. uni.$on('scrollIntoView', (target) => {
  191. this.$nextTick(() => {
  192. // 使用id属性定位
  193. uni.createSelectorQuery().select('#' + target).boundingClientRect().exec((rect) => {
  194. console.log(rect)
  195. uni.pageScrollTo({
  196. scrollTop: rect[0].top - 95,
  197. duration: 0
  198. });
  199. });
  200. });
  201. })
  202. this.$nextTick(() => {
  203. this.searchValue = ''
  204. this.isFocus = true;
  205. })
  206. },
  207. //监听
  208. watch: {
  209. Location(newValue, oldValue) {
  210. console.log(`Location changed from ${oldValue} to ${newValue}`)
  211. this.Location = newValue
  212. // 可以在这里执行相应的操作
  213. },
  214. indexList(newValue, oldValue) {
  215. console.log(`Location changed from ${oldValue} to ${newValue}`)
  216. this.indexList = newValue
  217. // 可以在这里执行相应的操作
  218. },
  219. },
  220. data() {
  221. return {
  222. formId: '',
  223. fbillType: '',
  224. isFocus: true,
  225. indexList: [],
  226. clientHeight: '',
  227. searchValue: '',
  228. scrollItem: '', // 滚动到的指定元素
  229. color: '',
  230. Location: '', //正操作仓位
  231. uniqueFStockLocId: [],
  232. balance: 0,
  233. isStage: false,
  234. stageIds: [],
  235. stageLists: [],
  236. tableName: "common_bill",
  237. destStockLocId: '',
  238. isCreate: false,
  239. showPicker: false,
  240. depotList: [],
  241. };
  242. },
  243. //获取上一页传过来的参数
  244. onLoad(option) {
  245. this.formId = uni.getStorageSync("formId")
  246. this.fbillType = uni.getStorageSync("fbillType");
  247. this.isCreate = option.isCreate || false
  248. console.log(option.isCreate)
  249. console.log(this.formId)
  250. console.log(this.fbillType)
  251. uni.setNavigationBarTitle({
  252. title: uni.getStorageSync("moudleName")
  253. });
  254. uni.$on('item', (data) => {
  255. console.log(data)
  256. let index = data["index"]
  257. this.indexList[index]['FQty'] = data["FQty"]
  258. if ("NewFENCHASENUM.LT" in data) {
  259. this.indexList[index]["FENCHASENUM.LT"] = data["NewFENCHASENUM.LT"]
  260. }
  261. if (this.indexList[index]["FSrcStockLocId.FF102029.FName"] != data[
  262. "FSrcStockLocId.FF102029.FName"]) {
  263. const requestData = createInventoryQueryRequest(data["FSrcStockLocId.FF102029.FName"])
  264. getInventoryList(JSON.stringify(requestData)).then(res => {
  265. this.indexList[index]["quantity"] = res.length
  266. console.log("修改了原仓位条数", res.length)
  267. this.indexList[index]['FSrcStockLocId.FF102029.FName'] = data[
  268. "FSrcStockLocId.FF102029.FName"]
  269. // 用于记录每个组合的计数
  270. let countMap = {};
  271. // 统计每个组合的行数
  272. this.indexList.forEach(obj => {
  273. // 获取当前对象的组合键
  274. let key = obj.FBillNo + '|' + obj['FSrcStockLocId.FF102029.FName'];
  275. // 如果该组合已经存在于 countMap 中,则增加计数,否则初始化为 1
  276. if (countMap[key]) {
  277. countMap[key]++;
  278. } else {
  279. countMap[key] = 1;
  280. }
  281. });
  282. // 将计数值添加到每个对象中
  283. this.indexList.forEach(obj => {
  284. let key = obj.FBillNo + '|' + obj['FSrcStockLocId.FF102029.FName'];
  285. obj.rowCount = countMap[key];
  286. });
  287. })
  288. }
  289. this.indexList[index]['FInventoryQty'] = data["FInventoryQty"]
  290. // 定义一个映射对象
  291. const formIdMap = {
  292. 'STK_TransferDirect': 'FQty',
  293. };
  294. // 获取对应的字段名称
  295. const field = formIdMap[this.formId];
  296. // 如果存在匹配的字段,则更新 indexList
  297. if (field) {
  298. this.indexList[index][field] = data[field];
  299. }
  300. console.log(this.indexList[index])
  301. this.$nextTick(() => {
  302. this.searchValue = ''
  303. this.isFocus = true
  304. })
  305. })
  306. uni.$on('search', (data) => {
  307. console.log(data)
  308. this.indexList = data
  309. this.indexList.forEach(item => {
  310. // item.smzt = 0; // 增加属性 smzt,并设置初始值为0
  311. this.$set(item, 'smzt', 0);
  312. })
  313. // 用于记录每个组合的计数
  314. let countMap = {};
  315. // 统计每个组合的行数
  316. this.indexList.forEach(obj => {
  317. // 获取当前对象的组合键
  318. let key = obj.FBillNo + '|' + obj['FSrcStockLocId.FF102029.FName'];
  319. // 如果该组合已经存在于 countMap 中,则增加计数,否则初始化为 1
  320. if (countMap[key]) {
  321. countMap[key]++;
  322. } else {
  323. countMap[key] = 1;
  324. }
  325. });
  326. // 将计数值添加到每个对象中
  327. this.indexList.forEach(obj => {
  328. let key = obj.FBillNo + '|' + obj['FSrcStockLocId.FF102029.FName'];
  329. // obj.rowCount = countMap[key];
  330. this.$set(obj, 'rowCount', countMap[key])
  331. });
  332. // 1. 提取不同的仓位
  333. this.uniqueFStockLocId = [...new Set(this.indexList.map(obj => obj[
  334. 'FSrcStockLocId.FF102029.FName']))];
  335. // this.processQuantity(this.uniqueFStockLocId[0])
  336. this.updateIndexList(this.indexList)
  337. this.$nextTick(() => {
  338. this.searchValue = ''
  339. this.isFocus = true;
  340. })
  341. })
  342. uni.$on('summary', (data) => {
  343. console.log(data)
  344. this.indexList = data
  345. this.searchValue = ''
  346. this.isFocus = true;
  347. })
  348. uni.$on('stage', (data) => {
  349. console.log(data)
  350. // 处理每个对象
  351. this.stageLists = data.map(item => {
  352. // 解析 data 字段
  353. const parsedData = JSON.parse(item.data);
  354. // 返回处理后的对象
  355. return {
  356. ...item,
  357. data: parsedData
  358. };
  359. });
  360. this.stageIds = data.map(item => item.id)
  361. // this.stageLists = data.map(item => item.data)
  362. console.log(this.stageIds)
  363. console.log(this.stageLists)
  364. // 解析字符串为数组并合并
  365. const combinedArray = this.stageLists
  366. .map(item => item.data) // 解析每个字符串
  367. .flat(); // 合并所有数组
  368. console.log(combinedArray);
  369. this.indexList = combinedArray
  370. this.searchValue = ''
  371. this.isFocus = true;
  372. this.isStage = true
  373. })
  374. uni.$on('selectStock', (data) => {
  375. const index = this.indexList.findIndex(item => item.FCMKBarCode === data.FCMKBarCode);
  376. if (index !== -1) {
  377. this.indexList[index] = data;
  378. }
  379. console.log(this.indexList)
  380. })
  381. this.$nextTick(() => {
  382. console.log('dddd')
  383. this.searchValue = ''
  384. this.isFocus = true;
  385. })
  386. // this.$forceUpdate()
  387. },
  388. methods: {
  389. getActualWorkQuantity(item) {
  390. switch (this.formId) {
  391. case 'LT_PRD_PMCWorkBench':
  392. case 'SP_PickMtrl':
  393. return item["FActualQty"];
  394. case 'STK_MisDelivery':
  395. return item["FQty"];
  396. case 'PUR_MRB':
  397. return item["FRMREALQTY"];
  398. default:
  399. return item["FQty"];
  400. }
  401. },
  402. getFabricOrderNo(item) {
  403. switch (this.formId) {
  404. case 'PUR_MRB':
  405. return item["FFabricOrderNo"];
  406. default:
  407. return item["FFabricOrderNo.LT"];
  408. }
  409. },
  410. getWorkCenterName(item) {
  411. switch (this.formId) {
  412. case 'LT_PRD_PMCWorkBench':
  413. return item["FEWorkCenterId.LT.fname"];
  414. case 'STK_MisDelivery':
  415. case 'SP_PickMtrl':
  416. return item["FWorkCenterId.fname"];
  417. default:
  418. return '';
  419. }
  420. },
  421. getApplicantName(item) {
  422. switch (this.formId) {
  423. case 'LT_PRD_PMCWorkBench':
  424. return item["FApplicantId.fname"];
  425. case 'STK_MisDelivery':
  426. return item["FPickingPeople.LT.fname"];
  427. case 'SP_PickMtrl':
  428. return item["FPickerId.fname"];
  429. default:
  430. return ''; // 默认返回值,可以根据需求调整
  431. }
  432. },
  433. async updateIndexList(data1) {
  434. try {
  435. // 存储所有的异步操作 promise
  436. let promises = [];
  437. // 遍历 uniqueFStockLocId 数组
  438. for (let fname of this.uniqueFStockLocId) {
  439. const requestData = createInventoryQueryRequest(fname)
  440. // 发起异步请求,并将 promise 存储在数组中
  441. let promise = getInventoryList(JSON.stringify(requestData)).then(res => {
  442. let objs = data1.filter(item => item['FSrcStockLocId.FF102029.FName'] === fname);
  443. objs.forEach(obj => {
  444. this.$set(obj, 'quantity', res.length);
  445. });
  446. });
  447. promises.push(promise);
  448. }
  449. // 等待所有异步操作完成
  450. await Promise.all(promises)
  451. console.log(data1)
  452. this.indexList = data1
  453. console.log('indexList updated:', this.indexList);
  454. } catch (error) {
  455. console.error('Error updating indexList:', error);
  456. }
  457. },
  458. scrollToItem(itemId) {
  459. // 设置滚动到的指定元素的 ID
  460. this.scrollItem = itemId;
  461. console.log(this.scrollItem)
  462. },
  463. //取消
  464. reset() {
  465. const self = this
  466. modal.confirm("是否重置?").then(res => {
  467. if (res) {
  468. self.depotList = []
  469. self.indexList = []
  470. self.searchValue = ""
  471. self.balance = 0
  472. this.isFocus = true
  473. playVoice(audioUrls.warningSuccessUrl)
  474. } else {
  475. // 用户点击取消,不执行任何操作
  476. }
  477. })
  478. },
  479. edit(item, index) {
  480. if (this.isCreate) {
  481. uni.navigateTo({
  482. url: '/pages/direct-transfer/show?isCreate=true&&item=' + encodeURIComponent(JSON
  483. .stringify(
  484. item)) +
  485. '&&index=' + encodeURIComponent(JSON.stringify(index))
  486. });
  487. } else {
  488. uni.navigateTo({
  489. url: '/pages/direct-transfer/show?isCreate=false&&item=' + encodeURIComponent(JSON.stringify(
  490. item)) +
  491. '&&index=' + encodeURIComponent(JSON.stringify(index))
  492. });
  493. }
  494. },
  495. showDetail(index) {
  496. console.log(index);
  497. let item = this.indexList[index.name]
  498. console.log(item)
  499. uni.navigateTo({
  500. url: '/pages/automatedwarehouse/listshow?Info=' + encodeURIComponent(JSON.stringify(
  501. item))
  502. });
  503. },
  504. focusPoint() {
  505. this.isFocus = false;
  506. this.$nextTick(() => {
  507. this.isFocus = true;
  508. });
  509. },
  510. clear() {
  511. this.focusPoint()
  512. },
  513. submit() {
  514. if(this.indexList.length < 1){
  515. modal.showToast("请扫描条形码!")
  516. return
  517. }
  518. //检查仓位是否都已选择
  519. const isOK = this.indexList.every(item => item['FDestStockLocId.FF102029.FNumber'] && item[
  520. 'FDestStockLocId.FF102029.FNumber'].trim() !== '');
  521. if (!isOK) {
  522. modal.showToast("存在未选择的调入仓位!")
  523. return
  524. }
  525. let vm = this
  526. uni.showModal({
  527. title: "提示",
  528. content: "是否生成单据?",
  529. showCancel: true,
  530. success: function(res) {
  531. if (res.confirm) {
  532. vm.createSubmit()
  533. } else {
  534. // 执行取消后的操作
  535. vm.$nextTick(() => {
  536. vm.searchValue = ''
  537. vm.focusPoint();
  538. })
  539. // return
  540. }
  541. }
  542. })
  543. },
  544. //跳转到查询页面
  545. navigateToSearch() {
  546. if (this.indexList.length > 0) {
  547. // this.isRangeSelected = false; // 显示错误提示
  548. playVoice(audioUrls.failVoiceUrl)
  549. uni.showToast({
  550. title: '源单已选择',
  551. duration: 2000,
  552. icon: "error"
  553. });
  554. return;
  555. }
  556. uni.navigateTo({
  557. // url: '/pages/production-replenishment/search', //这是你的当前页面地址
  558. url: `/pages/direct-transfer/search?FormId=${this.formId}&FBillType=${this.fbillType}`
  559. });
  560. },
  561. navigateToSummary() {
  562. uni.navigateTo({
  563. url: '/pages/direct-transfer/summary?Info=' + encodeURIComponent(JSON
  564. .stringify(this.indexList)) + '&&stageInfo=' + encodeURIComponent(JSON
  565. .stringify(this.stageLists)), //这是你的当前页面地址
  566. });
  567. },
  568. navigateToStage() {
  569. uni.navigateTo({
  570. url: '/pages/direct-transfer/stage?Info=' + encodeURIComponent(JSON
  571. .stringify(this.indexList)), //这是你的当前页面地址
  572. });
  573. },
  574. searchValueIsEmpty(data) {
  575. console.log(data)
  576. if (data == "" || data == undefined) {
  577. return true
  578. } else {
  579. return false
  580. }
  581. },
  582. checkBarcodeInArray(barcode, arrayOfObjects, propertyName) {
  583. if (arrayOfObjects.findIndex(item => item[propertyName] === barcode) < 0) { //不存在
  584. return true
  585. }
  586. return false
  587. },
  588. areAllDetailsScanned(nowindex) {
  589. if (this.indexList.filter(item =>
  590. item["FBillNo"] == this.indexList[nowindex].FBillNo && item[
  591. 'smzt'] == 0
  592. ).length == 0) {
  593. return true
  594. }
  595. return false
  596. },
  597. showToast() {
  598. uni.showToast({
  599. title: '请扫描条码',
  600. icon: 'none',
  601. duration: 3000
  602. })
  603. },
  604. handlePositionScanCompletion() { //根据仓位扫描的完成情况来处理不同的逻辑
  605. if (this.indexList.filter(item =>
  606. item["FSrcStockLocId.FF102029.FName"] == this.Location && item[
  607. 'smzt'] != 1
  608. ).length == 0) { //该仓位扫描完
  609. playVoice(audioUrls.allSuccessVoiceUrl)
  610. uni.showToast({
  611. title: '该仓位扫描完成',
  612. icon: 'none',
  613. duration: 3000
  614. })
  615. } else { //如果改仓位未扫描完,提示音
  616. playVoice(audioUrls.successVoiceUrl)
  617. uni.showToast({
  618. title: '扫描成功',
  619. icon: 'none',
  620. duration: 3000
  621. })
  622. }
  623. },
  624. handleError(error) {
  625. playVoice(audioUrls.failVoiceUrl)
  626. console.error('操作失败:', error);
  627. modal.confirm(error.message || '操作失败').then(res => {
  628. if (res) {
  629. } else {
  630. // 用户点击取消,不执行任何操作
  631. }
  632. })
  633. // uni.showToast({
  634. // title: error.message || '操作失败',
  635. // duration: 3000,
  636. // icon: "none"
  637. // });
  638. },
  639. async createSubmit() {
  640. const FormId = uni.getStorageSync('formId')
  641. try {
  642. await submitHelper.createSubmit(FormId, this.indexList);
  643. //重置页面
  644. {
  645. this.depotList = []
  646. this.indexList = []
  647. this.searchValue = ""
  648. this.balance = 0
  649. this.isFocus = true
  650. playVoice(audioUrls.warningSuccessUrl)
  651. }
  652. console.log("提交成功!this.indexList已清空");
  653. } catch (error) {
  654. this.handleError(error)
  655. }
  656. },
  657. async handleSubmit(FID) {
  658. const FormId = uni.getStorageSync('formId')
  659. try {
  660. await submitHelper.submit(FormId, FID, this.indexList);
  661. this.indexList = this.indexList.filter(item => item.FID !== FID);
  662. console.log(this.indexList)
  663. if (this.isStage == true) {
  664. // 处理每个对象
  665. this.stageLists.forEach(item => {
  666. // 过滤掉 FID 匹配的对象
  667. item.data = item.data.filter(obj => obj.FID !== FID);
  668. // 检查 data 数组是否为空
  669. if (item.data.length === 0) {
  670. console.log("data 数组为空"); //删除暂存
  671. this.deleteStages(item.id)
  672. } else {
  673. console.log("data 数组不为空");
  674. }
  675. })
  676. console.log(this.stageLists)
  677. }
  678. this.balance = 0
  679. } catch (error) {
  680. this.handleError(error)
  681. }
  682. },
  683. async deleteStages(id) {
  684. let condition = `id = (${id})`
  685. let sql = `delete from ${this.tableName} where ${condition}`
  686. executeSql(sql).then(result => {
  687. console.log('结果:', result);
  688. // this.handleDeleteSuccess()
  689. })
  690. .catch(error => {
  691. console.error('捕获错误:', error); // 输出: 捕获错误: 失败的结果
  692. // this.handleDeleteFail(error)
  693. })
  694. },
  695. showModalAndHandleSubmit(nowindex) {
  696. let vm = this
  697. console.log(nowindex)
  698. let bBillNo = this.indexList[nowindex]["FBillNo"]
  699. let FID = this.indexList[nowindex]["FID"]
  700. this.$nextTick(() => {
  701. this.searchValue = ''
  702. this.isFocus = true;
  703. })
  704. playVoice(audioUrls.allSuccessVoiceUrl)
  705. uni.showModal({
  706. title: "提示",
  707. content: "单号(" + bBillNo + ")已扫描完毕,是否提交",
  708. showCancel: true,
  709. success: function(res) {
  710. if (res.confirm) {
  711. // this.submit(FID)
  712. this.handleSubmit(FID)
  713. } else {
  714. // 执行取消后的操作
  715. }
  716. }.bind(this)
  717. })
  718. },
  719. handleScanSuccess(nowindex) {
  720. this.Location = this.indexList[nowindex]["FSrcStockLocId.FF102029.FName"]
  721. this.indexList[nowindex].smzt = 1 //修改数据状态
  722. console.log(this.indexList.filter(obj => obj.smzt === 1).length)
  723. this.$forceUpdate()
  724. const audioUrlsArr = [];
  725. console.log(this.getActualWorkQuantity(this.indexList[nowindex]))
  726. //是否全发
  727. // if (this.getActualWorkQuantity(this.indexList[nowindex]) == this.indexList[nowindex][
  728. // "FInventoryQty"
  729. // ]) { //全发播放声音
  730. // console.log("播放声音")
  731. // audioUrlsArr.push(audioUrls.successVoiceUrl);
  732. // } else { //不全发播放声音
  733. // audioUrlsArr.push(audioUrls.success2VoiceUrl);
  734. // }
  735. audioUrlsArr.push(audioUrls.success2VoiceUrl);
  736. playSequentially(audioUrlsArr);
  737. if (this.indexList.filter(item =>
  738. item["FSrcStockLocId.FF102029.FName"] == this.Location && item[
  739. 'smzt'] != 1
  740. ).length == 0) { //该仓位扫描完
  741. // playVoice(audioUrls.allSuccessVoiceUrl)
  742. audioUrlsArr.push(audioUrls.storeSuccessUrl);
  743. }
  744. if (this.areAllDetailsScanned(nowindex)) { //校验单号是否全扫完
  745. audioUrlsArr.push(audioUrls.allSuccessVoiceUrl)
  746. // playVoice(audioUrls.allSuccessVoiceUrl)
  747. this.showModalAndHandleSubmit(nowindex)
  748. } else { //单号未全扫完
  749. // this.handlePositionScanCompletion()
  750. this.$nextTick(() => {
  751. this.searchValue = ''
  752. this.isFocus = true;
  753. this.scrollToItem("scrollItem-" + nowindex)
  754. })
  755. }
  756. playSequentially(audioUrlsArr);
  757. },
  758. CreateScanSuccess(nowindex) {
  759. console.log("扫描完成开始渲染------------", nowindex)
  760. this.indexList[nowindex].smzt = 1
  761. // this.$forceUpdate()
  762. this.$nextTick(() => {
  763. console.log("准备刷新---------------", this.indexList)
  764. this.searchValue = ''
  765. this.isFocus = true;
  766. this.scrollToItem("scrollItem-" + nowindex)
  767. })
  768. console.log("-----------", this.indexList)
  769. const audioUrlsArr = [];
  770. audioUrlsArr.push(audioUrls.success2VoiceUrl);
  771. playSequentially(audioUrlsArr);
  772. },
  773. async scanToCreate() {
  774. console.log("```````````````````进入扫描生成块")
  775. let vm = this
  776. let info = {}
  777. //校验是否输入条码
  778. if (this.searchValueIsEmpty(this.searchValue)) {
  779. playVoice(audioUrls.failVoiceUrl)
  780. this.showToast()
  781. this.focusPoint()
  782. return
  783. }
  784. info.FCMKBarCode = this.searchValue
  785. //校验是否重复扫码
  786. const isDuplicate = this.indexList.some(item => item.FCMKBarCode === info.FCMKBarCode);
  787. if (isDuplicate) {
  788. uni.showModal({
  789. title: '提示',
  790. content: "该条形码已扫描!",
  791. showCancel: false,
  792. success: function(res) {
  793. if (res.confirm) {
  794. this.focusPoint()
  795. vm.searchValue = ''
  796. return
  797. }
  798. }.bind(this)
  799. })
  800. playVoice(audioUrls.successVoiceUrl)
  801. return;
  802. }
  803. modal.loading('扫描数据中,请耐心等待...')
  804. try {
  805. //根据条形码找编码
  806. const lot = await this.getFLotCode(this.searchValue)
  807. if (!lot) {
  808. uni.showModal({
  809. title: '提示',
  810. content: "未查询到编码!",
  811. showCancel: false,
  812. success: function(res) {
  813. if (res.confirm) {
  814. this.focusPoint()
  815. vm.searchValue = ''
  816. return
  817. } else {
  818. // 执行取消后的操作
  819. }
  820. }.bind(this)
  821. })
  822. playVoice(audioUrls.failVoiceUrl)
  823. return
  824. }
  825. Object.assign(info, lot)
  826. console.log("找到编码--------------------", lot)
  827. //根据编码批号找即时库存
  828. const stockLoc = await this.getStockLoc(lot["FLot.FNumber"], lot["FMaterialId.FNumber"])
  829. if (!stockLoc || stockLoc.length == 0) {
  830. uni.showModal({
  831. title: '提示',
  832. content: "未查询到即时库存信息!",
  833. showCancel: false,
  834. success: function(res) {
  835. if (res.confirm) {
  836. this.focusPoint()
  837. vm.searchValue = ''
  838. return
  839. } else {
  840. // 执行取消后的操作
  841. }
  842. }.bind(this)
  843. })
  844. playVoice(audioUrls.failVoiceUrl)
  845. return
  846. }
  847. //有多条时进行仓位选择
  848. if (stockLoc.length > 1) {
  849. console.log("进行仓位选择--------------------", stockLoc)
  850. this.depotList = [stockLoc]
  851. this.showPicker = true
  852. info.index = this.indexList.length
  853. this.indexList.push(info)
  854. } else {
  855. info.index = this.indexList.length
  856. Object.assign(info, stockLoc[0])
  857. console.log("不用选择--------------------", info)
  858. this.$nextTick(() => {
  859. this.indexList.push(info);
  860. this.CreateScanSuccess(this.indexList.length - 1);
  861. });
  862. }
  863. } finally {
  864. modal.closeLoading();
  865. console.log("`````````````结束扫描生成", this.indexList)
  866. }
  867. },
  868. scan() {
  869. let vm = this
  870. //校验是否输入条码
  871. if (this.searchValueIsEmpty(this.searchValue)) {
  872. playVoice(audioUrls.failVoiceUrl)
  873. this.showToast()
  874. this.focusPoint()
  875. return
  876. }
  877. // 校验条码是否存在
  878. if (this.checkBarcodeInArray(this.searchValue, this.indexList, "FENCHASENUM.LT")) {
  879. uni.showModal({
  880. title: '提示',
  881. content: "条码:" + vm.searchValue + "不存在",
  882. showCancel: false,
  883. success: function(res) {
  884. if (res.confirm) {
  885. this.focusPoint()
  886. vm.searchValue = ''
  887. return
  888. } else {
  889. // 执行取消后的操作
  890. }
  891. }.bind(this)
  892. })
  893. playVoice(audioUrls.failVoiceUrl)
  894. return
  895. }
  896. //条码存在未扫描
  897. let nowlocation = null; //该条码的仓位
  898. let nowindex = null; //该条码的索引
  899. for (let i = 0; i < this.indexList.length; i++) { //获取查询装箱单号对应仓位,并切换当前仓位
  900. if (this.indexList[i]["FENCHASENUM.LT"] === this.searchValue) {
  901. nowlocation = this.indexList[i]["FSrcStockLocId.FF102029.FName"] //当前仓位
  902. nowindex = i //当前索引
  903. this.balance = this.indexList[i]["quantity"] - this.indexList[i]["rowCount"]
  904. break;
  905. }
  906. }
  907. //不是首次扫描
  908. if (this.indexListLength != 0) { //已有操作,计算上次操作的仓位未扫描数
  909. let UnscannedNumber = this.indexList.filter(item =>
  910. item["FSrcStockLocId.FF102029.FName"] === this.Location && item['smzt'] != 1
  911. ).length
  912. if (nowlocation != this.Location && UnscannedNumber != 0) { //仓位不一致
  913. playVoice(audioUrls.warningSuccessUrl)
  914. uni.showModal({
  915. title: "提示",
  916. content: "是否切换仓位",
  917. showCancel: true,
  918. success: function(res) {
  919. if (res.confirm) {
  920. vm.handleScanSuccess(nowindex)
  921. } else {
  922. // 执行取消后的操作
  923. vm.$nextTick(() => {
  924. vm.searchValue = ''
  925. vm.isFocus = true;
  926. })
  927. }
  928. }
  929. })
  930. return
  931. } else { //仓位一致或原仓位已扫完,正常扫描,无切换
  932. this.handleScanSuccess(nowindex)
  933. }
  934. } else { //首次扫描
  935. this.handleScanSuccess(nowindex)
  936. }
  937. },
  938. getIsCreate() {
  939. if (this.isCreate) {
  940. this.scanToCreate()
  941. } else {
  942. this.scan()
  943. }
  944. },
  945. getHeightStyle() {
  946. return 'height:' + this.listHeight + 'px';
  947. },
  948. getStyle(smzt) {
  949. return smzt ? 'background-color: Navy;color:white' : '';
  950. // return 'scrollItem-' + index === this.scrollItem ? 'background-color: blue;color:white' : '';
  951. },
  952. async getFLotCode(code) {
  953. const searchParam = getFLotFNumber(code)
  954. let ress = await getBillList(JSON.stringify(searchParam))
  955. return ress?.[0]
  956. },
  957. async getStockLoc(lot, material) {
  958. const searchParam = getInventory(lot, material)
  959. let ress = await getBillList(JSON.stringify(searchParam))
  960. return ress
  961. },
  962. pickDepot(e) {
  963. console.log('confirm', e)
  964. const selectedValue = e.value[0];
  965. if (this.indexList.length > 0) {
  966. this.$set(this.indexList, this.indexList.length - 1, {
  967. ...this.indexList[this.indexList.length - 1],
  968. ...selectedValue,
  969. });
  970. }
  971. // this.indexList[this.indexList.length - 1].FStockName = e.value[0].FStockName
  972. console.log('confirm2', this.indexList)
  973. this.showPicker = false
  974. this.CreateScanSuccess(this.indexList.length - 1)
  975. }
  976. }
  977. };
  978. </script>
  979. <style lang="scss">
  980. .button-group {
  981. display: flex;
  982. justify-content: space-between;
  983. /* 主轴上左对齐 */
  984. align-items: center;
  985. /* 垂直居中对齐 */
  986. }
  987. .button-group button {
  988. white-space: nowrap;
  989. margin: 0;
  990. /* 禁止换行 */
  991. // margin-right: 10px;
  992. }
  993. .button-item {
  994. flex: 1;
  995. text-align: center;
  996. padding: 10px;
  997. font-size: 16px;
  998. background-color: #eee;
  999. }
  1000. /* 容器样式 */
  1001. .table-container {
  1002. width: 100%;
  1003. // overflow: hidden;
  1004. /* 添加滚动条 */
  1005. }
  1006. /* 表头样式 */
  1007. .table-header {
  1008. // background-color: #f0f0f0;
  1009. font-weight: bold;
  1010. display: flex;
  1011. }
  1012. /* 表行样式 */
  1013. .table-row {
  1014. display: flex;
  1015. flex-direction: row;
  1016. /* 水平布局 */
  1017. // border-top: 1px solid #ccc;
  1018. }
  1019. /* 表内容样式 */
  1020. .table-content {
  1021. width: 100%;
  1022. overflow: auto;
  1023. }
  1024. /* 单元格样式 */
  1025. .table-cell1 {
  1026. min-width: 85px;
  1027. /* 设置最小宽度 */
  1028. display: flex;
  1029. justify-content: center;
  1030. align-items: center;
  1031. padding: 5px;
  1032. border: 0.5px solid #ccc;
  1033. // text-align: center;
  1034. }
  1035. /* 单元格样式 */
  1036. .table-cell2 {
  1037. min-width: 90px;
  1038. /* 设置最小宽度 */
  1039. display: flex;
  1040. justify-content: center;
  1041. align-items: center;
  1042. padding: 5px;
  1043. border: 0.5px solid #ccc;
  1044. // text-align: center;
  1045. }
  1046. /* 单元格样式 */
  1047. .table-cell3 {
  1048. min-width: 100px;
  1049. /* 设置最小宽度 */
  1050. display: flex;
  1051. justify-content: center;
  1052. align-items: center;
  1053. padding: 5px;
  1054. border: 0.5px solid #ccc;
  1055. // text-align: center;
  1056. }
  1057. /* 单元格样式 */
  1058. .table-cell4 {
  1059. min-width: 85px;
  1060. /* 设置最小宽度 */
  1061. flex: 1;
  1062. padding: 8px;
  1063. border: 0.5px solid #ccc;
  1064. text-align: center;
  1065. }
  1066. /* 单元格样式 */
  1067. .table-cell {
  1068. min-width: 80px;
  1069. padding: 5px;
  1070. display: flex;
  1071. justify-content: center;
  1072. align-items: center;
  1073. border: 0.5px solid #ccc;
  1074. // text-align: center;
  1075. }
  1076. /* 单元格样式 */
  1077. .table-cellph {
  1078. min-width: 310px;
  1079. display: flex;
  1080. justify-content: center;
  1081. align-items: center;
  1082. border: 0.5px solid #ccc;
  1083. }
  1084. /* 单元格样式 */
  1085. .table-cellwl {
  1086. min-width: 150px;
  1087. /* 设置最小宽度 */
  1088. display: flex;
  1089. justify-content: center;
  1090. align-items: center;
  1091. border: 0.5px solid #ccc;
  1092. // text-align: center;
  1093. }
  1094. /* 最后一个单元格去掉右边框 */
  1095. .table-cell:last-child {
  1096. // border-right: none;
  1097. }
  1098. .example {
  1099. padding: 15px;
  1100. background-color: #fff;
  1101. }
  1102. .form-item {
  1103. display: flex;
  1104. align-items: center;
  1105. }
  1106. .sticky-box {
  1107. /* #ifndef APP-PLUS-NVUE */
  1108. // display: flex;
  1109. position: -webkit-sticky;
  1110. /* #endif */
  1111. position: sticky;
  1112. top: var(--window-top);
  1113. z-index: 99;
  1114. flex-direction: row;
  1115. margin: 0px;
  1116. // padding: 15px 0 15px 0;
  1117. background-color: #F4F5F6;
  1118. // border-bottom-style: solid;
  1119. // border-bottom-color: #E2E2E2;
  1120. }
  1121. .button {
  1122. border-color: #e5e5e5;
  1123. border-style: solid;
  1124. border-width: 1px;
  1125. padding: 4px 8px;
  1126. border-radius: 4px;
  1127. }
  1128. .card-bottom {
  1129. touch-action: none;
  1130. // height: 60px;
  1131. position: fixed;
  1132. bottom: 0;
  1133. width: 100%;
  1134. z-index: 999;
  1135. background-color: white;
  1136. border-top: 1px;
  1137. display: flex;
  1138. flex-direction: column;
  1139. }
  1140. .text {
  1141. font-size: 12px;
  1142. color: #666;
  1143. margin-top: 5px;
  1144. }
  1145. .button {
  1146. margin-bottom: 10px;
  1147. }
  1148. .segmented-control {
  1149. margin-bottom: 15px;
  1150. }
  1151. // .button-group {
  1152. // margin-top: 15px;
  1153. // display: flex;
  1154. // justify-content: space-around;
  1155. // }
  1156. .form-item {
  1157. display: flex;
  1158. align-items: center;
  1159. }
  1160. .button {
  1161. display: flex;
  1162. align-items: center;
  1163. height: 35px;
  1164. margin-left: 10px;
  1165. }
  1166. </style>
  1167. <style lang="scss">
  1168. .u-page {
  1169. padding: 0;
  1170. }
  1171. .u-demo-block__title {
  1172. padding: 10px 0 2px 15px;
  1173. }
  1174. .swipe-action {
  1175. &__content {
  1176. padding: 25rpx 0;
  1177. display: flex;
  1178. flex-direction: column; //设置布局方向为竖直
  1179. &__text {
  1180. font-size: 15px;
  1181. color: $u-main-color;
  1182. padding-left: 30rpx;
  1183. }
  1184. }
  1185. }
  1186. .u-swipe-action-item {
  1187. touch-action: none;
  1188. }
  1189. .red {
  1190. color: red;
  1191. }
  1192. .label-picker-container {
  1193. display: flex;
  1194. align-items: center;
  1195. /* 垂直居中对齐 */
  1196. font-size: 12px;
  1197. /* 设置标签的字体大小 */
  1198. }
  1199. </style>