index.vue 34 KB

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