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.

699 lines
26 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <div>
  3. <div class="pda-container" v-loading.fullscreen.lock="fullscreenLoading"
  4. element-loading-background="rgba(255, 255, 255, 0.3)"
  5. element-loading-spinner="el-icon-loading"
  6. :element-loading-text="loadingText">
  7. <div class="status-bar">
  8. <div class="goBack" @click="handleBack"><i class="el-icon-arrow-left"></i>上一页</div>
  9. <div class="goBack">生产入库</div>
  10. <div class="network" style="color: #fff" @click="$router.push({ path: '/' })">🏠首页</div>
  11. </div>
  12. <div style="overflow-y: auto">
  13. <!-- Step 1: 扫描工单号 -->
  14. <div v-if="processFlag === 1">
  15. <div class="scan-box" style="margin: 2px;">
  16. <el-input clearable v-model="scanCode" placeholder="扫描或输入工单号"
  17. @keyup.enter.native="searchShopOrder" ref="scanCodeRef" />
  18. </div>
  19. <div class="item-list" v-if="shopOrderList.length > 0" style="margin: 2px;">
  20. <el-form label-position="top" style="margin: 3px;">
  21. <el-row :gutter="5"
  22. v-for="(orderDetail, index) in shopOrderList" :key="index" :class="index < shopOrderList.length - 1 ? 'bottom-line-row' : ''">
  23. <el-col :span="8">
  24. <el-form-item label="料号"><span>{{ orderDetail.partNo }}</span></el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="行号/下达号"><span>{{ orderDetail.releaseNo }}/{{ orderDetail.sequenceNo }}</span></el-form-item>
  28. </el-col>
  29. <el-col :span="8">
  30. <el-form-item label="">
  31. <el-button type="text" class="recvButton" @click="selectShopOrder(orderDetail)"
  32. style="margin-top: 10px;margin-left: 20px" size="small">入库</el-button>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="24">
  36. <el-form-item label="物料描述"><span>{{ orderDetail.partDesc }}</span></el-form-item>
  37. </el-col>
  38. <el-col :span="6" :class="{ mt10: getTextWidth(orderDetail.partDesc) > 34 }">
  39. <el-form-item label="订单数量"><span>{{ orderDetail.lotSize }}</span></el-form-item>
  40. </el-col>
  41. <el-col :span="6" :class="{ mt10: getTextWidth(orderDetail.partDesc) > 34 }">
  42. <el-form-item label="已完成数"><span>{{ orderDetail.qtyComplete }}</span></el-form-item>
  43. </el-col>
  44. <el-col :span="6" :class="{ mt10: getTextWidth(orderDetail.partDesc) > 34 }">
  45. <el-form-item label="状态">
  46. <el-tag :type="orderDetail.objstate === 'Started' ? 'success' : 'warning'" size="mini">
  47. {{ orderDetail.objstate }}
  48. </el-tag>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="6" :class="{ mt10: getTextWidth(orderDetail.partDesc) > 34 }">
  52. <el-form-item style="margin-left: 20px" label="单位"><span>{{ orderDetail.uom }}</span></el-form-item>
  53. </el-col>
  54. </el-row>
  55. </el-form>
  56. </div>
  57. </div>
  58. <!-- Step 2: 入库明细 -->
  59. <div v-if="processFlag === 2">
  60. <el-form label-position="top" class="form-section" style="margin: 5px;">
  61. <el-row :gutter="20">
  62. <el-col :span="12"><el-form-item label="工单号"><el-input v-model="inboundItem.orderNo" disabled /></el-form-item></el-col>
  63. <el-col :span="12"><el-form-item label="下达号/序列号"><el-input v-model="displayReleaseSeq" disabled /></el-form-item></el-col>
  64. <el-col :span="12"><el-form-item label="料号"><el-input v-model="inboundItem.partNo" disabled /></el-form-item></el-col>
  65. <el-col :span="12"><el-form-item label="计量单位"><el-input v-model="inboundItem.uom" disabled /></el-form-item></el-col>
  66. <el-col :span="24"><el-form-item label="物料描述"><el-input v-model="inboundItem.partDesc" disabled /></el-form-item></el-col>
  67. <el-col :span="12"><el-form-item label="订单数量"><el-input v-model="inboundItem.lotSize" disabled /></el-form-item></el-col>
  68. <el-col :span="12"><el-form-item label="已完成数"><el-input v-model="inboundItem.qtyComplete" disabled /></el-form-item></el-col>
  69. <el-col :span="12">
  70. <el-form-item label="此次入库数量">
  71. <el-input v-model="inboundItem.transQty" type="number" @blur="checkQuantity" />
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="12">
  75. <el-form-item label=" ">
  76. <el-button type="text" @click.stop="handlingUnitStep"
  77. style="font-size: 16px;margin-top: -5px" size="small">包装记录</el-button>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="12"><el-form-item label="库位">
  81. <el-input v-model="inboundItem.locationNo" placeholder="请输入库位" />
  82. </el-form-item></el-col>
  83. <el-col :span="12"><el-form-item label="批号">
  84. <el-input v-model="inboundItem.batchNo" placeholder="请输入批号" />
  85. </el-form-item></el-col>
  86. <el-col :span="12"><el-form-item label="WDR">
  87. <el-input v-model="inboundItem.wdr" placeholder="请输入WDR" />
  88. </el-form-item></el-col>
  89. <el-col :span="12"><el-form-item label="高度(mm)">
  90. <el-input v-model="inboundItem.height" type="number" placeholder="请输入高度" />
  91. </el-form-item></el-col>
  92. <!-- 勾选框 -->
  93. <el-col :span="12" style="margin-top: 0px">
  94. <el-form-item>
  95. <el-checkbox v-model="inboundItem.ifsAutoReport">Auto Report of Operation</el-checkbox>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="24" style="margin-top: 5px">
  99. <el-form-item>
  100. <el-checkbox v-model="inboundItem.ifsSimplifiedMaterial">Simplified Material Check</el-checkbox>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. <el-row :gutter="20">
  105. <el-col :span="8" style="margin-top: 10px"><el-form-item><el-button type="text" style="font-size: 16px;margin-left: 30px" @click="processFlag = 1">回退</el-button></el-form-item></el-col>
  106. <el-col :span="8" style="margin-top: 10px"><el-form-item><el-button type="text" style="font-size: 16px;margin-left: 20px" @click="confirmInbound">确认</el-button></el-form-item></el-col>
  107. <el-col :span="8" style="margin-top: 10px"><el-form-item><el-button type="text" style="font-size: 16px;margin-left: 10px" @click="$router.push('/')">退出</el-button></el-form-item></el-col>
  108. </el-row>
  109. </el-form>
  110. </div>
  111. <!-- Step 3: 包装记录 -->
  112. <div v-if="processFlag === 3">
  113. <el-form label-position="top" class="form-section" style="margin: 5px;">
  114. <el-row :gutter="20">
  115. <el-col :span="12"><el-form-item label="料号"><el-input v-model="inboundItem.partNo" disabled /></el-form-item></el-col>
  116. <el-col :span="12"><el-form-item label="未完成数量"><el-input v-model="inboundItem.unCompleteQty" disabled /></el-form-item></el-col>
  117. <el-col :span="24"><el-form-item label="物料描述"><el-input v-model="inboundItem.partDesc" disabled /></el-form-item></el-col>
  118. <!-- 自动计算开关 -->
  119. <el-col :span="24" style="margin-bottom: 10px;">
  120. <el-form-item>
  121. <el-switch
  122. v-model="autoCalculate"
  123. active-text="自动计算模式"
  124. inactive-text="手动输入模式"
  125. active-color="#17B3A3"
  126. style="display: block;"
  127. >
  128. </el-switch>
  129. <span v-if="autoCalculate" style="font-size: 13px; color: #17B3A3; margin-top: 5px; display: block; font-weight: bold;">
  130. 💡 输入单包装数量后按回车键或点击确定按钮
  131. </span>
  132. <span v-else style="font-size: 12px; color: #999; margin-top: 5px; display: block;">
  133. 手动输入单包装数量和包装数然后点击"创建"按钮
  134. </span>
  135. </el-form-item>
  136. </el-col>
  137. <el-col :span="8" style="margin-top: 5px"><el-form-item label="单包装数量">
  138. <el-input
  139. v-model="hanlingItem.perQty"
  140. type="number"
  141. :placeholder="autoCalculate ? '输入完按回车或失去焦点' : '请输入单包装数量'"
  142. @blur="autoCalculate && autoCreateHandlingUnits()"
  143. @keyup.enter.native="autoCalculate && autoCreateHandlingUnits()"
  144. />
  145. </el-form-item></el-col>
  146. <el-col :span="8" style="margin-top: 5px" v-if="!autoCalculate"><el-form-item label="包装数">
  147. <el-input v-model="hanlingItem.packageQty" type="number" placeholder="请输入包装数" />
  148. </el-form-item></el-col>
  149. <el-col :span="8" v-if="!autoCalculate" style="margin-top: 16px"><el-form-item>
  150. <el-button type="text" @click="createHandlingUnit" style="font-size: 16px">创建</el-button></el-form-item></el-col>
  151. <el-col :span="8" v-else style="margin-top: 16px"><el-form-item>
  152. <el-button type="text" style="font-size: 16px">确定</el-button></el-form-item></el-col>
  153. <el-table :data="handlingUnit" :row-style="{ height: '30px' }" style="width: 94%; margin-left: 10px;" highlight-current-row>
  154. <el-table-column prop="code" label="序号" />
  155. <el-table-column prop="packageQty" label="包装数" width="80" />
  156. <el-table-column prop="perQty" label="单包装数量" width="100" />
  157. <el-table-column label="操作" v-if="!autoCalculate">
  158. <template slot-scope="scope">
  159. <a @click="removeItem(scope.$index)">删除</a>
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. <el-col :span="24" v-if="autoCalculate && handlingUnit.length > 0" style="margin-top: 10px;">
  164. <span style="font-size: 12px; color: #999;">
  165. 💡 如需修改请重新输入单包装数量
  166. </span>
  167. </el-col>
  168. <el-col :span="24"><el-form-item><span>合计</span><span style="margin-left: 38%">{{ totalQty }}</span></el-form-item></el-col>
  169. <el-col :span="12"><el-form-item><el-button type="text" @click="processFlag = 2" style="font-size: 18px;margin-left: 60px">回退</el-button></el-form-item></el-col>
  170. <el-col :span="12"><el-form-item><el-button type="text" @click="processFlag = 2" style="font-size: 18px;">确定</el-button></el-form-item></el-col>
  171. </el-row>
  172. </el-form>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. </template>
  178. <script>
  179. import { getShopOrderFromIfs, getNextSequenceNo, submitShopOrderInbound, validateMaterialIssued, printLabelCommon } from "@/api/production/production-inbound.js";
  180. export default {
  181. data() {
  182. return {
  183. processFlag: 1,
  184. scanCode: '',
  185. shopOrderList: [],
  186. inboundItem: {},
  187. handlingUnit: [],
  188. hanlingItem: { code: '', qty: '', perQty: '', packageQty: '' },
  189. site: localStorage.getItem('site'),
  190. warehouseId: localStorage.getItem('selectedWarehouse'),
  191. fullscreenLoading: false,
  192. loadingText: '加载中...',
  193. autoCalculate: false
  194. };
  195. },
  196. computed: {
  197. totalQty() {
  198. const sum = this.handlingUnit.reduce((sum, item) => sum + Number(item.qty), 0);
  199. this.inboundItem.transQty = sum;
  200. return sum;
  201. },
  202. huKey() {
  203. return `hu_shop_${this.inboundItem.orderNo}_${this.inboundItem.releaseNo}`;
  204. },
  205. displayReleaseSeq() {
  206. return `${this.inboundItem.releaseNo || ''}/${this.inboundItem.sequenceNo || ''}`;
  207. }
  208. },
  209. watch: {
  210. autoCalculate(newVal, oldVal) {
  211. this.hanlingItem.perQty = '';
  212. this.hanlingItem.packageQty = '';
  213. this.handlingUnit = [];
  214. localStorage.setItem(this.huKey, JSON.stringify(this.handlingUnit));
  215. if (newVal) {
  216. this.$message.success('已切换到自动创建HU模式');
  217. } else {
  218. this.$message.success('已切换到手动输入模式');
  219. }
  220. }
  221. },
  222. methods: {
  223. // 计算"显示宽度"
  224. getTextWidth(text) {
  225. if (!text) return 0
  226. let len = 0
  227. for (let char of text) {
  228. if (/[\u4e00-\u9fa5\u3000-\u303F\uFF00-\uFFEF]/.test(char)) {
  229. len += 2
  230. } else {
  231. len += 1
  232. }
  233. }
  234. return len
  235. },
  236. handleBack() {
  237. if (this.processFlag === 1) this.$router.back();
  238. else if (this.processFlag === 3) this.processFlag = 2;
  239. else this.processFlag = 1;
  240. },
  241. // 搜索工单
  242. searchShopOrder() {
  243. if (!this.scanCode) return this.shopOrderList = [];
  244. this.loadingText = '搜索中...';
  245. this.fullscreenLoading = true;
  246. // 解析工单号:支持 "3038851" 或 "3038851-1-2" 格式
  247. let orderNo = this.scanCode.trim();
  248. let releaseNo = "*";
  249. let sequenceNo = "*";
  250. // 如果包含"-",则按照 orderNo-releaseNo-sequenceNo 格式解析
  251. const parts = orderNo.split('-');
  252. if (parts.length >= 2) {
  253. orderNo = parts[0];
  254. releaseNo = parts[1];
  255. if (parts.length >= 3) {
  256. sequenceNo = parts[2];
  257. }
  258. }
  259. const requestData = {
  260. ifsDBName: "IFST",
  261. domainUserID: "CCL_WMS",
  262. ifsSiteID: this.site,
  263. ifsOrderNo: orderNo,
  264. ifsReleaseNo: releaseNo,
  265. ifsSequenceNo: sequenceNo
  266. };
  267. console.log('工单查询参数:', requestData);
  268. getShopOrderFromIfs(requestData).then(({ data }) => {
  269. if (data.code === 0) {
  270. this.shopOrderList = data.data || []
  271. if (this.shopOrderList.length === 0) {
  272. this.$message.warning('未找到匹配的工单');
  273. }
  274. } else {
  275. this.$message.error(data.msg || '查询失败');
  276. this.shopOrderList = []
  277. }
  278. this.$nextTick(() => {
  279. if (this.$refs.scanCodeRef) {
  280. this.$refs.scanCodeRef.blur();
  281. }
  282. });
  283. }).catch(error => {
  284. console.error('搜索失败:', error);
  285. this.$message.error('搜索失败,请重试');
  286. this.shopOrderList = []
  287. }).finally(() => {
  288. this.fullscreenLoading = false;
  289. });
  290. },
  291. // 选择工单
  292. async selectShopOrder(row) {
  293. // 校验状态
  294. if (row.objstate !== 'Started') {
  295. return this.$message.warning(`工单状态为 ${row.objstate},只有Started状态才能入库`);
  296. }
  297. this.fullscreenLoading = true;
  298. this.loadingText = '检查物料发料状态...';
  299. try {
  300. // 1. 检查物料是否已发料
  301. const validateResult = await validateMaterialIssued({
  302. site: this.site,
  303. orderNo: row.orderNo,
  304. releaseNo: row.releaseNo || '*',
  305. sequenceNo: row.sequenceNo || '*'
  306. });
  307. if (validateResult.data.code !== 0) {
  308. this.$alert(validateResult.data.msg || '物料发料检查失败', '操作提示', {
  309. confirmButtonText: '确定',
  310. type: 'warning'
  311. });
  312. return;
  313. }
  314. this.loadingText = '加载中...';
  315. // 2. 获取下一个序列号
  316. let nextSequence = 1;
  317. try {
  318. const { data } = await getNextSequenceNo({
  319. orderNo: row.orderNo,
  320. releaseNo: row.releaseNo || '*',
  321. sequenceNo: row.sequenceNo || '*'
  322. });
  323. if (data.code === 0) {
  324. nextSequence = data.data;
  325. }
  326. } catch (error) {
  327. console.error('获取序列号失败:', error);
  328. }
  329. this.inboundItem = {
  330. ...row,
  331. transQty: '',
  332. unCompleteQty: parseFloat(row.lotSize) - parseFloat(row.qtyComplete),
  333. sequenceNoNew: nextSequence,
  334. batchNo: `${row.orderNo}-${row.releaseNo}-${row.sequenceNo}-${nextSequence}`,
  335. locationNo: 'AS',
  336. serialNo: '*',
  337. wdr: '*',
  338. engChgLevel: '1',
  339. ifsAutoReport: false, // Auto Report of Operation
  340. ifsSimplifiedMaterial: true, // Simplified Material Check默认选中
  341. height: this.parseHeightFromPartNo(row.partNo) // 根据物料编码自动填充高度
  342. };
  343. this.processFlag = 2;
  344. } catch (error) {
  345. console.error('操作失败:', error);
  346. this.$message.error(error.message || '操作失败');
  347. } finally {
  348. this.fullscreenLoading = false;
  349. }
  350. },
  351. // 检查数量
  352. checkQuantity() {
  353. const transQty = parseFloat(this.inboundItem.transQty) || 0;
  354. const qtyComplete = parseFloat(this.inboundItem.qtyComplete) || 0;
  355. const lotSize = parseFloat(this.inboundItem.lotSize) || 0;
  356. if (qtyComplete + transQty > lotSize) {
  357. this.$confirm(
  358. `当前已完成数量(${qtyComplete}) + 本次入库数量(${transQty}) = ${qtyComplete + transQty},超过订单数量(${lotSize}),是否继续?`,
  359. '数量超出提示',
  360. {
  361. confirmButtonText: '继续',
  362. cancelButtonText: '取消',
  363. type: 'warning'
  364. }
  365. ).catch(() => {
  366. this.inboundItem.transQty = '';
  367. });
  368. }
  369. },
  370. handlingUnitStep() {
  371. this.processFlag = 3;
  372. this.autoCalculate = false; // 默认使用自动计算模式
  373. const saved = localStorage.getItem(this.huKey);
  374. this.handlingUnit = saved ? JSON.parse(saved) : [];
  375. },
  376. /**
  377. * 自动创建HU列表自动模式
  378. */
  379. autoCreateHandlingUnits() {
  380. const perQty = this.hanlingItem.perQty;
  381. if (!perQty || isNaN(perQty) || parseFloat(perQty) <= 0) {
  382. this.$message.warning('请输入有效的单包装数量');
  383. return;
  384. }
  385. const qtyToReceive = parseFloat(this.inboundItem.transQty) || 0;
  386. if (qtyToReceive <= 0) {
  387. this.$message.warning('入库数量为0,无法创建HU');
  388. this.hanlingItem.perQty = '';
  389. return;
  390. }
  391. const perQtyValue = parseFloat(perQty);
  392. const packageQty = Math.floor(qtyToReceive / perQtyValue);
  393. const remainder = qtyToReceive - (packageQty * perQtyValue);
  394. this.handlingUnit = [];
  395. if (packageQty > 0) {
  396. for (let i = 1; i <= packageQty; i++) {
  397. const qty = perQtyValue;
  398. const code = String(i);
  399. this.handlingUnit.push({
  400. code: code,
  401. perQty: perQtyValue,
  402. packageQty: 1,
  403. qty: qty
  404. });
  405. }
  406. }
  407. if (remainder > 0) {
  408. const code = String(this.handlingUnit.length + 1);
  409. this.handlingUnit.push({
  410. code: code,
  411. perQty: remainder,
  412. packageQty: 1,
  413. qty: remainder
  414. });
  415. }
  416. localStorage.setItem(this.huKey, JSON.stringify(this.handlingUnit));
  417. this.hanlingItem.perQty = '';
  418. this.hanlingItem.packageQty = '';
  419. this.$message.success(`自动创建了${this.handlingUnit.length}个HU,合计数量:${qtyToReceive}`);
  420. },
  421. /**
  422. * 手动创建HU手动模式
  423. */
  424. createHandlingUnit() {
  425. const { perQty, packageQty } = this.hanlingItem;
  426. if (!perQty || !packageQty || isNaN(perQty) || isNaN(packageQty)) {
  427. return this.$message.warning("请填写有效的包装信息");
  428. }
  429. const qty = parseFloat(perQty) * parseInt(packageQty);
  430. const code = String(this.handlingUnit.length + 1);
  431. const newItem = { ...this.hanlingItem, qty, code };
  432. this.handlingUnit.push(newItem);
  433. localStorage.setItem(this.huKey, JSON.stringify(this.handlingUnit));
  434. this.hanlingItem.perQty = '';
  435. this.hanlingItem.packageQty = '';
  436. },
  437. removeItem(index) {
  438. this.handlingUnit.splice(index, 1);
  439. localStorage.setItem(this.huKey, JSON.stringify(this.handlingUnit));
  440. },
  441. clearAllHandlingUnitCache() {
  442. this.hanlingItem = { code: '', qty: '', perQty: '', packageQty: '' };
  443. const keys = Object.keys(localStorage);
  444. keys.forEach(key => {
  445. if (key.startsWith('hu_shop_')) {
  446. localStorage.removeItem(key);
  447. }
  448. });
  449. },
  450. // 确认入库
  451. async confirmInbound() {
  452. if (this.fullscreenLoading) return;
  453. const item = this.inboundItem;
  454. if (!item.transQty || !item.locationNo || !item.batchNo) {
  455. return this.$message.error("请填写完整信息");
  456. }
  457. // 检查数量是否超出
  458. const transQty = parseFloat(item.transQty) || 0;
  459. const qtyComplete = parseFloat(item.qtyComplete) || 0;
  460. const lotSize = parseFloat(item.lotSize) || 0;
  461. if (qtyComplete + transQty > lotSize) {
  462. try {
  463. await this.$confirm(
  464. `当前已完成数量(${qtyComplete}) + 本次入库数量(${transQty}) = ${qtyComplete + transQty},超过订单数量(${lotSize}),是否继续?`,
  465. '数量超出提示',
  466. {
  467. confirmButtonText: '继续',
  468. cancelButtonText: '取消',
  469. type: 'warning'
  470. }
  471. );
  472. } catch (error) {
  473. // 用户取消
  474. return;
  475. }
  476. }
  477. this.loadingText = '提交中...';
  478. this.fullscreenLoading = true;
  479. // 构建提交数据
  480. const submitData = {
  481. // 基本字段
  482. site: this.site,
  483. warehouseId: this.warehouseId,
  484. orderNo: item.orderNo,
  485. releaseNo: item.releaseNo,
  486. sequenceNo: item.sequenceNo,
  487. partNo: item.partNo,
  488. partDesc: item.partDesc,
  489. transQty: item.transQty,
  490. batchNo: item.batchNo,
  491. locationNo: item.locationNo,
  492. serialNo: item.serialNo || '*',
  493. engChgLevel: item.engChgLevel || '1',
  494. uom: item.uom,
  495. lotSize: item.lotSize,
  496. qtyComplete: item.qtyComplete,
  497. height: item.height || null, // 高度(mm)
  498. // IFS参数
  499. ifsAutoReport: item.ifsAutoReport ? 'Yes' : 'No',
  500. ifsSimplifiedMaterial: item.ifsSimplifiedMaterial ? 'Yes' : 'No',
  501. ifsAutoClose:item.closeCodeDb==='Y'?'TRUE':'FALSE',
  502. // 处理单元列表
  503. handlingUnitList: this.handlingUnit.map(hu => ({
  504. perQty: hu.perQty,
  505. packageQty: hu.packageQty
  506. }))
  507. };
  508. submitShopOrderInbound(submitData).then(({ data }) => {
  509. if (data.code === 0) {
  510. this.$message.success("入库成功");
  511. this.clearAllHandlingUnitCache();
  512. // 获取unitIds并打印标签
  513. const unitIds = data.unitIds || [];
  514. if (unitIds.length > 0) {
  515. this.printViaServer(unitIds);
  516. }
  517. this.processFlag = 1;
  518. this.scanCode = '';
  519. this.shopOrderList = [];
  520. this.inboundItem = {};
  521. this.handlingUnit = [];
  522. } else {
  523. this.$message.error(data.msg || '入库失败');
  524. }
  525. }).catch(error => {
  526. console.error('入库失败:', error);
  527. this.$message.error('网络错误,请重试');
  528. }).finally(() => {
  529. this.fullscreenLoading = false;
  530. });
  531. },
  532. /**
  533. * 通过服务器打印
  534. * @param {Array} unitIds - HU unitId列表
  535. */
  536. async printViaServer(unitIds) {
  537. if (!unitIds || unitIds.length === 0) {
  538. console.warn('没有可打印的标签');
  539. return;
  540. }
  541. this.$emit('print-start')
  542. try {
  543. const printRequest = {
  544. userId: localStorage.getItem('userName'),
  545. username: localStorage.getItem('userName'),
  546. site: localStorage.getItem('site'),
  547. unitIds: unitIds,
  548. labelType: "库存成品标签"
  549. }
  550. console.log('打印请求:', printRequest);
  551. const { data } = await printLabelCommon(printRequest)
  552. if (data.code === 200 || data.code === 0) {
  553. this.$message.success(`打印任务已发送!共${unitIds.length}个标签`)
  554. } else {
  555. this.$message.error(data.msg || '打印失败')
  556. }
  557. } catch (error) {
  558. console.error('服务器打印失败:', error)
  559. this.$message.error(`打印失败: ${error.message || error}`)
  560. }
  561. },
  562. /**
  563. * 从物料编码中解析高度
  564. * 如果物料编码格式是 70004479-0030则高度为30
  565. * 如果物料编码格式是 70004479则高度为空
  566. */
  567. parseHeightFromPartNo(partNo) {
  568. if (!partNo) return '';
  569. // 检查是否包含横杠
  570. const parts = partNo.split('-');
  571. if (parts.length >= 2) {
  572. // 取横杠后面的数字部分
  573. const heightStr = parts[1];
  574. // 转换为数字,去掉前导0
  575. const height = parseInt(heightStr, 10);
  576. return isNaN(height) ? '' : height;
  577. }
  578. return '';
  579. }
  580. },
  581. mounted() {
  582. this.$nextTick(() => this.$refs.scanCodeRef.focus());
  583. },
  584. };
  585. </script>
  586. <style scoped>
  587. .mt10 {
  588. margin-top: 10px;
  589. }
  590. .scan-box input {
  591. width: 100%;
  592. padding: 12px;
  593. font-size: 16px;
  594. }
  595. .item-list {
  596. flex: 1;
  597. overflow-y: auto;
  598. margin: 10px 0;
  599. border: 1px solid rgba(200, 200, 200, 0.8);
  600. }
  601. .item-list span {
  602. color: #000;
  603. font-size: 15px;
  604. }
  605. .bottom-line-row {
  606. border-bottom: 1px solid rgba(200, 200, 200, 0.8);
  607. }
  608. .recvButton {
  609. font-size: 16px;
  610. border-radius: 3px;
  611. color: #17b3a3;
  612. }
  613. .item-list .el-row {
  614. cursor: pointer;
  615. transition: background 0.3s;
  616. }
  617. .item-list .el-row:hover {
  618. background: #f5f7fa;
  619. }
  620. .disabled-button {
  621. color: #ccc !important;
  622. cursor: not-allowed !important;
  623. }
  624. .form-section >>> .el-col {
  625. margin-bottom: 2px;
  626. }
  627. .status-bar {
  628. display: flex;
  629. justify-content: space-between;
  630. align-items: center;
  631. background: #17b3a3;
  632. color: white;
  633. }
  634. /* 自定义loading样式 */
  635. .pda-container >>> .el-loading-mask {
  636. background-color: rgba(255, 255, 255, 0.3) !important;
  637. }
  638. .pda-container >>> .el-loading-spinner {
  639. margin-top: -25px;
  640. }
  641. .pda-container >>> .el-loading-spinner .circular {
  642. width: 35px;
  643. height: 35px;
  644. }
  645. .pda-container >>> .el-loading-text {
  646. color: #17b3a3 !important;
  647. font-size: 14px;
  648. font-weight: 500;
  649. margin-top: 10px;
  650. }
  651. </style>