list.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. <template>
  2. <view>
  3. <view class="sticky-box">
  4. <uni-easyinput ref="myInput" prefixIcon="search" :focus="isFocus" v-model="searchValue"
  5. @blur="isFocus = false" @clear="clear" @confirm="search" placeholder="请扫描拼件单号">
  6. </uni-easyinput>
  7. </view>
  8. <xw-scan></xw-scan>
  9. <u-swipe-action>
  10. <u-swipe-action-item :options="options" v-for="(item, index) in indexList" v-if="item.BillNO == null"
  11. :index="index" :id="item.Pjdh" :key="index" @click="remove" :name="index">
  12. <view class="swipe-action u-border-top" :class="[index === indexList.length - 1 && 'u-border-bottom']">
  13. <view class="swipe-action__content" :style="item.msg ? 'background-color:red' : ''">
  14. <text class="swipe-action__content__text">装箱单号:{{ item.Pjdh }}</text>
  15. <!-- <text class="swipe-action__content__text">拼件日期:{{ item.Pjrq }}</text> -->
  16. <text class="swipe-action__content__text">数量:{{ item.Sl }}</text>
  17. <text class="swipe-action__content__text">段数:{{ item.ds
  18. }}</text>
  19. <text v-if="item.msg" class="swipe-action__content__text">错误信息:{{ item.msg }}</text>
  20. </view>
  21. </view>
  22. </u-swipe-action-item>
  23. <u-swipe-action-item :options="options2" v-for="(item, index) in indexList" v-if="item.BillNO != null"
  24. :index="index" :id="item.Pjdh" :key="index" @click="remove2" :name="index">
  25. <view class="swipe-action u-border-top" :class="[index === indexList.length - 1 && 'u-border-bottom']">
  26. <view class="swipe-action__content" :style="item.msg ? 'background-color:red' : ''">
  27. <text class="swipe-action__content__text">装箱单号:{{ item.Pjdh }}</text>
  28. <!-- <text class="swipe-action__content__text">拼件日期:{{ item.Pjrq }}</text> -->
  29. <text class="swipe-action__content__text">数量:{{ item.Sl }}</text>
  30. <text class="swipe-action__content__text">段数:{{ item.ds
  31. }}</text>
  32. <text v-if="item.msg" class="swipe-action__content__text">错误信息:{{ item.msg }}</text>
  33. </view>
  34. </view>
  35. </u-swipe-action-item>
  36. </u-swipe-action>
  37. <!-- <uni-fab :pattern="pattern" :horizontal="horizontal" :vertical="vertical" :direction="direction"
  38. @trigger="trigger"></uni-fab> -->
  39. <view style="height: 200px;touch-action: none;"></view>
  40. <!-- <uni-card class="card-bottom"> -->
  41. <view class="card-bottom" style="">
  42. <view style="display: flex;flex-direction: row;margin: 0 auto;">
  43. <!-- <view style="font-size: 14px;"> -->
  44. <view style="margin-top: 7px;font-size: 12px;">
  45. 已扫描:{{ indexListLength }}
  46. </view>
  47. <!-- </view> -->
  48. <label v-show="IsAutoWarehouse && (BillNO == null || BillNO == '')"
  49. style="margin-top: 6px;font-size: 12px;">
  50. <checkbox :checked="this.formData.IsProcedures" v-model="this.formData.IsProcedures" @tap="tap1" />
  51. 手续
  52. </label>
  53. <label v-show="IsAutoWarehouse && (BillNO == null || BillNO == '')"
  54. style="margin-top: 6px;margin-right: 3px;font-size: 12px;">
  55. <checkbox :checked="VirtualboardChecked" v-model="VirtualboardChecked" disabled="true" />虚拟板号
  56. </label>
  57. <uni-forms-item style="padding: 0;margin: 0;">
  58. <div class="label-picker-container">
  59. <label>去向:</label>
  60. <uni-data-picker v-model="formData.Pbqx" :localdata="PbqxRange" @change="change">
  61. </uni-data-picker>
  62. </div>
  63. </uni-forms-item>
  64. </view>
  65. <view>
  66. <uni-forms-item label="板号" v-show="!VirtualboardChecked && IsAutoWarehouse"
  67. style="padding: 0;margin: 0;">
  68. <uni-easyinput v-model="formData.BoardNO" placeholder="请输入板号" />
  69. </uni-forms-item>
  70. </view>
  71. <!-- <view>
  72. <uni-forms-item label="去向">
  73. <uni-data-picker v-model="formData.Pbqx" :localdata="PbqxRange" @change="change">
  74. </uni-data-picker>
  75. </uni-forms-item>
  76. </view> -->
  77. <!-- <view class="uni-padding-wrap uni-common-mt"> -->
  78. <view style="display: flex;">
  79. <button style="width:100%;" type="primary" @click="storage"
  80. v-if="BillNO == null || BillNO == ''">入库</button>
  81. <button style="width:100%;" type="default" @click="updatestorage" v-if="BillNO != null">修改</button>
  82. <button style="width:100%;" type="warn" @click="cancelstorage" v-if="BillNO != null">作废</button>
  83. </view>
  84. <!-- </view> -->
  85. </view>
  86. <!-- </uni-card> -->
  87. </view>
  88. </template>
  89. <script>
  90. import {
  91. getBomItems,
  92. addToStorage,
  93. modifyDestination,
  94. cancelInWarehouse
  95. } from '@/api/workshop.js'
  96. export default {
  97. components: {},
  98. data() {
  99. return {
  100. audioContext: {},
  101. isFocus: true,
  102. procedureChecked: true, //手续默认选中
  103. VirtualboardChecked: true, // 默认选中状态
  104. IsAutoWarehouse: '',
  105. BillNO: '',
  106. options: [{
  107. text: '删除',
  108. style: {
  109. backgroundColor: '#dd524d'
  110. }
  111. }, {
  112. text: '详情'
  113. }],
  114. options2: [{
  115. text: '详情'
  116. }],
  117. indexList: [],
  118. formData: {
  119. BillTypeCode: "STK_ProInWarehouse_GreyFab",
  120. Pbqx: "",
  121. BoardNO: "",
  122. EquipmentNO: "",
  123. IsProcedures: true,
  124. RKList: []
  125. },
  126. title: 'uni-fab',
  127. directionStr: '垂直',
  128. horizontal: 'left',
  129. vertical: 'bottom',
  130. direction: 'horizontal',
  131. PbqxRange: [{
  132. value: '仓库',
  133. text: "仓库"
  134. },
  135. {
  136. value: '车间',
  137. text: "车间"
  138. }
  139. ],
  140. pattern: {
  141. color: '#7A7E83',
  142. backgroundColor: '#fff',
  143. selectedColor: '#007AFF',
  144. buttonColor: '#007AFF',
  145. iconColor: '#fff'
  146. },
  147. is_color_type: false,
  148. // searchValue: 'B20230522002',
  149. // searchValue: '',
  150. searchValue: '',
  151. // searchValue: 'F20150216132',
  152. show: false,
  153. isOpened: 'none',
  154. swipeList: [{
  155. options: [{
  156. text: '添加',
  157. style: {
  158. backgroundColor: '#F56C6C'
  159. }
  160. }],
  161. id: 0,
  162. content: '左滑点击添加新增一条数据'
  163. },
  164. {
  165. id: 1,
  166. options: [{
  167. text: '置顶'
  168. },
  169. {
  170. text: '删除',
  171. style: {
  172. backgroundColor: 'rgb(255,58,49)'
  173. }
  174. }
  175. ],
  176. content: 'item2'
  177. },
  178. {
  179. id: 2,
  180. options: [{
  181. text: '置顶'
  182. },
  183. {
  184. text: '标记为已读',
  185. style: {
  186. backgroundColor: 'rgb(254,156,1)'
  187. }
  188. },
  189. {
  190. text: '删除',
  191. style: {
  192. backgroundColor: 'rgb(255,58,49)'
  193. }
  194. }
  195. ],
  196. content: 'item3'
  197. }
  198. ]
  199. };
  200. },
  201. computed: {
  202. //已扫描数量
  203. indexListLength() {
  204. return this.indexList.length
  205. },
  206. },
  207. //监听虚拟板号是否选中
  208. watch: {
  209. VirtualboardChecked: function(newVal, oldVal) {
  210. if (newVal) {
  211. //用坯布GreyFab加时分秒生成虚拟板号
  212. this.formData.BoardNO = "GreyFab" + this.$moment().format('YYYYMMDDHHmmss')
  213. console.log(this.formData.BoardNO);
  214. }
  215. },
  216. //搜索框失去焦点时重新聚焦
  217. // searchValue: function (newVal, oldVal) {
  218. // if (newVal == '') {
  219. // this.isFocus = true
  220. // }
  221. // }
  222. },
  223. //获取上一页传过来的IsAutoWarehouse参数
  224. onLoad(option) {
  225. this.IsAutoWarehouse = JSON.parse(decodeURIComponent(option.IsAutoWarehouse))
  226. this.IsXnbh = JSON.parse(decodeURIComponent(option.IsXnbh)) //获取上一页传过来的是否虚拟板号参数
  227. console.log('isxnbh', this.IsXnbh)
  228. if (this.IsAutoWarehouse) {
  229. this.formData.IsProcedures = false
  230. // this.VirtualboardChecked = true
  231. // this.formData.BoardNO = "GreyFab" + this.$moment().format('YYYYMMDDHHmmss')
  232. if (this.IsXnbh) {
  233. this.VirtualboardChecked = true
  234. this.formData.BoardNO = "GreyFab" + this.$moment().format('YYYYMMDDHHmmss')
  235. }
  236. }
  237. // if (this.IsXnbh) {
  238. // this.VirtualboardChecked = true
  239. // this.formData.BoardNO = "GreyFab" + this.$moment().format('YYYYMMDDHHmmss')
  240. // }
  241. this.formData.EquipmentNO = uni.getDeviceInfo().deviceId;
  242. console.log(this.IsAutoWarehouse);
  243. console.log(this.formData.IsProcedures);
  244. console.log(this.VirtualboardChecked);
  245. },
  246. onBackPress() {
  247. if (this.$refs.fab.isShow) {
  248. this.$refs.fab.close()
  249. return true
  250. }
  251. return false
  252. },
  253. onUnload() {
  254. uni.$off('xwscan');
  255. },
  256. mounted() {
  257. uni.$on('scrollIntoView', (target) => {
  258. // console.log('targe', target)
  259. this.$nextTick(() => {
  260. // 使用id属性定位
  261. uni.createSelectorQuery().select('#' + target).boundingClientRect().exec((rect) => {
  262. console.log(rect)
  263. uni.pageScrollTo({
  264. scrollTop: rect[0].top,
  265. duration: 100
  266. });
  267. });
  268. });
  269. })
  270. },
  271. methods: {
  272. scrollToItem(id) {
  273. console.log(id)
  274. // 使用id属性定位
  275. this.$nextTick(() => {
  276. uni.$emit('scrollIntoView', id);
  277. })
  278. },
  279. tap1() {
  280. this.formData.IsProcedures = !this.formData.IsProcedures
  281. },
  282. remove(index) {
  283. console.log(index);
  284. // console.log(index.index);
  285. if (index.index == 0) {
  286. this.indexList.splice(index.name, 1);
  287. // this.$u.toast(`删除了第${index.name}个cell`);
  288. } else {
  289. let item = this.indexList[index.name]
  290. uni.navigateTo({
  291. url: '/pages/workshop/show?Info=' + encodeURIComponent(JSON.stringify(item))
  292. });
  293. }
  294. },
  295. remove2(index) {
  296. console.log(index);
  297. // console.log(index.index);
  298. if (index.index == 0) {
  299. let item = this.indexList[index.name]
  300. uni.navigateTo({
  301. url: '/pages/workshop/show?Info=' + encodeURIComponent(JSON.stringify(item))
  302. });
  303. } else {
  304. }
  305. },
  306. showDetail(item) {
  307. console.log('showDetail', item);
  308. uni.navigateTo({
  309. url: '/pages/workshop/show?Info=' + encodeURIComponent(JSON.stringify(item))
  310. });
  311. },
  312. change(e) {
  313. console.log(e.detail.value[0].value)
  314. this.formData.Pbqx = e.detail.value[0].value
  315. },
  316. storage() {
  317. if (this.indexList.length == 0) {
  318. uni.showToast({
  319. title: '请扫描条码',
  320. icon: 'none',
  321. duration: 3000
  322. })
  323. this.focusPoint()
  324. this.playvoice()
  325. return
  326. }
  327. if (this.IsAutoWarehouse == true && this.formData.BoardNO == '') {
  328. uni.showToast({
  329. title: '板号不能为空',
  330. icon: 'none',
  331. duration: 3000
  332. })
  333. this.playvoice()
  334. return
  335. }
  336. console.log(this.formData)
  337. // return
  338. //坯布去向不为空
  339. if (this.formData.Pbqx == null) {
  340. uni.showToast({
  341. title: '坯布去向不能为空',
  342. icon: 'none',
  343. duration: 3000
  344. })
  345. this.playvoice()
  346. return
  347. }
  348. let RKList = this.indexList.map(({
  349. Pjrq,
  350. Pbqx,
  351. Pmgg,
  352. Djlb,
  353. Wssbm,
  354. Xswlh,
  355. InWarehouseState,
  356. Rkdjbh,
  357. Dj,
  358. Ph,
  359. ...rest
  360. }) => rest)
  361. console.log(RKList)
  362. this.formData.RKList = RKList
  363. console.log(this.formData)
  364. addToStorage(this.formData).then(res => {
  365. console.log(res)
  366. if (res.Code == "0000") {
  367. this.playSuccessvoice()
  368. console.log(res)
  369. uni.showToast({
  370. title: '入库成功',
  371. icon: 'none',
  372. duration: 3000
  373. })
  374. uni.redirectTo({
  375. url: `/pages/workshop/list?IsAutoWarehouse=${this.IsAutoWarehouse}&IsXnbh=${this.IsXnbh}` //这是你的当前页面地址
  376. });
  377. // uni.navigateTo({
  378. // //传IsAutoWarehouse值到下一页
  379. // url: `/pages/workshop/list?IsAutoWarehouse=${this.IsAutoWarehouse}`,
  380. // success: res => { },
  381. // fail: () => { },
  382. // complete: () => { }
  383. // });
  384. // this.$nextTick(() => {
  385. window.location.reload();
  386. // })
  387. } else {
  388. uni.showToast({
  389. title: res.Msg,
  390. icon: 'none',
  391. duration: 3000
  392. })
  393. this.playvoice()
  394. }
  395. })
  396. },
  397. updatestorage() {
  398. console.log('点击了修改')
  399. //坯布去向不为空
  400. if (this.formData.Pbqx == "") {
  401. uni.showToast({
  402. title: '坯布去向不能为空',
  403. icon: 'none',
  404. duration: 3000
  405. })
  406. this.playvoice()
  407. return
  408. }
  409. console.log(this.indexList)
  410. let ConditionList = this.indexList.map(({
  411. Sl,
  412. ProStreamNO,
  413. Cwh,
  414. Pbqx,
  415. MaterialGuid,
  416. BatchNO,
  417. LocationNO,
  418. FabricLevelGuid,
  419. BillNO,
  420. ...rest
  421. }) => rest)
  422. console.log(ConditionList)
  423. const data = {
  424. "Pbqx": this.formData.Pbqx,
  425. "Billno": this.indexList[0].BillNO,
  426. "ConditionList": ConditionList
  427. }
  428. console.log(data)
  429. modifyDestination(data).then(res => {
  430. console.log(res)
  431. if (res.Code == "0000") {
  432. console.log(res)
  433. uni.showToast({
  434. title: '修改成功',
  435. icon: 'none',
  436. duration: 3000
  437. })
  438. // uni.navigateTo({
  439. // //传IsAutoWarehouse值到下一页
  440. // url: `/pages/workshop/list?IsAutoWarehouse=${this.IsAutoWarehouse}`,
  441. // success: res => { },
  442. // fail: () => { },
  443. // complete: () => { }
  444. // });
  445. uni.redirectTo({
  446. url: `/pages/workshop/list?IsAutoWarehouse=${this.IsAutoWarehouse}&IsXnbh=${this.IsXnbh}` //这是你的当前页面地址
  447. });
  448. } else {
  449. uni.showToast({
  450. title: res.Msg,
  451. icon: 'none',
  452. duration: 3000
  453. })
  454. this.playvoice()
  455. }
  456. })
  457. },
  458. //作废入库单
  459. cancelstorage() {
  460. let ConditionList1 = this.indexList.map(({
  461. Cwh,
  462. Pbqx,
  463. BillNO,
  464. ...rest
  465. }) => rest)
  466. let ConditionList = ConditionList1.map(item => {
  467. return {
  468. ...item,
  469. PackNo: item.Pjdh
  470. }
  471. })
  472. console.log(ConditionList)
  473. const data = {
  474. "BillNo": this.indexList[0].BillNO,
  475. "Conditions": ConditionList
  476. }
  477. console.log(data)
  478. cancelInWarehouse(data).then(res => {
  479. console.log(res)
  480. if (res.Code == "0000") {
  481. console.log(res)
  482. uni.showToast({
  483. title: '作废成功',
  484. icon: 'none',
  485. duration: 3000
  486. })
  487. // uni.navigateTo({
  488. // //传IsAutoWarehouse值到下一页
  489. // url: `/pages/workshop/list?IsAutoWarehouse=${this.IsAutoWarehouse}`,
  490. // success: res => { },
  491. // fail: () => { },
  492. // complete: () => { }
  493. // });
  494. uni.redirectTo({
  495. url: `/pages/workshop/list?IsAutoWarehouse=${this.IsAutoWarehouse}&IsXnbh=${this.IsXnbh}` //这是你的当前页面地址
  496. });
  497. } else {
  498. uni.showToast({
  499. title: res.Msg,
  500. icon: 'none',
  501. duration: 3000
  502. })
  503. this.playvoice()
  504. }
  505. })
  506. },
  507. trigger(e) {
  508. console.log(e)
  509. this.content[e.index].active = !e.item.active
  510. this.playvoice()
  511. uni.showModal({
  512. title: '提示',
  513. content: `您${this.content[e.index].active ? '选中了' : '取消了'}${e.item.text}`,
  514. success: function(res) {
  515. if (res.confirm) {
  516. console.log('用户点击确定')
  517. } else if (res.cancel) {
  518. console.log('用户点击取消')
  519. }
  520. }
  521. })
  522. },
  523. playvoice() {
  524. const innerAudioContext = uni.createInnerAudioContext();
  525. innerAudioContext.autoplay = true;
  526. innerAudioContext.src = '../../static/y1809.mp3';
  527. innerAudioContext.onPlay(() => {
  528. console.log('开始播放');
  529. });
  530. },
  531. playSuccessvoice() {
  532. const innerAudioContext = uni.createInnerAudioContext();
  533. innerAudioContext.autoplay = true;
  534. innerAudioContext.src = '../../static/success.mp3';
  535. innerAudioContext.onPlay(() => {
  536. console.log('开始播放');
  537. });
  538. },
  539. focusPoint() {
  540. this.isFocus = false;
  541. this.$nextTick(() => {
  542. this.isFocus = true;
  543. });
  544. },
  545. // blur(res) {
  546. // this.isFocus = false;
  547. // // console.log(this.isFocus);
  548. // // // this.$nextTick(() => {
  549. // // this.isFocus = true;
  550. // // // });
  551. // // this.$forceUpdate();
  552. // // // his.$set(this.isFocus,'status',"1");
  553. // // console.log('----blur:', this.isFocus)
  554. // },
  555. // input(res) {
  556. // console.log('----input:', res)
  557. // },
  558. clear() {
  559. this.focusPoint()
  560. },
  561. // selectInputValue() {
  562. // // 获取 uni-easyinput 组件对应的节点
  563. // this.$nextTick(() => {
  564. // uni.createSelectorQuery().select('.uni-easyinput').fields({
  565. // node: true,
  566. // size: true,
  567. // }).exec((res) => {
  568. // const inputNode = res[0].node;
  569. // console.log('inputNode', inputNode)
  570. // if (inputNode) {
  571. // // 选中输入框中的所有内容
  572. // inputNode.selectAll();
  573. // }
  574. // })
  575. // });
  576. // },
  577. //获取拼件单号信息
  578. search(value) {
  579. let res = {
  580. value: this.searchValue
  581. }
  582. if (res.value == "") {
  583. uni.showToast({
  584. title: '请扫描条码',
  585. icon: 'none',
  586. duration: 3000
  587. })
  588. this.focusPoint()
  589. this.playvoice()
  590. return
  591. }
  592. let data = {
  593. bomItemNum: res.value
  594. }
  595. //如果indexList没有数据
  596. if (this.indexList.length == 0) {
  597. getBomItems(data).then(res => {
  598. console.log(res)
  599. if (res.Code == "0000") {
  600. this.playSuccessvoice()
  601. console.log(res)
  602. this.indexList = res.Result.T01
  603. this.formData.Pbqx = res.Result.T01[0].Pbqx
  604. this.BillNO = res.Result.T01[0].BillNO
  605. console.log(this.indexList)
  606. // this.$refs.myInput.select();
  607. // this.selectInputValue()
  608. this.searchValue = '';
  609. // this.isFocus = false;
  610. // this.$nextTick(() => {
  611. // this.isFocus = true;
  612. // });
  613. } else {
  614. uni.showToast({
  615. title: res.Msg,
  616. icon: 'none',
  617. duration: 3000
  618. })
  619. this.playvoice()
  620. }
  621. })
  622. this.focusPoint()
  623. } else {
  624. //如果indexList有数据
  625. //判断是否已扫描已入库单据
  626. let vm = this
  627. if (this.indexList.findIndex(item => item.Pjdh === res.value) >= 0) {
  628. uni.showToast({
  629. title: '该条码已扫描',
  630. icon: 'none',
  631. duration: 3000
  632. })
  633. this.playvoice()
  634. this.focusPoint()
  635. return
  636. }
  637. if (this.indexList[this.indexList.length - 1].BillNO !== null) {
  638. //提示框是否继续
  639. this.playvoice()
  640. uni.showModal({
  641. title: '提示',
  642. content: '已扫描入库单据,是否继续',
  643. success: function(res) {
  644. if (res.confirm) {
  645. console.log('用户点击确定')
  646. //清空indexlist数据
  647. vm.indexList.splice(0, vm.indexList.length)
  648. getBomItems(data).then(res => {
  649. if (res.Code == "0000") {
  650. //更新视图中indexlist的值
  651. vm.indexList = res.Result.T01
  652. vm.BillNO = res.Result.T01[0].BillNO
  653. console.log(vm.indexList)
  654. vm.searchValue = '';
  655. vm.playSuccessvoice()
  656. } else {
  657. uni.showToast({
  658. title: res.Msg,
  659. icon: 'none',
  660. duration: 3000
  661. })
  662. vm.playvoice()
  663. }
  664. })
  665. vm.focusPoint()
  666. //结束进程
  667. return
  668. } else if (res.cancel) {
  669. console.log('用户点击取消')
  670. vm.focusPoint()
  671. return
  672. }
  673. }
  674. })
  675. } else {
  676. let vm = this
  677. if (this.indexList.findIndex(item => item.Pjdh === res.value) < 0) {
  678. let data = {
  679. bomItemNum: res.value
  680. }
  681. getBomItems(data).then(res => {
  682. if (res.Code == "0000") {
  683. //如果扫描到已入库的单据
  684. if (res.Result.T01[0].BillNO !== null) {
  685. //提示框是否继续
  686. this.playvoice()
  687. uni.showModal({
  688. title: '提示',
  689. content: '拼件单号已入库,是否继续?',
  690. success: function(res1) {
  691. if (res1.confirm) {
  692. vm.playSuccessvoice()
  693. //清空indexlist数据
  694. vm.indexList = [];
  695. //将扫描到的数据数组添加到indexlist
  696. vm.indexList = res.Result.T01;
  697. vm.BillNO = res.Result.T01[0].BillNO
  698. console.log(vm.indexList);
  699. vm.focusPoint()
  700. } else if (res1.cancel) {
  701. console.log('用户点击取消')
  702. vm.focusPoint()
  703. return
  704. }
  705. }
  706. })
  707. } else {
  708. vm.indexList.push(res.Result.T01[0]);
  709. this.playSuccessvoice()
  710. console.log(vm.indexList);
  711. vm.$forceUpdate()
  712. vm.$nextTick(() => {
  713. console.log(data.bomItemNum)
  714. vm.scrollToItem(data.bomItemNum)
  715. })
  716. }
  717. this.searchValue = '';
  718. // this.playSuccessvoice()
  719. } else {
  720. uni.showToast({
  721. title: res.Msg,
  722. icon: 'none',
  723. duration: 3000
  724. })
  725. this.playvoice()
  726. }
  727. })
  728. } else {
  729. uni.showToast({
  730. title: '该条码已扫描',
  731. icon: 'none',
  732. duration: 3000
  733. })
  734. }
  735. this.focusPoint()
  736. }
  737. }
  738. // this.isFocus = false
  739. // this.$nextTick(() => {
  740. // this.isFocus = true
  741. // })
  742. // console.log('isFocus', this.isFocus)
  743. // setTimeout(() => {
  744. // this.isFocus = true
  745. // }, 800);
  746. // console.log('isFocus', this.isFocus)
  747. },
  748. cancel(res) {
  749. uni.showToast({
  750. title: '点击取消,输入值为:' + res.value,
  751. icon: 'none',
  752. duration: 3000
  753. })
  754. },
  755. contentClick() {
  756. console.log('点击内容');
  757. uni.showToast({
  758. title: '点击内容',
  759. icon: 'none',
  760. duration: 3000
  761. })
  762. },
  763. bindClick(e) {
  764. console.log(e);
  765. uni.showToast({
  766. title: `点击了${e.position === 'left' ? '左侧' : '右侧'} ${e.content.text}按钮`,
  767. icon: 'none',
  768. duration: 3000
  769. });
  770. },
  771. setOpened() {
  772. if (this.isOpened === 'none') {
  773. this.isOpened = 'left';
  774. return;
  775. }
  776. if (this.isOpened === 'left') {
  777. this.isOpened = 'right';
  778. return;
  779. }
  780. if (this.isOpened === 'right') {
  781. this.isOpened = 'none';
  782. return;
  783. }
  784. },
  785. // change(e) {
  786. // this.isOpened = e;
  787. // console.log('返回:', e);
  788. // },
  789. // swipeChange(e, index) {
  790. // console.log('返回:', e);
  791. // console.log('当前索引:', index);
  792. // },
  793. // swipeClick(e, index) {
  794. // let {
  795. // content
  796. // } = e;
  797. // if (content.text === '删除') {
  798. // this.playvoice()
  799. // uni.showModal({
  800. // title: '提示',
  801. // content: '是否删除',
  802. // success: res => {
  803. // if (res.confirm) {
  804. // this.swipeList.splice(index, 1);
  805. // } else if (res.cancel) {
  806. // console.log('用户点击取消');
  807. // }
  808. // }
  809. // });
  810. // } else if (content.text === '添加') {
  811. // // if (this.swipeList.length < 10) {
  812. // this.swipeList.push({
  813. // id: new Date().getTime(),
  814. // options: [{
  815. // text: '置顶'
  816. // },
  817. // {
  818. // text: '标记为已读',
  819. // style: {
  820. // backgroundColor: 'rgb(254,156,1)'
  821. // }
  822. // },
  823. // {
  824. // text: '删除',
  825. // style: {
  826. // backgroundColor: 'rgb(255,58,49)'
  827. // }
  828. // }
  829. // ],
  830. // content: '新增' + new Date().getTime()
  831. // });
  832. // uni.showToast({
  833. // title: `添加了一条数据`,
  834. // icon: 'none',
  835. // duration: 3000
  836. // });
  837. // } else {
  838. // uni.showToast({
  839. // title: `点击了${e.content.text}按钮`,
  840. // icon: 'none',
  841. // duration: 3000
  842. // });
  843. // }
  844. // }
  845. }
  846. };
  847. </script>
  848. <style lang="scss">
  849. .sticky-box {
  850. /* #ifndef APP-PLUS-NVUE */
  851. // display: flex;
  852. position: -webkit-sticky;
  853. /* #endif */
  854. position: sticky;
  855. top: var(--window-top);
  856. z-index: 99;
  857. flex-direction: row;
  858. margin: 0px;
  859. // padding: 15px 0 15px 0;
  860. background-color: #F4F5F6;
  861. // border-bottom-style: solid;
  862. // border-bottom-color: #E2E2E2;
  863. }
  864. .content-box {
  865. flex: 1;
  866. /* #ifdef APP-NVUE */
  867. justify-content: center;
  868. /* #endif */
  869. height: 44px;
  870. line-height: 44px;
  871. padding: 0 15px;
  872. position: relative;
  873. background-color: #fff;
  874. border-bottom-color: #f5f5f5;
  875. border-bottom-width: 1px;
  876. border-bottom-style: solid;
  877. }
  878. .content-text {
  879. font-size: 15px;
  880. }
  881. .example-body {
  882. /* #ifndef APP-NVUE */
  883. display: flex;
  884. /* #endif */
  885. flex-direction: row;
  886. justify-content: center;
  887. padding: 10px 0;
  888. background-color: #fff;
  889. }
  890. .button {
  891. border-color: #e5e5e5;
  892. border-style: solid;
  893. border-width: 1px;
  894. padding: 4px 8px;
  895. border-radius: 4px;
  896. }
  897. .button-text {
  898. font-size: 15px;
  899. }
  900. .slot-button {
  901. /* #ifndef APP-NVUE */
  902. display: flex;
  903. height: 100%;
  904. /* #endif */
  905. flex: 1;
  906. flex-direction: row;
  907. justify-content: center;
  908. align-items: center;
  909. padding: 0 20px;
  910. background-color: #ff5a5f;
  911. }
  912. .slot-button-text {
  913. color: #ffffff;
  914. font-size: 14px;
  915. }
  916. .search-result {
  917. // padding-top: 10px;
  918. // padding-bottom: 20px;
  919. text-align: center;
  920. }
  921. .search-result-text {
  922. text-align: center;
  923. font-size: 14px;
  924. color: #666;
  925. }
  926. .example-body {
  927. /* #ifndef APP-NVUE */
  928. display: block;
  929. /* #endif */
  930. padding: 0px;
  931. }
  932. .uni-mt-10 {
  933. margin-top: 10px;
  934. }
  935. .card-bottom {
  936. touch-action: none;
  937. // height: 60px;
  938. position: fixed;
  939. bottom: 0;
  940. width: 100%;
  941. z-index: 999;
  942. background-color: white;
  943. border-top: 1px;
  944. display: flex;
  945. flex-direction: column;
  946. }
  947. .text {
  948. font-size: 12px;
  949. color: #666;
  950. margin-top: 5px;
  951. }
  952. .uni-px-5 {
  953. padding-left: 10px;
  954. padding-right: 10px;
  955. }
  956. .uni-pb-5 {
  957. padding-bottom: 10px;
  958. }
  959. .warp {
  960. padding: 10px;
  961. }
  962. .button {
  963. margin-bottom: 10px;
  964. }
  965. .segmented-control {
  966. margin-bottom: 15px;
  967. }
  968. .button-group {
  969. margin-top: 15px;
  970. display: flex;
  971. justify-content: space-around;
  972. }
  973. .form-item {
  974. display: flex;
  975. align-items: center;
  976. }
  977. .button {
  978. display: flex;
  979. align-items: center;
  980. height: 35px;
  981. margin-left: 10px;
  982. }
  983. </style>
  984. <style lang="scss">
  985. .u-page {
  986. padding: 0;
  987. }
  988. .u-demo-block__title {
  989. padding: 10px 0 2px 15px;
  990. }
  991. .swipe-action {
  992. &__content {
  993. padding: 25rpx 0;
  994. display: flex;
  995. flex-direction: column; //设置布局方向为竖直
  996. &__text {
  997. font-size: 15px;
  998. color: $u-main-color;
  999. padding-left: 30rpx;
  1000. }
  1001. }
  1002. }
  1003. .u-swipe-action-item {
  1004. touch-action: none;
  1005. }
  1006. .red {
  1007. color: red;
  1008. }
  1009. .label-picker-container {
  1010. display: flex;
  1011. align-items: center;
  1012. /* 垂直居中对齐 */
  1013. font-size: 12px;
  1014. /* 设置标签的字体大小 */
  1015. }
  1016. .label-class {
  1017. margin-right: 10px;
  1018. /* 设置标签与选择框之间的横向间距 */
  1019. }
  1020. </style>