warehousingApplication.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <gui-page :custom-header="true" :header-class="['gui-theme-background-color']">
  3. <template #gHeader>
  4. <view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
  5. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  6. <text
  7. style="font-size:44rpx;"
  8. class="gui-header-leader-btns gui-color-white font-icons"
  9. @tap="goBack"
  10. >&#xe6c5;</text>
  11. <!-- 导航文本此处也可以是其他自定义内容 -->
  12. <text
  13. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text"
  14. >入库申请</text>
  15. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  16. <!-- 实际宽度请根据自己情况设置 -->
  17. <view style="width:40px;" />
  18. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  19. </view>
  20. </template>
  21. <template #gBody>
  22. <view class="list-content">
  23. <view class="scan">
  24. <view class="scan-card">
  25. <uni-easyinput
  26. ref="easyinput"
  27. v-model="scanNumber"
  28. :input-border="false"
  29. :clearable="false"
  30. type="text"
  31. focus
  32. @focus="handleInputFocus"
  33. placeholder="扫描完成品标签"
  34. @confirm="handleKeydown"
  35. />
  36. <text class="font-icons" @click="handleMapass">&#xe6b7;</text>
  37. </view>
  38. </view>
  39. <view class="table-title">
  40. <span>入库需求清单</span>
  41. </view>
  42. <view class="custom-table">
  43. <uni-table border stripe empty-text="暂无更多数据">
  44. <!-- 表头行 -->
  45. <uni-tr class="custom-table-head">
  46. <uni-th align="center" width="20px" />
  47. <uni-th align="center" width="100px">工单</uni-th>
  48. <uni-th align="center" width="180px">产品</uni-th>
  49. <uni-th align="center" width="90px">数量</uni-th>
  50. </uni-tr>
  51. <!-- 表格数据行 -->
  52. <uni-tr v-for="(item, key) in warehousingList" :key="key">
  53. <uni-td align="center" style="padding: 8px 4px !important;">
  54. <text
  55. class="font-icons"
  56. style="font-size: 20px;text-align: right;color: red;"
  57. @click="handleRemoveRow(item)"
  58. >&#xe68c;</text>
  59. </uni-td>
  60. <uni-td align="center">{{ item.erpWorkOrderNo }}</uni-td>
  61. <uni-td align="center">{{ item.productCode }}({{ item.productName }})</uni-td>
  62. <uni-td align="center">{{ item.boxQty }}</uni-td>
  63. </uni-tr>
  64. </uni-table>
  65. </view>
  66. <view
  67. class="card-list-item"
  68. style="margin: 12px 0;display: grid;grid-template-columns: 1fr;grid-template-rows: 1fr;"
  69. >
  70. <button
  71. type="primary"
  72. style="width: calc(100% - 8px);margin: 0 4px;"
  73. @click="handleGenerateWarehousing"
  74. >生成入库申请单</button>
  75. </view>
  76. </view>
  77. <uni-popup ref="errorTip" type="dialog">
  78. <uni-popup-dialog
  79. type="error"
  80. cancel-text="关闭"
  81. confirm-text="确认"
  82. title="提示"
  83. :content="errorTipMessage"
  84. @confirm="handleCloseErrorTipsModal"
  85. @close="handleCloseErrorTipsModal"
  86. />
  87. </uni-popup>
  88. </template>
  89. </gui-page>
  90. </template>
  91. <script>
  92. import {
  93. defineComponent,
  94. ref,
  95. onBeforeMount
  96. } from 'vue'
  97. export default defineComponent({
  98. setup() {
  99. const modalForm = ref('')
  100. const errorState = ref(0)
  101. const easyinput = ref()
  102. const errorTip = ref('')
  103. const errorTipMessage = ref('')
  104. const warehousingList = ref([])
  105. const scanNumber = ref('')
  106. onBeforeMount(() => {
  107. uni.$reqGet('getProductInDetailTempPage', {
  108. pageNo: 1,
  109. pageSize: 100
  110. })
  111. .then(({
  112. code,
  113. data,
  114. msg
  115. }) => {
  116. if (code === 0) {
  117. setInputFocus()
  118. warehousingList.value = data?.list ?? []
  119. } else {
  120. // #ifdef APP-PLUS
  121. plus.device.beep(2)
  122. // #endif
  123. errorTipMessage.value = msg
  124. errorTip.value.open()
  125. errorState.value = 0
  126. }
  127. })
  128. })
  129. const handleMapass = function() {
  130. // #ifdef APP-PLUS
  131. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  132. mpaasScanModule.mpaasScan({
  133. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  134. 'scanType': ['qrCode', 'barCode'],
  135. // 是否隐藏相册,默认false不隐藏
  136. 'hideAlbum': false
  137. },
  138. (ret) => {
  139. if (ret.resp_code === 1000) {
  140. uni.$reqGet('scanProductInDetailTemp', {
  141. id: ret.resp_result
  142. })
  143. .then(({
  144. code,
  145. data,
  146. msg
  147. }) => {
  148. if (code === 0) {
  149. if (data.status === -1) {
  150. uni.$reqGet('getProductInDetailTempPage', {
  151. pageNo: 1,
  152. pageSize: 100
  153. })
  154. .then(({
  155. code,
  156. data,
  157. msg
  158. }) => {
  159. if (code === 0) {
  160. setInputFocus()
  161. warehousingList.value = data?.list ?? []
  162. } else {
  163. // #ifdef APP-PLUS
  164. plus.device.beep(2)
  165. // #endif
  166. errorTipMessage.value = msg
  167. errorTip.value.open()
  168. errorState.value = 0
  169. }
  170. })
  171. } else if (data.status === 0) {
  172. // #ifdef APP-PLUS
  173. plus.device.beep(2)
  174. // #endif
  175. errorTipMessage.value = '此产品已被使用'
  176. errorTip.value.open()
  177. errorState.value = 0
  178. }
  179. } else {
  180. // #ifdef APP-PLUS
  181. plus.device.beep(2)
  182. // #endif
  183. errorTipMessage.value = msg
  184. errorTip.value.open()
  185. errorState.value = 0
  186. }
  187. })
  188. }
  189. })
  190. // #endif
  191. }
  192. // 扫描完成品标签输入框回车事件
  193. const handleKeydown = function(e) {
  194. uni.$reqGet('scanProductInDetailTemp', {
  195. id: e
  196. })
  197. .then(({
  198. code,
  199. data,
  200. msg
  201. }) => {
  202. if (code === 0) {
  203. if (data.status === -1) {
  204. uni.$reqGet('getProductInDetailTempPage', {
  205. pageNo: 1,
  206. pageSize: 100
  207. })
  208. .then(({
  209. code,
  210. data,
  211. msg
  212. }) => {
  213. if (code === 0) {
  214. setInputFocus()
  215. warehousingList.value = data?.list ?? []
  216. } else {
  217. // #ifdef APP-PLUS
  218. plus.device.beep(2)
  219. // #endif
  220. errorTipMessage.value = msg
  221. errorTip.value.open()
  222. errorState.value = 0
  223. }
  224. })
  225. } else if (data.status === 0) {
  226. // #ifdef APP-PLUS
  227. plus.device.beep(2)
  228. // #endif
  229. errorTipMessage.value = '此产品已被使用'
  230. errorTip.value.open()
  231. errorState.value = 0
  232. }
  233. } else {
  234. // #ifdef APP-PLUS
  235. plus.device.beep(2)
  236. // #endif
  237. errorTipMessage.value = msg
  238. errorTip.value.open()
  239. errorState.value = 0
  240. }
  241. })
  242. }
  243. // 登记
  244. const handleGenerateWarehousing = function() {
  245. if (warehousingList.value.length > 0) {
  246. const paramsList = []
  247. warehousingList.value.forEach(item => {
  248. const newItem = JSON.parse(JSON.stringify(item))
  249. Reflect.deleteProperty(newItem, 'id')
  250. paramsList.push({
  251. ...newItem,
  252. tempId: item.id
  253. })
  254. })
  255. uni.$reqPost('createProductInStorageDetail', paramsList)
  256. .then(({
  257. code,
  258. data,
  259. msg
  260. }) => {
  261. if (code === 0) {
  262. easyinput.value.onBlur()
  263. easyinput.value.onFocus()
  264. warehousingList.value.length = 0
  265. uni.showToast({
  266. title: '入库申请单生成成功',
  267. icon: 'none',
  268. duration: 2000
  269. })
  270. } else {
  271. // #ifdef APP-PLUS
  272. plus.device.beep(2)
  273. // #endif
  274. errorTipMessage.value = msg
  275. errorTip.value.open()
  276. errorState.value = -1
  277. }
  278. })
  279. } else {
  280. // #ifdef APP-PLUS
  281. plus.device.beep(2)
  282. // #endif
  283. errorTipMessage.value = '请先扫描标签'
  284. errorTip.value.open()
  285. errorState.value = -1
  286. }
  287. }
  288. const handleRemoveRow = function(ret) {
  289. uni.$reqDelete('deleteProductInDetailTemp', {
  290. id: ret.id
  291. })
  292. .then(({
  293. code,
  294. data,
  295. msg
  296. }) => {
  297. if (code === 0) {
  298. easyinput.value.onBlur()
  299. easyinput.value.onFocus()
  300. uni.$reqGet('getProductInDetailTempPage', {
  301. pageNo: 1,
  302. pageSize: 100
  303. })
  304. .then(({
  305. code,
  306. data,
  307. msg
  308. }) => {
  309. if (code === 0) {
  310. warehousingList.value = data?.list ?? []
  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. } else {
  321. // #ifdef APP-PLUS
  322. plus.device.beep(2)
  323. // #endif
  324. errorTipMessage.value = msg
  325. errorTip.value.open()
  326. errorState.value = -1
  327. }
  328. })
  329. }
  330. const goBack = function() {
  331. uni.$goBack('/pages/workbranch/warehouse/warehousing/warehousingType')
  332. }
  333. const setInputFocus = function() {
  334. scanNumber.value = ''
  335. easyinput.value.onBlur()
  336. easyinput.value.onFocus()
  337. }
  338. // 关闭错误信息弹窗
  339. const handleCloseErrorTipsModal = async function() {
  340. errorTip.value.close()
  341. if (errorState.value === 0) {
  342. await setInputFocus()
  343. }
  344. }
  345. // 禁用软键盘
  346. const handleInputFocus = function() {
  347. setTimeout(() => {
  348. uni.hideKeyboard()
  349. }, 100)
  350. }
  351. return {
  352. options: [{
  353. text: '删除',
  354. style: {
  355. backgroundColor: '#dd524d'
  356. }
  357. }],
  358. goBack,
  359. easyinput,
  360. errorTip,
  361. errorTipMessage,
  362. modalForm,
  363. scanNumber,
  364. handleMapass,
  365. handleKeydown,
  366. warehousingList,
  367. handleRemoveRow,
  368. handleInputFocus,
  369. handleCloseErrorTipsModal,
  370. handleGenerateWarehousing
  371. }
  372. }
  373. })
  374. </script>
  375. <style lang="scss" scoped>
  376. .gui-header-leader-btns {
  377. color: black;
  378. font-size: 24px !important;
  379. }
  380. .list-content {
  381. margin-top: 80px;
  382. background-color: #edeeee;
  383. }
  384. .input-200 {
  385. width: 200px;
  386. padding-left: 10px;
  387. }
  388. .font-icons {
  389. width: 40px;
  390. font-size: 20px;
  391. text-align: right;
  392. }
  393. .scan {
  394. height: 45px;
  395. width: calc(100% - 48px);
  396. margin: 12px;
  397. padding: 0 12px;
  398. display: flex;
  399. justify-content: space-between;
  400. align-items: center;
  401. border-radius: 6px;
  402. background-color: white;
  403. .scan-card {
  404. width: 100%;
  405. display: grid;
  406. grid-template-rows: 1fr;
  407. grid-template-columns: 7fr 2fr;
  408. align-items: center;
  409. input {
  410. height: 35px;
  411. line-height: 35px;
  412. }
  413. text {
  414. width: 100%;
  415. text-align: right;
  416. }
  417. }
  418. }
  419. .card-list-flexbox {
  420. width: calc(100vw - 24px);
  421. height: 195px;
  422. margin: 0 12px;
  423. display: flex;
  424. justify-content: center;
  425. flex-direction: column;
  426. align-items: center;
  427. overflow-y: scroll;
  428. .card-list-title {
  429. width: 100%;
  430. height: 35px;
  431. line-height: 35px;
  432. margin: 0 4px 0 4px;
  433. border-radius: 4px 4px 0 0;
  434. text-align: center;
  435. color: white;
  436. background-color: rgba(0, 160, 233, 1.0);
  437. }
  438. .card-list-item,
  439. .card-list-item-operation {
  440. width: 100%;
  441. height: 35px;
  442. margin: 0 4px 3rpx 4px;
  443. border-radius: 4px;
  444. display: flex;
  445. flex-direction: row;
  446. align-items: center;
  447. justify-content: space-between;
  448. background-color: #fff;
  449. uni-text {
  450. font-size: 14px;
  451. height: 50rpx;
  452. text-align: left;
  453. padding: 0 8px;
  454. display: flex;
  455. flex-direction: row;
  456. align-items: center;
  457. }
  458. .text-1 {
  459. flex: 1;
  460. height: 35px;
  461. justify-content: flex-start;
  462. }
  463. .text-2 {
  464. flex: 3;
  465. height: 35px;
  466. justify-content: flex-end;
  467. margin-right: 4px;
  468. padding: 2px 6px;
  469. }
  470. }
  471. }
  472. .table-title {
  473. height: 40px;
  474. line-height: 40px;
  475. margin: 4px 0 -3px 0;
  476. padding: 0 12px;
  477. font-size: 16px;
  478. font-weight: bold;
  479. background-color: white;
  480. }
  481. .custom-table {
  482. height: calc(100vh - 265px);
  483. min-height: 230px;
  484. margin: 5px 0;
  485. overflow-y: scroll;
  486. }
  487. </style>