index.vue 33 KB

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