From 94e0abbf193f9e1fc953716ca7868d74cd14a2cd Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 21 九月 2026 11:06:25 +0800
Subject: [PATCH] fix(inspectionTask): 修复连接实验室功能并更新字段标签
---
src/views/CNAS/process/method/standardMethod/index.vue | 338 ++++++++++++++++++++++++++++++-------------------------
1 files changed, 184 insertions(+), 154 deletions(-)
diff --git a/src/views/CNAS/process/method/standardMethod/index.vue b/src/views/CNAS/process/method/standardMethod/index.vue
index bb4602e..801222f 100644
--- a/src/views/CNAS/process/method/standardMethod/index.vue
+++ b/src/views/CNAS/process/method/standardMethod/index.vue
@@ -1,86 +1,51 @@
<style scoped>
.search {
- background-color: #fff;
- height: 80px;
+ height: 46px;
display: flex;
- align-items: center;
-}
-
-.search_thing {
- width: 350px;
- display: flex;
- align-items: center;
-}
-
-.search_label {
- width: 110px;
- font-size: 14px;
- text-align: right;
-}
-
-.search_input {
- width: calc(100% - 110px);
-}
-
-.table {
- margin-top: 10px;
- background-color: #fff;
- width: calc(100% - 40px);
- height: calc(100% - 60px - 80px - 10px - 40px);
- padding: 20px;
+ justify-content: space-between;
}
</style>
<template>
- <div class="standard_method">
+ <div class="capacity-scope">
<div class="search">
- <div class="search_thing">
- <div class="search_label">鏍囧噯缂栧彿锛�</div>
- <div class="search_input">
- <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="queryParams.code"
- @keyup.enter.native="refreshTable()"></el-input>
- </div>
+ <div>
+ <el-form :model="queryParams" ref="queryParams" size="small" :inline="true">
+ <el-form-item label="鏍囧噯缂栧彿" prop="code">
+ <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="queryParams.code"
+ @keyup.enter.native="refreshTable()"></el-input>
+ </el-form-item>
+ <el-form-item label="鏍囧噯鍚嶇О" prop="name">
+ <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="queryParams.name"
+ @keyup.enter.native="refreshTable()"></el-input>
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" size="mini" @click="refreshTable">鏌ヨ</el-button>
+ <el-button size="mini" @click="refresh">閲嶇疆</el-button>
+ </el-form-item>
+ </el-form>
</div>
- <div class="search_thing">
- <div class="search_label">鏍囧噯鍚嶇О锛�</div>
- <div class="search_input">
- <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="queryParams.name"
- @keyup.enter.native="refreshTable()"></el-input>
- </div>
- </div>
- <div class="search_thing" style="padding-left: 30px">
- <el-button size="small" @click="refresh()">閲� 缃�</el-button>
- <el-button size="small" type="primary" @click="refreshTable()">鏌� 璇�</el-button>
- </div>
- <div class="btn">
- <!-- <el-button size="small" @click="$refs.ValueTable.openUpload()" v-if="inPower">
- <i class="el-icon-upload2" style="color: #3a7bfa"></i>
- <span style="color: #3a7bfa">瀵煎叆</span></el-button> -->
+ <div>
<el-button size="small" type="primary" @click="openAdd" v-if="addPower">鏂板</el-button>
</div>
</div>
<lims-table :tableData="tableData" :column="column" :page="page" :tableLoading="tableLoading"
- :height="'calc(100vh - 250px)'" style="padding: 20px; padding-top: 0" @pagination="pagination"></lims-table>
+ :height="'calc(100vh - 250px)'" @pagination="pagination"></lims-table>
<!-- 鏂板/缂栬緫 -->
<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">
- </el-input>
- </el-form-item>
- <el-form-item label="鏍囧噯鎻忚堪EN" prop="nameEn">
- <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="addForm.nameEn">
</el-input>
</el-form-item>
<el-form-item label="澶囨敞" prop="remark">
@@ -95,15 +60,23 @@
</el-form-item>
<el-form-item label="鏄惁浜у搧鏍囧噯" prop="isProduct">
<el-select v-model="addForm.isProduct" size="small" clearable placeholder="璇烽�夋嫨" style="width: 100%">
- <el-option label="鍚�" :value="0"> </el-option>
- <el-option label="鏄�" :value="1"> </el-option>
+ <el-option label="鍚�" :value="0"></el-option>
+ <el-option label="鏄�" :value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item label="鏄惁鍚敤" prop="isUse">
<el-select v-model="addForm.isUse" size="small" clearable placeholder="璇烽�夋嫨" style="width: 100%">
- <el-option label="鍚�" :value="0"> </el-option>
- <el-option label="鏄�" :value="1"> </el-option>
+ <el-option label="鍚�" :value="0"></el-option>
+ <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">鏀寔澶氫釜闄勪欢锛屽崟涓笉瓒呰繃200MB</div>
+ </el-upload>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
@@ -111,22 +84,45 @@
<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 {
@@ -136,13 +132,11 @@
queryParams: {},
tableData: [],
column: [
- { label: "棰嗗煙", prop: "field", width: "100px" },
- { label: "鏍囧噯缂栧彿", prop: "code", width: "100px" },
- { label: "妫�楠屽璞�", prop: "structureTestObjectId", width: "140px" },
- { label: "鏍囧噯鎻忚堪", prop: "name", width: "100px" },
- { label: "鏍囧噯鎻忚堪EN", prop: "nameEn", width: "100px" },
- { label: "澶囨敞", prop: "remark" },
- { label: "璧勮川", prop: "qualificationId" },
+ {label: "琛屼笟", prop: "industryNames", width: "140px"},
+ {label: "鏍囧噯缂栧彿", prop: "code", width: "100px"},
+ {label: "鏍囧噯鎻忚堪", prop: "name", width: "100px"},
+ {label: "澶囨敞", prop: "remark"},
+ {label: "璧勮川", prop: "qualificationId"},
{
label: "鏄惁浜у搧鏍囧噯",
prop: "isProduct",
@@ -181,10 +175,10 @@
}
},
},
- { label: "鍒涘缓浜�", prop: "createUserName" },
- { label: "鍒涘缓鏃堕棿", prop: "createTime" },
- { label: "鏇存柊浜�", prop: "updateUserName" },
- { label: "鏇存柊鏃堕棿", prop: "updateTime" },
+ {label: "鍒涘缓浜�", prop: "createUserName"},
+ {label: "鍒涘缓鏃堕棿", prop: "createTime"},
+ {label: "鏇存柊浜�", prop: "updateUserName"},
+ {label: "鏇存柊鏃堕棿", prop: "updateTime"},
{
dataType: "action",
fixed: "right",
@@ -194,13 +188,17 @@
name: "缂栬緫",
type: "text",
clickFun: (row) => {
- this.title = "缂栬緫";
- this.addForm = row;
- this.addForm.structureTestObjectId = JSON.parse(
- this.addForm.structureTestObjectId
- );
- this.addDlog = true;
+ this.openEdit(row)
},
+ },
+ {
+ 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: "鍒犻櫎",
@@ -222,33 +220,32 @@
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" }],
- nameEn: [
- { required: true, message: "璇疯緭鍏ユ爣鍑嗘弿杩癊N", trigger: "blur" },
- ],
+ code: [{required: true, message: "璇疯緭鍏ユ爣鍑嗙紪鍙�", trigger: "blur"}],
+ name: [{required: true, message: "璇疯緭鍏ユ爣鍑嗘弿杩�", trigger: "blur"}],
isProduct: [
- { required: true, message: "璇烽�夋嫨鏄惁浜у搧鏍囧噯", trigger: "change" },
+ {required: true, message: "璇烽�夋嫨鏄惁浜у搧鏍囧噯", trigger: "change"},
],
isUse: [
- { required: true, message: "璇烽�夋嫨鏄惁鍚敤", trigger: "change" },
+ {required: true, message: "璇烽�夋嫨鏄惁鍚敤", trigger: "change"},
],
},
};
},
mounted() {
this.getQualificationList();
- this.selectTestObjectByName();
+ this.loadIndustryOptions();
this.getList();
},
methods: {
getList() {
this.tableLoading = true;
- let param = { ...this.queryParams, ...this.page };
+ let param = {...this.queryParams, ...this.page};
delete param.total;
- selectStandardMethodList({ ...param })
+ selectStandardMethodList({...param})
.then((res) => {
this.tableLoading = false;
if (res.code === 200) {
@@ -260,7 +257,7 @@
this.tableLoading = false;
});
},
- pagination({ page, limit }) {
+ pagination({page, limit}) {
this.page.current = page;
this.page.size = limit;
this.getList();
@@ -268,42 +265,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();
},
- // 鏉冮檺鍒嗛厤
- getPower() {
- let power = JSON.parse(sessionStorage.getItem("power"));
- let up = false;
- let del = false;
- let add = false;
- let inPower = false;
- for (var i = 0; i < power.length; i++) {
- if (power[i].menuMethod == "addStandardMethod") {
- add = true;
- }
- if (power[i].menuMethod == "delStandardMethod") {
- del = true;
- }
- if (power[i].menuMethod == "upStandardMethod") {
- up = true;
- }
- if (power[i].menuMethod == "importStandardDetails") {
- inPower = true;
- }
- }
- this.addPower = add;
- this.inPower = inPower;
- },
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.industryIds = this.addForm.industryIds || [];
},
getQualificationList() {
this.getDicts("cnas_method_qualification").then((response) => {
@@ -316,44 +296,32 @@
this.qualificationList = arr;
});
},
- selectTestObjectByName() {
- getStandardTree2().then((res) => {
- res.data.forEach((a) => {
- this.cascaderFieldData(a);
- });
- this.tandardTree = res.data;
+ loadIndustryOptions() {
+ selectIndustryOptions().then(res => {
+ this.industryOptions = 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);
- });
- }
},
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) => {
- this.addLoading = false;
- if (res.code != 200) {
- return;
- }
- this.$message.success("鎻愪氦鎴愬姛");
- this.getList();
- this.addDlog = false;
- })
+ 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;
+ this.$message.success("鎻愪氦鎴愬姛");
+ this.getList();
+ this.addDlog = false;
+ })
.catch((err) => {
this.addLoading = false;
});
@@ -377,6 +345,63 @@
}
});
},
+ 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 || [];
+ 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("鏄惁鍒犻櫎璇ユ潯鏁版嵁?", "鎻愮ず", {
confirmButtonText: "纭畾",
@@ -384,14 +409,19 @@
type: "warning",
})
.then(() => {
- delStandardMethod({ id: row.id }).then((res) => {
- if (res.code == 201) return;
+ delStandardMethod({id: row.id}).then((res) => {
this.$message.success("鍒犻櫎鎴愬姛");
this.getList();
});
})
- .catch(() => { });
+ .catch(() => {
+ });
},
},
+ computed: {
+ attachmentAction() {
+ return this.javaApi + '/standardMethod/uploadAttachment?standardMethodId=' + this.currentMethod.id;
+ }
+ },
};
</script>
--
Gitblit v1.9.3