registerOverflow.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <template>
  2. <view class="mian">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. @clickLeft="back"
  8. title="登记溢出物品"
  9. >
  10. </uni-nav-bar>
  11. <view class="">
  12. <view class="title"> 存放货位 </view>
  13. <view class="huowe-wrap">
  14. <view class="row">
  15. <view class="item" @click="handlscanCheck"> 扫描货位码 </view>
  16. </view>
  17. <view class="row">
  18. <!-- 仓库 -->
  19. <view class="item s2">
  20. <picker
  21. @change="pickerConfirm('ck', $event)"
  22. :range-key="'name'"
  23. :range="option_ck"
  24. >
  25. <view class="uni-input">{{ form.ck.name || '选择仓库' }}</view>
  26. </picker>
  27. </view>
  28. <!-- 库区 -->
  29. <view class="item s2">
  30. <picker
  31. @change="pickerConfirm('kq', $event)"
  32. :range-key="'areaName'"
  33. :range="option_kq"
  34. >
  35. <view class="uni-input">{{
  36. form.kq.areaName || '选择库区'
  37. }}</view>
  38. </picker>
  39. </view>
  40. </view>
  41. <view class="row">
  42. <!-- 货架 -->
  43. <view class="item s2">
  44. <picker
  45. @change="pickerConfirm('hj', $event)"
  46. :range-key="'goodsshelvesCode'"
  47. :range="option_hj"
  48. >
  49. <view class="uni-input">{{
  50. form.hj.goodsshelvesCode || '选择货架'
  51. }}</view>
  52. </picker>
  53. </view>
  54. <!-- 货位 -->
  55. <view class="item s2" @click="open('goodsAllocation')">
  56. {{ form.hw.goodsAllocationCode || '选择货位' }}
  57. </view>
  58. </view>
  59. </view>
  60. <view class="title"> 定义资产 </view>
  61. <view class="huowe-wrap">
  62. <view class="row">
  63. <view class="item">
  64. <picker
  65. @change="pickerConfirm('propertyType', $event)"
  66. :range-key="'dictValue'"
  67. :range="option_propertyType"
  68. >
  69. <view class="uni-input">{{
  70. form.propertyType.dictValue || '选择资产类型'
  71. }}</view>
  72. </picker>
  73. </view>
  74. </view>
  75. <view class="row" v-if="form.propertyType.dictValue">
  76. <view class="item" @click="open('selectSupplies')">
  77. {{
  78. form.materialsInformation.name ||
  79. `选择${form.propertyType.dictValue}信息`
  80. }}
  81. </view>
  82. </view>
  83. </view>
  84. <view class="order-list" v-if="form.materialsInformation">
  85. <view class="s1">
  86. <view class="b1">
  87. {{ form.materialsInformation.assetName }}
  88. </view>
  89. <view class="b2"> </view>
  90. </view>
  91. <view class="wrap">
  92. <view class="item">
  93. <view class="label"> 编码 </view>
  94. <view class="value">
  95. {{ form.materialsInformation.informationCode }}
  96. </view>
  97. </view>
  98. <view class="item">
  99. <view class="label"> 类型 </view>
  100. <view class="value">
  101. {{ form.materialsInformation.classificationUrl }}
  102. </view>
  103. </view>
  104. </view>
  105. <view class="wrap">
  106. <view class="item">
  107. <view class="label"> 牌号 </view>
  108. <view class="value">
  109. {{ form.materialsInformation.brandNum }}
  110. </view>
  111. </view>
  112. <view class="item">
  113. <view class="label"> 型号 </view>
  114. <view class="value">
  115. {{ form.materialsInformation.modelType }}
  116. </view>
  117. </view>
  118. </view>
  119. <view class="wrap">
  120. <view class="item">
  121. <view class="label">
  122. <text style="color: red">*</text>最小包装单元
  123. </view>
  124. <view class="input-wrap">
  125. <u--input
  126. class="input"
  127. placeholder="请输入"
  128. border="surround"
  129. v-model="form.measurementUnit"
  130. ></u--input>
  131. </view>
  132. </view>
  133. <view class="item">
  134. <view class="label">
  135. {{ form.materialsInformation.measuringUnit }}/{{
  136. form.materialsInformation.packingUnit
  137. }}
  138. </view>
  139. <view class="value"> </view>
  140. </view>
  141. </view>
  142. <view class="wrap">
  143. <view class="item">
  144. <view class="label"> <text style="color: red">*</text>数量 </view>
  145. <view class="input-wrap">
  146. <u--input
  147. class="input"
  148. type="number"
  149. placeholder="请输入"
  150. border="surround"
  151. v-model="form.checkNum"
  152. ></u--input>
  153. </view>
  154. </view>
  155. </view>
  156. <view class="wrap">
  157. <view class="item">
  158. <view class="label">
  159. <text style="color: red">*</text>
  160. 批次号
  161. </view>
  162. <view class="input-wrap">
  163. <u--input
  164. class="input"
  165. placeholder="请输入"
  166. border="surround"
  167. v-model="form.batchNum"
  168. ></u--input>
  169. </view>
  170. </view>
  171. </view>
  172. </view>
  173. <!-- 弹框 -->
  174. <goodsAllocation
  175. ref="goodsAllocation"
  176. :dataInfo="option_hw"
  177. @succeed="succeedGoodsAllocation"
  178. >
  179. </goodsAllocation>
  180. <selectSupplies
  181. ref="selectSupplies"
  182. :classificationIds="form.propertyType.id"
  183. @succeed="succeedSelectSupplies"
  184. >
  185. </selectSupplies>
  186. </view>
  187. <view class="fixed-bottom">
  188. <view class="btn-wrap">
  189. <button type="primary" class="qr-btn" @click="onsubmit">
  190. 确认信息
  191. </button>
  192. <button type="primary" class="qx-btn" @click="back">取消</button>
  193. </view>
  194. </view>
  195. <!-- <ScanCode @scancodedate="cbScancodedate" :model="'uni'"></ScanCode> -->
  196. </view>
  197. </template>
  198. <script>
  199. import goodsAllocation from '../components/goodsAllocation.vue'
  200. import selectSupplies from '../components/selectSupplies.vue'
  201. import ScanCode from '@/components/ScanCode.vue'
  202. import { mapActions, mapGetters } from 'vuex'
  203. import { postJ, post, get } from '@/utils/api'
  204. import { reject } from 'lodash'
  205. import dictEnum from '@/enum/dict'
  206. export default {
  207. components: {
  208. goodsAllocation,
  209. selectSupplies,
  210. ScanCode
  211. },
  212. data () {
  213. return {
  214. dictName: '物品类型',
  215. // 工单id
  216. workOrderId: '',
  217. /* 仓库/货位所有信息 */
  218. warehouseInfo: [],
  219. form: {
  220. // 仓库
  221. ck: '',
  222. // 库区
  223. kq: '',
  224. // 货架
  225. hj: '',
  226. // 货位
  227. hw: '',
  228. // 资产类型
  229. propertyType: '',
  230. // 物料信息
  231. materialsInformation: '',
  232. // 计量单位数量
  233. measurementUnit: '',
  234. // 数量
  235. checkNum: '',
  236. // 批次号
  237. batchNum: ''
  238. },
  239. MyDict: {
  240. code: {
  241. 1: '生产设备',
  242. 2: '舟皿',
  243. 3: '物料',
  244. 4: '产品',
  245. 5: '周转车',
  246. 6: '模具',
  247. 7: '备品备件'
  248. },
  249. assetTypeDict: {
  250. 1: 'SHENGCHANSHEBEI',
  251. 2: 'ZHOUMIN',
  252. 3: 'WULIAO',
  253. 4: 'CHANPIN',
  254. 5: 'ZHOUZHUANCHE',
  255. 6: 'MOJU',
  256. 7: 'BEIPINBEIJIAN'
  257. }
  258. },
  259. qrContent: '',
  260. barType: ''
  261. }
  262. },
  263. computed: {
  264. ...mapGetters(['dict', 'getDict', 'getDictValue']),
  265. option_ck () {
  266. return this.warehouseInfo
  267. },
  268. option_kq () {
  269. if (this.form.ck) {
  270. return this.form.ck.wareHouseArea
  271. } else {
  272. return []
  273. }
  274. },
  275. option_hj () {
  276. if (this.form.kq) {
  277. return this.form.kq.wareHouseGoodsshelves
  278. } else {
  279. return []
  280. }
  281. },
  282. option_hw () {
  283. if (this.form.hj) {
  284. return this.form.hj.wareHouseGoodsAllocation
  285. } else {
  286. return []
  287. }
  288. },
  289. option_propertyType () {
  290. return this.dict[dictEnum[this.dictName]] || []
  291. }
  292. },
  293. watch: {
  294. 'form.propertyType': function (Nval) {
  295. this.form.materialsInformation = ''
  296. }
  297. },
  298. created () {
  299. this.getwarehouseList()
  300. if (this.dictName) {
  301. this.requestDict(this.dictName)
  302. }
  303. },
  304. onLoad (option) {
  305. this.workOrderId = option.workOrderId
  306. },
  307. onShow () {
  308. let _this = this
  309. uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
  310. uni.$on('scancodedate', function (data) {
  311. _this.cbScancodedate(data)
  312. })
  313. },
  314. onUnload () {
  315. uni.$off('scancodedate')
  316. },
  317. onHide () {
  318. uni.$off('scancodedate')
  319. },
  320. methods: {
  321. ...mapActions('dict', ['requestDict']),
  322. // 返回
  323. back () {
  324. uni.navigateBack({
  325. delta: 1
  326. })
  327. },
  328. // 弹窗确认
  329. pickerConfirm (type, e) {
  330. this.form[type] = this['option_' + type][e.detail.value]
  331. if (type == 'ck') {
  332. this.form.kq = ''
  333. this.form.hj = ''
  334. this.form.hw = ''
  335. }
  336. if (type == 'kq') {
  337. this.form.hj = ''
  338. this.form.hw = ''
  339. }
  340. if (type == 'hj') {
  341. this.form.hw = ''
  342. }
  343. },
  344. // 默认值
  345. defaultIndex (type) {
  346. if (this.option[type].length < 1) {
  347. return []
  348. }
  349. let index = this.option[type].findIndex(n => {
  350. return n.id == this.form[type].id
  351. })
  352. if (index !== -1) {
  353. return [index]
  354. } else {
  355. return []
  356. }
  357. },
  358. // 打开弹窗
  359. open (type) {
  360. this.$refs[type].open()
  361. },
  362. succeedGoodsAllocation (e) {
  363. this.form.hw = e.data
  364. },
  365. succeedSelectSupplies (e) {
  366. this.form.materialsInformation = e.data
  367. },
  368. //获取仓库/货位
  369. getwarehouseList () {
  370. post(this.apiUrl + '/outInWarehouse/select/getWarehouseChildren').then(
  371. res => {
  372. if (res.success) {
  373. this.warehouseInfo = res.data
  374. }
  375. }
  376. )
  377. },
  378. // 确认
  379. onsubmit () {
  380. this.verification()
  381. .then(() => {
  382. let par = {}
  383. par.workOrderId = this.workOrderId
  384. par.assetBrand = this.form.materialsInformation.brandNum
  385. par.assetCode = this.form.materialsInformation.informationCode
  386. par.assetId = this.form.materialsInformation.id
  387. par.assetName = this.form.materialsInformation.informationName
  388. par.assetSku = this.form.materialsInformation.informationName
  389. par.assetTypeDict = this.form.propertyType.dictCode
  390. par.bizTypeId = this.form.materialsInformation.id
  391. // 最小包装单位
  392. par.minPackUnit = this.form.materialsInformation.packingUnit
  393. // 计量单位数量
  394. par.measurementUnit = this.form.measurementUnit
  395. // 物品数量
  396. par.checkNum = this.form.checkNum
  397. // 批次号
  398. par.batchNo = this.form.batchNum
  399. // 计量单位
  400. par.unit = this.form.materialsInformation.measuringUnit
  401. par.informationId = this.form.materialsInformation.id
  402. par.informationCode = this.form.materialsInformation.informationCode
  403. // 参考单价
  404. par.univalence = this.form.materialsInformation.univalence
  405. par.univalenceUnit = this.form.materialsInformation.univalenceUnit
  406. let ck = {
  407. warehouseId: this.form.ck.id,
  408. warehouseName: this.form.ck.name
  409. }
  410. let kq = {
  411. reservoirId: this.form.kq.areaId,
  412. reservoirName: this.form.kq.areaName
  413. }
  414. let hj = {
  415. goodsShelfId: this.form.hj.goodsshelvesId,
  416. goodsShelfName: this.form.hj.goodsshelvesCode
  417. }
  418. let hw = {
  419. goodsAllocationId: this.form.hw.goodsAllocationId,
  420. goodsAllocationName: this.form.hw.goodsAllocationCode
  421. }
  422. par = Object.assign(par, ck, kq, hj, hw)
  423. postJ(this.apiUrl + '/repertoryCheck/meanwhileSave', par).then(
  424. res => {
  425. if (res.success) {
  426. uni.showToast({
  427. title: '登记成功',
  428. duration: 1000
  429. })
  430. setTimeout(() => {
  431. this.back()
  432. }, 1000)
  433. }
  434. }
  435. )
  436. })
  437. .catch(err => {
  438. uni.showToast({
  439. title: err,
  440. icon: 'none'
  441. })
  442. })
  443. },
  444. /* 验证 */
  445. verification () {
  446. return new Promise((resolve, reject) => {
  447. if (!this.form.ck) {
  448. reject('请选择仓库')
  449. }
  450. if (!this.form.kq) {
  451. reject('请选择库区')
  452. }
  453. if (!this.form.hj) {
  454. reject('请选择货架')
  455. }
  456. if (!this.form.hw) {
  457. reject('请选择货位')
  458. }
  459. if (!this.form.propertyType) {
  460. reject('请选择资产类型')
  461. }
  462. if (!this.form.materialsInformation) {
  463. reject('请选择物料信息')
  464. }
  465. if (!this.form.checkNum) {
  466. reject('请输入数量')
  467. }
  468. if (!this.form.measurementUnit) {
  469. reject('请输入计量单位')
  470. }
  471. if (!this.form.batchNum) {
  472. reject('请输入批次号')
  473. }
  474. resolve()
  475. })
  476. },
  477. // 扫码枪扫码
  478. cbScancodedate (data) {
  479. this.Scancodedate(data.code)
  480. },
  481. async Scancodedate (code) {
  482. this.qrContent = code.trim()
  483. this.barType = this.setBarType(this.qrContent)
  484. await this.getScanData()
  485. //let res = await this.getScanCheckMate()
  486. },
  487. // 相机扫码
  488. handlscanCheck () {
  489. // this.Scancodedate(data.code)
  490. let _this = this
  491. uni.scanCode({
  492. success: function (res) {
  493. _this.Scancodedate(res.result)
  494. }
  495. })
  496. },
  497. // 获取扫码货位详情
  498. getScanData () {
  499. let par = {
  500. qrContent: this.qrContent,
  501. barType: this.barType
  502. /* qrContent: '20230406/锤锤工厂/A-feifei01/D002/模压备件组/B01/C001@_@2',
  503. barType: 2 */
  504. }
  505. return postJ(this.apiUrl + '/scan/getAssetInfo', par).then(res => {
  506. console.log('par', par)
  507. if (!res.data.warehouseId) {
  508. uni.showToast({
  509. title: '扫描货位码失败,请检查货位码',
  510. icon: 'none',
  511. duration: 1000
  512. })
  513. }
  514. let ck = this.warehouseInfo.find(n => {
  515. return n.id == res.data.warehouseId
  516. })
  517. if (ck) {
  518. this.form.ck = ck
  519. }
  520. let kq = this.option_kq.find(n => {
  521. return n.areaId == res.data.warehouseAreaId
  522. })
  523. if (kq) {
  524. this.form.kq = kq
  525. }
  526. let hj = this.option_hj.find(n => {
  527. return n.goodsshelvesId == res.data.warehouseAreaGoodsId
  528. })
  529. if (hj) {
  530. this.form.hj = hj
  531. }
  532. let hw = this.option_hw.find(n => {
  533. return n.goodsAllocationId == res.data.id
  534. })
  535. if (hw) {
  536. // 已满不选
  537. if (hw.allocationStatus == 3 || hw.allocationStatus == 4) {
  538. uni.showToast({
  539. title: '该货位已满或失效',
  540. duration: 1000
  541. })
  542. // 清空
  543. this.form.kq = ''
  544. this.form.hj = ''
  545. this.form.hw = ''
  546. return
  547. }
  548. this.form.hw = hw
  549. }
  550. })
  551. },
  552. // 设置barType
  553. setBarType (val) {
  554. let index = val.indexOf('@_@')
  555. let result = 0
  556. if (index !== -1) {
  557. let item = val.substr(index + 3, 1)
  558. if (item) {
  559. result = Number(item)
  560. }
  561. }
  562. return result
  563. }
  564. }
  565. }
  566. </script>
  567. <style lang="scss" scoped>
  568. $cols: 2;
  569. $marginWidth: 10rpx;
  570. .mian {
  571. padding-bottom: 300rpx;
  572. }
  573. .title {
  574. padding: 20rpx;
  575. color: #333333;
  576. font-size: 28rpx;
  577. font-weight: bold;
  578. }
  579. .huowe-wrap {
  580. padding: 0 20rpx;
  581. .row {
  582. display: flex;
  583. & + .row {
  584. margin-top: 10rpx;
  585. }
  586. .item {
  587. flex: 1;
  588. display: flex;
  589. border: 1px solid #aaaaaa;
  590. color: #333333;
  591. font-size: 28rpx;
  592. height: 66rpx;
  593. justify-content: center;
  594. align-items: center;
  595. }
  596. .item.s2 {
  597. width: calc((100% - #{($cols - 1)} * $marginWidth) / #{$cols});
  598. margin-left: $marginWidth;
  599. }
  600. .item.s2:nth-of-type(#{$cols}n + 1) {
  601. margin-left: 0;
  602. }
  603. }
  604. }
  605. .fixed-bottom {
  606. background-color: #fff;
  607. width: 100%;
  608. position: fixed;
  609. left: 0;
  610. bottom: 0;
  611. padding: 30rpx;
  612. box-sizing: border-box;
  613. .btn-wrap {
  614. margin-top: 30rpx;
  615. .qr-btn {
  616. background-color: #70b603f3;
  617. }
  618. .qx-btn {
  619. background-color: transparent;
  620. color: #555555;
  621. margin-top: 20rpx;
  622. }
  623. }
  624. }
  625. .order-list {
  626. padding: 30rpx 20rpx;
  627. border-bottom: 1px solid #f2f2f2;
  628. position: relative;
  629. &.active {
  630. background-color: #caf982;
  631. }
  632. .s1 {
  633. display: flex;
  634. justify-content: space-between;
  635. align-items: center;
  636. .b1 {
  637. color: #555555;
  638. font-size: 30rpx;
  639. }
  640. .b2 {
  641. color: #000000;
  642. font-size: 28rpx;
  643. }
  644. }
  645. .wrap {
  646. display: flex;
  647. margin-top: 20rpx;
  648. .item {
  649. color: #555555;
  650. font-size: 28rpx;
  651. display: flex;
  652. width: 340rpx;
  653. align-items: center;
  654. .label {
  655. margin-right: 20rpx;
  656. white-space: nowrap;
  657. }
  658. .input-wrap {
  659. padding-right: 20rpx;
  660. }
  661. .input {
  662. border: 1px solid #f2f2f2;
  663. }
  664. }
  665. }
  666. .uni-input {
  667. border: 1px solid #f2f2f2;
  668. font-size: 28rpx;
  669. }
  670. }
  671. </style>