index.vue 28 KB

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