materialScanRegister.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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. <view class="form">
  21. <view class="card-list-flexbox">
  22. <text class="card-list-title" :style="[isPad?'font-size: 18px':'font-size: 14px']">单据信息</text>
  23. <view class="card-list-item">
  24. <text>送货单号</text>
  25. <text>{{ scanParams.deliveryOrderNo }}</text>
  26. </view>
  27. <view class="card-list-item">
  28. <text>供应商编码</text>
  29. <text>{{ scanParams.supplierCode }}</text>
  30. </view>
  31. <view class="card-list-item">
  32. <text>供应商名称</text>
  33. <text>{{ scanParams.supplierName }}</text>
  34. </view>
  35. <view class="card-list-item">
  36. <text>备注</text>
  37. <text>{{ scanParams.remark }}</text>
  38. </view>
  39. </view>
  40. <view class="row">
  41. <view class="row-card">
  42. <uni-easyinput ref="easyinput" v-model="scanParams.deliveryOrderNo" :input-border="false"
  43. :clearable="false" type="text" focus @focus="handleInputFocus" placeholder="扫描送货单条码"
  44. @confirm="confirmDeliverOrderNo" />
  45. <text class="font-icons" @click="handleMapass">&#xe6b7;</text>
  46. </view>
  47. </view>
  48. <view v-if="scanParams.deliveryOrderNo" class="row">
  49. <view class="row-card">
  50. <uni-easyinput ref="easyinput2" v-model="scanParams.deliverBatch" :input-border="false"
  51. :clearable="false" type="text" @focus="handleInputFocus" placeholder="扫描物料条码"
  52. @confirm="confirmMaterial" />
  53. <text class="font-icons" @click="handleScanMaterial">&#xe6b7;</text>
  54. </view>
  55. </view>
  56. <view class="table-title">
  57. <span>需求清单</span>
  58. </view>
  59. <view class="custom-table">
  60. <uni-table border stripe empty-text="暂无更多数据">
  61. <!-- 表头行 -->
  62. <uni-tr class="custom-table-head">
  63. <uni-th align="center" width="80px">数量</uni-th>
  64. <uni-th align="center" width="140px">采购单号</uni-th>
  65. <uni-th align="center" width="140px">物料编码</uni-th>
  66. <uni-th align="center" width="140px">送货批次</uni-th>
  67. <uni-th align="center" width="140px">生产日期</uni-th>
  68. </uni-tr>
  69. <!-- 表格数据行 -->
  70. <uni-tr v-for="(item, key) in scanParams.detail" :key="key">
  71. <uni-td align="center"
  72. :style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.receiptQty }}</uni-td>
  73. <uni-td align="center"
  74. :style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.purchaseOrderNo }}</uni-td>
  75. <uni-td align="center"
  76. :style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.materialNo }}</uni-td>
  77. <uni-td align="center"
  78. :style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.deliverBatch }}</uni-td>
  79. <uni-td align="center"
  80. :style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.produceDate }}</uni-td>
  81. </uni-tr>
  82. </uni-table>
  83. </view>
  84. <gui-right-menus>
  85. <!-- 扩展按钮 -->
  86. <template #menus-more>
  87. <view hover-class="gui-tap"
  88. class="menu-items gui-bg-green gui-flex gui-columns gui-justify-content-center"
  89. @click="handeleRegister">
  90. <text class="menu-text gui-block gui-text-center gui-color-white">登记</text>
  91. </view>
  92. <view hover-class="gui-tap"
  93. class="menu-items gui-bg-blue gui-flex gui-columns gui-justify-content-center"
  94. @click="handleNavigateToRegisterRecord">
  95. <text class="menu-text gui-block gui-text-center gui-color-white">登记记录</text>
  96. </view>
  97. </template>
  98. <!-- 核心按钮 -->
  99. <template #menus-primary>
  100. <view class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center">
  101. <text class="menu-icon gui-color-white gui-block gui-text-center gui-icons">&#xe614;</text>
  102. <text class="menu-text gui-color-white gui-block gui-text-center">操作</text>
  103. </view>
  104. </template>
  105. </gui-right-menus>
  106. <uni-popup ref="modalForm" type="dialog">
  107. <uni-popup-dialog type="error" cancel-text="不使用" confirm-text="继续使用" title="提示" content="此物料已过保质期!"
  108. @confirm="handleCompleteDialog" @close="handleCloseDialog" />
  109. </uni-popup>
  110. <uni-popup ref="errorTip" type="dialog">
  111. <uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示"
  112. :content="errorTipMessage" @confirm="handleCloseErrorTipsModal"
  113. @close="handleCloseErrorTipsModal" />
  114. </uni-popup>
  115. </view>
  116. </template>
  117. </gui-page>
  118. </template>
  119. <script>
  120. import {
  121. defineComponent,
  122. ref
  123. } from 'vue'
  124. export default defineComponent({
  125. setup() {
  126. const modalForm = ref('')
  127. const errorTip = ref('')
  128. const errorTipMessage = ref('')
  129. const easyinput = ref('')
  130. const easyinput2 = ref('')
  131. const errorState = ref(0)
  132. const fdIndex = ref(0)
  133. const scanParams = ref({
  134. deliveryOrderNo: '',
  135. supplierCode: '',
  136. supplierName: '',
  137. remark: '',
  138. deliverBatch: '',
  139. validateFlag: -1,
  140. detail: []
  141. })
  142. const handleMapass = function() {
  143. // uni.$reqGet("scanDeliveryOrderNo", {
  144. // deliveryOrderNo: "CGSH230907000007"
  145. // })
  146. // .then(({
  147. // code,
  148. // data,
  149. // msg
  150. // }) => {
  151. // if (code === 0) {
  152. // Object.assign(scanParams.value, data);
  153. // setInputFocus2();
  154. // } else {
  155. // // #ifdef APP-PLUS
  156. // plus.device.beep(2);
  157. // // #endif
  158. // errorTipMessage.value = msg;
  159. // errorTip.value.open();
  160. // errorState.value = 0;
  161. // }
  162. // })
  163. // #ifdef APP-PLUS
  164. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  165. mpaasScanModule.mpaasScan({
  166. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  167. 'scanType': ['qrCode', 'barCode'],
  168. // 是否隐藏相册,默认false不隐藏
  169. 'hideAlbum': false
  170. },
  171. (ret) => {
  172. // errorTipMessage.value = ret.resp_code + "-" + ret.resp_result;
  173. // errorTip.value.open();
  174. // errorState.value = -1;
  175. if (ret.resp_code === 1000) {
  176. uni.$reqGet('scanDeliveryOrderNo', {
  177. deliveryOrderNo: ret.resp_result
  178. })
  179. .then(({
  180. code,
  181. data,
  182. msg
  183. }) => {
  184. if (code === 0) {
  185. Object.assign(scanParams.value, data)
  186. setInputFocus2()
  187. } else {
  188. // #ifdef APP-PLUS
  189. plus.device.beep(2)
  190. // #endif
  191. errorTipMessage.value = msg
  192. errorTip.value.open()
  193. errorState.value = 0
  194. }
  195. })
  196. }
  197. })
  198. // #endif
  199. }
  200. // 扫描送货单输入框回车事件
  201. const confirmDeliverOrderNo = function(e) {
  202. uni.$reqGet('scanDeliveryOrderNo', {
  203. deliveryOrderNo: e
  204. })
  205. .then(({
  206. code,
  207. data,
  208. msg
  209. }) => {
  210. if (code === 0) {
  211. Object.assign(scanParams.value, data)
  212. setInputFocus2()
  213. } else {
  214. // #ifdef APP-PLUS
  215. plus.device.beep(2)
  216. // #endif
  217. errorTipMessage.value = msg
  218. errorTip.value.open()
  219. errorState.value = 0
  220. }
  221. })
  222. }
  223. const handleScanMaterial = function() {
  224. // #ifdef APP-PLUS
  225. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  226. mpaasScanModule.mpaasScan({
  227. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  228. 'scanType': ['qrCode', 'barCode'],
  229. // 是否隐藏相册,默认false不隐藏
  230. 'hideAlbum': false
  231. },
  232. (ret) => {
  233. if (ret.resp_code === 1000) {
  234. uni.$reqGet('scanRegisterMaterial', {
  235. batchNumber: ret.resp_result
  236. })
  237. .then(({
  238. code,
  239. data,
  240. msg
  241. }) => {
  242. scanParams.value.deliverBatch = data?.deliverBatch
  243. if (code === 0) {
  244. fdIndex.value = scanParams.value.detail.findIndex(item => item
  245. ?.deliverBatch ===
  246. data?.deliverBatch)
  247. if (fdIndex.value !== -1) {
  248. if (data?.ifExpired === 1) {
  249. // 物料超过保质期
  250. modalForm.value.open()
  251. } else {
  252. setInputFocus2()
  253. scanParams.value.detail[fdIndex.value].state = true
  254. }
  255. } else {
  256. // #ifdef APP-PLUS
  257. plus.device.beep(2)
  258. // #endif
  259. errorTipMessage.value = '请扫描正确的物料'
  260. errorTip.value.open()
  261. errorState.value = 1
  262. }
  263. } else {
  264. // #ifdef APP-PLUS
  265. plus.device.beep(2)
  266. // #endif
  267. errorTipMessage.value = msg
  268. errorTip.value.open()
  269. errorState.value = 1
  270. }
  271. })
  272. }
  273. })
  274. // #endif
  275. }
  276. // 扫描物料输入框回车事件
  277. const confirmMaterial = function(e) {
  278. uni.$reqGet('scanRegisterMaterial', {
  279. batchNumber: e
  280. })
  281. .then(({
  282. code,
  283. data,
  284. msg
  285. }) => {
  286. scanParams.value.deliverBatch = data?.deliverBatch
  287. if (code === 0) {
  288. fdIndex.value = scanParams.value.detail.findIndex(item => item
  289. ?.deliverBatch ===
  290. data?.deliverBatch)
  291. if (fdIndex.value !== -1) {
  292. if (data?.ifExpired === 1) {
  293. // 物料超过保质期
  294. modalForm.value.open()
  295. } else {
  296. setInputFocus2()
  297. scanParams.value.detail[fdIndex.value].state = true
  298. }
  299. } else {
  300. // #ifdef APP-PLUS
  301. plus.device.beep(2)
  302. // #endif
  303. errorTipMessage.value = '请扫描正确的物料'
  304. errorTip.value.open()
  305. errorState.value = 1
  306. }
  307. } else {
  308. // #ifdef APP-PLUS
  309. plus.device.beep(2)
  310. // #endif
  311. errorTipMessage.value = msg
  312. errorTip.value.open()
  313. errorState.value = 1
  314. }
  315. })
  316. }
  317. const handleNavigateToRegisterRecord = function() {
  318. uni.navigateTo({
  319. url: '/pages/workbranch/warehouse/materialRegister/Record/registerRecord'
  320. })
  321. }
  322. // 登记
  323. const handeleRegister = function() {
  324. let isTrue = false
  325. if (scanParams.value.detail.length === 0) {
  326. // #ifdef APP-PLUS
  327. plus.device.beep(2)
  328. // #endif
  329. errorTipMessage.value = '登记数据不能为空'
  330. errorTip.value.open()
  331. errorState.value = 0
  332. return
  333. }
  334. if (scanParams.value.validateFlag === 0) {
  335. isTrue = true
  336. } else {
  337. isTrue = scanParams.value.detail.every(item => item.state === true)
  338. }
  339. if (isTrue) {
  340. uni.showLoading({
  341. title: '数据请求中',
  342. duration: 20000,
  343. mask: true
  344. })
  345. uni.$reqPost('incomingReceiptMasterCreate', scanParams.value)
  346. .then(({
  347. code,
  348. data,
  349. msg
  350. }) => {
  351. scanParams.value = {
  352. deliveryOrderNo: '',
  353. supplierCode: '',
  354. supplierName: '',
  355. remark: '',
  356. deliverBatch: '',
  357. validateFlag: -1,
  358. detail: []
  359. }
  360. if (code === 0) {
  361. uni.showToast({
  362. title: '来料登记成功',
  363. icon: 'none',
  364. duration: 2000
  365. })
  366. } else {
  367. // #ifdef APP-PLUS
  368. plus.device.beep(2)
  369. // #endif
  370. errorTipMessage.value = msg
  371. errorTip.value.open()
  372. errorState.value = -1
  373. }
  374. })
  375. .finally(() => {
  376. uni.hideLoading()
  377. })
  378. } else {
  379. // #ifdef APP-PLUS
  380. plus.device.beep(2)
  381. // #endif
  382. errorTipMessage.value = '请填写完整需求清单'
  383. errorTip.value.open()
  384. errorState.value = 1
  385. }
  386. }
  387. const handleCompleteDialog = function() {
  388. setInputFocus2()
  389. scanParams.value.detail[fdIndex.value].state = true
  390. modalForm.value.close()
  391. }
  392. const handleCloseDialog = function() {
  393. setInputFocus2()
  394. modalForm.value.close()
  395. }
  396. const goBack = function() {
  397. uni.$goBack('/pages/workbranch/warehouse/materialRegister/registerType')
  398. }
  399. const setInputFocus = function() {
  400. scanParams.value.deliveryOrderNo = ''
  401. easyinput.value.onBlur()
  402. easyinput.value.onFocus()
  403. }
  404. const setInputFocus2 = function() {
  405. scanParams.value.deliverBatch = ''
  406. easyinput2.value.onBlur()
  407. easyinput2.value.onFocus()
  408. }
  409. // 关闭错误信息弹窗
  410. const handleCloseErrorTipsModal = async function() {
  411. errorTip.value.close()
  412. if (errorState.value === 0) {
  413. await setInputFocus()
  414. } else if (errorState.value === 1) {
  415. await setInputFocus2()
  416. }
  417. }
  418. // 禁用软键盘
  419. const handleInputFocus = function() {
  420. setTimeout(() => {
  421. uni.hideKeyboard()
  422. }, 100)
  423. }
  424. return {
  425. goBack,
  426. modalForm,
  427. easyinput,
  428. easyinput2,
  429. errorState,
  430. errorTip,
  431. errorTipMessage,
  432. scanParams,
  433. handleMapass,
  434. handleInputFocus,
  435. handleCompleteDialog,
  436. handleCloseDialog,
  437. handleScanMaterial,
  438. handeleRegister,
  439. confirmMaterial,
  440. confirmDeliverOrderNo,
  441. handleCloseErrorTipsModal,
  442. handleNavigateToRegisterRecord
  443. }
  444. }
  445. })
  446. </script>
  447. <style lang="scss" scoped>
  448. .gui-header-leader-btns {
  449. color: black;
  450. font-size: 24px !important;
  451. }
  452. .gui-sbody {
  453. background-color: rgba(234, 239, 242, 1);
  454. }
  455. .form {
  456. margin-top: 85px;
  457. font-size: 14px;
  458. }
  459. .row {
  460. height: 55px;
  461. display: flex;
  462. justify-content: center;
  463. padding-left: 20px;
  464. padding-right: 20px;
  465. margin: 10px 0;
  466. background-color: white;
  467. .row-card {
  468. display: flex;
  469. flex-direction: row;
  470. justify-content: space-between;
  471. align-items: center;
  472. width: calc(375px - 30px);
  473. }
  474. }
  475. .input-200 {
  476. width: 200px;
  477. padding-left: 10px;
  478. }
  479. .font-icons {
  480. width: 40px;
  481. font-size: 20px;
  482. text-align: right;
  483. }
  484. .card-list-flexbox {
  485. width: calc(100vw - 24px);
  486. height: 195px;
  487. margin: 0 12px;
  488. display: flex;
  489. justify-content: center;
  490. flex-direction: column;
  491. align-items: center;
  492. overflow-y: scroll;
  493. .card-list-title {
  494. width: 100%;
  495. height: 35px;
  496. line-height: 35px;
  497. margin: 0 4px 0 4px;
  498. border-radius: 4px 4px 0 0;
  499. text-align: center;
  500. color: white;
  501. background-color: rgba(0, 160, 233, 1.0);
  502. }
  503. .card-list-item,
  504. .card-list-item-operation {
  505. width: 100%;
  506. height: 35px;
  507. margin: 0 4px 3rpx 4px;
  508. border-radius: 4px;
  509. display: flex;
  510. flex-direction: row;
  511. align-items: center;
  512. justify-content: space-between;
  513. background-color: #fff;
  514. uni-text {
  515. font-size: 14px;
  516. height: 50rpx;
  517. text-align: left;
  518. padding: 0 8px;
  519. display: flex;
  520. flex-direction: row;
  521. align-items: center;
  522. }
  523. .text-1 {
  524. flex: 1;
  525. height: 35px;
  526. justify-content: flex-start;
  527. }
  528. .text-2 {
  529. flex: 3;
  530. height: 35px;
  531. justify-content: flex-end;
  532. margin-right: 4px;
  533. padding: 2px 6px;
  534. }
  535. }
  536. }
  537. .table-title {
  538. height: 40px;
  539. line-height: 40px;
  540. margin: 4px 0 -3px 0;
  541. padding: 0 12px;
  542. font-size: 16px;
  543. font-weight: bold;
  544. background-color: white;
  545. }
  546. .custom-table {
  547. height: calc(100vh - 405px);
  548. min-height: 230px;
  549. margin: 5px 0;
  550. overflow-y: scroll;
  551. }
  552. </style>