index.vue 34 KB

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