index.vue 34 KB

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