<template>
|
<Card>
|
<el-form ref="form" :model="form" :rules="rules" inline label-position="top">
|
<div class="header-title" style="margin-bottom: 38px">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>所属实验调度</div>
|
</div>
|
<el-button type="primary" class="el-icon-plus" @click="handleAddTask" v-if="!isView">选择实验调度</el-button>
|
</div>
|
|
<Table :data="taskTableData" :total="0" :height="null" class="rwuTable">
|
<el-table-column prop="projectName" label="所属项目课题方案" width="200"></el-table-column>
|
<el-table-column prop="experimentCode" label="实验编号"></el-table-column>
|
<el-table-column prop="experimentName" label="实验名称"></el-table-column>
|
<el-table-column prop="experimentDate" label="通知时间"></el-table-column>
|
<el-table-column prop="experimentStartTime" label="实验开始时间"></el-table-column>
|
<el-table-column prop="experimentEndTime" label="实验结束时间"></el-table-column>
|
<el-table-column prop="participantsName" label="参加人员"></el-table-column>
|
<el-table-column prop="status" label="状态">
|
<template slot-scope="scope">
|
<el-tag :type="getStatusType(scope.row.status)">
|
{{ getStatusText(scope.row.status) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
</Table>
|
|
<div class="header-title">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>一 、实验结果</div>
|
</div>
|
</div>
|
<Table :data="experimentResultData" :total="0" :height="null" class="rwuTable">
|
<el-table-column prop="projectName" label="项目课题方案名称"></el-table-column>
|
<el-table-column prop="experimentCode" label="实验编号"></el-table-column>
|
<el-table-column prop="experimentName" label="实验名称"></el-table-column>
|
<el-table-column prop="experimentDate" label="实验日期"></el-table-column>
|
<el-table-column prop="schemePersonName" label="实验员"></el-table-column>
|
<el-table-column prop="createTime" label="创建日期"></el-table-column>
|
<el-table-column prop="createBy" label="创建人"></el-table-column>
|
<el-table-column prop="status" label="当前状态">
|
<template slot-scope="scope">
|
<el-tag :type="getResultStatusType(scope.row.status)">
|
{{ getResultStatusText(scope.row.status) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" min-width="100" fixed="right">
|
<template slot-scope="scope">
|
<el-button type="text" @click="handleViewDetail(scope.row)">详情</el-button>
|
</template>
|
</el-table-column>
|
</Table>
|
|
<div class="header-title">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>二 、检验结果</div>
|
</div>
|
</div>
|
<Table :data="inspectionResultData" :total="0" :height="null" class="rwuTable">
|
<el-table-column prop="projectName" label="所属课题方案"></el-table-column>
|
<el-table-column prop="experimentCode" label="所属实验编号"></el-table-column>
|
<el-table-column prop="experimentName" label="实验名称"></el-table-column>
|
<el-table-column prop="createTime" label="创建时间"></el-table-column>
|
<el-table-column prop="createBy" label="创建人"></el-table-column>
|
<el-table-column prop="status" label="状态">
|
<template slot-scope="scope">
|
<el-tag :type="getCheckoutStatusType(scope.row.status)">
|
{{ getCheckoutStatusText(scope.row.status) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" min-width="100" fixed="right">
|
<template slot-scope="scope">
|
<el-button type="text" @click="handleViewInspectionDetail(scope.row)">详情</el-button>
|
</template>
|
</el-table-column>
|
</Table>
|
|
<div class="header-title">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>三 、实验数据分析及结论</div>
|
</div>
|
</div>
|
|
<div class="content-box">
|
<AiEditor ref="analysisEditor" :readOnly="isView" :value="form.experimentResult" height="200px"
|
placeholder="暂无实验数据分析及结论..." />
|
</div>
|
|
<div class="header-title">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>四 、化验师工作评定</div>
|
</div>
|
</div>
|
|
<div class="evaluate-card">
|
<div class="evaluate-card-people">
|
<div v-for="technician in labTechnicians" :key="technician.id" class="evaluate-card-people-item"
|
:class="{ 'active-people': selectedLabTechnician?.id == technician.id }"
|
@click="handleSelectLabTechnician(technician)">
|
{{ technician.nickName }}
|
</div>
|
</div>
|
<div class="evaluate-card-cotent">
|
<template v-if="selectedLabTechnician">
|
<template v-if="selectedLabTechnician.data">
|
<div class="evaluate-table-wrapper" @click="handleEvaluate('labTechnician')">
|
<EvaluateTable class="evaluate-table" :isReadonly="true" :type="1"
|
:viewJson="selectedLabTechnician.data.resultEvaluateJson" />
|
</div>
|
</template>
|
<template v-else>
|
<div class="no-data">暂未评定</div>
|
<div class="to-evaluate" @click="handleEvaluate('labTechnician')">去评价</div>
|
</template>
|
</template>
|
</div>
|
</div>
|
|
<div class="header-title">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>五 、实验员工作评定</div>
|
</div>
|
</div>
|
|
<div class="evaluate-card">
|
<div class="evaluate-card-people">
|
<div v-for="experimenter in experimenters" :key="experimenter.id" class="evaluate-card-people-item"
|
:class="{ 'active-people': selectedExperimenter?.id == experimenter.id }"
|
@click="handleSelectExperimenter(experimenter)">
|
{{ experimenter.nickName }}
|
</div>
|
</div>
|
<div class="evaluate-card-cotent">
|
<template v-if="selectedExperimenter">
|
<template v-if="selectedExperimenter.data">
|
<div class="evaluate-table-wrapper" @click="handleEvaluate('experimenter')">
|
<EvaluateTable ref="experimenterEvaluateTable" class="evaluate-table" :isReadonly="true"
|
:viewJson="selectedExperimenter.data.resultEvaluateJson" />
|
</div>
|
</template>
|
<template v-else>
|
<div class="no-data">暂未评定</div>
|
<div class="to-evaluate" @click="handleEvaluate('experimenter')">去评价</div>
|
</template>
|
</template>
|
</div>
|
</div>
|
<div class="header-title" v-if="isView">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>六 、工艺工程师工作评定</div>
|
</div>
|
</div>
|
|
<div class="evaluate-card" v-if="isView">
|
<div class="evaluate-card-people">
|
<div v-for="engineer in processEngineers" :key="engineer.id" class="evaluate-card-people-item"
|
:class="{ 'active-people': selectedProcessEngineer?.id == engineer.id }"
|
@click="handleSelectProcessEngineer(engineer)">
|
{{ engineer.nickName }}
|
</div>
|
</div>
|
<div class="evaluate-card-cotent">
|
<template v-if="selectedProcessEngineer">
|
<template v-if="selectedProcessEngineer.data">
|
<div class="evaluate-table-wrapper" @click="handleEvaluate('processEngineer')">
|
<EvaluateTable class="evaluate-table" :isReadonly="true" :type="1"
|
:viewJson="selectedProcessEngineer.data.resultEvaluateJson" />
|
</div>
|
</template>
|
<template v-else>
|
<div class="no-data">暂未评定</div>
|
<!-- <div v-if="canEvaluate" class="to-evaluate" >去评价</div> -->
|
</template>
|
</template>
|
</div>
|
</div>
|
<div class="add-project-footer" v-if="!isView">
|
<el-button type="primary" class="save-btn" @click="handleSubmit(1)">提交</el-button>
|
<el-button @click="handleSubmit(-1)">存草稿</el-button>
|
</div>
|
<div class="add-project-footer" v-if="isView && form.status == 2">
|
<el-button type="primary" class="save-btn" @click="handleEvaluate('processEngineer')">工艺工程师评定</el-button>
|
<!-- <el-button @click="handleSubmit(-1)">存草稿</el-button> -->
|
</div>
|
</el-form>
|
<!-- 选择实验调度弹窗 -->
|
<experimental-scheduling :show="schedulingDialogVisible" @close="handleSchedulingClose"
|
@submit="handleSchedulingSelect" />
|
<!-- 评价弹窗 -->
|
<evaluation-dialog :modelValue="evaluationDialogVisible" :type="currentEvaluationType"
|
:viewJson="currentEvaluationData ? currentEvaluationData : ''" @update:modelValue="updateEvaluationDialogVisible"
|
@submit="handleEvaluationSubmit" />
|
<!-- 检验结果详情弹窗 -->
|
<checkout-result :visible="checkoutResultVisible" :data="currentCheckoutResult"
|
@close="handleCheckoutResultClose" />
|
<!-- 新增组件弹窗 -->
|
<!-- <add-component-dialog
|
v-if="showNewDialog"
|
:visible.sync="showNewDialog"
|
@confirm="handleAddComponent"
|
/> -->
|
<!-- 实验结果详情 -->
|
<ExperimentResultDialog :visible.sync="experimentResultDialogVisible" :type="'view'"
|
:data="currentExperimentResult" />
|
</Card>
|
</template>
|
|
<script>
|
import ExperimentResultDialog from "./components/experimentResultDialog.vue";
|
import ExperimentalScheduling from "../sampleManage/components/experimental-scheduling.vue";
|
import moment from "moment";
|
import EvaluationDialog from "./components/evaluation-dialog.vue";
|
import CheckoutResult from "./components/checkout-result.vue";
|
import AiEditor from "@/components/AiEditor";
|
// import AddComponentDialog from "@/components/AddComponentDialog";
|
import { getOtherInfoByDispatchId, add, update, getDetail,evaluateProcess } from './service'
|
|
export default {
|
name: "AddProject",
|
components: {
|
ExperimentalScheduling,
|
EvaluationDialog,
|
CheckoutResult,
|
ExperimentResultDialog,
|
AiEditor
|
// AddComponentDialog
|
},
|
data() {
|
return {
|
showNewDialog: true,
|
dialogVisible: false,
|
schedulingDialogVisible: false,
|
experimentResultDialogVisible: false,
|
currentExperimentResult: null,
|
isEdit: false,
|
currentEditIndex: -1,
|
selectedScheduling: null,
|
form: {
|
dispatchId: "",
|
experimentResult: "",
|
id: "",
|
resultWorkEvaluates: [],
|
status: -1
|
},
|
rules: {
|
dispatchId: [
|
{ required: true, message: "请选择所属实验调度", trigger: "change" }
|
],
|
},
|
taskTableData: [],
|
experimentResultData: [],
|
inspectionResultData: [],
|
// 化验师数据
|
labTechnicians: [],
|
selectedLabTechnician: null,
|
|
// 实验员数据
|
experimenters: [],
|
selectedExperimenter: null,
|
|
// 工艺工程师数据
|
processEngineers: [],
|
selectedProcessEngineer: null,
|
|
// 弹窗控制
|
evaluationDialogVisible: false,
|
currentEvaluationType: '',
|
checkoutResultVisible: false,
|
currentCheckoutResult: null,
|
statusTypeMap: {
|
"-1": "info",
|
"1": "warning",
|
"2": "success",
|
"3": "info"
|
},
|
statusTextMap: {
|
"-1": "草稿箱",
|
"1": "待确认",
|
"2": "已确认",
|
"3": "已封存"
|
},
|
currentEvaluationData: null, // 添加当前评价数据
|
};
|
},
|
watch: {
|
selectedLabTechnician: {
|
handler(newVal) {
|
},
|
},
|
},
|
created() {
|
// 默认选中第一个人员
|
this.selectedLabTechnician = this.labTechnicians[0];
|
this.selectedExperimenter = this.experimenters[0];
|
this.selectedProcessEngineer = this.processEngineers[0];
|
|
// 如果是编辑模式,获取详情数据
|
const id = this.$route.query.id;
|
if (id) {
|
this.getDetailData(id);
|
}
|
},
|
methods: {
|
handleAddTask() {
|
this.isEdit = false;
|
this.currentEditIndex = -1;
|
this.schedulingDialogVisible = true;
|
},
|
handleEditTask(row) {
|
this.isEdit = true;
|
this.currentEditIndex = this.taskTableData.findIndex(
|
(item) => item == row
|
);
|
|
const editData = {
|
sampleCode: row.sampleCode,
|
testData: row.testData,
|
testTypes: [],
|
photos: [],
|
spectrums: [],
|
};
|
|
if (row.photos && row.photos.length > 0) {
|
editData.testTypes.push("photo");
|
editData.photos = row.photos.map((photo) => ({
|
name: photo.name,
|
url: photo.url,
|
raw: null,
|
}));
|
}
|
if (row.spectrums && row.spectrums.length > 0) {
|
editData.testTypes.push("spectrum");
|
editData.spectrums = row.spectrums.map((spectrum) => ({
|
name: spectrum.name,
|
url: spectrum.url,
|
raw: null,
|
}));
|
}
|
|
this.$nextTick(() => {
|
this.dialogVisible = true;
|
this.$refs.addDialog.setFormData(editData);
|
});
|
},
|
handleDeleteTask(row) {
|
this.$confirm("确认删除该检测数据吗?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
const index = this.taskTableData.findIndex((item) => item == row);
|
if (index > -1) {
|
const item = this.taskTableData[index];
|
if (item.photos) {
|
item.photos.forEach((photo) => {
|
if (photo.url.startsWith("blob:")) {
|
URL.revokeObjectURL(photo.url);
|
}
|
});
|
}
|
if (item.spectrums) {
|
item.spectrums.forEach((spectrum) => {
|
if (spectrum.url.startsWith("blob:")) {
|
URL.revokeObjectURL(spectrum.url);
|
}
|
});
|
}
|
|
this.taskTableData.splice(index, 1);
|
this.$message.success("删除成功");
|
}
|
})
|
.catch(() => { });
|
},
|
handleTaskSubmit(formData) {
|
const photos = formData.photos.map((file) => ({
|
name: file.name,
|
url: file.url || URL.createObjectURL(file.raw),
|
}));
|
|
const spectrums = formData.spectrums.map((file) => ({
|
name: file.name,
|
url: file.url || URL.createObjectURL(file.raw),
|
}));
|
|
const newData = {
|
sampleCode: formData.sampleCode,
|
testData: formData.testData,
|
testResult: "",
|
photos,
|
spectrums,
|
createTime: this.isEdit
|
? this.taskTableData[this.currentEditIndex].createTime
|
: moment().format("YYYY-MM-DD HH:mm:ss"),
|
};
|
|
if (this.isEdit && this.currentEditIndex > -1) {
|
const oldData = this.taskTableData[this.currentEditIndex];
|
if (oldData.photos) {
|
oldData.photos.forEach((photo) => {
|
if (
|
photo.url.startsWith("blob:") &&
|
!photos.find((p) => p.url == photo.url)
|
) {
|
URL.revokeObjectURL(photo.url);
|
}
|
});
|
}
|
if (oldData.spectrums) {
|
oldData.spectrums.forEach((spectrum) => {
|
if (
|
spectrum.url.startsWith("blob:") &&
|
!spectrums.find((s) => s.url == spectrum.url)
|
) {
|
URL.revokeObjectURL(spectrum.url);
|
}
|
});
|
}
|
|
this.taskTableData.splice(this.currentEditIndex, 1, newData);
|
this.$message.success("更新成功");
|
} else {
|
this.taskTableData.push(newData);
|
this.$message.success("添加成功");
|
}
|
|
this.dialogVisible = false;
|
this.isEdit = false;
|
this.currentEditIndex = -1;
|
},
|
getPhotoUrls(photos) {
|
return photos.map((photo) => photo.url);
|
},
|
handleViewDetail(row) {
|
// 获取实验结果详情
|
this.currentExperimentResult = row;
|
this.experimentResultDialogVisible = true;
|
},
|
handleViewInspectionDetail(row) {
|
// 获取检验结果详情
|
this.currentCheckoutResult = row;
|
this.checkoutResultVisible = true;
|
},
|
handleCheckoutResultClose() {
|
this.currentCheckoutResult = null
|
this.checkoutResultVisible = false;
|
},
|
// 选择化验师
|
handleSelectLabTechnician(technician) {
|
this.selectedLabTechnician = technician;
|
},
|
// 选择实验员
|
handleSelectExperimenter(experimenter) {
|
this.selectedExperimenter = experimenter;
|
},
|
// 选择工艺工程师
|
handleSelectProcessEngineer(engineer) {
|
this.selectedProcessEngineer = engineer;
|
},
|
// 去评价
|
handleEvaluate(type) {
|
if(this.$route.query.type == 'view' && type !='processEngineer'){
|
this.$message.warning('当前为查看模式,无法进行评价');
|
return;
|
}
|
this.currentEvaluationType = type;
|
// 根据类型获取当前选中人员的评定数据
|
if (type == 'labTechnician' && this.selectedLabTechnician) {
|
this.currentEvaluationData = this.selectedLabTechnician.data?.resultEvaluateJson;
|
} else if (type == 'experimenter' && this.selectedExperimenter) {
|
this.currentEvaluationData = this.selectedExperimenter.data?.resultEvaluateJson;
|
} else if (type == 'processEngineer' && this.selectedProcessEngineer) {
|
this.currentEvaluationData = this.selectedProcessEngineer.data?.resultEvaluateJson;
|
}
|
this.evaluationDialogVisible = true;
|
},
|
// 处理评价提交
|
handleEvaluationSubmit(evaluationData) {
|
const { type, activeIndex } = evaluationData;
|
|
// 将评分数据转换为后端需要的格式
|
const evaluateData = {
|
evaluateType: type == 'labTechnician' ? 2 : type == 'experimenter' ? 3 : 1, // 1=工艺工程师 2=化验师 3=实验员
|
evaluateOne: this.getEvaluateValue(activeIndex[0].score),
|
evaluateTwo: this.getEvaluateValue(activeIndex[1].score),
|
evaluateThree: this.getEvaluateValue(activeIndex[2].score),
|
evaluateFour: this.getEvaluateValue(activeIndex[3].score),
|
evaluateFive: this.getEvaluateValue(activeIndex[4].score),
|
evaluateSix: this.getEvaluateValue(activeIndex[5].score),
|
evaluateTime: moment().format('YYYY-MM-DD HH:mm:ss'),
|
resultEvaluateJson: JSON.stringify(activeIndex),
|
dispatchId: this.selectedScheduling?.id,
|
userId: type == 'labTechnician' ? this.selectedLabTechnician.id :
|
type == 'experimenter' ? this.selectedExperimenter.id :
|
this.selectedProcessEngineer.id,
|
// teamId: this.selectedScheduling?.teamId,
|
status: 1
|
};
|
|
if (type == 'labTechnician') {
|
// 更新化验师列表中的数据
|
const labTechnician = this.labTechnicians.find(item => item.id == this.selectedLabTechnician.id);
|
if (labTechnician) {
|
labTechnician.data = { ...labTechnician.data, ...evaluateData };
|
this.selectedLabTechnician = { ...labTechnician };
|
}
|
} else if (type == 'experimenter') {
|
// 更新实验员列表中的数据
|
const experimenter = this.experimenters.find(item => item.id == this.selectedExperimenter.id);
|
if (experimenter) {
|
experimenter.data = { ...experimenter.data, ...evaluateData };
|
this.selectedExperimenter = { ...experimenter };
|
}
|
} else if (type == 'processEngineer') {
|
// 工艺工程师评定直接调用接口
|
console.log('11111111111111111111',{
|
...evaluateData,
|
resultReportId: this.form.id // 添加实验报告ID
|
})
|
evaluateProcess({
|
...evaluateData,
|
resultReportId: this.form.id // 添加实验报告ID
|
}).then(res => {
|
if (res.code == 200) {
|
this.$message.success('评定成功');
|
// 重新获取详情数据
|
this.getDetailData(this.form.id);
|
} else {
|
this.$message.error(res.msg || '评定失败');
|
}
|
}).catch(err => {
|
this.$message.error('评定失败');
|
});
|
}
|
this.evaluationDialogVisible = false;
|
this.currentEvaluationData = null;
|
},
|
// 将分数转换为评定值
|
getEvaluateValue(score) {
|
// 2分 = 良好(1), 1分 = 正确(2), 0分 = 失误(3)
|
const scoreMap = {
|
2: 1, // 良好
|
1: 2, // 正确
|
0: 3 // 失误
|
};
|
return scoreMap[score] || 3; // 默认返回失误
|
},
|
// 收集评分数据
|
collectEvaluateData() {
|
const evaluates = [];
|
|
// 收集化验师评分
|
this.labTechnicians.forEach(tech => {
|
if (tech.data) {
|
evaluates.push({
|
...tech.data,
|
dispatchId: this.selectedScheduling?.id,
|
userId: tech.id,
|
teamId: this.selectedScheduling?.teamId,
|
status: -1,
|
id: tech.data.id || undefined
|
});
|
}
|
});
|
|
// 收集实验员评分
|
this.experimenters.forEach(exp => {
|
if (exp.data) {
|
evaluates.push({
|
...exp.data,
|
dispatchId: this.selectedScheduling?.id,
|
userId: exp.id,
|
teamId: this.selectedScheduling?.teamId,
|
status: -1,
|
id: exp.data.id || undefined
|
});
|
}
|
});
|
|
// 收集工艺工程师评分
|
this.processEngineers.forEach(eng => {
|
if (eng.data) {
|
evaluates.push({
|
...eng.data,
|
dispatchId: this.selectedScheduling?.id,
|
userId: eng.id,
|
teamId: this.selectedScheduling?.teamId,
|
status: -1,
|
id: eng.data.id || undefined
|
});
|
}
|
});
|
|
return evaluates;
|
},
|
// 更新弹窗显示状态
|
updateEvaluationDialogVisible(value) {
|
this.evaluationDialogVisible = value;
|
if (!value) {
|
this.currentEvaluationData = null; // 关闭弹窗时清空数据
|
}
|
},
|
handleSchedulingClose() {
|
this.schedulingDialogVisible = false;
|
},
|
handleSchedulingSelect(selectedData) {
|
if (selectedData && selectedData.length > 0) {
|
this.selectedScheduling = selectedData[0];
|
this.taskTableData = [selectedData[0]]; // 更新表格数据
|
|
// 调用getOtherInfoByDispatchId接口
|
this.getInfomationByDispatchId(selectedData[0]);
|
|
this.$message.success("选择成功");
|
}
|
},
|
getInfomationByDispatchId(selectedData) {
|
getOtherInfoByDispatchId({ dispatchId: selectedData.id }).then(res => {
|
// 直接使用接口返回的字段,因为字段名完全一致
|
let list = res.inspectionReports.map(item => ({
|
...item,
|
experimentName: selectedData.experimentName,
|
projectName: selectedData.projectName,
|
experimentCode: selectedData.experimentCode
|
})) || []
|
this.experimentResultData = res.experimentSchemeVOS || [];
|
this.inspectionResultData = list;
|
|
if (!this.$route.query.id) {
|
// 处理实验人员数据
|
const participants = res.experimentDispatchParticipants || [];
|
// 获取工艺工程师列表
|
this.processEngineers = participants
|
.filter(p => p.roleType == 3) // 3=工艺工程师
|
.map(p => ({
|
id: p.userId,
|
nickName: p.nickName || '工艺工程师',
|
role: '工艺工程师',
|
data: null
|
}));
|
|
// 获取化验师列表
|
this.labTechnicians = participants
|
.filter(p => p.roleType == 4) // 4=化验师
|
.map(p => ({
|
id: p.userId,
|
nickName: p.nickName || '化验师',
|
role: '化验师',
|
data: null
|
}));
|
|
// 获取实验员列表
|
this.experimenters = participants
|
.filter(p => p.roleType == 5) // 5=实验员
|
.map(p => ({
|
id: p.userId,
|
nickName: p.nickName || '实验员',
|
role: '实验员',
|
data: null
|
}));
|
|
// 处理评定数据
|
const evaluates = res.resultWorkEvaluates || [];
|
evaluates.forEach(evaluate => {
|
// 根据评定类型和用户ID匹配对应的评定数据
|
if (evaluate.evaluateType == 1) { // 1=工艺工程师
|
const engineer = this.processEngineers.find(e => e.id == evaluate.userId);
|
if (engineer) {
|
engineer.data = {
|
id: evaluate.id, // 保存id
|
evaluateOne: evaluate.evaluateOne,
|
evaluateTwo: evaluate.evaluateTwo,
|
evaluateThree: evaluate.evaluateThree,
|
evaluateFour: evaluate.evaluateFour,
|
evaluateFive: evaluate.evaluateFive,
|
evaluateSix: evaluate.evaluateSix,
|
evaluateTime: evaluate.evaluateTime,
|
resultEvaluateJson: evaluate.resultEvaluateJson
|
};
|
}
|
} else if (evaluate.evaluateType == 2) { // 2=化验师
|
const technician = this.labTechnicians.find(t => t.id == evaluate.userId);
|
if (technician) {
|
technician.data = {
|
id: evaluate.id, // 保存id
|
evaluateOne: evaluate.evaluateOne,
|
evaluateTwo: evaluate.evaluateTwo,
|
evaluateThree: evaluate.evaluateThree,
|
evaluateFour: evaluate.evaluateFour,
|
evaluateFive: evaluate.evaluateFive,
|
evaluateSix: evaluate.evaluateSix,
|
evaluateTime: evaluate.evaluateTime,
|
resultEvaluateJson: evaluate.resultEvaluateJson
|
};
|
}
|
} else if (evaluate.evaluateType == 3) { // 3=实验员
|
const experimenter = this.experimenters.find(e => e.id == evaluate.userId);
|
if (experimenter) {
|
experimenter.data = {
|
id: evaluate.id, // 保存id
|
evaluateOne: evaluate.evaluateOne,
|
evaluateTwo: evaluate.evaluateTwo,
|
evaluateThree: evaluate.evaluateThree,
|
evaluateFour: evaluate.evaluateFour,
|
evaluateFive: evaluate.evaluateFive,
|
evaluateSix: evaluate.evaluateSix,
|
evaluateTime: evaluate.evaluateTime,
|
resultEvaluateJson: evaluate.resultEvaluateJson
|
};
|
}
|
}
|
});
|
|
// 默认选中第一个人员
|
if (this.processEngineers.length > 0) {
|
this.selectedProcessEngineer = this.processEngineers[0];
|
}
|
if (this.labTechnicians.length > 0) {
|
this.selectedLabTechnician = this.labTechnicians[0];
|
}
|
if (this.experimenters.length > 0) {
|
this.selectedExperimenter = this.experimenters[0];
|
}
|
}
|
|
}).catch(err => {
|
this.$message.error('获取其他信息失败');
|
});
|
},
|
getStatusType(status) {
|
return this.statusTypeMap[status] || 'info';
|
},
|
getStatusText(status) {
|
return this.statusTextMap[status] || '未知状态';
|
},
|
getResultStatusType(status) {
|
const statusMap = {
|
'-1': "info",
|
'1': "warning",
|
'2': "warning",
|
'3': "success",
|
'4': "danger",
|
'5': "info",
|
'6': 'success'
|
};
|
return statusMap[status] || "info";
|
},
|
getResultStatusText(status) {
|
const statusMap = {
|
'-1': "草稿",
|
'1': "已发送",
|
'2': "申请中止待审核",
|
'3': "申请中止已通过",
|
'4': "申请中止已驳回",
|
'5': "已封存",
|
'6': '实验员已提交'
|
};
|
return statusMap[status] || "未知";
|
},
|
getCheckoutStatusType(status) {
|
const statusMap = {
|
'-1': 'info',
|
'1': 'warning',
|
'2': 'success'
|
};
|
return statusMap[status] || 'info';
|
},
|
getCheckoutStatusText(status) {
|
const statusMap = {
|
'-1': '草稿箱',
|
'1': '待提交',
|
'2': '已提交'
|
};
|
return statusMap[status] || '未知';
|
},
|
// 验证评分数据
|
validateEvaluates() {
|
// 检查是否所有实验员和化验师都有评分
|
const allTechnicians = this.labTechnicians.every(tech => tech.data);
|
const allExperimenters = this.experimenters.every(exp => exp.data);
|
|
if (!allTechnicians || !allExperimenters) {
|
this.$message.error('请完成所有实验员和化验师的评分');
|
return false;
|
}
|
return true;
|
},
|
|
// 提交表单
|
async handleSubmit(status) {
|
try {
|
// 如果是提交状态,进行必填校验
|
if (status == 1) {
|
// 校验表单
|
await this.$refs.form.validate();
|
|
// 获取富文本编辑器内容
|
const experimentResult = this.$refs.analysisEditor.getContent();
|
|
// 校验实验数据分析及结论
|
if (!experimentResult || experimentResult == '<p></p>' || experimentResult.trim() == '<p></p>') {
|
this.$message.error('请输入实验数据分析及结论');
|
return;
|
}
|
|
// 校验评分数据
|
if (!this.validateEvaluates()) {
|
return;
|
}
|
}
|
|
// 收集评分数据
|
const evaluates = this.collectEvaluateData();
|
|
// 更新评分数据的状态
|
evaluates.forEach(evaluate => {
|
evaluate.status = status;
|
});
|
|
// 构建提交数据
|
const submitData = {
|
dispatchId: this.selectedScheduling?.id,
|
experimentResult: this.$refs.analysisEditor.getContent(),
|
status: status,
|
resultWorkEvaluates: evaluates
|
};
|
console.log('111111111111',submitData)
|
|
// 如果有ID,则是编辑
|
if (this.form.id) {
|
submitData.id = this.form.id;
|
await update(submitData);
|
} else {
|
await add(submitData);
|
}
|
|
this.$message.success(status == 1 ? '提交成功' : '保存草稿成功');
|
this.$router.go(-1);
|
} catch (error) {
|
this.$message.error('提交失败,请重试');
|
}
|
},
|
|
// 获取详情数据
|
async getDetailData(id) {
|
try {
|
const res = await getDetail({ id });
|
if (res) {
|
this.form = {
|
...res,
|
experimentResult: res.experimentResult || ''
|
};
|
|
// 设置选中的实验调度
|
if (res.experimentDispatchVO) {
|
this.selectedScheduling = {
|
...res.experimentDispatchVO
|
};
|
this.taskTableData = [res.experimentDispatchVO]
|
// 获取其他信息
|
await this.getInfomationByDispatchId(res.experimentDispatchVO);
|
}
|
if (res.experimentDispatchParticipants) {
|
// 处理实验人员数据
|
const participants = res.experimentDispatchParticipants || [];
|
|
// 获取工艺工程师列表
|
this.processEngineers = participants
|
.filter(p => p.roleType == 3) // 3=工艺工程师
|
.map(p => ({
|
id: p.userId,
|
nickName: p.nickName || '工艺工程师',
|
role: '工艺工程师',
|
data: null
|
}));
|
|
// 获取化验师列表
|
this.labTechnicians = participants
|
.filter(p => p.roleType == 4)
|
.map(p => ({
|
id: p.userId,
|
nickName: p.nickName || '化验师',
|
role: '化验师',
|
data: null
|
}));
|
|
// 获取实验员列表
|
this.experimenters = participants
|
.filter(p => p.roleType == 5)
|
.map(p => ({
|
id: p.userId,
|
nickName: p.nickName || '实验员',
|
role: '实验员',
|
data: null
|
}));
|
|
// 处理评分数据
|
if (res.resultWorkEvaluates) {
|
res.resultWorkEvaluates.forEach(evaluate => {
|
if (evaluate.evaluateType == 1) { // 工艺工程师
|
const engineer = this.processEngineers.find(e => e.id == evaluate.userId);
|
if (engineer) {
|
engineer.data = {
|
id: evaluate.id,
|
evaluateOne: evaluate.evaluateOne,
|
evaluateTwo: evaluate.evaluateTwo,
|
evaluateThree: evaluate.evaluateThree,
|
evaluateFour: evaluate.evaluateFour,
|
evaluateFive: evaluate.evaluateFive,
|
evaluateSix: evaluate.evaluateSix,
|
evaluateTime: evaluate.evaluateTime,
|
resultEvaluateJson: evaluate.resultEvaluateJson
|
};
|
}
|
} else if (evaluate.evaluateType == 2) { // 化验师
|
const technician = this.labTechnicians.find(t => t.id == evaluate.userId);
|
if (technician) {
|
technician.data = {
|
id: evaluate.id,
|
evaluateOne: evaluate.evaluateOne,
|
evaluateTwo: evaluate.evaluateTwo,
|
evaluateThree: evaluate.evaluateThree,
|
evaluateFour: evaluate.evaluateFour,
|
evaluateFive: evaluate.evaluateFive,
|
evaluateSix: evaluate.evaluateSix,
|
evaluateTime: evaluate.evaluateTime,
|
resultEvaluateJson: evaluate.resultEvaluateJson
|
};
|
}
|
} else if (evaluate.evaluateType == 3) { // 实验员
|
const experimenter = this.experimenters.find(e => e.id == evaluate.userId);
|
if (experimenter) {
|
experimenter.data = {
|
id: evaluate.id,
|
evaluateOne: evaluate.evaluateOne,
|
evaluateTwo: evaluate.evaluateTwo,
|
evaluateThree: evaluate.evaluateThree,
|
evaluateFour: evaluate.evaluateFour,
|
evaluateFive: evaluate.evaluateFive,
|
evaluateSix: evaluate.evaluateSix,
|
evaluateTime: evaluate.evaluateTime,
|
resultEvaluateJson: evaluate.resultEvaluateJson
|
};
|
}
|
}
|
});
|
}
|
|
// 默认选中第一个人员
|
if (this.processEngineers.length > 0) {
|
this.selectedProcessEngineer = this.processEngineers[0];
|
}
|
if (this.labTechnicians.length > 0) {
|
this.selectedLabTechnician = this.labTechnicians[0];
|
}
|
if (this.experimenters.length > 0) {
|
this.selectedExperimenter = this.experimenters[0];
|
}
|
}
|
}
|
} catch (error) {
|
this.$message.error('获取详情失败');
|
}
|
},
|
// 判断是否可以评定
|
canEvaluate() {
|
const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
|
const isAdmin = userInfo.roleType == 1; // 1是超级管理员
|
const isApprover = userInfo.roleType == 2; // 2是审批人
|
return (isAdmin || isApprover) && this.form.status == 2; // 2是待评定状态
|
}
|
},
|
computed: {
|
isView() {
|
return this.$route.query.type == 'view';
|
},
|
|
},
|
};
|
</script>
|
|
<style scoped lang="less">
|
.el-form--inline .el-form-item {
|
margin-right: 83px;
|
}
|
|
.header-title {
|
display: flex;
|
align-items: center;
|
flex-wrap: wrap;
|
gap: 13px;
|
margin-top: 38px;
|
margin-bottom: 38px;
|
|
.header-title-left {
|
display: flex;
|
align-items: center;
|
gap: 13px;
|
|
img {
|
width: 12px;
|
height: 19px;
|
}
|
|
span {
|
flex-shrink: 0;
|
font-weight: bold;
|
font-size: 18px;
|
color: #222222;
|
line-height: 27px;
|
font-family: "Source Han Sans CN Bold Bold";
|
}
|
|
div {
|
flex-shrink: 0;
|
font-weight: bold;
|
font-size: 18px;
|
color: #222222;
|
line-height: 27px;
|
font-family: "Source Han Sans CN Bold Bold";
|
|
&:before {
|
content: "*";
|
color: #f56c6c;
|
margin-right: 4px;
|
}
|
}
|
}
|
}
|
|
.rwuTable {
|
width: 85%;
|
padding-left: 40px;
|
}
|
|
.add-project-footer {
|
margin-top: 43px;
|
|
button {
|
width: 220px;
|
}
|
|
.save-btn {
|
margin-right: 20px;
|
}
|
}
|
|
.image-preview {
|
display: flex;
|
gap: 8px;
|
flex-wrap: wrap;
|
|
.preview-image {
|
width: 50px;
|
height: 50px;
|
border-radius: 4px;
|
cursor: pointer;
|
}
|
|
.image-slot {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
width: 100%;
|
height: 100%;
|
background: #f5f7fa;
|
color: #909399;
|
}
|
}
|
|
.spectrum-link {
|
display: block;
|
margin-bottom: 5px;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
}
|
|
.evaluate-card {
|
width: calc(95% - 40px);
|
background: #eff8fa;
|
padding: 30px;
|
margin-left: 29px;
|
|
.evaluate-card-people {
|
display: flex;
|
align-items: center;
|
gap: 16px;
|
|
.evaluate-card-people-item {
|
width: 125px;
|
background: #ffffff;
|
border-radius: 6px;
|
padding: 10px 5px;
|
font-family: PingFangSC, PingFang SC;
|
font-weight: 400;
|
font-size: 16px;
|
color: #333333;
|
line-height: 22px;
|
text-align: center;
|
}
|
|
.active-people {
|
background: #ebffff;
|
border-radius: 6px;
|
border: 1px solid #049c9a;
|
color: rgba(4, 156, 154, 1);
|
}
|
}
|
|
.evaluate-card-cotent {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
|
.no-data {
|
font-family: PingFangSC, PingFang SC;
|
font-weight: 500;
|
font-size: 20px;
|
color: #909399;
|
line-height: 28px;
|
margin-top: 58px;
|
margin-bottom: 30px;
|
}
|
|
.to-evaluate {
|
width: 65px;
|
background: #049c9a;
|
border-radius: 4px;
|
font-family: SourceHanSansCN, SourceHanSansCN;
|
font-weight: 400;
|
font-size: 14px;
|
color: #ffffff;
|
line-height: 32px;
|
text-align: center;
|
margin-bottom: 12px;
|
}
|
|
.evaluate-table {
|
width: 100%;
|
margin-top: 29px;
|
}
|
}
|
}
|
|
.content-box {
|
padding: 0 20px;
|
margin: 20px 0;
|
}
|
|
.evaluate-table-wrapper {
|
width: 100%;
|
cursor: pointer;
|
transition: all 0.3s;
|
|
&:hover {
|
opacity: 0.8;
|
}
|
}
|
</style>
|