From 8d24d963f8b82163685c34b816998a904f08234d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 17 九月 2026 13:39:35 +0800
Subject: [PATCH] feat: 新聚-下单到检验
---
src/views/CNAS/process/method/standardMethod/index.vue | 125 +++++++++++++++++++++++++++--------------
1 files changed, 81 insertions(+), 44 deletions(-)
diff --git a/src/views/CNAS/process/method/standardMethod/index.vue b/src/views/CNAS/process/method/standardMethod/index.vue
index 80cfd50..7998cbb 100644
--- a/src/views/CNAS/process/method/standardMethod/index.vue
+++ b/src/views/CNAS/process/method/standardMethod/index.vue
@@ -34,16 +34,14 @@
<!-- 鏂板/缂栬緫 -->
<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="field">
- <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="addForm.field"></el-input>
+ <el-form-item label="琛屼笟" prop="industryIds">
+ <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>
<el-form-item label="鏍囧噯缂栧彿" prop="code">
<el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="addForm.code">
</el-input>
- </el-form-item>
- <el-form-item label="妫�楠屽璞�" prop="structureTestObjectId">
- <el-cascader size="small" :options="tandardTree" v-model="addForm.structureTestObjectId" collapse-tags
- :props="{ multiple: true, checkStrictly: true }" clearable style="width: 100%"></el-cascader>
</el-form-item>
<el-form-item label="鏍囧噯鎻忚堪" prop="name">
<el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="addForm.name">
@@ -75,28 +73,48 @@
<el-option label="鏄�" :value="1"> </el-option>
</el-select>
</el-form-item>
+ <el-form-item v-if="title === '鏂板'" label="闄勪欢">
+ <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-upload>
+ </el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="addDlog = false">鍙� 娑�</el-button>
<el-button :loading="addLoading" type="primary" @click="submitProduct('addForm')">纭� 璁�</el-button>
</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"
+ :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>
+ </el-upload>
+ <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>
+ </el-dialog>
+ <el-dialog title="棰勮闄勪欢" :visible.sync="previewDialog" fullscreen><file-preview v-if="previewDialog" :current-file="currentAttachment" :file-url="previewUrl" /></el-dialog>
</div>
</template>
<script>
import limsTable from "@/components/Table/lims-table.vue";
+import filePreview from "@/components/Preview/filePreview.vue";
import {
selectStandardMethodList,
- getStandardTree2,
delStandardMethod,
addStandardMethod,
- upStandardMethod,
+ upStandardMethod, selectIndustryOptions, selectAttachments, uploadAttachment, deleteAttachment,
} from "@/api/cnas/process/method/standardMethod";
export default {
name: 'StandardMethod',
components: {
- limsTable,
+ limsTable, filePreview,
},
data() {
return {
@@ -106,9 +124,8 @@
queryParams: {},
tableData: [],
column: [
- { label: "棰嗗煙", prop: "field", width: "100px" },
+ { label: "琛屼笟", prop: "industryNames", width: "140px" },
{ label: "鏍囧噯缂栧彿", prop: "code", width: "100px" },
- { label: "妫�楠屽璞�", prop: "structureTestObjectId", width: "140px" },
{ label: "鏍囧噯鎻忚堪", prop: "name", width: "100px" },
{ label: "鏍囧噯鎻忚堪EN", prop: "nameEn", width: "100px" },
{ label: "澶囨敞", prop: "remark" },
@@ -168,6 +185,15 @@
},
},
{
+ name: "涓婁紶闄勪欢", type: "text", clickFun: (row) => this.openAttachments(row),
+ },
+ {
+ name: "涓嬭浇闄勪欢", type: "text", clickFun: (row) => this.downloadAttachments(row),
+ },
+ {
+ name: "棰勮闄勪欢", type: "text", clickFun: (row) => this.previewAttachments(row),
+ },
+ {
name: "鍒犻櫎",
type: "text",
clickFun: (row) => {
@@ -187,7 +213,9 @@
addDlog: false,
addLoading: false,
qualificationList: [],
- tandardTree: [],
+ industryOptions: [],
+ pendingFiles: [], attachmentDialog: false, attachmentList: [], currentMethod: {},
+ previewDialog: false, currentAttachment: {}, previewUrl: '',
addRules: {
code: [{ required: true, message: "璇疯緭鍏ユ爣鍑嗙紪鍙�", trigger: "blur" }],
name: [{ required: true, message: "璇疯緭鍏ユ爣鍑嗘弿杩�", trigger: "blur" }],
@@ -202,7 +230,7 @@
},
mounted() {
this.getQualificationList();
- this.selectTestObjectByName();
+ this.loadIndustryOptions();
this.getList();
},
methods: {
@@ -230,26 +258,25 @@
refreshTable() {
this.page.current = 1;
this.getList();
- this.selectTestObjectByName();
+ this.loadIndustryOptions();
},
refresh() {
- this.selectTestObjectByName();
+ this.loadIndustryOptions();
this.page.current = 1;
this.queryParams = {};
this.getList();
},
openAdd() {
this.title = "鏂板";
- this.addForm = {};
+ this.addForm = { industryIds: [], isProduct: 1, isUse: 1 };
+ this.pendingFiles = [];
this.addDlog = true;
},
openEdit(row) {
this.title = "缂栬緫";
this.addDlog = true;
this.addForm = this.HaveJson(row)
- this.addForm.structureTestObjectId = JSON.parse(
- this.addForm.structureTestObjectId
- );
+ this.addForm.industryIds = this.addForm.industryIds || [];
},
getQualificationList() {
this.getDicts("cnas_method_qualification").then((response) => {
@@ -262,40 +289,24 @@
this.qualificationList = arr;
});
},
- selectTestObjectByName() {
- getStandardTree2().then((res) => {
- res.data.forEach((a) => {
- this.cascaderFieldData(a);
- });
- this.tandardTree = res.data;
- });
- },
- cascaderFieldData(val) {
- if (val.children === undefined) {
- return;
- } else if (val.children.length == 0) {
- delete val.children;
- } else {
- val.children.forEach((a) => {
- this.cascaderFieldData(a);
- });
- }
- },
+ loadIndustryOptions() { selectIndustryOptions().then(res => { this.industryOptions = res.data || []; }); },
submitProduct(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.addLoading = true;
let addForm = JSON.parse(JSON.stringify(this.addForm));
- addForm.structureTestObjectId = JSON.stringify(
- addForm.structureTestObjectId
- );
if (this.title == "鏂板") {
addStandardMethod(addForm)
.then((res) => {
+ const id = res.data;
+ if (!id) throw new Error('鏂板鏍囧噯鏈繑鍥炰富閿甀D');
+ return Promise.all(this.pendingFiles.map(item => {
+ const formData = new FormData();
+ formData.append('file', item.raw);
+ return uploadAttachment(formData, id);
+ }));
+ }).then(() => {
this.addLoading = false;
- if (res.code != 200) {
- return;
- }
this.$message.success("鎻愪氦鎴愬姛");
this.getList();
this.addDlog = false;
@@ -323,6 +334,31 @@
}
});
},
+ 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(); },
+ downloadAttachments(row) {
+ selectAttachments({ standardMethodId: row.id }).then(res => {
+ const attachments = res.data || [];
+ if (!attachments.length) this.$message.warning('鏆傛棤闄勪欢');
+ else if (attachments.length === 1) this.downloadAttachment(attachments[0]);
+ else this.openAttachments(row);
+ });
+ },
+ previewAttachments(row) {
+ selectAttachments({ standardMethodId: row.id }).then(res => {
+ const attachments = res.data || [];
+ if (!attachments.length) this.$message.warning('鏆傛棤闄勪欢');
+ else if (attachments.length === 1) this.previewAttachment(attachments[0]);
+ 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()); },
// 鍒犻櫎
handleDelete(row) {
this.$confirm("鏄惁鍒犻櫎璇ユ潯鏁版嵁?", "鎻愮ず", {
@@ -339,5 +375,6 @@
.catch(() => { });
},
},
+ computed: { attachmentAction() { return this.javaApi + '/standardMethod/uploadAttachment?standardMethodId=' + this.currentMethod.id; } },
};
</script>
--
Gitblit v1.9.3