You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

659 lines
16 KiB

  1. <template>
  2. <div>
  3. <div class="pda-container">
  4. <div class="status-bar">
  5. <div class="goBack" @click="$router.back()"><i class="el-icon-arrow-left"></i>上一页</div>
  6. <div class="goBack">其它出库</div>
  7. <div class="network" style="color: #fff" @click="$router.push({ path: '/' })">🏠首页</div>
  8. </div>
  9. <div style="overflow-y: auto">
  10. <!-- 搜索框 -->
  11. <div class="search-container">
  12. <el-input clearable class="compact-input"
  13. v-model="scanCode"
  14. placeholder="请扫描HandlingUnit条码"
  15. prefix-icon="el-icon-search"
  16. @keyup.enter.native="handleScan"
  17. ref="scanInput"
  18. />
  19. <div class="mode-switch">
  20. <el-switch
  21. class="custom-switch"
  22. v-model="isRemoveMode"
  23. active-color="#ff4949"
  24. inactive-color="#13ce66">
  25. </el-switch>
  26. <span v-if="isRemoveMode" class="switch-text">{{ '移除' }}</span>
  27. <span v-else class="switch-text2">{{ '添加' }}</span>
  28. </div>
  29. </div>
  30. <!-- 其它出库信息卡片 -->
  31. <div class="material-info-card">
  32. <div class="input-form">
  33. <div class="form-row">
  34. <div class="form-item">
  35. <label class="form-label">操作员</label>
  36. <el-input
  37. v-model="outboundForm.operatorName"
  38. placeholder="请输入操作员"
  39. size="small">
  40. </el-input>
  41. </div>
  42. <div class="form-item">
  43. <label class="form-label">操作时间</label>
  44. <el-date-picker
  45. v-model="outboundForm.operateTime"
  46. type="datetime"
  47. placeholder="选择操作时间"
  48. size="small"
  49. format="yyyy-MM-dd HH:mm:ss"
  50. value-format="yyyy-MM-dd HH:mm:ss">
  51. </el-date-picker>
  52. </div>
  53. </div>
  54. <div class="form-row">
  55. <div class="form-item full-width">
  56. <label class="form-label">出库原因</label>
  57. <el-input
  58. v-model="outboundForm.outboundReason"
  59. placeholder="请输入出库原因"
  60. size="small">
  61. </el-input>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <!-- 其它出库信息确认标题 -->
  67. <div class="section-title">
  68. <div class="title-left">
  69. <i class="el-icon-box"></i>
  70. <span>其它出库信息确认</span>
  71. </div>
  72. </div>
  73. <!-- 扫描的HandlingUnit明细列表 -->
  74. <div class="scanned-items" v-if="scannedItems.length > 0" style="margin: 2px;">
  75. <div class="label-list">
  76. <el-form label-position="top" style="margin: 3px;">
  77. <el-row :gutter="5"
  78. v-for="(label, index) in scannedItems"
  79. :key="label.id"
  80. :class="index < scannedItems.length - 1 ? 'bottom-line-row' : ''"
  81. style="border: 1px solid #e0e0e0; border-radius: 4px; margin-bottom: 8px; padding: 8px;">
  82. <el-col :span="12">
  83. <el-form-item label="HandlingUnit">
  84. <span>{{ label.unitId }}</span>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="8">
  88. <el-form-item label="物料编码">
  89. <span>{{ label.partNo }}</span>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="4">
  93. <el-form-item label="数量">
  94. <span>{{ label.qty }} {{ label.unit || '个' }}</span>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="24" v-if="label.partDesc">
  98. <el-form-item label="物料描述">
  99. <span>{{ label.partDesc }}</span>
  100. </el-form-item>
  101. </el-col>
  102. <el-col :span="12" v-if="label.batchNo">
  103. <el-form-item label="批次号">
  104. <span>{{ label.batchNo }}</span>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="12" v-if="label.locationId">
  108. <el-form-item label="库位">
  109. <span>{{ label.locationId }}</span>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="24">
  113. <div class="action-buttons" style="text-align: right; margin-top: 8px;">
  114. <el-button size="mini" type="danger" @click="removeLabel(label)">删除</el-button>
  115. </div>
  116. </el-col>
  117. </el-row>
  118. </el-form>
  119. </div>
  120. </div>
  121. <!-- 空状态 -->
  122. <div v-if="scannedItems.length === 0" class="empty-labels">
  123. <div style="text-align: center; padding: 20px;">
  124. <p style="color: #999; margin: 0;">暂无扫描HandlingUnit</p>
  125. </div>
  126. </div>
  127. <!-- 底部操作按钮 -->
  128. <div class="bottom-actions" v-if="scannedItems.length > 0">
  129. <button class="action-btn primary" @click="confirmOutbound">
  130. 确认其它出库
  131. </button>
  132. <button class="action-btn secondary" style="margin-left: 10px;" @click="cancelProcess">
  133. 取消
  134. </button>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. </template>
  140. <script>
  141. import { scanHandlingUnitLabel, confirmOtherOutbound, getOtherOutboundHistory } from '@/api/po/po'
  142. export default {
  143. name: 'OtherOutbound',
  144. data() {
  145. return {
  146. scanCode: '',
  147. isRemoveMode: false, // 默认为添加模式
  148. outboundForm: {
  149. operatorName: '',
  150. operateTime: '',
  151. outboundReason: ''
  152. },
  153. scannedItems: [],
  154. site: localStorage.getItem('site') || 'SITE01'
  155. };
  156. },
  157. methods: {
  158. // 处理扫描
  159. handleScan() {
  160. if (!this.scanCode.trim()) {
  161. return;
  162. }
  163. if (this.isRemoveMode) {
  164. this.removeLabelByCode(this.scanCode.trim());
  165. } else {
  166. this.validateAndAddLabel(this.scanCode.trim());
  167. }
  168. this.scanCode = '';
  169. },
  170. // 验证标签并添加到列表
  171. validateAndAddLabel(unitId) {
  172. const params = {
  173. unitId: unitId,
  174. site: this.site,
  175. };
  176. scanHandlingUnitLabel(params).then(({ data }) => {
  177. if (data && data.code === 0 && data.data) {
  178. const huInfo = data.data;
  179. this.processHandlingUnit(unitId, huInfo);
  180. } else {
  181. this.$message.error(data.msg || 'HandlingUnit不存在或查询失败');
  182. }
  183. }).catch(error => {
  184. this.$message.error('扫描失败');
  185. });
  186. },
  187. // 处理HandlingUnit数据
  188. processHandlingUnit(unitId, huInfo) {
  189. // 检查是否已经扫描过
  190. const exists = this.scannedItems.find(item => item.unitId === unitId);
  191. if (exists) {
  192. this.$message.warning('该HandlingUnit已扫描,请勿重复扫描');
  193. return;
  194. }
  195. // 校验HU是否属于当前站点
  196. if (huInfo.site && huInfo.site !== this.site) {
  197. this.$message.error('HandlingUnit站点不匹配');
  198. return;
  199. }
  200. // 校验HU是否在库
  201. if (huInfo.inStockFlag !== 'Y') {
  202. this.$message.error('HandlingUnit不在库,无法出库');
  203. return;
  204. }
  205. // 添加到列表
  206. this.scannedItems.push({
  207. id: Date.now(),
  208. unitId: unitId,
  209. partNo: huInfo.partNo,
  210. partDesc: huInfo.partDesc,
  211. qty: huInfo.qty,
  212. unit: huInfo.unit,
  213. batchNo: huInfo.batchNo,
  214. locationId: huInfo.locationId
  215. });
  216. this.$message.success('扫描成功');
  217. },
  218. // 根据扫描码移除标签
  219. removeLabelByCode(unitId) {
  220. const index = this.scannedItems.findIndex(item => item.unitId === unitId);
  221. if (index > -1) {
  222. this.scannedItems.splice(index, 1);
  223. this.$message.success('移除成功');
  224. } else {
  225. this.$message.warning('未找到该HandlingUnit');
  226. }
  227. },
  228. // 删除标签
  229. removeLabel(label) {
  230. const index = this.scannedItems.indexOf(label);
  231. if (index > -1) {
  232. this.scannedItems.splice(index, 1);
  233. this.$message.success('删除成功');
  234. }
  235. },
  236. // 确认其它出库
  237. confirmOutbound() {
  238. // 验证必填字段
  239. if (!this.outboundForm.operatorName) {
  240. this.$message.error('请输入操作员');
  241. return;
  242. }
  243. if (!this.outboundForm.operateTime) {
  244. this.$message.error('请选择操作时间');
  245. return;
  246. }
  247. if (this.scannedItems.length === 0) {
  248. this.$message.error('请至少扫描一个HandlingUnit');
  249. return;
  250. }
  251. // 构建HandlingUnit ID列表
  252. const handlingUnitIds = this.scannedItems.map(item => item.unitId);
  253. const params = {
  254. site: this.site,
  255. operatorName: this.outboundForm.operatorName,
  256. operateTime: this.outboundForm.operateTime,
  257. outboundReason: this.outboundForm.outboundReason,
  258. handlingUnitIds: handlingUnitIds,
  259. scannedItems: this.scannedItems
  260. };
  261. // 调用后端API
  262. confirmOtherOutbound(params).then(({ data }) => {
  263. if (data && data.code === 0) {
  264. this.$message({
  265. message: '其它出库成功!处理单元: ' + handlingUnitIds.length + '个',
  266. type: 'success',
  267. duration: 3000
  268. });
  269. // 跳转回其他出入库页面
  270. setTimeout(() => {
  271. this.$router.push({ path: '/otherinout' });
  272. }, 1000);
  273. } else {
  274. this.$message.error(data.msg || '其它出库失败');
  275. }
  276. }).catch(error => {
  277. console.error('其它出库失败:', error);
  278. this.$message.error('其它出库失败,请重试');
  279. });
  280. },
  281. // 取消处理
  282. cancelProcess() {
  283. if (this.scannedItems.length > 0) {
  284. this.$confirm('确认取消当前操作?已扫描的数据将会丢失。', '确认', {
  285. confirmButtonText: '确定',
  286. cancelButtonText: '取消',
  287. type: 'warning'
  288. }).then(() => {
  289. this.$router.go(-1);
  290. }).catch(() => {
  291. // 用户取消,不做任何操作
  292. });
  293. } else {
  294. this.$router.go(-1);
  295. }
  296. },
  297. // 初始化表单数据
  298. initFormData() {
  299. // 设置默认操作时间为当前时间
  300. const now = new Date();
  301. const year = now.getFullYear();
  302. const month = (now.getMonth() + 1).toString().padStart(2, '0');
  303. const day = now.getDate().toString().padStart(2, '0');
  304. const hours = now.getHours().toString().padStart(2, '0');
  305. const minutes = now.getMinutes().toString().padStart(2, '0');
  306. const seconds = now.getSeconds().toString().padStart(2, '0');
  307. this.outboundForm.operateTime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
  308. // 设置默认操作员
  309. this.outboundForm.operatorName = localStorage.getItem('userName') || '系统用户';
  310. }
  311. },
  312. mounted() {
  313. this.initFormData();
  314. this.$nextTick(() => {
  315. if (this.$refs.scanInput) {
  316. this.$refs.scanInput.focus();
  317. }
  318. });
  319. }
  320. };
  321. </script>
  322. <style scoped>
  323. /* 复用其它入库的样式 */
  324. .pda-container {
  325. width: 100%;
  326. height: 100vh;
  327. display: flex;
  328. flex-direction: column;
  329. overflow: hidden;
  330. }
  331. .status-bar {
  332. background: #17B3A3;
  333. color: white;
  334. padding: 8px 16px;
  335. display: flex;
  336. justify-content: space-between;
  337. align-items: center;
  338. height: 40px;
  339. min-height: 40px;
  340. }
  341. .goBack {
  342. cursor: pointer;
  343. font-size: 16px;
  344. font-weight: 500;
  345. }
  346. /* 搜索容器样式 */
  347. .search-container {
  348. padding: 12px 16px;
  349. background: white;
  350. display: flex;
  351. align-items: center;
  352. gap: 12px;
  353. }
  354. .search-container .el-input {
  355. width: 240px;
  356. margin-right: 12px;
  357. }
  358. /* 紧凑型输入框样式 */
  359. .compact-input ::v-deep .el-input__inner {
  360. height: 36px;
  361. padding: 0 12px 0 35px;
  362. font-size: 14px;
  363. }
  364. .compact-input ::v-deep .el-input__prefix {
  365. left: 10px;
  366. }
  367. .compact-input ::v-deep .el-input__suffix {
  368. right: 30px;
  369. }
  370. /* 模式切换开关 */
  371. .mode-switch {
  372. position: relative;
  373. display: inline-block;
  374. }
  375. .custom-switch {
  376. transform: scale(1.3);
  377. }
  378. /* 中间文字 */
  379. .switch-text {
  380. position: absolute;
  381. left: 25%;
  382. top: 53%;
  383. transform: translate(-50%, -50%);
  384. font-size: 12px;
  385. font-weight: bold;
  386. color: white;
  387. pointer-events: none;
  388. z-index: 2;
  389. }
  390. .switch-text2 {
  391. position: absolute;
  392. left: 75%;
  393. top: 53%;
  394. transform: translate(-50%, -50%);
  395. font-size: 12px;
  396. font-weight: bold;
  397. color: white;
  398. pointer-events: none;
  399. z-index: 2;
  400. }
  401. /* 调整 switch 尺寸以便容纳文字 */
  402. .custom-switch ::v-deep .el-switch__core {
  403. width: 60px;
  404. height: 28px;
  405. }
  406. /* 物料信息卡片 */
  407. .material-info-card {
  408. background: white;
  409. margin: 4px 16px;
  410. padding: 6px 20px;
  411. border-radius: 8px;
  412. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  413. border: 1px solid #f0f0f0;
  414. }
  415. .card-title {
  416. margin-bottom: 8px;
  417. display: flex;
  418. align-items: center;
  419. gap: 8px;
  420. }
  421. .title-label {
  422. font-size: 12px;
  423. color: #666;
  424. font-weight: 500;
  425. }
  426. .title-value {
  427. font-size: 16px;
  428. font-weight: bold;
  429. color: #333;
  430. line-height: 1.2;
  431. }
  432. /* 表单样式 */
  433. .input-form {
  434. margin-top: 8px;
  435. }
  436. .form-row {
  437. display: flex;
  438. gap: 12px;
  439. margin-bottom: 12px;
  440. }
  441. .form-row:last-child {
  442. margin-bottom: 0;
  443. }
  444. .form-item {
  445. flex: 1;
  446. display: flex;
  447. flex-direction: column;
  448. }
  449. .form-item.full-width {
  450. flex: none;
  451. width: 100%;
  452. }
  453. .form-label {
  454. font-size: 11px;
  455. color: #666;
  456. font-weight: 500;
  457. margin-bottom: 4px;
  458. display: block;
  459. }
  460. .form-item .el-input {
  461. width: 100%;
  462. }
  463. .form-item .el-date-editor {
  464. width: 100%;
  465. }
  466. /* 区域标题 */
  467. .section-title {
  468. display: flex;
  469. align-items: center;
  470. justify-content: space-between;
  471. padding: 6px 8px;
  472. background: white;
  473. margin: 0 16px;
  474. margin-top: 4px;
  475. border-radius: 8px 8px 0 0;
  476. border-bottom: 2px solid #17B3A3;
  477. }
  478. .title-left {
  479. display: flex;
  480. align-items: center;
  481. }
  482. .title-left i {
  483. color: #17B3A3;
  484. font-size: 16px;
  485. margin-right: 8px;
  486. }
  487. .title-left span {
  488. color: #17B3A3;
  489. font-size: 14px;
  490. font-weight: 500;
  491. }
  492. /* 标签列表 */
  493. .label-list {
  494. background: white;
  495. margin: 0 16px 12px;
  496. border-radius: 0 0 8px 8px;
  497. overflow: hidden;
  498. }
  499. .label-list .el-form-item {
  500. margin-bottom: 1px;
  501. }
  502. .label-list .el-form-item__label {
  503. padding-bottom: 1px;
  504. margin-bottom: 0;
  505. line-height: 1.1;
  506. font-size: 11px;
  507. }
  508. .label-list .el-form-item__content {
  509. line-height: 1.2;
  510. font-size: 12px;
  511. }
  512. .bottom-line-row {
  513. border-bottom: 1px solid #f0f0f0;
  514. margin-bottom: 8px;
  515. padding-bottom: 8px;
  516. }
  517. .empty-labels {
  518. padding: 20px;
  519. text-align: center;
  520. color: #999;
  521. background: white;
  522. margin: 0 16px;
  523. border-radius: 8px;
  524. }
  525. /* 底部操作按钮 */
  526. .bottom-actions {
  527. display: flex;
  528. padding: 16px;
  529. gap: 20px;
  530. background: white;
  531. margin-top: auto;
  532. }
  533. .action-btn {
  534. flex: 1;
  535. padding: 12px;
  536. border: 1px solid #17B3A3;
  537. background: #17B3A3;
  538. color: white;
  539. border-radius: 20px;
  540. font-size: 14px;
  541. cursor: pointer;
  542. transition: all 0.2s ease;
  543. }
  544. .action-btn.secondary {
  545. background: white;
  546. color: #17B3A3;
  547. }
  548. .action-btn:hover {
  549. background: #0d8f7f;
  550. border-color: #0d8f7f;
  551. }
  552. .action-btn.secondary:hover {
  553. background: #17B3A3;
  554. color: white;
  555. }
  556. .action-btn:active {
  557. transform: scale(0.98);
  558. }
  559. /* 响应式设计 */
  560. @media (max-width: 360px) {
  561. .status-bar {
  562. padding: 8px 12px;
  563. }
  564. .search-container {
  565. padding: 8px 12px;
  566. }
  567. .material-info-card {
  568. margin: 4px 12px;
  569. padding: 6px 16px;
  570. }
  571. .item-list {
  572. margin: 0 12px 8px;
  573. }
  574. .form-row {
  575. gap: 8px;
  576. margin-bottom: 8px;
  577. }
  578. .form-label {
  579. font-size: 10px;
  580. margin-bottom: 2px;
  581. }
  582. }
  583. </style>