index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  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.warningSuccessUrl)
  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. this.$forceUpdate()
  755. const audioUrlsArr = [];
  756. console.log(this.getActualWorkQuantity(this.indexList[nowindex]))
  757. //是否全发
  758. if (this.getActualWorkQuantity(this.indexList[nowindex]) == this.indexList[nowindex][
  759. "FInventoryQty"
  760. ]) { //全发播放声音
  761. console.log("播放声音")
  762. audioUrlsArr.push(audioUrls.successVoiceUrl);
  763. } else { //不全发播放声音
  764. audioUrlsArr.push(audioUrls.success2VoiceUrl);
  765. }
  766. // audioUrlsArr.push(audioUrls.success2VoiceUrl);
  767. // playSequentially(audioUrlsArr);
  768. if (this.indexList.filter(item =>
  769. item["FStockLocId.FF102029.fname"] == this.Location && item[
  770. 'smzt'] != 1
  771. ).length == 0) { //该仓位扫描完
  772. // playVoice(audioUrls.allSuccessVoiceUrl)
  773. audioUrlsArr.push(audioUrls.storeSuccessUrl);
  774. }
  775. if (this.areAllDetailsScanned(nowindex)) { //校验单号是否全扫完
  776. audioUrlsArr.push(audioUrls.allSuccessVoiceUrl)
  777. // playVoice(audioUrls.allSuccessVoiceUrl)
  778. this.showModalAndHandleSubmit(nowindex)
  779. } else { //单号未全扫完
  780. // this.handlePositionScanCompletion()
  781. this.$nextTick(() => {
  782. this.searchValue = ''
  783. this.isFocus = true;
  784. this.scrollToItem("scrollItem-" + nowindex)
  785. })
  786. }
  787. playSequentially(audioUrlsArr);
  788. },
  789. scan() {
  790. let vm = this
  791. //校验是否输入条码
  792. if (this.searchValueIsEmpty(this.searchValue)) {
  793. playVoice(audioUrls.failVoiceUrl)
  794. this.showToast()
  795. this.focusPoint()
  796. return
  797. }
  798. // 校验条码是否存在
  799. if (this.checkBarcodeInArray(this.searchValue, this.indexList, "FENCHASENUM.LT")) {
  800. uni.showModal({
  801. title: '提示',
  802. content: "条码:" + vm.searchValue + '不存在',
  803. showCancel: false,
  804. success: function(res) {
  805. if (res.confirm) {
  806. this.focusPoint()
  807. vm.searchValue = ''
  808. return
  809. } else {
  810. // 执行取消后的操作
  811. }
  812. }.bind(this)
  813. })
  814. playVoice(audioUrls.failVoiceUrl)
  815. return
  816. }
  817. //校验条码已扫描
  818. // if (this.indexList.findIndex(item => item["FENCHASENUM.LT"] === this.searchValue && item.smzt ==
  819. // 1) >= 0) {
  820. // uni.showModal({
  821. // // title: '提示',
  822. // content: "条码:" + vm.searchValue + '已扫描',
  823. // showCancel: false,
  824. // success: function(res) {
  825. // if (res.confirm) {
  826. // vm.focusPoint()
  827. // vm.searchValue = ''
  828. // return
  829. // } else {
  830. // // 执行取消后的操作
  831. // }
  832. // }
  833. // })
  834. // playVoice(audioUrls.failVoiceUrl)
  835. // return
  836. // }
  837. //条码存在未扫描
  838. let nowlocation = null; //该条码的仓位
  839. let nowindex = null; //该条码的索引
  840. for (let i = 0; i < this.indexList.length; i++) { //获取查询装箱单号对应仓位,并切换当前仓位
  841. if (this.indexList[i]["FENCHASENUM.LT"] === this.searchValue) {
  842. nowlocation = this.indexList[i]["FStockLocId.FF102029.fname"] //当前仓位
  843. nowindex = i //当前索引
  844. this.balance = this.indexList[i]["quantity"] - this.indexList[i]["rowCount"]
  845. break;
  846. }
  847. }
  848. //不是首次扫描
  849. if (this.indexListLength != 0) { //已有操作,计算上次操作的仓位未扫描数
  850. let UnscannedNumber = this.indexList.filter(item =>
  851. item["FStockLocId.FF102029.fname"] == this.Location && item['smzt'] != 1
  852. ).length
  853. if (nowlocation != this.Location && UnscannedNumber != 0) { //仓位不一致
  854. playVoice(audioUrls.warningSuccessUrl)
  855. uni.showModal({
  856. title: "提示",
  857. content: "是否切换仓位",
  858. showCancel: true,
  859. success: function(res) {
  860. if (res.confirm) {
  861. vm.handleScanSuccess(nowindex)
  862. } else {
  863. // 执行取消后的操作
  864. vm.$nextTick(() => {
  865. vm.searchValue = ''
  866. vm.isFocus = true;
  867. })
  868. }
  869. }
  870. })
  871. return
  872. } else { //仓位一致或原仓位已扫完,正常扫描,无切换
  873. this.handleScanSuccess(nowindex)
  874. }
  875. } else { //首次扫描
  876. this.handleScanSuccess(nowindex)
  877. }
  878. },
  879. getHeightStyle() {
  880. return 'height:' + this.listHeight + 'px';
  881. },
  882. getStyle(smzt) {
  883. return smzt ? 'background-color: Navy;color:white' : '';
  884. // return 'scrollItem-' + index === this.scrollItem ? 'background-color: blue;color:white' : '';
  885. },
  886. }
  887. };
  888. </script>
  889. <style lang="scss">
  890. .button-group {
  891. display: flex;
  892. justify-content: flex-start;
  893. /* 主轴上左对齐 */
  894. align-items: center;
  895. /* 垂直居中对齐 */
  896. }
  897. .button-group button {
  898. white-space: nowrap;
  899. /* 禁止换行 */
  900. // margin-right: 10px;
  901. }
  902. .button-item {
  903. flex: 1;
  904. text-align: center;
  905. padding: 10px;
  906. font-size: 16px;
  907. background-color: #eee;
  908. }
  909. /* 容器样式 */
  910. .table-container {
  911. width: 100%;
  912. // overflow: hidden;
  913. /* 添加滚动条 */
  914. }
  915. /* 表头样式 */
  916. .table-header {
  917. // background-color: #f0f0f0;
  918. font-weight: bold;
  919. display: flex;
  920. }
  921. /* 表行样式 */
  922. .table-row {
  923. display: flex;
  924. flex-direction: row;
  925. /* 水平布局 */
  926. // border-top: 1px solid #ccc;
  927. }
  928. /* 表内容样式 */
  929. .table-content {
  930. width: 100%;
  931. overflow: auto;
  932. }
  933. /* 单元格样式 */
  934. .table-cell1 {
  935. min-width: 85px;
  936. /* 设置最小宽度 */
  937. display: flex;
  938. justify-content: center;
  939. align-items: center;
  940. padding: 5px;
  941. border: 0.5px solid #ccc;
  942. // text-align: center;
  943. }
  944. /* 单元格样式 */
  945. .table-cell2 {
  946. min-width: 90px;
  947. /* 设置最小宽度 */
  948. display: flex;
  949. justify-content: center;
  950. align-items: center;
  951. padding: 5px;
  952. border: 0.5px solid #ccc;
  953. // text-align: center;
  954. }
  955. /* 单元格样式 */
  956. .table-cell3 {
  957. min-width: 100px;
  958. /* 设置最小宽度 */
  959. display: flex;
  960. justify-content: center;
  961. align-items: center;
  962. padding: 5px;
  963. border: 0.5px solid #ccc;
  964. // text-align: center;
  965. }
  966. /* 单元格样式 */
  967. .table-cell4 {
  968. min-width: 85px;
  969. /* 设置最小宽度 */
  970. flex: 1;
  971. padding: 8px;
  972. border: 0.5px solid #ccc;
  973. text-align: center;
  974. }
  975. /* 单元格样式 */
  976. .table-cell {
  977. min-width: 80px;
  978. padding: 5px;
  979. display: flex;
  980. justify-content: center;
  981. align-items: center;
  982. border: 0.5px solid #ccc;
  983. // text-align: center;
  984. }
  985. /* 单元格样式 */
  986. .table-cellph {
  987. min-width: 310px;
  988. display: flex;
  989. justify-content: center;
  990. align-items: center;
  991. border: 0.5px solid #ccc;
  992. }
  993. /* 单元格样式 */
  994. .table-cellwl {
  995. min-width: 150px;
  996. /* 设置最小宽度 */
  997. display: flex;
  998. justify-content: center;
  999. align-items: center;
  1000. border: 0.5px solid #ccc;
  1001. // text-align: center;
  1002. }
  1003. /* 最后一个单元格去掉右边框 */
  1004. .table-cell:last-child {
  1005. // border-right: none;
  1006. }
  1007. .example {
  1008. padding: 15px;
  1009. background-color: #fff;
  1010. }
  1011. .form-item {
  1012. display: flex;
  1013. align-items: center;
  1014. }
  1015. .sticky-box {
  1016. /* #ifndef APP-PLUS-NVUE */
  1017. // display: flex;
  1018. position: -webkit-sticky;
  1019. /* #endif */
  1020. position: sticky;
  1021. top: var(--window-top);
  1022. z-index: 99;
  1023. flex-direction: row;
  1024. margin: 0px;
  1025. // padding: 15px 0 15px 0;
  1026. background-color: #F4F5F6;
  1027. // border-bottom-style: solid;
  1028. // border-bottom-color: #E2E2E2;
  1029. }
  1030. .button {
  1031. border-color: #e5e5e5;
  1032. border-style: solid;
  1033. border-width: 1px;
  1034. padding: 4px 8px;
  1035. border-radius: 4px;
  1036. }
  1037. .card-bottom {
  1038. touch-action: none;
  1039. // height: 60px;
  1040. position: fixed;
  1041. bottom: 0;
  1042. width: 100%;
  1043. z-index: 999;
  1044. background-color: white;
  1045. border-top: 1px;
  1046. display: flex;
  1047. flex-direction: column;
  1048. }
  1049. .text {
  1050. font-size: 12px;
  1051. color: #666;
  1052. margin-top: 5px;
  1053. }
  1054. .button {
  1055. margin-bottom: 10px;
  1056. }
  1057. .segmented-control {
  1058. margin-bottom: 15px;
  1059. }
  1060. // .button-group {
  1061. // margin-top: 15px;
  1062. // display: flex;
  1063. // justify-content: space-around;
  1064. // }
  1065. .form-item {
  1066. display: flex;
  1067. align-items: center;
  1068. }
  1069. .button {
  1070. display: flex;
  1071. align-items: center;
  1072. height: 35px;
  1073. margin-left: 10px;
  1074. }
  1075. </style>
  1076. <style lang="scss">
  1077. .u-page {
  1078. padding: 0;
  1079. }
  1080. .u-demo-block__title {
  1081. padding: 10px 0 2px 15px;
  1082. }
  1083. .swipe-action {
  1084. &__content {
  1085. padding: 25rpx 0;
  1086. display: flex;
  1087. flex-direction: column; //设置布局方向为竖直
  1088. &__text {
  1089. font-size: 15px;
  1090. color: $u-main-color;
  1091. padding-left: 30rpx;
  1092. }
  1093. }
  1094. }
  1095. .u-swipe-action-item {
  1096. touch-action: none;
  1097. }
  1098. .red {
  1099. color: red;
  1100. }
  1101. .label-picker-container {
  1102. display: flex;
  1103. align-items: center;
  1104. /* 垂直居中对齐 */
  1105. font-size: 12px;
  1106. /* 设置标签的字体大小 */
  1107. }
  1108. </style>