productionPage.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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.caseNo" :input-border="false"
  36. :clearable="false" type="text" @focus="handleInputFocus" placeholder="请扫描箱号"
  37. @confirm="confirmCaseNo" />
  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.stockCode) }}</text>
  46. </view>
  47. <view class="row-space-between">
  48. <text>区域</text>
  49. <text>{{ computedStoreArea(submitParams.areaCode) }}</text>
  50. </view>
  51. <view class="row-space-between">
  52. <text>货位</text>
  53. <text>{{ computedStore(submitParams.locationCode) }}</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.workOrderNo }}</text>
  62. </view>
  63. <view class="row-space-between">
  64. <text>产品编码</text>
  65. <text>{{ submitParams.productCode }}</text>
  66. </view>
  67. <view class="row-space-between">
  68. <text>产品名称</text>
  69. <text>{{ submitParams.productName }}</text>
  70. </view>
  71. <view class="row-space-between">
  72. <text>箱号</text>
  73. <text>{{ submitParams.caseNo }}</text>
  74. </view>
  75. <view class="row-space-between">
  76. <text>数量</text>
  77. <text>{{ submitParams.inQty }}</text>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="row-operation">
  82. <view class="row-operation-card">
  83. <view class="button" size="primary" @click="handleSubmit">
  84. <text class="gui-color-white">上架</text>
  85. </view>
  86. </view>
  87. </view>
  88. </cell>
  89. </list>
  90. <view>
  91. <!-- 提示窗示例 -->
  92. <uni-popup ref="popup" type="dialog">
  93. <uni-popup-dialog type="warn" cancel-text="取消" confirm-text="确认" title="手动分配货位"
  94. content="欢迎使用 uni-popup!" @confirm="popup.close()" @close="popup.close()">
  95. <!-- eslint-disable-next-line -->
  96. <template #default="custom">
  97. <view class="select-group">
  98. <view class="select-item">
  99. <text class="store-text">仓库</text>
  100. <view class="custom-select">
  101. <uni-data-select v-model="submitParams.stockCode" :localdata="warehouseList"
  102. @change="handleSelectWareHouse" />
  103. </view>
  104. </view>
  105. <view class="select-item">
  106. <text class="store-text">区域</text>
  107. <view class="custom-select">
  108. <uni-data-select v-model="submitParams.areaCode" :localdata="regionList"
  109. @change="handleSelectRegion" />
  110. </view>
  111. </view>
  112. <view class="select-item">
  113. <text class="store-text">货位</text>
  114. <view class="custom-select">
  115. <uni-data-select v-model="submitParams.locationCode"
  116. :localdata="locationList" />
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. </uni-popup-dialog>
  122. </uni-popup>
  123. <uni-popup ref="errorTip" type="dialog">
  124. <uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示"
  125. :content="errorTipMessage" @confirm="handleCloseErrorTipsModal"
  126. @close="handleCloseErrorTipsModal" />
  127. </uni-popup>
  128. </view>
  129. </template>
  130. </gui-page>
  131. </template>
  132. <script>
  133. import {
  134. computed,
  135. defineComponent,
  136. ref,
  137. onBeforeMount
  138. } from 'vue'
  139. import {
  140. useSetWareHouseStore
  141. } from '@/stores/useSetWareHouseStore.js';
  142. export default defineComponent({
  143. setup() {
  144. const goBack = function() {
  145. uni.navigateBack({
  146. delta: 1
  147. })
  148. }
  149. const errorTip = ref('')
  150. const errorTipMessage = ref('')
  151. const easyinput = ref('')
  152. const easyinput2 = ref('')
  153. const errorState = ref(0)
  154. const isFetch = ref(false)
  155. const popup = ref()
  156. const regionList = ref([])
  157. const warehouseList = ref([])
  158. const locationList = ref([])
  159. const submitParams = ref({
  160. stockCode: '', // 入库仓库
  161. areaCode: '', // 入库区域
  162. locationCode: '', // 入库货位
  163. storeName: '', // 库位名称
  164. workOrderNo: '',
  165. productCode: '',
  166. productName: '',
  167. caseNo: '',
  168. inQty: ''
  169. })
  170. // 校验参数
  171. const validatorList = ref({
  172. stockCode: '入库仓库',
  173. areaCode: '入库区域',
  174. locationCode: '入库货位',
  175. workOrderNo: '生产订单',
  176. productCode: '产品编码',
  177. productName: '产品名称',
  178. inQty: '数量',
  179. caseNo: '箱号'
  180. })
  181. const store = useSetWareHouseStore();
  182. const computedStock = computed(() => {
  183. return item => warehouseList.value.find(opt => opt.id === item)?.text
  184. })
  185. const computedStore = computed(() => {
  186. return item => {
  187. return locationList.value.find(opt => opt.id === item)?.text
  188. }
  189. })
  190. const computedStoreArea = computed(() => {
  191. return item => regionList.value.find(opt => opt.id === item)?.text
  192. })
  193. onBeforeMount(() => {
  194. warehouseList.value = store.$state.warehouseList
  195. })
  196. const handleMapass = function(state) {
  197. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  198. mpaasScanModule.mpaasScan({
  199. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  200. 'scanType': ['qrCode', 'barCode'],
  201. // 是否隐藏相册,默认false不隐藏
  202. 'hideAlbum': false
  203. },
  204. (ret) => {
  205. if (ret.resp_code === 1000) {
  206. if (state === '货位') {
  207. uni.$reqGet('getStockLocaltionByCode', {
  208. code: ret.resp_result
  209. })
  210. .then(({
  211. data
  212. }) => {
  213. submitParams.value.storeName = data?.name // 库位名称
  214. submitParams.value.stockCode = data?.erpStockId // 入库仓库
  215. submitParams.value.areaCode = data
  216. ?.wmsStoreAreaId // 入库区域
  217. submitParams.value.locationCode = data?.wmsStoreId // 入库货位
  218. })
  219. } else {
  220. uni.$reqGet('productionGroundingScan', {
  221. caseNo: ret.resp_result
  222. })
  223. .then(({
  224. code,
  225. data,
  226. msg
  227. }) => {
  228. if (code === 0) {
  229. submitParams.value.workOrderNo = data?.erpOrderNo // 生产订单
  230. submitParams.value.productCode = data?.productCode // 产品编码
  231. submitParams.value.productName = data?.productName // 产品名称
  232. submitParams.value.caseNo = data?.boxNo // 箱号
  233. submitParams.value.inQty = data?.boxQty // 数量
  234. submitParams.value.detailErpId = data
  235. ?.detailErpId // 关联明细表MES-ID编码
  236. submitParams.value.warehousingOrderNo = data
  237. ?.warehousingOrderNo // 入库单号
  238. submitParams.value.storeName = data?.wmsStockName // 库位名称
  239. submitParams.value.stockCode = data?.wmsStockId // 入库仓库
  240. submitParams.value.areaCode = data
  241. ?.wmsStoreAreaId // 入库区域
  242. submitParams.value.locationCode = data
  243. ?.wmsStockLocationId // 入库货位
  244. } else {
  245. uni.showToast({
  246. title: msg,
  247. icon: 'none',
  248. duration: 2000
  249. })
  250. }
  251. })
  252. }
  253. }
  254. // 返回值中,resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
  255. // 返回值中,resp_message 表示返回结果信息
  256. // 返回值中,resp_result 表示扫码结果,只有成功才会有返回
  257. })
  258. }
  259. // 扫描货位输入框回车事件
  260. const confirmStore = function(e) {
  261. uni.$reqGet('getStockLocaltionByCode', {
  262. code: e
  263. })
  264. .then(({
  265. code,
  266. data,
  267. msg
  268. }) => {
  269. if (code === 0) {
  270. submitParams.value.storeName = data?.name // 库位名称
  271. submitParams.value.stockCode = data?.erpStockId // 入库仓库
  272. submitParams.value.areaCode = data
  273. ?.wmsStoreAreaId // 入库区域
  274. submitParams.value.locationCode = data?.wmsStoreId // 入库货位
  275. } else {
  276. // #ifdef APP-PLUS
  277. plus.device.beep(2)
  278. // #endif
  279. errorTipMessage.value = msg
  280. errorTip.value.open()
  281. errorState.value = 0
  282. }
  283. })
  284. }
  285. // 扫描箱号输入框回车事件
  286. const confirmCaseNo = function(e) {
  287. uni.$reqGet('productionGroundingScan', {
  288. caseNo: e
  289. })
  290. .then(({
  291. code,
  292. data,
  293. msg
  294. }) => {
  295. if (code === 0) {
  296. submitParams.value.workOrderNo = data?.erpOrderNo // 生产订单
  297. submitParams.value.productCode = data?.productCode // 产品编码
  298. submitParams.value.productName = data?.productName // 产品名称
  299. submitParams.value.caseNo = data?.boxNo // 箱号
  300. submitParams.value.inQty = data?.boxQty // 数量
  301. submitParams.value.detailErpId = data
  302. ?.detailErpId // 关联明细表MES-ID编码
  303. submitParams.value.warehousingOrderNo = data
  304. ?.warehousingOrderNo // 入库单号
  305. submitParams.value.storeName = data?.wmsStockName // 库位名称
  306. submitParams.value.stockCode = data?.wmsStockId // 入库仓库
  307. submitParams.value.areaCode = data
  308. ?.wmsStoreAreaId // 入库区域
  309. submitParams.value.locationCode = data
  310. ?.wmsStockLocationId // 入库货位
  311. } else {
  312. // #ifdef APP-PLUS
  313. plus.device.beep(2)
  314. // #endif
  315. errorTipMessage.value = msg
  316. errorTip.value.open()
  317. errorState.value = 1
  318. }
  319. })
  320. }
  321. // 上架
  322. const handleSubmit = function() {
  323. if (isFetch.value === true) {
  324. uni.$grace.msg('产品上架中...')
  325. } else {
  326. const keys = Object.keys(submitParams.value)
  327. for (let x = 0; x < keys.length; x++) {
  328. const validataIsItEmpty = ['', null, undefined, NaN].includes(submitParams.value[keys[
  329. x]])
  330. if (validataIsItEmpty) {
  331. uni.showToast({
  332. title: validatorList.value[keys[x]] + '不能为空!',
  333. icon: 'none',
  334. duration: 2000
  335. })
  336. return
  337. }
  338. }
  339. isFetch.value = true
  340. uni.$reqPost('productCreateBatch', [submitParams.value])
  341. .then(({
  342. code,
  343. data,
  344. msg
  345. }) => {
  346. submitParams.value.workOrderNo = ''
  347. submitParams.value.productCode = ''
  348. submitParams.value.productName = ''
  349. submitParams.value.caseNo = ''
  350. submitParams.value.inQty = ''
  351. submitParams.value.detailErpId = ''
  352. submitParams.value.warehousingOrderNo = ''
  353. isFetch.value = false
  354. if (code === 0) {
  355. uni.$grace.msg('产品上架完毕')
  356. return
  357. } else {
  358. // #ifdef APP-PLUS
  359. plus.device.beep(2)
  360. // #endif
  361. errorTipMessage.value = msg
  362. errorTip.value.open()
  363. errorState.value = -1
  364. }
  365. })
  366. }
  367. }
  368. const handleSelectWareHouse = function(e) {
  369. submitParams.value.areaCode = ''
  370. submitParams.value.locationCode = ''
  371. locationList.value = []
  372. store.handleGetRegionList(e).then(ret => {
  373. regionList.value = ret
  374. })
  375. }
  376. const handleSelectRegion = function(e) {
  377. submitParams.value.locationCode = ''
  378. locationList.value = []
  379. store.handleGetLocationList(e).then(ret => {
  380. locationList.value = ret
  381. })
  382. }
  383. const setInputFocus = function() {
  384. submitParams.value.storeName = ''
  385. easyinput.value.onBlur()
  386. easyinput.value.onFocus()
  387. }
  388. const setInputFocus2 = function() {
  389. submitParams.value.qrCode = ''
  390. easyinput2.value.onBlur()
  391. easyinput2.value.onFocus()
  392. }
  393. // 关闭错误信息弹窗
  394. const handleCloseErrorTipsModal = async function() {
  395. errorTip.value.close()
  396. if (errorState.value === 0) {
  397. await setInputFocus()
  398. } else if (errorState.value === 1) {
  399. await setInputFocus2()
  400. }
  401. }
  402. // 禁用软键盘
  403. const handleInputFocus = function() {
  404. setTimeout(() => {
  405. uni.hideKeyboard()
  406. }, 100)
  407. }
  408. return {
  409. goBack,
  410. easyinput,
  411. easyinput2,
  412. errorTip,
  413. errorTipMessage,
  414. submitParams,
  415. handleMapass,
  416. handleSubmit,
  417. popup,
  418. regionList,
  419. warehouseList,
  420. handleInputFocus,
  421. locationList,
  422. computedStock,
  423. computedStore,
  424. computedStoreArea,
  425. confirmStore,
  426. confirmCaseNo,
  427. handleSelectWareHouse,
  428. handleSelectRegion,
  429. handleCloseErrorTipsModal
  430. }
  431. }
  432. })
  433. </script>
  434. <style lang="scss" scoped>
  435. .gui-header-leader-btns {
  436. color: black;
  437. font-size: 24px !important;
  438. margin-left: 24rpx;
  439. }
  440. .gui-sbody {
  441. font-size: 14px;
  442. background-color: rgba(234, 239, 242, 1);
  443. }
  444. .form {
  445. margin-top: 85px;
  446. }
  447. .row-1,
  448. .row-2,
  449. .row-3,
  450. .row-4 {
  451. margin-top: 10px;
  452. height: 55px;
  453. display: flex;
  454. justify-content: center;
  455. background-color: white;
  456. }
  457. .row-1 {
  458. margin-top: 0px;
  459. }
  460. .row-1,
  461. .row-2 {
  462. .row-1-card,
  463. .row-2-card {
  464. display: flex;
  465. flex-direction: row;
  466. justify-content: space-between;
  467. align-items: center;
  468. width: 100%;
  469. padding-left: 10px;
  470. padding-right: 10px;
  471. }
  472. }
  473. .row-3 {
  474. height: 140px;
  475. .row-3-card {
  476. display: flex;
  477. flex-direction: column;
  478. .row-space-between {
  479. flex: 1;
  480. width: calc(100vw - 40px);
  481. display: flex;
  482. flex-direction: row;
  483. justify-content: space-between;
  484. align-items: center;
  485. padding-top: 12px;
  486. padding-bottom: 12px;
  487. }
  488. }
  489. }
  490. .row-4 {
  491. height: 260px;
  492. .row-4-card {
  493. display: flex;
  494. flex-direction: column;
  495. .row-space-between {
  496. flex: 1;
  497. width: calc(100vw - 40px);
  498. display: flex;
  499. flex-direction: row;
  500. justify-content: space-between;
  501. align-items: center;
  502. padding-top: 12px;
  503. padding-bottom: 12px;
  504. }
  505. }
  506. }
  507. .row-operation {
  508. height: 110px;
  509. padding-left: 20px;
  510. padding-right: 20px;
  511. display: flex;
  512. flex-direction: row;
  513. justify-content: center;
  514. align-items: center;
  515. .row-operation-card {
  516. flex: 1;
  517. .btn-row-1 {
  518. margin-bottom: 5px !important;
  519. }
  520. }
  521. }
  522. .input-200 {
  523. width: 200px;
  524. padding-left: 10px;
  525. }
  526. .input-300 {
  527. width: 300px;
  528. padding-left: 10px;
  529. }
  530. .font-icons {
  531. width: 40px;
  532. font-size: 20px;
  533. }
  534. .select-group {
  535. display: flex;
  536. flex-direction: column;
  537. flex: 1;
  538. .select-item {
  539. display: flex;
  540. flex-direction: row;
  541. align-items: center;
  542. margin-bottom: 10px;
  543. .store-text {
  544. margin-right: 14px;
  545. }
  546. }
  547. }
  548. </style>