index.vue 33 KB

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