index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  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.successVoiceUrl)
  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. // //判断仓位是否全部扫完
  738. // let UnscannedNumber = this.indexList.filter(item =>
  739. // item["FStockLocId.FF102029.fname"] == this.Location && item['smzt'] != 1
  740. // ).length //该仓位未扫描数量
  741. const audioUrlsArr = [];
  742. //是否全发
  743. if (this.indexList[nowindex]["FActualQty"] == this.indexList[nowindex]["FInventoryQty"]) { //全发播放声音
  744. console.log("播放声音")
  745. audioUrlsArr.push(audioUrls.successVoiceUrl);
  746. } else { //不全发播放声音
  747. audioUrlsArr.push(audioUrls.success2VoiceUrl);
  748. }
  749. // audioUrlsArr.push(audioUrls.success2VoiceUrl);
  750. // playSequentially(audioUrlsArr);
  751. if (this.indexList.filter(item =>
  752. item["FStockLocId.FF102029.fname"] == this.Location && item[
  753. 'smzt'] != 1
  754. ).length == 0) { //该仓位扫描完
  755. // playVoice(audioUrls.allSuccessVoiceUrl)
  756. audioUrlsArr.push(audioUrls.storeSuccessUrl);
  757. }
  758. if (this.areAllDetailsScanned(nowindex)) { //该单号全扫完
  759. // playVoice(audioUrls.allSuccessVoiceUrl)
  760. this.showModalAndHandleSubmit(nowindex, audioUrlsArr)
  761. } else { //单号未全扫完
  762. // this.handlePositionScanCompletion(audioUrlsArr)
  763. this.$nextTick(() => {
  764. this.searchValue = ''
  765. this.isFocus = true;
  766. this.scrollToItem("scrollItem-" + nowindex)
  767. })
  768. }
  769. playSequentially(audioUrlsArr);
  770. },
  771. scan() {
  772. let vm = this
  773. //校验是否输入条码
  774. if (this.searchValueIsEmpty(this.searchValue)) {
  775. playVoice(audioUrls.failVoiceUrl)
  776. this.showToast()
  777. this.focusPoint()
  778. return
  779. }
  780. // 校验条码是否存在
  781. if (this.checkBarcodeInArray(this.searchValue, this.indexList, "FENCHASENUM.LT")) {
  782. uni.showModal({
  783. title: '提示',
  784. content: "条码:" + vm.searchValue + '不存在',
  785. showCancel: false,
  786. success: function(res) {
  787. if (res.confirm) {
  788. this.focusPoint()
  789. vm.searchValue = ''
  790. return
  791. } else {
  792. // 执行取消后的操作
  793. }
  794. }.bind(this)
  795. })
  796. playVoice(audioUrls.failVoiceUrl)
  797. return
  798. }
  799. //校验条码已扫描
  800. if (this.indexList.findIndex(item => item["FENCHASENUM.LT"] === this.searchValue && item.smzt ==
  801. 1) >= 0) {
  802. uni.showModal({
  803. // title: '提示',
  804. content: "条码:" + vm.searchValue + '已扫描',
  805. showCancel: false,
  806. success: function(res) {
  807. if (res.confirm) {
  808. vm.focusPoint()
  809. vm.searchValue = ''
  810. return
  811. } else {
  812. // 执行取消后的操作
  813. }
  814. }
  815. })
  816. playVoice(audioUrls.failVoiceUrl)
  817. return
  818. }
  819. //条码存在未扫描
  820. let nowlocation = null; //该条码的仓位
  821. let nowindex = null; //该条码的索引
  822. for (let i = 0; i < this.indexList.length; i++) { //获取查询装箱单号对应仓位,并切换当前仓位
  823. if (this.indexList[i]["FENCHASENUM.LT"] === this.searchValue) {
  824. nowlocation = this.indexList[i]["FStockLocId.FF102029.fname"] //当前仓位
  825. nowindex = i //当前索引
  826. this.balance = this.indexList[i]["quantity"] - this.indexList[i]["rowCount"]
  827. break;
  828. }
  829. }
  830. //不是首次扫描
  831. if (this.indexListLength != 0) { //已有操作
  832. let UnscannedNumber = this.indexList.filter(item =>
  833. item["FStockLocId.FF102029.fname"] == this.Location && item['smzt'] != 1
  834. ).length //计算上次操作的仓位未扫描数
  835. if (nowlocation != this.Location && UnscannedNumber != 0) { //仓位不一致并且上个仓位未全扫描
  836. playVoice(audioUrls.successVoiceUrl)
  837. uni.showModal({
  838. title: "提示",
  839. content: "是否切换仓位",
  840. showCancel: true,
  841. success: function(res) {
  842. if (res.confirm) {
  843. vm.handleScanSuccess(nowindex)
  844. } else {
  845. // 执行取消后的操作
  846. vm.$nextTick(() => {
  847. vm.searchValue = ''
  848. vm.isFocus = true;
  849. })
  850. }
  851. }
  852. })
  853. return
  854. } else { //仓位一致或原仓位已扫完,正常扫描,无切换
  855. this.handleScanSuccess(nowindex)
  856. }
  857. } else { //首次扫描
  858. this.handleScanSuccess(nowindex)
  859. }
  860. },
  861. getHeightStyle() {
  862. return 'height:' + this.listHeight + 'px';
  863. },
  864. getStyle(smzt) {
  865. return smzt ? 'background-color: Navy;color:white' : '';
  866. // return 'scrollItem-' + index === this.scrollItem ? 'background-color: blue;color:white' : '';
  867. },
  868. }
  869. };
  870. </script>
  871. <style lang="scss">
  872. .button-group {
  873. display: flex;
  874. justify-content: flex-start;
  875. /* 主轴上左对齐 */
  876. align-items: center;
  877. /* 垂直居中对齐 */
  878. }
  879. .button-group button {
  880. white-space: nowrap;
  881. /* 禁止换行 */
  882. // margin-right: 10px;
  883. }
  884. .button-item {
  885. flex: 1;
  886. text-align: center;
  887. padding: 10px;
  888. font-size: 16px;
  889. background-color: #eee;
  890. }
  891. /* 容器样式 */
  892. .table-container {
  893. width: 100%;
  894. // overflow: hidden;
  895. /* 添加滚动条 */
  896. }
  897. /* 表头样式 */
  898. .table-header {
  899. // background-color: #f0f0f0;
  900. font-weight: bold;
  901. display: flex;
  902. }
  903. /* 表行样式 */
  904. .table-row {
  905. display: flex;
  906. flex-direction: row;
  907. /* 水平布局 */
  908. // border-top: 1px solid #ccc;
  909. }
  910. /* 表内容样式 */
  911. .table-content {
  912. width: 100%;
  913. overflow: auto;
  914. }
  915. /* 单元格样式 */
  916. .table-cell1 {
  917. min-width: 85px;
  918. /* 设置最小宽度 */
  919. display: flex;
  920. justify-content: center;
  921. align-items: center;
  922. padding: 5px;
  923. border: 0.5px solid #ccc;
  924. // text-align: center;
  925. }
  926. /* 单元格样式 */
  927. .table-cell2 {
  928. min-width: 90px;
  929. /* 设置最小宽度 */
  930. display: flex;
  931. justify-content: center;
  932. align-items: center;
  933. padding: 5px;
  934. border: 0.5px solid #ccc;
  935. // text-align: center;
  936. }
  937. /* 单元格样式 */
  938. .table-cell3 {
  939. min-width: 100px;
  940. /* 设置最小宽度 */
  941. display: flex;
  942. justify-content: center;
  943. align-items: center;
  944. padding: 5px;
  945. border: 0.5px solid #ccc;
  946. // text-align: center;
  947. }
  948. /* 单元格样式 */
  949. .table-cell4 {
  950. min-width: 85px;
  951. /* 设置最小宽度 */
  952. flex: 1;
  953. padding: 8px;
  954. border: 0.5px solid #ccc;
  955. text-align: center;
  956. }
  957. /* 单元格样式 */
  958. .table-cell {
  959. min-width: 80px;
  960. padding: 5px;
  961. display: flex;
  962. justify-content: center;
  963. align-items: center;
  964. border: 0.5px solid #ccc;
  965. // text-align: center;
  966. }
  967. /* 单元格样式 */
  968. .table-cellph {
  969. min-width: 310px;
  970. display: flex;
  971. justify-content: center;
  972. align-items: center;
  973. border: 0.5px solid #ccc;
  974. }
  975. /* 单元格样式 */
  976. .table-cellwl {
  977. min-width: 150px;
  978. /* 设置最小宽度 */
  979. display: flex;
  980. justify-content: center;
  981. align-items: center;
  982. border: 0.5px solid #ccc;
  983. // text-align: center;
  984. }
  985. /* 最后一个单元格去掉右边框 */
  986. .table-cell:last-child {
  987. // border-right: none;
  988. }
  989. .example {
  990. padding: 15px;
  991. background-color: #fff;
  992. }
  993. .form-item {
  994. display: flex;
  995. align-items: center;
  996. }
  997. .sticky-box {
  998. /* #ifndef APP-PLUS-NVUE */
  999. // display: flex;
  1000. position: -webkit-sticky;
  1001. /* #endif */
  1002. position: sticky;
  1003. top: var(--window-top);
  1004. z-index: 99;
  1005. flex-direction: row;
  1006. margin: 0px;
  1007. // padding: 15px 0 15px 0;
  1008. background-color: #F4F5F6;
  1009. // border-bottom-style: solid;
  1010. // border-bottom-color: #E2E2E2;
  1011. }
  1012. .button {
  1013. border-color: #e5e5e5;
  1014. border-style: solid;
  1015. border-width: 1px;
  1016. padding: 4px 8px;
  1017. border-radius: 4px;
  1018. }
  1019. .card-bottom {
  1020. touch-action: none;
  1021. // height: 60px;
  1022. position: fixed;
  1023. bottom: 0;
  1024. width: 100%;
  1025. z-index: 999;
  1026. background-color: white;
  1027. border-top: 1px;
  1028. display: flex;
  1029. flex-direction: column;
  1030. }
  1031. .text {
  1032. font-size: 12px;
  1033. color: #666;
  1034. margin-top: 5px;
  1035. }
  1036. .button {
  1037. margin-bottom: 10px;
  1038. }
  1039. .segmented-control {
  1040. margin-bottom: 15px;
  1041. }
  1042. // .button-group {
  1043. // margin-top: 15px;
  1044. // display: flex;
  1045. // justify-content: space-around;
  1046. // }
  1047. .form-item {
  1048. display: flex;
  1049. align-items: center;
  1050. }
  1051. .button {
  1052. display: flex;
  1053. align-items: center;
  1054. height: 35px;
  1055. margin-left: 10px;
  1056. }
  1057. </style>
  1058. <style lang="scss">
  1059. .u-page {
  1060. padding: 0;
  1061. }
  1062. .u-demo-block__title {
  1063. padding: 10px 0 2px 15px;
  1064. }
  1065. .swipe-action {
  1066. &__content {
  1067. padding: 25rpx 0;
  1068. display: flex;
  1069. flex-direction: column; //设置布局方向为竖直
  1070. &__text {
  1071. font-size: 15px;
  1072. color: $u-main-color;
  1073. padding-left: 30rpx;
  1074. }
  1075. }
  1076. }
  1077. .u-swipe-action-item {
  1078. touch-action: none;
  1079. }
  1080. .red {
  1081. color: red;
  1082. }
  1083. .label-picker-container {
  1084. display: flex;
  1085. align-items: center;
  1086. /* 垂直居中对齐 */
  1087. font-size: 12px;
  1088. /* 设置标签的字体大小 */
  1089. }
  1090. </style>