InspectFileUpload.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <el-dialog
  3. v-dialogDrag
  4. :visible.sync="visible"
  5. title="文件上传"
  6. append-to-body
  7. width="800px"
  8. @open="onOpen"
  9. >
  10. <FileUpload ref="fileUpload" />
  11. <div slot="footer">
  12. <el-button @click="close">取消</el-button>
  13. <el-button
  14. v-hasPermi="['wms:ipqc-result-file:create']"
  15. type="primary"
  16. :loading="ensureLoading"
  17. :disabled="isUploadShow !== -1"
  18. @click="handelConfirm"
  19. >确定</el-button
  20. >
  21. </div>
  22. </el-dialog>
  23. </template>
  24. <script>
  25. import FileUpload from "@/components/FileUpload/index.vue";
  26. import { createFileUpload } from "@/api/wms/quality/iqcInspectionExecute";
  27. export default {
  28. components: {
  29. FileUpload,
  30. },
  31. props: {
  32. processNo: {
  33. type: String,
  34. default: "",
  35. },
  36. },
  37. data() {
  38. return {
  39. ensureLoading: false,
  40. // iqc->在表头传
  41. wmsIncomingReceiptInspectionId: undefined,
  42. // ipqc -> 表体的每一条
  43. wmsMaterialItemResultId: undefined,
  44. // 文件列表
  45. fileList: [],
  46. form: {},
  47. isUploadShow: "",
  48. selectRows: [],
  49. rules: {},
  50. visible: false,
  51. };
  52. },
  53. methods: {
  54. // onOpen() {
  55. // this.$nextTick(() => {
  56. // this.$refs.fileUpload.isUploadShow = this.isUploadShow
  57. // this.$refs.fileUpload.fileList = this.fileList
  58. // })
  59. // },
  60. onOpen() {
  61. this.$nextTick(() => {
  62. // 如果外部已经把 fileList 传进来,就不再调接口
  63. if (this.fileList && this.fileList.length) {
  64. this.$refs.fileUpload.fileList = this.fileList;
  65. this.$refs.fileUpload.isUploadShow = this.isUploadShow;
  66. return;
  67. }
  68. // 否则保持原有逻辑(兼容旧场景)
  69. this.$refs.fileUpload.isUploadShow = this.isUploadShow;
  70. this.$refs.fileUpload.fileList = this.fileList;
  71. });
  72. },
  73. close() {
  74. this.reset();
  75. this.visible = false;
  76. },
  77. reset() {
  78. this.form = {
  79. id: undefined,
  80. inspectionItemId: undefined,
  81. inspectionNo: undefined,
  82. };
  83. this.resetForm("form");
  84. },
  85. handelConfirm() {
  86. this.fileList = this.$refs.fileUpload.fileList;
  87. const idList = this.fileList.map((item) => {
  88. const { url, id } = item;
  89. return url.fileId === undefined ? id : url.fileId;
  90. });
  91. const params = {
  92. wmsIncomingReceiptInspectionId: this.wmsIncomingReceiptInspectionId,
  93. wmsMaterialItemResultId: this.wmsMaterialItemResultId,
  94. fileIds: idList,
  95. processNo: this.processNo || null,
  96. };
  97. createFileUpload(params).then((res) => {
  98. this.$modal.msgSuccess("上传成功!");
  99. this.visible = false;
  100. this.fileList = [];
  101. this.$refs.fileUpload.fileList = res.data;
  102. this.$emit("uploadComplete");
  103. });
  104. },
  105. queryDetails() {},
  106. badCodeChange(v) {
  107. console.log(v);
  108. },
  109. },
  110. };
  111. </script>
  112. <style></style>