index.vue 32 KB

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