inventory.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <!-- 盘点清单 -->
  3. <view class="">
  4. <uni-nav-bar
  5. fixed="true"
  6. statusBar="true"
  7. left-icon="back"
  8. @clickLeft="back"
  9. :title="`盘点清单(${infoData.bizTypeName})`"
  10. >
  11. <block slot="right">
  12. <view class="bc-btn" @click="handlBc"> 提交 </view>
  13. </block>
  14. </uni-nav-bar>
  15. <view class="tab-title">
  16. <view
  17. v-for="[key, item] in Object.entries(tabList)"
  18. :key="key"
  19. class="tab-item"
  20. :class="{ active: active == key }"
  21. @click="changeChartsTab(key)"
  22. >{{ key }}({{ item.num }})
  23. </view>
  24. </view>
  25. <view class="tab-main">
  26. <uni-search-bar
  27. @input="search"
  28. v-model="searchKey"
  29. cancelButton="none"
  30. placeholder="编码/名称/货位/批次"
  31. >
  32. </uni-search-bar>
  33. <template v-if="tabList[active].list.length > 0">
  34. <view
  35. class="order-list"
  36. v-for="(item, index) in tabList[active].list"
  37. :key="index"
  38. >
  39. <view class="s1">
  40. <view class="b1"> {{ item.assetName }}({{ item.assetCode }}) </view>
  41. <view class="b2">
  42. <template v-if="[5, 6, 7].includes(item.equStatus)">
  43. <view
  44. class="type"
  45. :style="styleClass(el.type)"
  46. v-for="el in ycEquStatus(item)"
  47. >
  48. {{ dict.equStatus[el.type] }}({{ el.num }})
  49. </view>
  50. </template>
  51. <view class="type" :style="styleClass(item.equStatus)" v-else>
  52. {{ dict.equStatus[item.equStatus] }}
  53. </view>
  54. </view>
  55. </view>
  56. <view class="wrap">
  57. <view class="item">
  58. <view class="label"> 牌号 </view>
  59. <view class="value">
  60. {{ item.assetBrand }}
  61. </view>
  62. </view>
  63. <view class="item">
  64. <view class="label"> 型号 </view>
  65. <view class="value">
  66. {{ item.assetSku }}
  67. </view>
  68. </view>
  69. </view>
  70. <view class="wrap">
  71. <view class="item">
  72. <view class="label"> 类型 </view>
  73. <view class="value">
  74. {{ item.assetTypeDictDESC }}
  75. </view>
  76. </view>
  77. </view>
  78. <view class="wrap">
  79. <view class="item">
  80. <view class="label"> 最小单元 </view>
  81. <view class="value">
  82. {{ item.measurementUnit }} {{ item.unit }}/{{
  83. item.minPackUnit
  84. }}
  85. </view>
  86. </view>
  87. <view class="item">
  88. <view class="label"> 数量 </view>
  89. <view class="value">
  90. <text v-if="active == '待盘点'">{{ item.yetNum }}/</text
  91. >{{ item.inventoryNum }}
  92. </view>
  93. </view>
  94. </view>
  95. <view class="wrap" style="padding-right: 100rpx">
  96. <view class="item" v-if="item.equStatus == 3" style="width: 100%">
  97. <view class="label"> 货位 </view>
  98. <view class="value">
  99. {{ item.warehouseName }}/{{ item.reservoirName }}/{{
  100. item.goodsShelfName
  101. }}/{{ item.goodsAllocationName }}
  102. </view>
  103. </view>
  104. </view>
  105. <!-- <view class="wrap">
  106. <view class="item">
  107. <view class="label">
  108. 货位
  109. </view>
  110. <view class="value">
  111. {{item.warehouseName}}/{{item.reservoirName}}/{{item.goodsShelfName}}/{{item.goodsAllocationName}}
  112. </view>
  113. </view>
  114. </view> -->
  115. <template
  116. v-if="isExecute && (infoData.status == 1 || infoData.status == 6)"
  117. >
  118. <template v-if="active == '待盘点'">
  119. <view
  120. class="bd-btn"
  121. @click="handlSdpd(item)"
  122. v-if="item.inventoryNum > 0"
  123. >
  124. 手动盘点
  125. </view>
  126. <view class="bd-btn" @click="handlQrpd(item)" v-else>
  127. 标记已盘
  128. </view>
  129. </template>
  130. <view
  131. class="bd-btn"
  132. @click="handlDelete(item)"
  133. v-if="active == '已盘点' || active == '异常记录'"
  134. >
  135. 移除
  136. </view>
  137. </template>
  138. </view>
  139. </template>
  140. <u-empty v-else> </u-empty>
  141. </view>
  142. <view
  143. class="fixed-bottom"
  144. v-if="isExecute && (infoData.status === 1 || infoData.status == 6)"
  145. >
  146. <view class="ycdj" @click="handlYc"> 溢出登记 </view>
  147. <!-- <view class="smpd" @click="handlscanCheck">
  148. 扫码盘点
  149. </view> -->
  150. <view class="smpd" @click="handlscanCheck"> 扫码盘点 </view>
  151. </view>
  152. <view class="fixed-bottom" v-if="isExecute && infoData.status === 0">
  153. <view class="kspd" @click="handlStart"> 开始盘点 </view>
  154. </view>
  155. <!-- <ScanCode @scancodedate="cbScancodedate" :model="'uni'"></ScanCode> -->
  156. </view>
  157. </template>
  158. <script>
  159. import { postJ, post, get } from '@/utils/api'
  160. let [page, size, isEnd] = [1, 20, true]
  161. import ScanCode from '@/components/ScanCode.vue'
  162. import _ from 'lodash'
  163. export default {
  164. components: {
  165. ScanCode
  166. },
  167. data () {
  168. return {
  169. active: '待盘点',
  170. tabList: {
  171. 待盘点: {
  172. num: 0,
  173. type: [0],
  174. list: []
  175. },
  176. 已盘点: {
  177. num: 0,
  178. type: [4],
  179. list: []
  180. },
  181. 异常记录: {
  182. num: 0,
  183. type: [1, 2, 3, 5, 6, 7],
  184. list: []
  185. }
  186. },
  187. searchKey: '',
  188. /* 盘点工单id */
  189. workOrderId: '',
  190. // 工单编码
  191. workOrderCode: '',
  192. // 盘点类型,仓库内,仓库外
  193. BizType: '',
  194. // 工单详情
  195. infoData: '',
  196. dict: {
  197. equStatus: {
  198. 0: '待盘',
  199. 1: '丢失',
  200. 2: '破损',
  201. 3: '溢出',
  202. 4: '正常',
  203. 5: '异常'
  204. }
  205. },
  206. // 扫码条码信息
  207. qrContent: '',
  208. barType: '',
  209. ScanData: ''
  210. }
  211. },
  212. onLoad (data) {
  213. this.workOrderId = data.id
  214. this.workOrderCode = data.workOrderCode
  215. this.BizType = data.BizType
  216. this.search = _.debounce(this.search, 1000)
  217. },
  218. onShow () {
  219. this.initPagination()
  220. this.getdata()
  221. this.getNum()
  222. this.getdetales()
  223. let _this = this
  224. uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
  225. uni.$on('scancodedate', function (data) {
  226. _this.cbScancodedate(data)
  227. })
  228. },
  229. onUnload () {
  230. uni.$off('scancodedate')
  231. },
  232. onHide () {
  233. uni.$off('scancodedate')
  234. },
  235. onReachBottom () {
  236. if (isEnd) {
  237. return
  238. }
  239. this.getMoreLists()
  240. console.log('触底')
  241. },
  242. onPullDownRefresh () {
  243. this.initPagination()
  244. this.getdata()
  245. this.getNum()
  246. console.log('下拉刷新')
  247. },
  248. computed: {
  249. // 当前是否为执行人
  250. isExecute () {
  251. let userInfo = uni.getStorageSync('userInfo')
  252. // 当前登录人id
  253. let userId = userInfo.id
  254. console.log()
  255. // 审批人id
  256. let executeUserId = this.infoData.executeUserId
  257. if (executeUserId == userId) {
  258. return true
  259. } else {
  260. return false
  261. }
  262. }
  263. },
  264. methods: {
  265. changeChartsTab (key) {
  266. this.active = key
  267. this.initPagination()
  268. this.getdata()
  269. this.getNum()
  270. },
  271. search (e) {
  272. this.searchKey = e
  273. this.initPagination()
  274. this.getdata()
  275. },
  276. getdata () {
  277. uni.showLoading({
  278. title: '加载中'
  279. })
  280. let par = {
  281. size: size,
  282. page: page,
  283. workOrderId: this.workOrderId,
  284. equStatusList: this.tabList[this.active].type,
  285. searchKey: this.searchKey,
  286. bizType: Number(this.BizType)
  287. //bizType:2
  288. }
  289. //par = this.URLSearchParams(par)
  290. postJ(this.apiUrl + '/repertoryCheck/getList', par).then(res => {
  291. if (res.success) {
  292. let list = this.tabList[this.active].list
  293. this.tabList[this.active].list = [...list, ...res.data.records]
  294. let pages = res.data.pages
  295. if (page < pages) {
  296. isEnd = false
  297. } else {
  298. isEnd = true
  299. }
  300. console.log(page, pages, isEnd)
  301. setTimeout(() => {
  302. uni.stopPullDownRefresh()
  303. uni.hideLoading()
  304. }, 1000)
  305. }
  306. })
  307. },
  308. getMoreLists () {
  309. page++
  310. this.getdata()
  311. },
  312. // 初始化分页
  313. initPagination () {
  314. size = 10
  315. page = 1
  316. isEnd = true
  317. this.tabList[this.active].list = []
  318. },
  319. // 删除清单
  320. handlDelete (item) {
  321. uni.showModal({
  322. content: '是否移除已盘清单?',
  323. success: res => {
  324. if (res.confirm) {
  325. let par = {
  326. id: item.id
  327. }
  328. par = this.URLSearchParams(par)
  329. post(this.apiUrl + '/repertoryCheck/deleteInventory?' + par).then(
  330. res => {
  331. if (res.success) {
  332. uni.showToast({
  333. title: '已移除'
  334. })
  335. this.initPagination()
  336. this.getdata()
  337. this.getNum()
  338. }
  339. }
  340. )
  341. }
  342. }
  343. })
  344. },
  345. // 获取数量
  346. getNum () {
  347. let par = {
  348. workOrderId: this.workOrderId
  349. }
  350. par = this.URLSearchParams(par)
  351. post(this.apiUrl + '/repertoryCheck/statistics?' + par).then(res => {
  352. if (res.success) {
  353. this.tabList['待盘点'].num = res.data.stayNum
  354. this.tabList['已盘点'].num = res.data.yetNum
  355. this.tabList['异常记录'].num = res.data.abnormalNum
  356. }
  357. })
  358. },
  359. // 跳转盘点详情
  360. handlBc () {
  361. let par = {
  362. workOrderId: this.workOrderId
  363. }
  364. par = this.URLSearchParams(par)
  365. uni.navigateTo({
  366. url: '/pages/warehouse/workOrder/details/details?' + par
  367. })
  368. },
  369. // 手动盘点
  370. handlSdpd (item) {
  371. let par = {
  372. workOrderId: this.workOrderId,
  373. planInventoryId: item.id,
  374. bizType: this.BizType,
  375. info: encodeURIComponent(JSON.stringify(item))
  376. }
  377. par = this.URLSearchParams(par)
  378. uni.navigateTo({
  379. url: '/pages/warehouse/workOrder/manualCheck/manualCheck?' + par
  380. })
  381. },
  382. // 扫码盘点
  383. handlscanCheck () {
  384. // this.Scancodedate(data.code)
  385. let _this = this
  386. uni.scanCode({
  387. success: function (res) {
  388. _this.Scancodedate(res.result)
  389. }
  390. })
  391. },
  392. // 溢出登记
  393. handlYc () {
  394. let par = {
  395. workOrderId: this.workOrderId
  396. }
  397. par = this.URLSearchParams(par)
  398. uni.navigateTo({
  399. url:
  400. '/pages/warehouse/workOrder/registerOverflow/registerOverflow?' + par
  401. })
  402. },
  403. // 获取工单详情
  404. getdetales () {
  405. let par = {
  406. workOrderId: this.workOrderId
  407. }
  408. postJ(this.apiUrl + '/repertoryCheck/getCheckDetail', par).then(res => {
  409. if (res.success) {
  410. this.infoData = res.data
  411. this.infoData.status = res.data.status.code
  412. }
  413. })
  414. },
  415. // 开始盘点
  416. handlStart () {
  417. let par = this.URLSearchParams({
  418. workOrderCode: this.workOrderCode
  419. })
  420. post(this.apiUrl + '/workOrder/execute?' + par).then(res => {
  421. if (res.success) {
  422. uni.showToast({
  423. title: '操作成功'
  424. })
  425. this.getdetales()
  426. }
  427. })
  428. },
  429. // 异常的显示
  430. ycEquStatus (item) {
  431. let list = []
  432. if (item.loseNum) {
  433. list.push({
  434. type: 1,
  435. num: item.loseNum
  436. })
  437. }
  438. if (item.damageNum) {
  439. list.push({
  440. type: 2,
  441. num: item.damageNum
  442. })
  443. }
  444. if (item.normalNum) {
  445. list.push({
  446. type: 4,
  447. num: item.normalNum
  448. })
  449. }
  450. return list
  451. },
  452. styleClass (type) {
  453. switch (Number(type)) {
  454. case 0:
  455. case 4:
  456. return 'background-color: #70B603;color: #fff;'
  457. case 1:
  458. return 'background-color: #feeaeb;color: #555;'
  459. case 2:
  460. return 'background-color: #555;color: #fff;'
  461. case 3:
  462. return 'background-color: #dacde6;color: #fff;'
  463. default:
  464. break
  465. }
  466. },
  467. // 数量为0标记已盘
  468. handlQrpd (item) {
  469. uni.showModal({
  470. content: '该清单没有可盘项,是否标记已盘?',
  471. success: res => {
  472. if (res.confirm) {
  473. let par = {
  474. planInventoryId: item.id
  475. }
  476. par = this.URLSearchParams(par)
  477. post(this.apiUrl + '/repertoryCheck/checkVerify?' + par).then(
  478. res => {
  479. if (res.success) {
  480. uni.showToast({
  481. title: '操作成功'
  482. })
  483. this.initPagination()
  484. this.getdata()
  485. this.getNum()
  486. }
  487. }
  488. )
  489. }
  490. }
  491. })
  492. },
  493. // 扫码枪扫码
  494. cbScancodedate (data) {
  495. this.Scancodedate(data.code)
  496. },
  497. async Scancodedate (code) {
  498. this.qrContent = code.trim()
  499. this.barType = this.setBarType(this.qrContent)
  500. await this.getScanData()
  501. let res = await this.getScanCheckMate()
  502. // 扫码失败
  503. if (!res.success) return
  504. if (res.message === 'false') {
  505. uni.showToast({
  506. title: '该资产不在盘点清单内',
  507. duration: 2000,
  508. icon: 'none'
  509. })
  510. return
  511. }
  512. let par = {
  513. workOrderId: this.workOrderId,
  514. info: encodeURIComponent(JSON.stringify(res.data)),
  515. bizType: this.BizType
  516. }
  517. par = this.URLSearchParams(par)
  518. uni.navigateTo({
  519. url: '/pages/warehouse/workOrder/scanCheck/scanCheck?' + par
  520. })
  521. },
  522. // 设置barType
  523. setBarType (val) {
  524. let index = val.indexOf('@_@')
  525. let result = 0
  526. if (index !== -1) {
  527. let item = val.substr(index + 3, 1)
  528. if (item) {
  529. result = Number(item)
  530. }
  531. }
  532. return result
  533. },
  534. // 获取扫码设备详情
  535. getScanData () {
  536. let par = {
  537. qrContent: this.qrContent,
  538. barType: this.barType
  539. }
  540. return postJ(this.apiUrl + '/scan/getAssetInfo', par).then(res => {
  541. this.ScanData = res.data
  542. })
  543. },
  544. // 获取扫码盘点明细数据
  545. getScanCheckMate () {
  546. if (!this.ScanData.assetCode) {
  547. uni.showToast({
  548. title: '设备编码为空'
  549. })
  550. return
  551. }
  552. let par = {
  553. assetCode: this.ScanData.assetCode,
  554. bizType: this.BizType,
  555. workOrderId: this.workOrderId
  556. // assetCode: 'w05xing0002test0510050',
  557. // bizType: '1',
  558. // workOrderId: '9173'
  559. }
  560. console.log(par)
  561. return postJ(
  562. this.apiUrl + '/repertoryCheck/scanCheckMate',
  563. par,
  564. true,
  565. false
  566. ).catch(err => {
  567. if (err.code === '222') {
  568. uni.showModal({
  569. title: '提示',
  570. content: err.message,
  571. confirmText: '确认', // 确认按钮的文字
  572. showCancel: false, // 是否显示取消按钮,默认为 true
  573. success: res => {}
  574. })
  575. }
  576. })
  577. }
  578. }
  579. }
  580. </script>
  581. <style lang="scss" scoped>
  582. .bc-btn {
  583. height: 60rpx;
  584. line-height: 60rpx;
  585. background-color: #157a2c;
  586. font-size: 28rpx;
  587. color: #fff;
  588. padding: 0 30rpx;
  589. border-radius: 10rpx;
  590. }
  591. .tab-title {
  592. position: fixed;
  593. width: 100%;
  594. display: flex;
  595. justify-content: space-between;
  596. height: 82rpx;
  597. line-height: 82rpx;
  598. background-color: #ffffff;
  599. border-bottom: 1px solid #f2f2f2;
  600. z-index: 99;
  601. box-sizing: border-box;
  602. .tab-item {
  603. width: 50%;
  604. text-align: center;
  605. font-size: 32rpx;
  606. color: $uni-text-color-grey;
  607. }
  608. .tab-item.active {
  609. color: $j-primary-border-green;
  610. border-bottom: 1px solid $j-primary-border-green;
  611. }
  612. }
  613. .tab-main {
  614. margin-top: 82rpx;
  615. padding-bottom: 82rpx;
  616. }
  617. .order-list {
  618. padding: 30rpx 20rpx;
  619. border-bottom: 1px solid #f2f2f2;
  620. position: relative;
  621. .s1 {
  622. display: flex;
  623. justify-content: space-between;
  624. align-items: center;
  625. .b1 {
  626. color: #555555;
  627. font-size: 30rpx;
  628. }
  629. .b2 {
  630. color: #000000;
  631. font-size: 28rpx;
  632. display: flex;
  633. width: 500rpx;
  634. justify-content: flex-end;
  635. }
  636. .type {
  637. font-size: 28rpx;
  638. height: 40rpx;
  639. padding: 0 10rpx;
  640. line-height: 40rpx;
  641. & + .type {
  642. margin-left: 10rpx;
  643. }
  644. &.yc {
  645. background-color: #dacde6;
  646. }
  647. &.ds {
  648. background-color: #feeaeb;
  649. }
  650. &.ps {
  651. background-color: #cbcbcb;
  652. }
  653. }
  654. }
  655. .wrap {
  656. display: flex;
  657. margin-top: 20rpx;
  658. .item {
  659. color: #555555;
  660. font-size: 28rpx;
  661. display: flex;
  662. width: 340rpx;
  663. .label {
  664. margin-right: 20rpx;
  665. }
  666. }
  667. }
  668. }
  669. .bd-btn {
  670. height: 56rpx;
  671. padding: 0 20rpx;
  672. display: flex;
  673. justify-content: center;
  674. align-items: center;
  675. color: #4b7902;
  676. font-size: 28rpx;
  677. border: 1px solid #4b7902;
  678. position: absolute;
  679. bottom: 20rpx;
  680. right: 20rpx;
  681. }
  682. .fixed-bottom {
  683. position: fixed;
  684. left: 0;
  685. bottom: 0;
  686. width: 100%;
  687. height: 80rpx;
  688. display: flex;
  689. border: 1px solid #157a2c;
  690. box-sizing: border-box;
  691. .ycdj {
  692. background-color: #fff;
  693. width: 200rpx;
  694. display: flex;
  695. justify-content: center;
  696. align-items: center;
  697. color: #157a2c;
  698. }
  699. .smpd {
  700. background-color: #157a2c;
  701. flex: 1;
  702. display: flex;
  703. justify-content: center;
  704. align-items: center;
  705. color: #fff;
  706. }
  707. }
  708. .kspd {
  709. height: 100%;
  710. width: 100%;
  711. display: flex;
  712. justify-content: center;
  713. align-items: center;
  714. background-color: #157a2c;
  715. color: #fff;
  716. font-size: 28rpx;
  717. }
  718. </style>