liding
2026-09-20 2b2fa317c30ee2de7a8b6f5fc964532031adea66
src/views/CNAS/process/method/standardMethod/index.vue
@@ -35,7 +35,8 @@
    <el-dialog :title="title" :visible.sync="addDlog" width="500px">
      <el-form :model="addForm" ref="addForm" :rules="addRules" label-position="right" label-width="120px">
        <el-form-item label="行业" prop="industryIds">
          <el-select v-model="addForm.industryIds" multiple filterable clearable collapse-tags placeholder="请选择行业" style="width: 100%">
          <el-select v-model="addForm.industryIds" multiple filterable clearable collapse-tags placeholder="请选择行业"
                     style="width: 100%">
            <el-option v-for="item in industryOptions" :key="item.id" :label="item.laboratoryName" :value="item.id" />
          </el-select>
        </el-form-item>
@@ -73,7 +74,8 @@
          <el-upload ref="addUpload" action="#" :auto-upload="false" multiple :file-list="pendingFiles"
            :on-change="pendingFileChange" :on-remove="pendingFileRemove" :before-upload="beforeFileUpload"
            accept=".jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar">
            <el-button size="small" type="primary">选择附件</el-button><div slot="tip" class="el-upload__tip">支持多个附件,单个不超过10MB</div>
            <el-button size="small" type="primary">选择附件</el-button>
            <div slot="tip" class="el-upload__tip">支持多个附件,单个不超过200MB</div>
          </el-upload>
        </el-form-item>
      </el-form>
@@ -83,7 +85,8 @@
      </span>
    </el-dialog>
    <el-dialog title="标准附件" :visible.sync="attachmentDialog" width="760px">
      <el-upload v-if="currentMethod.id" :action="attachmentAction" :headers="uploadHeader" multiple :show-file-list="false"
      <el-upload v-if="currentMethod.id" :action="attachmentAction" :headers="uploadHeader" multiple
                 :show-file-list="false"
        :before-upload="beforeFileUpload" :on-success="attachmentUploadSuccess"
        accept=".jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar">
        <el-button size="small" type="primary">上传附件</el-button>
@@ -91,10 +94,18 @@
      <el-table :data="attachmentList" border size="small" style="margin-top:12px">
        <el-table-column label="文件名称" prop="fileName" min-width="280" />
        <el-table-column label="上传时间" prop="createTime" width="170" />
        <el-table-column label="操作" width="180"><template slot-scope="scope"><el-button type="text" @click="previewAttachment(scope.row)">预览</el-button><el-button type="text" @click="downloadAttachment(scope.row)">下载</el-button><el-button type="text" style="color:#f56c6c" @click="removeAttachment(scope.row)">删除</el-button></template></el-table-column>
        <el-table-column label="操作" width="180">
          <template slot-scope="scope">
            <el-button type="text" @click="previewAttachment(scope.row)">预览</el-button>
            <el-button type="text" @click="downloadAttachment(scope.row)">下载</el-button>
            <el-button type="text" style="color:#f56c6c" @click="removeAttachment(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="预览附件" :visible.sync="previewDialog" fullscreen><file-preview v-if="previewDialog" :current-file="currentAttachment" :file-url="previewUrl" /></el-dialog>
    <el-dialog title="预览附件" :visible.sync="previewDialog" fullscreen>
      <file-preview v-if="previewDialog" :current-file="currentAttachment" :file-url="previewUrl"/>
    </el-dialog>
  </div>
</template>
@@ -107,6 +118,7 @@
  addStandardMethod,
  upStandardMethod, selectIndustryOptions, selectAttachments, uploadAttachment, deleteAttachment,
} from "@/api/cnas/process/method/standardMethod";
export default {
  name: 'StandardMethod',
  components: {
@@ -284,7 +296,11 @@
        this.qualificationList = arr;
      });
    },
    loadIndustryOptions() { selectIndustryOptions().then(res => { this.industryOptions = res.data || []; }); },
    loadIndustryOptions() {
      selectIndustryOptions().then(res => {
        this.industryOptions = res.data || [];
      });
    },
    submitProduct(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
@@ -329,10 +345,24 @@
        }
      });
    },
    beforeFileUpload(file) { if (file.size > 10 * 1024 * 1024) { this.$message.error('上传文件不超过10MB'); return false; } return true; },
    pendingFileChange(file, files) { this.pendingFiles = files; },
    pendingFileRemove(file, files) { this.pendingFiles = files; },
    openAttachments(row) { this.currentMethod = row; this.attachmentDialog = true; this.loadAttachments(); },
    beforeFileUpload(file) {
      if (file.size > 200 * 1024 * 1024) {
        this.$message.error('上传文件不超过200MB');
        return false;
      }
      return true;
    },
    pendingFileChange(file, files) {
      this.pendingFiles = files;
    },
    pendingFileRemove(file, files) {
      this.pendingFiles = files;
    },
    openAttachments(row) {
      this.currentMethod = row;
      this.attachmentDialog = true;
      this.loadAttachments();
    },
    downloadAttachments(row) {
      selectAttachments({ standardMethodId: row.id }).then(res => {
        const attachments = res.data || [];
@@ -349,11 +379,28 @@
        else this.openAttachments(row);
      });
    },
    loadAttachments() { selectAttachments({ standardMethodId: this.currentMethod.id }).then(res => { this.attachmentList = res.data || []; }); },
    attachmentUploadSuccess(res) { if (res.code === 200) { this.$message.success('上传成功'); this.loadAttachments(); } },
    downloadAttachment(row) { this.$download.saveAs(row.fileUrl, row.fileName); },
    previewAttachment(row) { this.currentAttachment = row; this.previewUrl = /\.(jpg|jpeg|png|gif)$/i.test(row.fileUrl) ? this.javaApi + '/img/' + row.fileUrl : this.javaApi + '/word/' + row.fileUrl; this.previewDialog = true; },
    removeAttachment(row) { this.$confirm('是否删除该附件?', '提示', { type: 'warning' }).then(() => deleteAttachment({ id: row.id })).then(() => this.loadAttachments()); },
    loadAttachments() {
      selectAttachments({standardMethodId: this.currentMethod.id}).then(res => {
        this.attachmentList = res.data || [];
      });
    },
    attachmentUploadSuccess(res) {
      if (res.code === 200) {
        this.$message.success('上传成功');
        this.loadAttachments();
      }
    },
    downloadAttachment(row) {
      this.$download.saveAs(row.fileUrl, row.fileName);
    },
    previewAttachment(row) {
      this.currentAttachment = row;
      this.previewUrl = /\.(jpg|jpeg|png|gif)$/i.test(row.fileUrl) ? this.javaApi + '/img/' + row.fileUrl : this.javaApi + '/word/' + row.fileUrl;
      this.previewDialog = true;
    },
    removeAttachment(row) {
      this.$confirm('是否删除该附件?', '提示', {type: 'warning'}).then(() => deleteAttachment({id: row.id})).then(() => this.loadAttachments());
    },
    // 删除
    handleDelete(row) {
      this.$confirm("是否删除该条数据?", "提示", {
@@ -367,9 +414,14 @@
            this.getList();
          });
        })
        .catch(() => { });
        .catch(() => {
        });
    },
  },
  computed: { attachmentAction() { return this.javaApi + '/standardMethod/uploadAttachment?standardMethodId=' + this.currentMethod.id; } },
  computed: {
    attachmentAction() {
      return this.javaApi + '/standardMethod/uploadAttachment?standardMethodId=' + this.currentMethod.id;
    }
  },
};
</script>