<template>
|
<Card>
|
<template style="position: relative">
|
<el-form
|
ref="form"
|
:model="form"
|
:rules="rules"
|
inline
|
label-position="top"
|
>
|
<div class="header-title" style="margin-bottom: 38px;justify-content: space-between;">
|
<div style="display: flex;align-items: center;gap: 13px;">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>所属实验调度</div>
|
</div>
|
<el-button
|
@click="showScheduling = true"
|
class="el-icon-plus"
|
type="primary"
|
>
|
选择实验调度</el-button
|
>
|
</div>
|
<el-button
|
@click="handleStopExperiment"
|
type="danger"
|
>
|
申请终止实验</el-button
|
>
|
</div>
|
<Table
|
:data="groupTableData"
|
:total="0"
|
:height="null"
|
class="groupTable"
|
>
|
<el-table-column
|
type="index"
|
label="序号"
|
width="80"
|
></el-table-column>
|
<el-table-column prop="groupName" label="组别"></el-table-column>
|
<el-table-column prop="remark" label="备注"></el-table-column>
|
<el-table-column label="操作" width="200">
|
<template slot-scope="scope">
|
<el-button type="text" @click="handleEditGroup(scope.row)"
|
>编辑</el-button
|
>
|
<el-button type="text" @click="handleDeleteGroup(scope.row)"
|
>移除</el-button
|
>
|
</template>
|
</el-table-column>
|
</Table>
|
|
<div class="header-title" style="margin-bottom: 38px">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<span>基础信息</span>
|
</div>
|
</div>
|
|
<div class="add-group">
|
<span>组别列表</span>
|
<!-- <el-button type="primary" class="el-icon-plus" @click="handleAddGroup">添加组别</el-button> -->
|
</div>
|
|
<Table
|
:data="groupTableData"
|
:total="0"
|
:height="null"
|
class="groupTable"
|
>
|
<el-table-column
|
type="index"
|
label="序号"
|
width="80"
|
></el-table-column>
|
<el-table-column prop="groupName" label="组别"></el-table-column>
|
<el-table-column prop="remark" label="备注"></el-table-column>
|
</Table>
|
|
<div style="padding-left: 25px">
|
<el-form-item prop="name" label="试验日期">
|
<el-input v-model="form.name" placeholder="请输入" />
|
</el-form-item>
|
</div>
|
|
<div class="add-group">
|
<div>*</div>
|
<span>参加人员</span>
|
<el-button type="primary" class="el-icon-plus" @click="addMember"
|
>选择参加人员</el-button
|
>
|
</div>
|
<div class="member-list">
|
<div v-for="item in 3" :key="item" class="member-list-card">
|
<div class="member-item">
|
<div class="member-title">
|
{{ ["工艺工程师", "实验员", "化验师"][item - 1] }}
|
</div>
|
<div
|
:class="item == 1 || item == 2 ? 'member-name-box' : 'flex1'"
|
>
|
<div
|
:class="
|
item == 1 || item == 2
|
? 'member-name-box'
|
: 'member-name-box-2'
|
"
|
>
|
<div
|
v-for="i in memberList(item)"
|
:key="i"
|
class="member-name"
|
>
|
张三
|
</div>
|
</div>
|
</div>
|
<div class="member-change">
|
<div class="member-change-btn">修改</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<div class="header-title" style="margin-bottom: 38px">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>一、实验目的</div>
|
</div>
|
</div>
|
<div class="content-box">
|
<AiEditor
|
ref="purposeEditor"
|
v-model="editorContents.purpose"
|
height="200px"
|
placeholder="请输入实验目的..."
|
/>
|
</div>
|
|
<div class="header-title" style="margin-bottom: 38px">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>二、工艺参数及路线</div>
|
</div>
|
</div>
|
<div class="content-box">
|
<AiEditor
|
ref="processEditor"
|
v-model="editorContents.process"
|
height="200px"
|
placeholder="请输入工艺参数及路线..."
|
/>
|
</div>
|
|
<div class="header-title" style="margin-bottom: 38px">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>三、实验材料及设备</div>
|
</div>
|
</div>
|
<DynamicComponent
|
ref="materialComponent"
|
title="实验材料"
|
@submit="handleMaterialSubmit"
|
/>
|
<DynamicComponent
|
ref="equipmentComponent"
|
title="实验所用设备"
|
@submit="handleEquipmentSubmit"
|
/>
|
|
<div class="header-title" style="margin-bottom: 38px">
|
<div class="header-title-left">
|
<img src="@/assets/public/headercard.png" />
|
<div>四、实验操作步骤记录</div>
|
</div>
|
<el-button @click="handleAddStep" class="el-icon-plus" type="primary">
|
添加步骤</el-button
|
>
|
</div>
|
|
<div class="step-list" v-for="(item, idx) in stepList" :key="idx">
|
<div class="step-list-item">
|
<div class="step-list-item-title">
|
步骤{{ idx + 1 }}:{{ item.stepName }}
|
</div>
|
<div class="step-list-item-control">
|
<div class="controlBtn edit" @click="handleEditStep(idx)">
|
<img
|
src="@/assets/public/edit.png"
|
alt="编辑"
|
class="edit-icon"
|
/>
|
编辑
|
</div>
|
<div class="controlBtn delete" @click="handleDeleteStep(idx)">
|
<img
|
src="@/assets/public/delete.png"
|
alt="删除"
|
class="delete-icon"
|
/>
|
删除
|
</div>
|
</div>
|
</div>
|
<DynamicComponent
|
:ref="'stepContent' + idx"
|
@submit="(content) => handleStepContentSubmit(idx, content)"
|
/>
|
</div>
|
|
<div class="add-project-footer">
|
<el-button type="primary" class="save-btn" @click="handleSave"
|
>发送</el-button
|
>
|
<el-button @click="handleSaveDraft">存草稿</el-button>
|
</div>
|
</el-form>
|
</template>
|
<SelectMember ref="selectMember" />
|
<experimentalScheduling :show="showScheduling" />
|
<AddStep ref="addStepDialog" @submit="handleStepSubmit" />
|
</Card>
|
</template>
|
|
<script>
|
import SelectMember from "@/components/SelectMember";
|
import experimentalScheduling from "../confirmation-sheet/components/experimental-scheduling.vue";
|
import DynamicComponent from "@/components/DynamicComponent";
|
import AddStep from "./components/add-step.vue";
|
import AiEditor from "@/components/AiEditor";
|
|
export default {
|
name: "AddProject",
|
components: {
|
SelectMember,
|
experimentalScheduling,
|
DynamicComponent,
|
AddStep,
|
AiEditor,
|
},
|
data() {
|
return {
|
showScheduling: false,
|
form: {
|
material: null,
|
equipment: null,
|
},
|
editorContents: {
|
purpose: "",
|
process: "",
|
},
|
stepList: [],
|
editingStepIndex: -1,
|
rules: {
|
name: [
|
{ required: true, message: "请输入项目组名称", trigger: "blur" },
|
],
|
description: [
|
{ required: true, message: "请输入项目组描述", trigger: "blur" },
|
],
|
material: [
|
{ required: true, message: "请添加实验材料", trigger: "change" },
|
],
|
equipment: [
|
{ required: true, message: "请添加实验设备", trigger: "change" },
|
],
|
},
|
groupTableData: [],
|
taskTableData: [],
|
};
|
},
|
methods: {
|
submitForm() {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
console.log("submit!");
|
}
|
});
|
},
|
addMember() {
|
this.$refs.selectMember.open();
|
},
|
memberList(i) {
|
switch (i) {
|
case 1:
|
return [1];
|
case 2:
|
return [1];
|
case 3:
|
return [1, 2, 3, 4, 5, 6, 7, 8];
|
case 4:
|
return [1, 2, 3, 4, 5, 6, 7, 8];
|
default:
|
break;
|
}
|
},
|
handleAddGroup() {
|
this.$refs.addGroupDialog.open();
|
},
|
handleEditGroup(row) {
|
this.$refs.addGroupDialog.open(row);
|
},
|
handleDeleteGroup(row) {
|
this.$confirm("确认删除该组别吗?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
const index = this.groupTableData.findIndex((item) => item === row);
|
if (index > -1) {
|
this.groupTableData.splice(index, 1);
|
this.$message.success("删除成功");
|
}
|
})
|
.catch(() => {});
|
},
|
handleGroupSubmit(form) {
|
const index = this.groupTableData.findIndex(
|
(item) => item.groupName === form.groupName
|
);
|
if (index > -1) {
|
this.groupTableData.splice(index, 1, form);
|
} else {
|
this.groupTableData.push(form);
|
}
|
},
|
handleAddTask() {
|
this.$refs.addTaskDialog.open();
|
},
|
handleEditTask(row) {
|
this.$refs.addTaskDialog.open(row);
|
},
|
handleDeleteTask(row) {
|
this.$confirm("确认删除该任务吗?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
const index = this.taskTableData.findIndex((item) => item === row);
|
if (index > -1) {
|
this.taskTableData.splice(index, 1);
|
this.$message.success("删除成功");
|
}
|
})
|
.catch(() => {});
|
},
|
handleTaskSubmit(form) {
|
const index = this.taskTableData.findIndex(
|
(item) => item.taskName === form.taskName
|
);
|
if (index > -1) {
|
this.taskTableData.splice(index, 1, form);
|
} else {
|
this.taskTableData.push(form);
|
}
|
},
|
handleMaterialSubmit(data) {
|
this.form.material = data;
|
},
|
handleEquipmentSubmit(data) {
|
this.form.equipment = data;
|
},
|
handleSave() {
|
this.$refs.form.validate((valid) => {
|
if (valid && this.validateContent()) {
|
this.$refs.materialComponent.submit();
|
this.$refs.equipmentComponent.submit();
|
|
const formData = {
|
...this.form,
|
...this.getAllEditorContent(),
|
steps: this.stepList,
|
};
|
console.log("提交的数据:", formData);
|
this.$message.success("保存成功");
|
}
|
});
|
},
|
handleSaveDraft() {
|
this.$refs.materialComponent.submit();
|
this.$refs.equipmentComponent.submit();
|
|
const formData = {
|
...this.form,
|
...this.getAllEditorContent(),
|
steps: this.stepList,
|
status: "draft",
|
};
|
console.log("草稿数据:", formData);
|
this.$message.success("草稿保存成功");
|
},
|
handleAddStep() {
|
this.$refs.addStepDialog.open();
|
},
|
handleStepSubmit(stepData) {
|
if (this.editingStepIndex > -1) {
|
this.stepList[this.editingStepIndex].stepName = stepData.stepName;
|
this.editingStepIndex = -1;
|
} else {
|
this.stepList.push({
|
stepName: stepData.stepName,
|
content: null,
|
});
|
}
|
},
|
handleDeleteStep(index) {
|
this.$confirm("确认删除该步骤吗?删除后步骤内容将无法恢复", "警告", {
|
confirmButtonText: "确定删除",
|
cancelButtonText: "取消",
|
type: "warning",
|
confirmButtonClass: "confirm-danger-btn",
|
})
|
.then(() => {
|
this.stepList.splice(index, 1);
|
this.$message.success("删除成功");
|
})
|
.catch(() => {});
|
},
|
handleEditStep(index) {
|
this.editingStepIndex = index;
|
this.$refs.addStepDialog.open(true);
|
this.$refs.addStepDialog.setStepName(this.stepList[index].stepName);
|
},
|
handleStepContentSubmit(index, content) {
|
this.stepList[index].content = content;
|
},
|
getAllEditorContent() {
|
return {
|
purpose: this.$refs.purposeEditor.getContent(),
|
process: this.$refs.processEditor.getContent(),
|
};
|
},
|
validateContent() {
|
const contents = this.getAllEditorContent();
|
if (!contents.purpose) {
|
this.$message.error("请填写实验目的");
|
return false;
|
}
|
if (!contents.process) {
|
this.$message.error("请填写工艺参数及路线");
|
return false;
|
}
|
return true;
|
},
|
handleStopExperiment() {
|
this.$router.push('/dataManagement/scheme-management/stop-experiment')
|
},
|
},
|
};
|
</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;
|
.header-title-left {
|
display: flex;
|
align-items: center;
|
gap: 13px;
|
|
img {
|
width: 12px;
|
height: 19px;
|
}
|
|
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;
|
}
|
}
|
|
span {
|
flex-shrink: 0;
|
font-weight: bold;
|
font-size: 18px;
|
color: #222222;
|
line-height: 27px;
|
font-family: "Source Han Sans CN Bold Bold";
|
}
|
}
|
|
.header-title-left :first-child {
|
margin-top: 0;
|
}
|
}
|
|
.item-title {
|
padding-left: 25px;
|
|
span {
|
flex-shrink: 0;
|
font-weight: bold;
|
font-size: 14px;
|
color: #222222;
|
line-height: 27px;
|
font-family: "Source Han Sans CN Bold Bold";
|
margin: 18px 0;
|
|
&:before {
|
content: "*";
|
color: #f56c6c;
|
margin-right: 4px;
|
}
|
}
|
}
|
|
.header-title:first-child {
|
margin-top: 0px;
|
.header-title-left {
|
margin-top: 0;
|
}
|
}
|
|
.add-group {
|
padding-left: 25px;
|
margin-top: 14px;
|
display: flex;
|
align-items: center;
|
margin-bottom: 19px;
|
|
div {
|
color: #f56c6c;
|
}
|
|
span {
|
font-weight: 500;
|
font-size: 14px;
|
color: #222222;
|
line-height: 21px;
|
margin: 0 32px 0 8px;
|
}
|
}
|
|
.groupTable {
|
width: 65%;
|
padding-left: 40px;
|
}
|
.rwuTable {
|
width: 85%;
|
padding-left: 40px;
|
}
|
|
.member-list {
|
margin-top: 18px;
|
display: flex;
|
flex-wrap: wrap;
|
gap: 28px;
|
margin-left: 38px;
|
|
.member-list-card {
|
width: 340px;
|
height: 400px;
|
border-radius: 8px;
|
border: 1px solid #dcdfe6;
|
|
&:nth-child(1) {
|
background: linear-gradient(
|
to bottom,
|
rgba(4, 156, 154, 0.2) 0%,
|
rgba(5, 242, 194, 0) 70%
|
);
|
}
|
|
&:nth-child(2) {
|
background: linear-gradient(
|
to bottom,
|
rgba(5, 160, 193, 0.2) 0%,
|
rgba(5, 242, 194, 0) 70%
|
);
|
}
|
|
&:nth-child(3) {
|
background: linear-gradient(
|
to bottom,
|
rgba(255, 77, 79, 0.2) 0%,
|
rgba(255, 242, 194, 0) 70%
|
);
|
}
|
|
&:nth-child(4) {
|
background: linear-gradient(
|
to bottom,
|
rgba(250, 199, 20, 0.21) 0%,
|
rgba(255, 242, 194, 0) 70%
|
);
|
}
|
|
.member-item {
|
height: 100%;
|
display: flex;
|
flex-direction: column;
|
|
.member-title {
|
margin-top: 20px;
|
width: 100%;
|
font-family: "Source Han Sans CN Bold Bold";
|
font-weight: bold;
|
font-size: 16px;
|
color: rgba(0, 0, 0, 0.8);
|
line-height: 16px;
|
text-align: center;
|
}
|
.flex1 {
|
flex: 1;
|
}
|
|
.member-name-box {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.member-name-box-2 {
|
flex: 1;
|
padding: 0 20px;
|
padding-top: 40px;
|
display: grid;
|
grid-template-columns: repeat(4, 1fr);
|
gap: 20px;
|
justify-items: center;
|
align-items: start;
|
}
|
|
.member-name {
|
width: 60px;
|
height: 60px;
|
background: #7d8b79;
|
border-radius: 50%;
|
text-align: center;
|
line-height: 60px;
|
font-weight: 500;
|
font-size: 16px;
|
color: #ffffff;
|
margin: 0;
|
}
|
|
.member-change {
|
display: flex;
|
justify-content: center;
|
padding: 10px 0;
|
margin-top: auto;
|
cursor: pointer;
|
.member-change-btn {
|
background: #fff1f0;
|
border-radius: 4px;
|
border: 1px solid #ffccc7;
|
padding: 1px 8px;
|
font-weight: 400;
|
font-size: 12px;
|
color: #ff4d4f;
|
}
|
}
|
}
|
}
|
}
|
|
.add-project-footer {
|
margin-top: 43px;
|
|
button {
|
width: 220px;
|
}
|
|
.save-btn {
|
margin-right: 20px;
|
}
|
}
|
|
.choose-material {
|
background: #eff8fa;
|
padding: 20px;
|
margin-top: 37px;
|
}
|
.step-list {
|
background: #eff8fa;
|
padding: 20px;
|
.step-list-item {
|
display: flex;
|
justify-content: space-between;
|
padding: 25px;
|
background: #ffffff;
|
.step-list-item-title {
|
font-weight: 500;
|
font-size: 14px;
|
color: rgba(0, 0, 0, 0.8);
|
line-height: 20px;
|
flex-wrap: wrap;
|
flex: 1;
|
}
|
.step-list-item-control {
|
display: flex;
|
align-items: center;
|
.controlBtn {
|
height: 24px;
|
background: #ffffff;
|
border-radius: 4px;
|
padding: 0px 8px;
|
display: flex;
|
align-items: center;
|
}
|
.edit {
|
border: 1px solid #44be09;
|
font-family: PingFangSC, PingFang SC;
|
font-weight: 400;
|
font-size: 14px;
|
color: #52c41a;
|
line-height: 24px;
|
margin-right: 50px;
|
}
|
.delete {
|
border: 1px solid #ff4d4f;
|
font-family: PingFangSC, PingFang SC;
|
font-weight: 400;
|
font-size: 14px;
|
color: #ff4d4f;
|
line-height: 24px;
|
}
|
.edit-icon {
|
width: 14px;
|
height: 14px;
|
margin-right: 8px;
|
}
|
.delete-icon {
|
width: 13px;
|
height: 13px;
|
margin-right: 9px;
|
}
|
}
|
}
|
}
|
|
.content-box {
|
padding: 0 25px;
|
margin-bottom: 30px;
|
width: 65%;
|
}
|
</style>
|