incomingPage.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <gui-page :custom-header="true" :is-header-sized="false"
  3. :header-class="['gui-theme-background-color', isLandscapeScreen?'width: 100vmax;':'']"
  4. :style="[isLandscapeScreen?'width: 100vmax':'']">
  5. <template #gHeader>
  6. <view :style="[isLandscapeScreen?'height:44px;width: 100vmax':'height:44px;']"
  7. class="gui-flex gui-nowrap gui-rows gui-align-items-center">
  8. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  9. <text style="font-size:44rpx;" class="gui-header-leader-btns gui-color-white font-icons"
  10. @tap="goBack">&#xe6c5;</text>
  11. <!-- 导航文本此处也可以是其他自定义内容 -->
  12. <text
  13. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-color-white gui-ellipsis gui-primary-text">物料上架</text>
  14. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  15. <!-- 实际宽度请根据自己情况设置 -->
  16. <view style="width:40px;" />
  17. </view>
  18. </template>
  19. <template #gBody>
  20. <list class="form">
  21. <cell>
  22. <view class="row-1">
  23. <view class="row-1-card">
  24. <uni-easyinput ref="easyinput" v-model="submitParams.storeName" :input-border="false"
  25. :clearable="false" type="text" focus @focus="handleInputFocus" placeholder="请扫描库位信息"
  26. @confirm="confirmStore" />
  27. <view style="display: flex; flex-direction: row;">
  28. <text class="font-icons" @click="popup.open('center')">&#xe6a8;</text>
  29. <text class="font-icons" @click="handleMapass('货位')">&#xe6b7;</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="row-2">
  34. <view class="row-2-card">
  35. <uni-easyinput ref="easyinput2" v-model="submitParams.qrCode" :input-border="false"
  36. :clearable="false" type="text" @focus="handleInputFocus" placeholder="请扫描物料"
  37. @confirm="confirmMaterial" />
  38. <text class="font-icons" @click="handleMapass('物料')">&#xe6b7;</text>
  39. </view>
  40. </view>
  41. <view class="row-3">
  42. <view class="row-3-card">
  43. <view class="row-space-between">
  44. <text>仓库</text>
  45. <text>{{ computedStock(submitParams.erpStockId) }}</text>
  46. </view>
  47. <view class="row-space-between">
  48. <text>区域</text>
  49. <text>{{ computedStoreArea(submitParams.wmsStoreAreaId) }}</text>
  50. </view>
  51. <view class="row-space-between">
  52. <text>货位</text>
  53. <text>{{ computedStore(submitParams.wmsStoreId) }}</text>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="row-4">
  58. <view class="row-4-card">
  59. <view class="row-space-between">
  60. <text>物料编码</text>
  61. <text>{{ submitParams.materialNo }}</text>
  62. </view>
  63. <view class="row-space-between">
  64. <text>物料批次</text>
  65. <text>{{ submitParams.materialLots }}</text>
  66. </view>
  67. <view class="row-space-between">
  68. <text>物料名称</text>
  69. <text>{{ submitParams.materialName }}</text>
  70. </view>
  71. <view class="row-space-between">
  72. <text>生产日期</text>
  73. <text>{{ submitParams.produceDate }}</text>
  74. </view>
  75. <view class="row-space-between">
  76. <text>批次数量</text>
  77. <text>{{ submitParams.inQty }}</text>
  78. </view>
  79. <view class="row-space-between">
  80. <text>供应商</text>
  81. <text>{{ submitParams.supplierName }}</text>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="row-operation">
  86. <view class="row-operation-card">
  87. <view class="button" size="primary" @click="handleSubmit">
  88. <text class="gui-color-white">上架</text>
  89. </view>
  90. </view>
  91. </view>
  92. </cell>
  93. </list>
  94. <view>
  95. <!-- 提示窗示例 -->
  96. <uni-popup ref="popup" type="dialog">
  97. <uni-popup-dialog type="warn" cancel-text="取消" confirm-text="确认" title="手动分配货位"
  98. content="欢迎使用 uni-popup!" @confirm="popup.close()" @close="popup.close()">
  99. <!-- eslint-disable-next-line -->
  100. <template #default="custom">
  101. <view class="select-group">
  102. <view class="select-item">
  103. <text class="store-text">仓库</text>
  104. <view class="custom-select">
  105. <uni-data-select v-model="submitParams.erpStockId" :localdata="warehouseList"
  106. @change="handleSelectWareHouse" />
  107. </view>
  108. </view>
  109. <view class="select-item">
  110. <text class="store-text">区域</text>
  111. <view class="custom-select">
  112. <uni-data-select v-model="submitParams.wmsStoreAreaId" :localdata="regionList"
  113. @change="handleSelectRegion" />
  114. </view>
  115. </view>
  116. <view class="select-item">
  117. <text class="store-text">货位</text>
  118. <view class="custom-select">
  119. <uni-data-select v-model="submitParams.wmsStoreId" :localdata="locationList" />
  120. </view>
  121. </view>
  122. </view>
  123. </template>
  124. </uni-popup-dialog>
  125. </uni-popup>
  126. <uni-popup ref="errorTip" type="dialog">
  127. <uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示"
  128. :content="errorTipMessage" @confirm="handleCloseErrorTipsModal"
  129. @close="handleCloseErrorTipsModal" />
  130. </uni-popup>
  131. </view>
  132. </template>
  133. </gui-page>
  134. </template>
  135. <script>
  136. import {
  137. computed,
  138. defineComponent,
  139. ref
  140. } from 'vue'
  141. import {
  142. useSetWareHouseStore
  143. } from '@/stores/useSetWareHouseStore.js';
  144. export default defineComponent({
  145. setup() {
  146. const goBack = function() {
  147. uni.navigateBack({
  148. delta: 1
  149. })
  150. }
  151. const errorTip = ref('')
  152. const errorTipMessage = ref('')
  153. const easyinput = ref('')
  154. const easyinput2 = ref('')
  155. const errorState = ref(0)
  156. const submitParams = ref({
  157. qrCode: '',
  158. erpStockId: '', // 入库仓库
  159. wmsStoreAreaId: '', // 入库区域
  160. wmsStoreId: '', // 入库货位
  161. storeName: '', // 库位名称
  162. materialNo: '',
  163. materialName: '',
  164. materialLots: '',
  165. produceDate: '',
  166. inQty: '',
  167. supplierName: ''
  168. })
  169. // 校验参数
  170. const validatorList = ref({
  171. erpStockId: '入库仓库',
  172. wmsStoreAreaId: '入库区域',
  173. wmsStoreId: '入库货位',
  174. materialNo: '物料编码',
  175. materialLots: '物料批次',
  176. produceDate: '生产日期',
  177. inQty: '批次数量'
  178. // supplierName: "供应商",
  179. })
  180. const isFetch = ref(false)
  181. const popup = ref()
  182. const regionList = ref([])
  183. const warehouseList = ref([])
  184. const locationList = ref([])
  185. const store = useSetWareHouseStore();
  186. const computedStock = computed(() => {
  187. return item => warehouseList.value.find(opt => opt.id === item)?.text
  188. })
  189. const computedStore = computed(() => {
  190. return item => {
  191. return locationList.value.find(opt => opt.id === item)?.text
  192. }
  193. })
  194. const computedStoreArea = computed(() => {
  195. return item => regionList.value.find(opt => opt.id === item)?.text
  196. })
  197. const handleMapass = function(state) {
  198. // #ifdef APP-PLUS
  199. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  200. mpaasScanModule.mpaasScan({
  201. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  202. 'scanType': ['qrCode', 'barCode'],
  203. // 是否隐藏相册,默认false不隐藏
  204. 'hideAlbum': false
  205. },
  206. (ret) => {
  207. if (ret.resp_code === 1000) {
  208. if (state === '货位') {
  209. uni.$reqGet('getStockLocaltionByCode', {
  210. code: ret.resp_result
  211. })
  212. .then(({
  213. code,
  214. data,
  215. msg
  216. }) => {
  217. if (code === 0) {
  218. submitParams.value.storeName = data?.name // 库位名称
  219. submitParams.value.erpStockId = data?.erpStockId // 入库仓库
  220. submitParams.value.wmsStoreAreaId = data
  221. ?.wmsStoreAreaId // 入库区域
  222. submitParams.value.wmsStoreId = data?.wmsStoreId // 入库货位
  223. } else {
  224. uni.showToast({
  225. title: msg,
  226. icon: 'none',
  227. duration: 2000
  228. })
  229. }
  230. })
  231. } else {
  232. uni.$reqGet('materialGroundingScan', {
  233. qrCode: ret.resp_result
  234. })
  235. .then(({
  236. code,
  237. data,
  238. msg
  239. }) => {
  240. if (code === 0) {
  241. submitParams.value.qrCode = data?.qrCode // qrCode
  242. submitParams.value.materialLots = data
  243. ?.materialLots // 物料批次
  244. submitParams.value.materialNo = data?.materialNo // 物料编码
  245. submitParams.value.materialName = data
  246. ?.materialName // 物料名称
  247. submitParams.value.purchaseOrderNo = data
  248. ?.purchaseOrderNo // 采购单号
  249. submitParams.value.produceDate = data?.produceDate // 生产日期
  250. submitParams.value.supplierName = data
  251. ?.supplierName // 供应商
  252. submitParams.value.inQty = data?.qty // 数量
  253. submitParams.value.wmsIncomingReceiptId = data
  254. ?.wmsIncomingReceiptId
  255. submitParams.value.storeName = data?.wmsStockName // 库位名称
  256. submitParams.value.erpStockId = data?.wmsStockId // 入库仓库
  257. submitParams.value.wmsStoreAreaId = data
  258. ?.wmsStoreAreaId // 入库区域
  259. submitParams.value.wmsStoreId = data
  260. ?.wmsStockLocationId // 入库货位
  261. } else {
  262. uni.showToast({
  263. title: msg,
  264. icon: 'none',
  265. duration: 2000
  266. })
  267. }
  268. })
  269. }
  270. }
  271. // 返回值中,resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
  272. // 返回值中,resp_message 表示返回结果信息
  273. // 返回值中,resp_result 表示扫码结果,只有成功才会有返回
  274. })
  275. // #endif
  276. // #ifdef H5
  277. if (state === '货位') {
  278. uni.$reqGet('getStockLocaltionByCode', {
  279. code: 'PC-1'
  280. })
  281. .then(({
  282. code,
  283. data,
  284. msg
  285. }) => {
  286. if (code === 0) {
  287. submitParams.value.storeName = data?.name // 库位名称
  288. submitParams.value.erpStockId = data?.erpStockId // 入库仓库
  289. submitParams.value.wmsStoreAreaId = data
  290. ?.wmsStoreAreaId // 入库区域
  291. submitParams.value.wmsStoreId = data?.wmsStoreId // 入库货位
  292. } else {
  293. uni.showToast({
  294. title: msg,
  295. icon: 'none',
  296. duration: 2000
  297. })
  298. }
  299. })
  300. } else {
  301. uni.$reqGet('materialGroundingScan', {
  302. qrCode: '1696449966668177410'
  303. })
  304. .then(({
  305. code,
  306. data,
  307. msg
  308. }) => {
  309. if (code === 0) {
  310. submitParams.value.qrCode = data?.qrCode // qrCode
  311. submitParams.value.materialLots = data
  312. ?.materialLots // 物料批次
  313. submitParams.value.materialNo = data?.materialNo // 物料编码
  314. submitParams.value.materialName = data
  315. ?.materialName // 物料名称
  316. submitParams.value.purchaseOrderNo = data
  317. ?.purchaseOrderNo // 采购单号
  318. submitParams.value.produceDate = data?.produceDate // 生产日期
  319. submitParams.value.supplierName = data
  320. ?.supplierName // 供应商
  321. submitParams.value.inQty = data?.qty // 数量
  322. submitParams.value.wmsIncomingReceiptId = data
  323. ?.wmsIncomingReceiptId
  324. submitParams.value.storeName = data?.wmsStockName // 库位名称
  325. submitParams.value.erpStockId = data?.wmsStockId // 入库仓库
  326. submitParams.value.wmsStoreAreaId = data
  327. ?.wmsStoreAreaId // 入库区域
  328. submitParams.value.wmsStoreId = data?.wmsStockLocationId // 入库货位
  329. } else {
  330. uni.showToast({
  331. title: msg,
  332. icon: 'none',
  333. duration: 2000
  334. })
  335. }
  336. })
  337. }
  338. // #endif
  339. }
  340. // 扫描货位输入框回车事件
  341. const confirmStore = function(e) {
  342. uni.$reqGet('getStockLocaltionByCode', {
  343. code: e
  344. })
  345. .then(({
  346. code,
  347. data,
  348. msg
  349. }) => {
  350. if (code === 0) {
  351. submitParams.value.storeName = data?.name // 库位名称
  352. submitParams.value.erpStockId = data?.erpStockId // 入库仓库
  353. submitParams.value.wmsStoreAreaId = data
  354. ?.wmsStoreAreaId // 入库区域
  355. submitParams.value.wmsStoreId = data?.wmsStoreId // 入库货位
  356. } else {
  357. // #ifdef APP-PLUS
  358. plus.device.beep(2)
  359. // #endif
  360. errorTipMessage.value = msg
  361. errorTip.value.open()
  362. errorState.value = 0
  363. }
  364. })
  365. }
  366. // 扫描物料输入框回车事件
  367. const confirmMaterial = function(e) {
  368. uni.$reqGet('materialGroundingScan', {
  369. qrCode: e
  370. })
  371. .then(({
  372. code,
  373. data,
  374. msg
  375. }) => {
  376. if (code === 0) {
  377. submitParams.value.qrCode = data?.qrCode // qrCode
  378. submitParams.value.materialLots = data?.materialLots // 物料批次
  379. submitParams.value.materialNo = data?.materialNo // 物料编码
  380. submitParams.value.materialName = data?.materialName // 物料名称
  381. submitParams.value.purchaseOrderNo = data
  382. ?.purchaseOrderNo // 采购单号
  383. submitParams.value.produceDate = data?.produceDate // 生产日期
  384. submitParams.value.supplierName = data?.supplierName // 供应商
  385. submitParams.value.inQty = data?.qty // 数量
  386. submitParams.value.wmsIncomingReceiptId = data
  387. ?.wmsIncomingReceiptId
  388. } else {
  389. // #ifdef APP-PLUS
  390. plus.device.beep(2)
  391. // #endif
  392. errorTipMessage.value = msg
  393. errorTip.value.open()
  394. errorState.value = 1
  395. }
  396. })
  397. }
  398. // 上架
  399. const handleSubmit = function() {
  400. if (isFetch.value === true) {
  401. uni.$grace.msg('物料上架中...')
  402. } else {
  403. const keys = Object.keys(validatorList.value)
  404. for (let x = 0; x < keys.length; x++) {
  405. if ([null, undefined, NaN].includes(submitParams.value[keys[x]])) {
  406. uni.$grace.msg(validatorList.value[keys[x]] + '不能为空!')
  407. return
  408. }
  409. }
  410. isFetch.value = true
  411. uni.$reqPost('materialCreateBatch', [submitParams.value])
  412. .then(({
  413. code,
  414. data,
  415. msg
  416. }) => {
  417. submitParams.value.materialLots = '' // 物料批次
  418. submitParams.value.materialNo = '' // 物料编码
  419. submitParams.value.purchaseOrderNo = '' // 采购单号
  420. submitParams.value.produceDate = '' // 生产日期
  421. submitParams.value.materialName = '' // 物料名称
  422. submitParams.value.supplierName = '' // 供应商
  423. submitParams.value.inQty = '' // 数量
  424. submitParams.value.wmsIncomingReceiptId = ''
  425. isFetch.value = false
  426. if (code === 0) {
  427. uni.showToast({
  428. title: '来料上架完毕',
  429. icon: 'none',
  430. duration: 2000
  431. })
  432. } else {
  433. // #ifdef APP-PLUS
  434. plus.device.beep(2)
  435. // #endif
  436. errorTipMessage.value = msg
  437. errorTip.value.open()
  438. errorState.value = -1
  439. }
  440. })
  441. }
  442. }
  443. const handleSelectWareHouse = function(e) {
  444. const stock = warehouseList.value.find(item => item.value === e)
  445. submitParams.value.wmsStoreAreaId = ''
  446. submitParams.value.wmsStoreId = ''
  447. locationList.value = []
  448. store.handleGetRegionList(e).then(ret => {
  449. regionList.value = ret
  450. })
  451. }
  452. const handleSelectRegion = function(e) {
  453. const area = regionList.value.find(item => item.value === e)
  454. submitParams.value.wmsStoreId = ''
  455. locationList.value = []
  456. store.handleGetRegionList(e).then(ret => {
  457. locationList.value = ret
  458. })
  459. }
  460. const setInputFocus = function() {
  461. submitParams.value.storeName = ''
  462. easyinput.value.onBlur()
  463. easyinput.value.onFocus()
  464. }
  465. const setInputFocus2 = function() {
  466. submitParams.value.qrCode = ''
  467. easyinput2.value.onBlur()
  468. easyinput2.value.onFocus()
  469. }
  470. // 关闭错误信息弹窗
  471. const handleCloseErrorTipsModal = async function() {
  472. errorTip.value.close()
  473. if (errorState.value === 0) {
  474. await setInputFocus()
  475. } else if (errorState.value === 1) {
  476. await setInputFocus2()
  477. }
  478. }
  479. // 禁用软键盘
  480. const handleInputFocus = function() {
  481. setTimeout(() => {
  482. uni.hideKeyboard()
  483. }, 100)
  484. }
  485. return {
  486. goBack,
  487. popup,
  488. easyinput,
  489. easyinput2,
  490. errorTip,
  491. errorTipMessage,
  492. submitParams,
  493. regionList,
  494. warehouseList,
  495. locationList,
  496. computedStock,
  497. computedStore,
  498. computedStoreArea,
  499. handleInputFocus,
  500. handleMapass,
  501. handleSubmit,
  502. confirmStore,
  503. confirmMaterial,
  504. handleSelectWareHouse,
  505. handleSelectRegion,
  506. handleCloseErrorTipsModal
  507. }
  508. }
  509. })
  510. </script>
  511. <style lang="scss" scoped>
  512. .gui-header-leader-btns {
  513. color: black;
  514. font-size: 24px !important;
  515. margin-left: 24rpx;
  516. }
  517. .gui-sbody {
  518. font-size: 14px;
  519. background-color: rgba(234, 239, 242, 1);
  520. }
  521. .form {
  522. margin-top: 85px;
  523. }
  524. .row-1,
  525. .row-2,
  526. .row-3,
  527. .row-4 {
  528. margin-top: 10px;
  529. height: 55px;
  530. display: flex;
  531. justify-content: center;
  532. background-color: white;
  533. }
  534. .row-1 {
  535. margin-top: 0px;
  536. }
  537. .row-1,
  538. .row-2 {
  539. .row-1-card,
  540. .row-2-card {
  541. display: flex;
  542. flex-direction: row;
  543. justify-content: space-between;
  544. align-items: center;
  545. width: 100%;
  546. padding-left: 10px;
  547. padding-right: 10px;
  548. }
  549. }
  550. .row-3 {
  551. height: 140px;
  552. .row-3-card {
  553. display: flex;
  554. flex-direction: column;
  555. .row-space-between {
  556. flex: 1;
  557. width: calc(100vw - 40px);
  558. display: flex;
  559. flex-direction: row;
  560. justify-content: space-between;
  561. align-items: center;
  562. padding-top: 12px;
  563. padding-bottom: 12px;
  564. }
  565. }
  566. }
  567. .row-4 {
  568. height: 260px;
  569. .row-4-card {
  570. display: flex;
  571. flex-direction: column;
  572. .row-space-between {
  573. flex: 1;
  574. width: calc(100vw - 40px);
  575. display: flex;
  576. flex-direction: row;
  577. justify-content: space-between;
  578. align-items: center;
  579. padding-top: 12px;
  580. padding-bottom: 12px;
  581. }
  582. }
  583. }
  584. .row-operation {
  585. height: 110px;
  586. padding-left: 20px;
  587. padding-right: 20px;
  588. display: flex;
  589. flex-direction: row;
  590. justify-content: center;
  591. align-items: center;
  592. .row-operation-card {
  593. flex: 1;
  594. .btn-row-1 {
  595. margin-bottom: 5px !important;
  596. }
  597. }
  598. }
  599. .input-200 {
  600. width: 200px;
  601. padding-left: 10px;
  602. }
  603. .input-300 {
  604. width: 300px;
  605. padding-left: 10px;
  606. }
  607. .font-icons {
  608. width: 40px;
  609. font-size: 20px;
  610. }
  611. .select-group {
  612. display: flex;
  613. flex-direction: column;
  614. flex: 1;
  615. .select-item {
  616. display: flex;
  617. flex-direction: row;
  618. align-items: center;
  619. margin-bottom: 10px;
  620. .store-text {
  621. margin-right: 14px;
  622. }
  623. }
  624. }
  625. </style>