index.vue 37 KB

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