index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284
  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["FStockLocId.FF102029.FName"] }}</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. console.log("找到编码--------------------", lot)
  823. //根据编码批号找即时库存
  824. const stockLoc = await this.getStockLoc(lot["FLot.FNumber"], lot["FMaterialId.FNumber"])
  825. if (!stockLoc || stockLoc.length == 0) {
  826. uni.showModal({
  827. title: '提示',
  828. content: "未查询到即时库存信息!",
  829. showCancel: false,
  830. success: function(res) {
  831. if (res.confirm) {
  832. this.focusPoint()
  833. vm.searchValue = ''
  834. return
  835. } else {
  836. // 执行取消后的操作
  837. }
  838. }.bind(this)
  839. })
  840. playVoice(audioUrls.failVoiceUrl)
  841. return
  842. }
  843. //有多条时进行仓位选择
  844. if (stockLoc.length > 1) {
  845. console.log("进行仓位选择--------------------", stockLoc)
  846. this.depotList = [stockLoc]
  847. this.showPicker = true
  848. info.index = this.indexList.length
  849. this.indexList.push(info)
  850. } else {
  851. info.index = this.indexList.length
  852. Object.assign(info, stockLoc[0])
  853. console.log("不用选择--------------------", info)
  854. this.$nextTick(() => {
  855. this.indexList.push(info);
  856. this.CreateScanSuccess(this.indexList.length - 1);
  857. });
  858. }
  859. } finally {
  860. modal.closeLoading();
  861. console.log("`````````````结束扫描生成", this.indexList)
  862. }
  863. },
  864. scan() {
  865. let vm = this
  866. //校验是否输入条码
  867. if (this.searchValueIsEmpty(this.searchValue)) {
  868. playVoice(audioUrls.failVoiceUrl)
  869. this.showToast()
  870. this.focusPoint()
  871. return
  872. }
  873. // 校验条码是否存在
  874. if (this.checkBarcodeInArray(this.searchValue, this.indexList, "FENCHASENUM.LT")) {
  875. uni.showModal({
  876. title: '提示',
  877. content: "条码:" + vm.searchValue + "不存在",
  878. showCancel: false,
  879. success: function(res) {
  880. if (res.confirm) {
  881. this.focusPoint()
  882. vm.searchValue = ''
  883. return
  884. } else {
  885. // 执行取消后的操作
  886. }
  887. }.bind(this)
  888. })
  889. playVoice(audioUrls.failVoiceUrl)
  890. return
  891. }
  892. //条码存在未扫描
  893. let nowlocation = null; //该条码的仓位
  894. let nowindex = null; //该条码的索引
  895. for (let i = 0; i < this.indexList.length; i++) { //获取查询装箱单号对应仓位,并切换当前仓位
  896. if (this.indexList[i]["FENCHASENUM.LT"] === this.searchValue) {
  897. nowlocation = this.indexList[i]["FSrcStockLocId.FF102029.FName"] //当前仓位
  898. nowindex = i //当前索引
  899. this.balance = this.indexList[i]["quantity"] - this.indexList[i]["rowCount"]
  900. break;
  901. }
  902. }
  903. //不是首次扫描
  904. if (this.indexListLength != 0) { //已有操作,计算上次操作的仓位未扫描数
  905. let UnscannedNumber = this.indexList.filter(item =>
  906. item["FSrcStockLocId.FF102029.FName"] === this.Location && item['smzt'] != 1
  907. ).length
  908. if (nowlocation != this.Location && UnscannedNumber != 0) { //仓位不一致
  909. playVoice(audioUrls.warningSuccessUrl)
  910. uni.showModal({
  911. title: "提示",
  912. content: "是否切换仓位",
  913. showCancel: true,
  914. success: function(res) {
  915. if (res.confirm) {
  916. vm.handleScanSuccess(nowindex)
  917. } else {
  918. // 执行取消后的操作
  919. vm.$nextTick(() => {
  920. vm.searchValue = ''
  921. vm.isFocus = true;
  922. })
  923. }
  924. }
  925. })
  926. return
  927. } else { //仓位一致或原仓位已扫完,正常扫描,无切换
  928. this.handleScanSuccess(nowindex)
  929. }
  930. } else { //首次扫描
  931. this.handleScanSuccess(nowindex)
  932. }
  933. },
  934. getIsCreate() {
  935. if (this.isCreate) {
  936. this.scanToCreate()
  937. } else {
  938. this.scan()
  939. }
  940. },
  941. getHeightStyle() {
  942. return 'height:' + this.listHeight + 'px';
  943. },
  944. getStyle(smzt) {
  945. return smzt ? 'background-color: Navy;color:white' : '';
  946. // return 'scrollItem-' + index === this.scrollItem ? 'background-color: blue;color:white' : '';
  947. },
  948. async getFLotCode(code) {
  949. const searchParam = getFLotFNumber(code)
  950. let ress = await getBillList(JSON.stringify(searchParam))
  951. return ress?.[0]
  952. },
  953. async getStockLoc(lot, material) {
  954. const searchParam = getInventory(lot, material)
  955. let ress = await getBillList(JSON.stringify(searchParam))
  956. return ress
  957. },
  958. pickDepot(e) {
  959. console.log('confirm', e)
  960. const selectedValue = e.value[0];
  961. if (this.indexList.length > 0) {
  962. this.$set(this.indexList, this.indexList.length - 1, {
  963. ...this.indexList[this.indexList.length - 1],
  964. ...selectedValue,
  965. });
  966. }
  967. // this.indexList[this.indexList.length - 1].FStockName = e.value[0].FStockName
  968. console.log('confirm2', this.indexList)
  969. this.showPicker = false
  970. this.CreateScanSuccess(this.indexList.length - 1)
  971. }
  972. }
  973. };
  974. </script>
  975. <style lang="scss">
  976. .button-group {
  977. display: flex;
  978. justify-content: space-between;
  979. /* 主轴上左对齐 */
  980. align-items: center;
  981. /* 垂直居中对齐 */
  982. }
  983. .button-group button {
  984. white-space: nowrap;
  985. margin: 0;
  986. /* 禁止换行 */
  987. // margin-right: 10px;
  988. }
  989. .button-item {
  990. flex: 1;
  991. text-align: center;
  992. padding: 10px;
  993. font-size: 16px;
  994. background-color: #eee;
  995. }
  996. /* 容器样式 */
  997. .table-container {
  998. width: 100%;
  999. // overflow: hidden;
  1000. /* 添加滚动条 */
  1001. }
  1002. /* 表头样式 */
  1003. .table-header {
  1004. // background-color: #f0f0f0;
  1005. font-weight: bold;
  1006. display: flex;
  1007. }
  1008. /* 表行样式 */
  1009. .table-row {
  1010. display: flex;
  1011. flex-direction: row;
  1012. /* 水平布局 */
  1013. // border-top: 1px solid #ccc;
  1014. }
  1015. /* 表内容样式 */
  1016. .table-content {
  1017. width: 100%;
  1018. overflow: auto;
  1019. }
  1020. /* 单元格样式 */
  1021. .table-cell1 {
  1022. min-width: 85px;
  1023. /* 设置最小宽度 */
  1024. display: flex;
  1025. justify-content: center;
  1026. align-items: center;
  1027. padding: 5px;
  1028. border: 0.5px solid #ccc;
  1029. // text-align: center;
  1030. }
  1031. /* 单元格样式 */
  1032. .table-cell2 {
  1033. min-width: 90px;
  1034. /* 设置最小宽度 */
  1035. display: flex;
  1036. justify-content: center;
  1037. align-items: center;
  1038. padding: 5px;
  1039. border: 0.5px solid #ccc;
  1040. // text-align: center;
  1041. }
  1042. /* 单元格样式 */
  1043. .table-cell3 {
  1044. min-width: 100px;
  1045. /* 设置最小宽度 */
  1046. display: flex;
  1047. justify-content: center;
  1048. align-items: center;
  1049. padding: 5px;
  1050. border: 0.5px solid #ccc;
  1051. // text-align: center;
  1052. }
  1053. /* 单元格样式 */
  1054. .table-cell4 {
  1055. min-width: 85px;
  1056. /* 设置最小宽度 */
  1057. flex: 1;
  1058. padding: 8px;
  1059. border: 0.5px solid #ccc;
  1060. text-align: center;
  1061. }
  1062. /* 单元格样式 */
  1063. .table-cell {
  1064. min-width: 80px;
  1065. padding: 5px;
  1066. display: flex;
  1067. justify-content: center;
  1068. align-items: center;
  1069. border: 0.5px solid #ccc;
  1070. // text-align: center;
  1071. }
  1072. /* 单元格样式 */
  1073. .table-cellph {
  1074. min-width: 310px;
  1075. display: flex;
  1076. justify-content: center;
  1077. align-items: center;
  1078. border: 0.5px solid #ccc;
  1079. }
  1080. /* 单元格样式 */
  1081. .table-cellwl {
  1082. min-width: 150px;
  1083. /* 设置最小宽度 */
  1084. display: flex;
  1085. justify-content: center;
  1086. align-items: center;
  1087. border: 0.5px solid #ccc;
  1088. // text-align: center;
  1089. }
  1090. /* 最后一个单元格去掉右边框 */
  1091. .table-cell:last-child {
  1092. // border-right: none;
  1093. }
  1094. .example {
  1095. padding: 15px;
  1096. background-color: #fff;
  1097. }
  1098. .form-item {
  1099. display: flex;
  1100. align-items: center;
  1101. }
  1102. .sticky-box {
  1103. /* #ifndef APP-PLUS-NVUE */
  1104. // display: flex;
  1105. position: -webkit-sticky;
  1106. /* #endif */
  1107. position: sticky;
  1108. top: var(--window-top);
  1109. z-index: 99;
  1110. flex-direction: row;
  1111. margin: 0px;
  1112. // padding: 15px 0 15px 0;
  1113. background-color: #F4F5F6;
  1114. // border-bottom-style: solid;
  1115. // border-bottom-color: #E2E2E2;
  1116. }
  1117. .button {
  1118. border-color: #e5e5e5;
  1119. border-style: solid;
  1120. border-width: 1px;
  1121. padding: 4px 8px;
  1122. border-radius: 4px;
  1123. }
  1124. .card-bottom {
  1125. touch-action: none;
  1126. // height: 60px;
  1127. position: fixed;
  1128. bottom: 0;
  1129. width: 100%;
  1130. z-index: 999;
  1131. background-color: white;
  1132. border-top: 1px;
  1133. display: flex;
  1134. flex-direction: column;
  1135. }
  1136. .text {
  1137. font-size: 12px;
  1138. color: #666;
  1139. margin-top: 5px;
  1140. }
  1141. .button {
  1142. margin-bottom: 10px;
  1143. }
  1144. .segmented-control {
  1145. margin-bottom: 15px;
  1146. }
  1147. // .button-group {
  1148. // margin-top: 15px;
  1149. // display: flex;
  1150. // justify-content: space-around;
  1151. // }
  1152. .form-item {
  1153. display: flex;
  1154. align-items: center;
  1155. }
  1156. .button {
  1157. display: flex;
  1158. align-items: center;
  1159. height: 35px;
  1160. margin-left: 10px;
  1161. }
  1162. </style>
  1163. <style lang="scss">
  1164. .u-page {
  1165. padding: 0;
  1166. }
  1167. .u-demo-block__title {
  1168. padding: 10px 0 2px 15px;
  1169. }
  1170. .swipe-action {
  1171. &__content {
  1172. padding: 25rpx 0;
  1173. display: flex;
  1174. flex-direction: column; //设置布局方向为竖直
  1175. &__text {
  1176. font-size: 15px;
  1177. color: $u-main-color;
  1178. padding-left: 30rpx;
  1179. }
  1180. }
  1181. }
  1182. .u-swipe-action-item {
  1183. touch-action: none;
  1184. }
  1185. .red {
  1186. color: red;
  1187. }
  1188. .label-picker-container {
  1189. display: flex;
  1190. align-items: center;
  1191. /* 垂直居中对齐 */
  1192. font-size: 12px;
  1193. /* 设置标签的字体大小 */
  1194. }
  1195. </style>