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.

983 lines
31 KiB

4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
1 month ago
4 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
1 month ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <div class="mod-config">
  3. <el-form :inline="true" label-position="top">
  4. <el-form-item label="入库状态">
  5. <el-select v-model="queryHeaderData.inStockFlag" placeholder="请选择" style="width: 120px;">
  6. <el-option label="全部" value=""></el-option>
  7. <el-option label="未入库" value="X"></el-option>
  8. <el-option label="已出库" value="N"></el-option>
  9. <el-option label="在库" value="Y"></el-option>
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item label="物料编号">
  13. <el-input style="width: 120px;" v-model="queryHeaderData.partNo" placeholder="请输入物料编号" @keyup.enter.native="getDataList()"></el-input>
  14. </el-form-item>
  15. <el-form-item label="批次号">
  16. <el-input style="width: 120px;" v-model="queryHeaderData.batchNo" placeholder="请输入批次号" @keyup.enter.native="getDataList()"></el-input>
  17. </el-form-item>
  18. <el-form-item label="库位">
  19. <el-input style="width: 120px;" v-model="queryHeaderData.locationId" placeholder="请输入库位" @keyup.enter.native="getDataList()"></el-input>
  20. </el-form-item>
  21. <el-form-item label="标签号">
  22. <el-input style="width: 120px;" v-model="queryHeaderData.unitId" placeholder="请输入标签号" @keyup.enter.native="getDataList()"></el-input>
  23. </el-form-item>
  24. <el-form-item label="物料描述">
  25. <el-input style="width: 120px;" v-model="queryHeaderData.partDesc" placeholder="请输入物料描述" @keyup.enter.native="getDataList()"></el-input>
  26. </el-form-item>
  27. <el-form-item style="margin-top: 20px;">
  28. <el-button @click="getDataList()" type="primary">查询</el-button>
  29. <el-button @click="resetQuery()" type="default">重置</el-button>
  30. <el-button @click="showOtherInboundDialog()" type="success">其它入库标签打印</el-button>
  31. <el-button @click="showFailedPrintTasksDialog()" type="warning">失败打印任务重试</el-button>
  32. <!-- 导出按钮 - rqrq -->
  33. <download-excel
  34. :fields="fields()"
  35. :data="exportData"
  36. type="xls"
  37. :name="exportName"
  38. :header="exportHeader"
  39. :footer="exportFooter"
  40. :fetch="createExportData"
  41. :before-generate="startDownload"
  42. :before-finish="finishDownload"
  43. worksheet="导出信息"
  44. class="el-button el-button--primary el-button--medium">
  45. {{ '导出' }}
  46. </download-excel>
  47. </el-form-item>
  48. </el-form>
  49. <el-table
  50. id="labelQueryTable"
  51. :height="height"
  52. :data="dataList"
  53. border
  54. v-loading="dataListLoading || printLoading"
  55. :element-loading-text="loadingText"
  56. style="width: 100%; margin-bottom: 15px;">
  57. <!-- 动态列配置 - rqrq -->
  58. <el-table-column
  59. v-for="(item,index) in columnList" :key="index"
  60. :sortable="item.columnSortable"
  61. :prop="item.columnProp"
  62. :header-align="item.headerAlign"
  63. :show-overflow-tooltip="item.showOverflowTooltip"
  64. :align="item.align"
  65. :fixed="item.fixed==''?false:item.fixed"
  66. :min-width="item.columnWidth"
  67. :label="item.columnLabel">
  68. <template slot-scope="scope">
  69. <span v-if="item.columnProp === 'inStockFlag'">
  70. <span v-if="scope.row.inStockFlag === 'Y'" type="success">在库</span>
  71. <span v-else-if="scope.row.inStockFlag === 'N'" type="info">已出库</span>
  72. <span v-else-if="scope.row.inStockFlag === 'X'" type="warning">未入库</span>
  73. <span v-else>{{ scope.row.inStockFlag }}</span>
  74. </span>
  75. <span v-else-if="item.columnProp === 'lastPrintDate' || item.columnProp === 'createdDate'">
  76. {{ formatDate(scope.row[item.columnProp]) }}
  77. </span>
  78. <span v-else-if="item.columnProp === 'reserveFlag'">
  79. {{ scope.row.reserveFlag === 'Y' ? '是' : '否' }}
  80. </span>
  81. <span v-else>{{ scope.row[item.columnProp] }}</span>
  82. </template>
  83. </el-table-column>
  84. <!-- 操作列 - rqrq -->
  85. <el-table-column label="操作" min-width="150" fixed="right" header-align="center" align="center">
  86. <template slot-scope="scope">
  87. <a
  88. @click="reprintLabel(scope.row)"
  89. type="primary"
  90. :loading="scope.row.printing">
  91. 重打标签
  92. </a>
  93. <a
  94. @click="deleteLabel(scope.row)"
  95. type="danger"
  96. style="color: #f56c6c;">
  97. 删除
  98. </a>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <el-pagination
  103. @size-change="sizeChangeHandle"
  104. @current-change="currentChangeHandle"
  105. :current-page="pageIndex"
  106. :page-sizes="[20, 50, 100]"
  107. :page-size="pageSize"
  108. :total="totalPage"
  109. layout="total, sizes, prev, pager, next, jumper">
  110. </el-pagination>
  111. <!-- 其它入库标签打印弹窗 -->
  112. <el-dialog
  113. title="其它入库标签打印"
  114. :visible.sync="otherInboundVisible"
  115. width="450px"
  116. :close-on-click-modal="false">
  117. <el-form :model="otherInboundForm" ref="otherInboundForm" class="other-inbound-form">
  118. <el-row :gutter="20">
  119. <el-col :span="12">
  120. <el-form-item label="物料编码" prop="partNo" class="form-item-vertical">
  121. <el-input v-model="otherInboundForm.partNo" placeholder="请输入物料编码"></el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="12">
  125. <el-form-item label="物料描述" prop="partDesc" class="form-item-vertical">
  126. <el-input v-model="otherInboundForm.partDesc" placeholder="请输入物料描述"></el-input>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. <el-row :gutter="20">
  131. <el-col :span="12">
  132. <el-form-item label="批次号" prop="batchNo" class="form-item-vertical">
  133. <el-input v-model="otherInboundForm.batchNo" placeholder="请输入批次号"></el-input>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="12">
  137. <el-form-item label="WDR" prop="wdr" class="form-item-vertical">
  138. <el-input v-model="otherInboundForm.wdr" placeholder="请输入WDR" value="*"></el-input>
  139. </el-form-item>
  140. </el-col>
  141. </el-row>
  142. <el-row :gutter="20">
  143. <el-col :span="12">
  144. <el-form-item label="数量" prop="qty" class="form-item-vertical">
  145. <el-input
  146. v-model="otherInboundForm.qty"
  147. :min="0.01"
  148. :precision="2"
  149. style="width: 100%"
  150. placeholder="请输入数量">
  151. </el-input>
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="12">
  155. <el-form-item label="包装数" prop="packageCount" class="form-item-vertical">
  156. <el-input
  157. v-model="otherInboundForm.packageCount"
  158. :min="1"
  159. style="width: 100%"
  160. placeholder="请输入包装数">
  161. </el-input>
  162. </el-form-item>
  163. </el-col>
  164. </el-row>
  165. <el-row :gutter="20">
  166. <el-col :span="12">
  167. <el-form-item label="高度(mm)" prop="height" class="form-item-vertical">
  168. <el-input v-model="otherInboundForm.height"></el-input>
  169. </el-form-item>
  170. </el-col>
  171. <el-col :span="12">
  172. <el-form-item label="失效日期" class="form-item-vertical">
  173. <el-date-picker
  174. v-model="otherInboundForm.expiredDate"
  175. type="date"
  176. placeholder="请选择失效日期"
  177. style="width: 100%"
  178. format="yyyy-MM-dd"
  179. value-format="yyyy-MM-dd">
  180. </el-date-picker>
  181. </el-form-item>
  182. </el-col>
  183. </el-row>
  184. </el-form>
  185. <div slot="footer" class="dialog-footer">
  186. <el-button @click="otherInboundVisible = false">取消</el-button>
  187. <el-button type="primary" @click="createOtherInboundHU()" :loading="otherInboundLoading">保存并打印</el-button>
  188. </div>
  189. </el-dialog>
  190. <!-- 失败打印任务重试弹窗 -->
  191. <el-dialog
  192. title="失败打印任务列表"
  193. :visible.sync="failedPrintTasksVisible"
  194. width="600px"
  195. :close-on-click-modal="false">
  196. <el-table
  197. :data="failedPrintTasksList"
  198. border
  199. stripe
  200. v-loading="failedPrintTasksLoading"
  201. max-height="400"
  202. style="width: 100%">
  203. <el-table-column
  204. prop="unitId"
  205. label="标签号"
  206. min-width="150"
  207. align="center"
  208. header-align="center">
  209. </el-table-column>
  210. <el-table-column
  211. prop="printerIp"
  212. label="打印机IP"
  213. min-width="120"
  214. align="center"
  215. header-align="center">
  216. </el-table-column>
  217. <el-table-column
  218. prop="retryCount"
  219. label="打印次数"
  220. width="80"
  221. align="center"
  222. header-align="center">
  223. </el-table-column>
  224. <el-table-column
  225. prop="createdDate"
  226. label="创建时间"
  227. min-width="150"
  228. align="center"
  229. header-align="center">
  230. <template slot-scope="scope">
  231. {{ formatDate(scope.row.createdDate) }}
  232. </template>
  233. </el-table-column>
  234. </el-table>
  235. <div slot="footer" class="dialog-footer">
  236. <el-button @click="failedPrintTasksVisible = false">取消</el-button>
  237. <el-button type="primary" @click="retryAllFailedTasks()" :loading="retryLoading">重试全部</el-button>
  238. </div>
  239. </el-dialog>
  240. </div>
  241. </template>
  242. <script>
  243. import { getHandlingUnitLabelList, reprintLabel, deleteLabel, getFailedPrintTasks, retryFailedPrintTasks } from '@/api/warehouse/labelQuery'
  244. import { searchSysLanguagePackList, saveUserFavorite, searchUserFavorite } from '@/api/sysLanguage'
  245. import { createOtherInboundHU, printLabel } from '@/api/warehouse/otherInbound'
  246. export default {
  247. data() {
  248. return {
  249. dataForm: {
  250. key: ''
  251. },
  252. dataList: [],
  253. pageIndex: 1,
  254. pageSize: 50,
  255. totalPage: 0,
  256. dataListLoading: false,
  257. printLoading: false,
  258. loadingText: '加载中...',
  259. dataListSelections: [],
  260. favorite: false,
  261. height: 500,
  262. // 表格列配置 - rqrq
  263. columnList: [
  264. {
  265. columnProp: "unitId",
  266. headerAlign: "center",
  267. align: "center",
  268. columnLabel: "标签号",
  269. columnWidth: 150,
  270. columnSortable: false,
  271. showOverflowTooltip: true,
  272. fixed: ""
  273. },
  274. {
  275. columnProp: "partNo",
  276. headerAlign: "center",
  277. align: "center",
  278. columnLabel: "物料编号",
  279. columnWidth: 120,
  280. columnSortable: false,
  281. showOverflowTooltip: true,
  282. fixed: ""
  283. },
  284. {
  285. columnProp: "partDesc",
  286. headerAlign: "center",
  287. align: "center",
  288. columnLabel: "物料描述",
  289. columnWidth: 150,
  290. columnSortable: false,
  291. showOverflowTooltip: true,
  292. fixed: ""
  293. },
  294. {
  295. columnProp: "batchNo",
  296. headerAlign: "center",
  297. align: "center",
  298. columnLabel: "批次号",
  299. columnWidth: 120,
  300. columnSortable: false,
  301. showOverflowTooltip: true,
  302. fixed: ""
  303. },
  304. {
  305. columnProp: "locationId",
  306. headerAlign: "center",
  307. align: "center",
  308. columnLabel: "库位",
  309. columnWidth: 100,
  310. columnSortable: false,
  311. showOverflowTooltip: true,
  312. fixed: ""
  313. },
  314. {
  315. columnProp: "warehouseId",
  316. headerAlign: "center",
  317. align: "center",
  318. columnLabel: "仓库",
  319. columnWidth: 100,
  320. columnSortable: false,
  321. showOverflowTooltip: true,
  322. fixed: ""
  323. },
  324. {
  325. columnProp: "wdr",
  326. headerAlign: "center",
  327. align: "center",
  328. columnLabel: "WDR",
  329. columnWidth: 100,
  330. columnSortable: false,
  331. showOverflowTooltip: true,
  332. fixed: ""
  333. },
  334. {
  335. columnProp: "engChgLevel",
  336. headerAlign: "center",
  337. align: "center",
  338. columnLabel: "engChgLevel",
  339. columnWidth: 100,
  340. columnSortable: false,
  341. showOverflowTooltip: true,
  342. fixed: ""
  343. },
  344. {
  345. columnProp: "expiredDate",
  346. headerAlign: "center",
  347. align: "center",
  348. columnLabel: "expiredDate",
  349. columnWidth: 130,
  350. columnSortable: false,
  351. showOverflowTooltip: true,
  352. fixed: ""
  353. },
  354. {
  355. columnProp: "qty",
  356. headerAlign: "center",
  357. align: "right",
  358. columnLabel: "数量",
  359. columnWidth: 80,
  360. columnSortable: false,
  361. showOverflowTooltip: true,
  362. fixed: ""
  363. },
  364. {
  365. columnProp: "inStockFlag",
  366. headerAlign: "center",
  367. align: "center",
  368. columnLabel: "入库状态",
  369. columnWidth: 80,
  370. columnSortable: false,
  371. showOverflowTooltip: true,
  372. fixed: ""
  373. },
  374. {
  375. columnProp: "printCount",
  376. headerAlign: "center",
  377. align: "center",
  378. columnLabel: "打印次数",
  379. columnWidth: 80,
  380. columnSortable: false,
  381. showOverflowTooltip: true,
  382. fixed: ""
  383. },
  384. {
  385. columnProp: "lastPrintDate",
  386. headerAlign: "center",
  387. align: "center",
  388. columnLabel: "最后打印时间",
  389. columnWidth: 150,
  390. columnSortable: false,
  391. showOverflowTooltip: true,
  392. fixed: ""
  393. },
  394. {
  395. columnProp: "createdDate",
  396. headerAlign: "center",
  397. align: "center",
  398. columnLabel: "创建时间",
  399. columnWidth: 150,
  400. columnSortable: false,
  401. showOverflowTooltip: true,
  402. fixed: ""
  403. },
  404. {
  405. columnProp: "height",
  406. headerAlign: "center",
  407. align: "right",
  408. columnLabel: "高度(mm)",
  409. columnWidth: 100,
  410. columnSortable: false,
  411. showOverflowTooltip: true,
  412. fixed: ""
  413. },
  414. {
  415. columnProp: "reserveFlag",
  416. headerAlign: "center",
  417. align: "center",
  418. columnLabel: "是否预留",
  419. columnWidth: 80,
  420. columnSortable: false,
  421. showOverflowTooltip: true,
  422. fixed: ""
  423. },
  424. {
  425. columnProp: "reserveOrderRef1",
  426. headerAlign: "center",
  427. align: "center",
  428. columnLabel: "预留单号1",
  429. columnWidth: 120,
  430. columnSortable: false,
  431. showOverflowTooltip: true,
  432. fixed: ""
  433. },
  434. {
  435. columnProp: "reserveOrderRef2",
  436. headerAlign: "center",
  437. align: "center",
  438. columnLabel: "预留单号2",
  439. columnWidth: 120,
  440. columnSortable: false,
  441. showOverflowTooltip: true,
  442. fixed: ""
  443. },
  444. {
  445. columnProp: "reserveOrderRef3",
  446. headerAlign: "center",
  447. align: "center",
  448. columnLabel: "预留单号3",
  449. columnWidth: 120,
  450. columnSortable: false,
  451. showOverflowTooltip: true,
  452. fixed: ""
  453. }
  454. ],
  455. queryHeaderData: {
  456. inStockFlag: '',
  457. partNo: '',
  458. batchNo: '',
  459. locationId: '',
  460. unitId: '',
  461. partDesc: ''
  462. },
  463. // 打印相关配置
  464. reportId: 'HU_LABEL', // 默认报表ID,可根据实际情况调整
  465. zplCode: '', // ZPL代码
  466. paperSize: 'A4',
  467. orientation: 'portrait',
  468. dpi: 203,
  469. // 其它入库标签打印相关
  470. otherInboundVisible: false,
  471. otherInboundLoading: false,
  472. otherInboundForm: {
  473. partNo: '',
  474. partDesc: '',
  475. batchNo: '',
  476. locationId: '',
  477. warehouseId: '',
  478. wdr: '*',
  479. qty: 1,
  480. umId: '个',
  481. packageCount: 1,
  482. manufactureDate: '',
  483. expiredDate: '',
  484. remark: ''
  485. },
  486. // 导出相关 - rqrq
  487. exportData: [],
  488. exportName: '标签查询' + this.dayjs().format('YYYYMMDDHHmmss'),
  489. exportHeader: ["标签查询"],
  490. exportFooter: [],
  491. otherInboundRules: {
  492. partNo: [
  493. { required: true, message: '物料编码不能为空', trigger: 'blur' }
  494. ],
  495. partDesc: [
  496. { required: true, message: '物料描述不能为空', trigger: 'blur' }
  497. ],
  498. batchNo: [
  499. { required: true, message: '批次号不能为空', trigger: 'blur' }
  500. ],
  501. locationId: [
  502. { required: true, message: '库位不能为空', trigger: 'blur' }
  503. ],
  504. warehouseId: [
  505. { required: true, message: '仓库不能为空', trigger: 'blur' }
  506. ],
  507. qty: [
  508. { required: true, message: '数量不能为空', trigger: 'blur' },
  509. { type: 'number', min: 0.01, message: '数量必须大于0', trigger: 'blur' }
  510. ],
  511. umId: [
  512. { required: true, message: '单位不能为空', trigger: 'blur' }
  513. ],
  514. packageCount: [
  515. { required: true, message: '包装数不能为空', trigger: 'blur' },
  516. { type: 'number', min: 1, message: '包装数必须大于等于1', trigger: 'blur' }
  517. ]
  518. },
  519. // 失败打印任务相关
  520. failedPrintTasksVisible: false,
  521. failedPrintTasksLoading: false,
  522. failedPrintTasksList: [],
  523. retryLoading: false
  524. }
  525. },
  526. activated() {
  527. this.getDataList()
  528. this.getHeight()
  529. },
  530. mounted() {
  531. this.getDataList()
  532. this.getHeight()
  533. },
  534. methods: {
  535. // 获取数据列表
  536. getDataList() {
  537. this.dataListLoading = true
  538. const params = {
  539. page: this.pageIndex,
  540. size: this.pageSize,
  541. site: localStorage.getItem('site'),
  542. ...this.queryHeaderData
  543. }
  544. getHandlingUnitLabelList(params).then(({ data }) => {
  545. if (data && data.code === 0) {
  546. this.dataList = data.page.list || []
  547. this.totalPage = data.page.totalCount || 0
  548. } else {
  549. this.dataList = []
  550. this.totalPage = 0
  551. this.$message.error(data.msg || '查询失败')
  552. }
  553. this.dataListLoading = false
  554. }).catch(() => {
  555. this.dataList = []
  556. this.totalPage = 0
  557. this.dataListLoading = false
  558. })
  559. },
  560. // 重置查询条件
  561. resetQuery() {
  562. this.queryHeaderData = {
  563. inStockFlag: '',
  564. partNo: '',
  565. batchNo: '',
  566. locationId: '',
  567. unitId: '',
  568. partDesc: ''
  569. }
  570. this.pageIndex = 1
  571. this.getDataList()
  572. },
  573. // 重打标签
  574. async reprintLabel(row) {
  575. try {
  576. // 设置页面打印状态
  577. this.printLoading = true
  578. this.loadingText = `${row.unitId} 打印中...`
  579. // 设置行打印状态
  580. this.$set(row, 'printing', true)
  581. let printLabelType;
  582. if (row.partNo && row.partNo.startsWith("80")) {
  583. printLabelType = '库存成品标签';
  584. } else {
  585. printLabelType = 'BIL标签';
  586. }
  587. const printRequest = {
  588. reportId: this.reportId,
  589. zplCode: this.zplCode,
  590. paperSize: this.paperSize,
  591. orientation: this.orientation,
  592. dpi: this.dpi,
  593. userId: localStorage.getItem('userName'),
  594. username: localStorage.getItem('userName'),
  595. site: localStorage.getItem('site'),
  596. unitId: row.unitId,
  597. labelType:printLabelType
  598. }
  599. const { data } = await reprintLabel(printRequest)
  600. if (data && data.code === 0) {
  601. this.$message.success('打印任务已发送成功')
  602. // 刷新当前行数据
  603. this.getDataList()
  604. } else {
  605. this.$message.error(data.msg || '打印失败')
  606. }
  607. } catch (error) {
  608. this.$message.error('打印失败:' + error.message)
  609. } finally {
  610. // 清除页面打印状态
  611. this.printLoading = false
  612. this.loadingText = '加载中...'
  613. // 清除行打印状态
  614. this.$set(row, 'printing', false)
  615. }
  616. },
  617. // 删除标签
  618. deleteLabel(row) {
  619. this.$confirm(`确定要删除单元ID为 ${row.unitId} 的标签吗?此操作不可恢复!`, '删除确认', {
  620. confirmButtonText: '确定删除',
  621. cancelButtonText: '取消',
  622. type: 'warning'
  623. }).then(async () => {
  624. try {
  625. this.dataListLoading = true
  626. const { data } = await deleteLabel({
  627. site: localStorage.getItem('site'),
  628. unitId: row.unitId
  629. })
  630. if (data && data.code === 0) {
  631. this.$message.success('删除成功')
  632. // 刷新数据列表
  633. this.getDataList()
  634. } else {
  635. this.$message.error(data.msg || '删除失败')
  636. }
  637. } catch (error) {
  638. this.$message.error('删除失败:' + error.message)
  639. } finally {
  640. this.dataListLoading = false
  641. }
  642. }).catch(() => {
  643. // 用户取消删除
  644. })
  645. },
  646. // 每页数
  647. sizeChangeHandle(val) {
  648. this.pageSize = val
  649. this.pageIndex = 1
  650. this.getDataList()
  651. },
  652. // 当前页
  653. currentChangeHandle(val) {
  654. this.pageIndex = val
  655. this.getDataList()
  656. },
  657. // 格式化日期
  658. formatDate(date) {
  659. if (!date) return ''
  660. const d = new Date(date)
  661. const year = d.getFullYear()
  662. const month = String(d.getMonth() + 1).padStart(2, '0')
  663. const day = String(d.getDate()).padStart(2, '0')
  664. const hours = String(d.getHours()).padStart(2, '0')
  665. const minutes = String(d.getMinutes()).padStart(2, '0')
  666. const seconds = String(d.getSeconds()).padStart(2, '0')
  667. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  668. },
  669. // 导出相关方法 - rqrq
  670. async createExportData() {
  671. const queryParams = {
  672. site: localStorage.getItem('site'),
  673. ...this.queryHeaderData,
  674. page: 1,
  675. size: 999999 // 设置一个很大的数字来获取全部数据 - rqrq
  676. }
  677. const {data} = await getHandlingUnitLabelList(queryParams)
  678. if (data && data.code === 0) {
  679. return (data.page.list || []).map(item => {
  680. return {
  681. ...item,
  682. inStockFlag: item.inStockFlag === 'Y' ? '在库' : item.inStockFlag === 'N' ? '已出库' : item.inStockFlag === 'X' ? '未入库' : item.inStockFlag,
  683. reserveFlag: item.reserveFlag === 'Y' ? '是' : '否',
  684. lastPrintDate: this.formatDate(item.lastPrintDate),
  685. createdDate: this.formatDate(item.createdDate)
  686. }
  687. })
  688. }
  689. return []
  690. },
  691. startDownload() {
  692. // 开始导出 - rqrq
  693. },
  694. finishDownload() {
  695. // 导出完成 - rqrq
  696. },
  697. fields() {
  698. let json = "{"
  699. this.columnList.forEach((item, index) => {
  700. if (index == this.columnList.length - 1) {
  701. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  702. } else {
  703. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  704. }
  705. })
  706. json += "}"
  707. let s = eval("(" + json + ")")
  708. return s
  709. },
  710. // 获取表格高度
  711. getHeight() {
  712. this.$nextTick(() => {
  713. this.height = window.innerHeight - 280
  714. })
  715. },
  716. // 显示其它入库标签打印对话框
  717. showOtherInboundDialog() {
  718. this.otherInboundVisible = true
  719. // 重置表单
  720. this.otherInboundForm = {
  721. partNo: '',
  722. partDesc: '',
  723. batchNo: '',
  724. locationId: '',
  725. warehouseId: '',
  726. wdr: '*',
  727. qty: 1,
  728. umId: '个',
  729. packageCount: 1,
  730. manufactureDate: '',
  731. expiredDate: '',
  732. remark: '',
  733. height: '',
  734. }
  735. this.$nextTick(() => {
  736. if (this.$refs['otherInboundForm']) {
  737. this.$refs['otherInboundForm'].clearValidate()
  738. }
  739. })
  740. },
  741. // 创建其它入库HandlingUnit
  742. async createOtherInboundHU() {
  743. try {
  744. // 基本验证
  745. if (!this.otherInboundForm.partNo) {
  746. this.$message.error('物料编码不能为空')
  747. return
  748. }
  749. if (!this.otherInboundForm.partDesc) {
  750. this.$message.error('物料描述不能为空')
  751. return
  752. }
  753. if (!this.otherInboundForm.batchNo) {
  754. this.$message.error('批次号不能为空')
  755. return
  756. }
  757. if (!this.otherInboundForm.qty || parseFloat(this.otherInboundForm.qty) <= 0) {
  758. this.$message.error('数量必须大于0')
  759. return
  760. }
  761. if (!this.otherInboundForm.packageCount || parseInt(this.otherInboundForm.packageCount) <= 0) {
  762. this.$message.error('包装数必须大于0')
  763. return
  764. }
  765. this.otherInboundLoading = true
  766. // 准备创建HU的数据
  767. const createData = {
  768. site: localStorage.getItem('site'),
  769. warehouseId: this.otherInboundForm.warehouseId,
  770. partNo: this.otherInboundForm.partNo,
  771. partDesc: this.otherInboundForm.partDesc,
  772. batchNo: this.otherInboundForm.batchNo,
  773. wdr: this.otherInboundForm.wdr,
  774. locationId: this.otherInboundForm.locationId,
  775. umid: this.otherInboundForm.umId,
  776. perPackageQty: parseFloat(this.otherInboundForm.qty),
  777. packageCount: parseInt(this.otherInboundForm.packageCount),
  778. manufactureDate: this.otherInboundForm.manufactureDate || null,
  779. expiredDate: this.otherInboundForm.expiredDate || null,
  780. remark: this.otherInboundForm.remark,
  781. height: this.otherInboundForm.height || null,
  782. }
  783. // 创建HandlingUnit
  784. const { data } = await createOtherInboundHU(createData)
  785. if (data && data.code === 0) {
  786. this.$message.success('创建HandlingUnit成功')
  787. // 确定标签类型
  788. let printLabelType
  789. if (this.otherInboundForm.partNo && this.otherInboundForm.partNo.startsWith("80")) {
  790. printLabelType = '库存成品标签'
  791. } else {
  792. printLabelType = 'BIL标签'
  793. }
  794. // 创建成功后进行打印
  795. await this.printHandlingUnits(data.unitIds, printLabelType)
  796. this.otherInboundVisible = false
  797. this.getDataList() // 刷新列表
  798. } else {
  799. this.$message.error(data.msg || '创建HandlingUnit失败')
  800. }
  801. } catch (error) {
  802. this.$message.error('创建失败:' + error.message)
  803. } finally {
  804. this.otherInboundLoading = false
  805. }
  806. },
  807. // 打印HandlingUnit标签
  808. async printHandlingUnits(unitIds, printLabelType) {
  809. if (!unitIds || unitIds.length === 0) {
  810. return
  811. }
  812. try {
  813. // 逐个打印每个HandlingUnit
  814. for (const unitId of unitIds) {
  815. await this.printViaServer(unitId, printLabelType)
  816. }
  817. this.$message.success(`成功打印 ${unitIds.length} 个HandlingUnit标签`)
  818. } catch (error) {
  819. this.$message.error('打印失败: ' + error.message)
  820. }
  821. },
  822. // 通过服务器打印
  823. async printViaServer(unitId, printLabelType) {
  824. try {
  825. const printRequest = {
  826. reportId: this.reportId,
  827. zplCode: this.zplCode,
  828. paperSize: this.paperSize,
  829. orientation: this.orientation,
  830. dpi: this.dpi,
  831. userId: localStorage.getItem('userName'),
  832. username: localStorage.getItem('userName'),
  833. site: localStorage.getItem('site'),
  834. unitId: unitId,
  835. labelType: printLabelType
  836. }
  837. const { data } = await printLabel(printRequest)
  838. if (data.code === 200) {
  839. return Promise.resolve()
  840. } else {
  841. return Promise.reject(new Error(data.msg || '打印失败'))
  842. }
  843. } catch (error) {
  844. return Promise.reject(error)
  845. }
  846. },
  847. /**
  848. * 显示失败打印任务对话框
  849. */
  850. async showFailedPrintTasksDialog() {
  851. this.failedPrintTasksVisible = true
  852. this.failedPrintTasksLoading = true
  853. try {
  854. const { data } = await getFailedPrintTasks({
  855. site: localStorage.getItem('site')
  856. })
  857. if (data && data.code === 0) {
  858. this.failedPrintTasksList = data.rows || []
  859. if (this.failedPrintTasksList.length === 0) {
  860. this.$message.warning('没有失败的打印任务')
  861. }
  862. } else {
  863. this.$message.error(data.msg || '查询失败')
  864. this.failedPrintTasksList = []
  865. }
  866. } catch (error) {
  867. this.$message.error('查询失败:' + error.message)
  868. this.failedPrintTasksList = []
  869. } finally {
  870. this.failedPrintTasksLoading = false
  871. }
  872. },
  873. /**
  874. * 重试全部失败的打印任务
  875. */
  876. async retryAllFailedTasks() {
  877. if (this.failedPrintTasksList.length === 0) {
  878. this.$message.warning('没有需要重试的任务')
  879. return
  880. }
  881. this.$confirm(`确定要重试全部 ${this.failedPrintTasksList.length} 个失败的打印任务吗?`, '重试确认', {
  882. confirmButtonText: '确定',
  883. cancelButtonText: '取消',
  884. type: 'warning'
  885. }).then(async () => {
  886. this.retryLoading = true
  887. try {
  888. const { data } = await retryFailedPrintTasks({
  889. site: localStorage.getItem('site')
  890. })
  891. if (data && data.code === 0) {
  892. this.$message.success(`成功将 ${data.count || 0} 个任务重新加入打印队列`)
  893. // 关闭对话框
  894. this.failedPrintTasksVisible = false
  895. // 清空列表
  896. this.failedPrintTasksList = []
  897. } else {
  898. this.$message.error(data.msg || '重试失败')
  899. }
  900. } catch (error) {
  901. this.$message.error('重试失败:' + error.message)
  902. } finally {
  903. this.retryLoading = false
  904. }
  905. }).catch(() => {
  906. // 用户取消重试
  907. })
  908. }
  909. }
  910. }
  911. </script>
  912. <style>
  913. .mod-config .el-form-item {
  914. margin-bottom: 15px;
  915. }
  916. .sl-svg {
  917. font-size: 20px;
  918. cursor: pointer;
  919. color: #409EFF;
  920. }
  921. /* 其它入库标签打印表单样式 */
  922. .other-inbound-form .form-item-vertical {
  923. margin-bottom: 20px;
  924. }
  925. .other-inbound-form .form-item-vertical .el-form-item__label {
  926. display: block;
  927. text-align: left;
  928. padding: 0 0 8px 0;
  929. line-height: 1.5;
  930. font-weight: 500;
  931. }
  932. .other-inbound-form .form-item-vertical .el-form-item__content {
  933. margin-left: 0 !important;
  934. }
  935. .other-inbound-form .el-row {
  936. margin-bottom: 0;
  937. }
  938. </style>