| | |
| | | <template> |
| | | <div id="app"> |
| | | <router-view :key="$route.fullPath"/> |
| | | <keep-alive> |
| | | <router-view :key="$route.fullPath"/> |
| | | </keep-alive> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | created() { |
| | | this.reset() |
| | | this.getList() |
| | | },activated() { |
| | | this.reset() |
| | | this.getList() |
| | | }, |
| | | methods: { |
| | | goDetail(id) { |
| | |
| | | nodeData: {}, |
| | | nodeType: "", //1母代 2计划数 3子孙代 |
| | | tableData: [], |
| | | cacheData: null, // 👈 添加这一行 |
| | | confirmStorageDialogVisible: false, |
| | | storageVisible: false, |
| | | editBoolean: false, |
| | |
| | | this.initGraph(); |
| | | this.initEvents(); |
| | | }, |
| | | created() { |
| | | deactivated() { |
| | | // 缓存数据 |
| | | this.cacheData = { |
| | | form: JSON.parse(JSON.stringify(this.form)), |
| | | graphData: JSON.parse(JSON.stringify(this.graphData)), |
| | | nodeCount: this.nodeCount, |
| | | selectedNode: this.selectedNode ? JSON.parse(JSON.stringify(this.selectedNode)) : null, |
| | | tableData: JSON.parse(JSON.stringify(this.tableData)), |
| | | newTableData: JSON.parse(JSON.stringify(this.newTableData)), |
| | | total: this.total, |
| | | newTotal: this.newTotal, |
| | | projectData: JSON.parse(JSON.stringify(this.projectData)), |
| | | treeData: JSON.parse(JSON.stringify(this.treeData)), |
| | | nodeTreeStatus: this.nodeTreeStatus |
| | | }; |
| | | }, |
| | | activated() { |
| | | if (this.cacheData) { |
| | | // 恢复数据 |
| | | this.form = JSON.parse(JSON.stringify(this.cacheData.form)); |
| | | this.graphData = JSON.parse(JSON.stringify(this.cacheData.graphData)); |
| | | this.nodeCount = this.cacheData.nodeCount; |
| | | this.selectedNode = this.cacheData.selectedNode; |
| | | this.tableData = this.cacheData.tableData || []; |
| | | this.newTableData = this.cacheData.newTableData || []; |
| | | this.total = this.cacheData.total || 0; |
| | | this.newTotal = this.cacheData.newTotal || 0; |
| | | this.projectData = this.cacheData.projectData || []; |
| | | this.treeData = this.cacheData.treeData || []; |
| | | this.nodeTreeStatus = this.cacheData.nodeTreeStatus || 1; |
| | | |
| | | // 更新图表 |
| | | if (this.graphData.nodes.length > 0) { |
| | | this.updateGraphData(); |
| | | } |
| | | return; |
| | | } |
| | | if (this.$route.query.id) { |
| | | this.reloadData(); |
| | | } |
| | |
| | | |
| | | // 更新图表 |
| | | this.updateGraphData(); |
| | | this.cacheData = null; |
| | | }); |
| | | }, |
| | | addNodeSign(value, type) { |
| | |
| | | edit({ ...baseData }).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message.success("编辑成功"); |
| | | this.cacheData = null; // 👈 添加这一行 |
| | | this.$router.back(); |
| | | } |
| | | }); |
| | |
| | | add(baseData).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message.success("保存成功"); |
| | | this.cacheData = null; |
| | | this.$router.back(); |
| | | } |
| | | }); |
| | |
| | | currentApprovalData: null, |
| | | }; |
| | | }, |
| | | created() { |
| | | activated() { |
| | | this.getTableData(); |
| | | }, |
| | | mounted() { |
| | | this.fetchTeamList() |
| | | }, |
| | | methods: { |
| | |
| | | created() { |
| | | this.getList(); |
| | | }, |
| | | activated() { |
| | | this.getList(); |
| | | }, |
| | | methods: { |
| | | handleProject(type, id) { |
| | | if (type == "add") { |
| | |
| | | return this.form.culturePreservations.slice(start, start + pageSize); |
| | | } |
| | | }, |
| | | mounted() { |
| | | if (this.$route.query.id) { |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | if (this.$route.query.id && !this.cacheForm) { |
| | | this.getDetail() |
| | | } |
| | | }, |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | }, |
| | | methods: { |
| | | getProjectData(data) { |
| | |
| | | edit(this.form).then(res => { |
| | | if (res.code === 200) { |
| | | this.$message.success('编辑成功'); |
| | | this.cacheForm = null |
| | | this.$router.back(); |
| | | } else { |
| | | this.$message.error('编辑失败'); |
| | |
| | | add(this.form).then(res => { |
| | | if (res.code === 200) { |
| | | this.$message.success('添加成功'); |
| | | this.cacheForm = null |
| | | this.$router.back(); |
| | | } else { |
| | | this.$message.error('添加失败'); |
| | |
| | | roleType: Number(JSON.parse(sessionStorage.getItem('userInfo')).roleType), |
| | | }; |
| | | }, |
| | | created() { |
| | | activated() { |
| | | this.getTableData(); |
| | | this.fetchTeamList(); |
| | | }, |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="菌种编号" prop="strainCode"> |
| | | <el-input v-model="form.strainCode" placeholder="请输入"></el-input> |
| | | <!-- <el-input v-model="form.strainCode" placeholder="请输入"></el-input>--> |
| | | <div class="strain-code-wrapper"> |
| | | <el-input |
| | | v-model="form.strainCode" |
| | | placeholder="请输入前缀" |
| | | class="strain-code-input" |
| | | /> |
| | | <span class="strain-code-separator">-</span> |
| | | <el-input |
| | | :value="displayStrainSeq" |
| | | placeholder="序号" |
| | | class="strain-seq-input" |
| | | maxlength="3" |
| | | @input="handleSeqInput" |
| | | @blur="formatSeq" |
| | | @focus="handleFocus" |
| | | /> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="菌种名称" prop="strainName"> |
| | | <el-input v-model="form.strainName" placeholder="请输入"></el-input> |
| | |
| | | batchForm: { |
| | | count: '' |
| | | }, |
| | | displayStrainSeq: '', // 显示用的序号(可能包含前导零) |
| | | form: { |
| | | strainCode: '', |
| | | strainName: '', |
| | |
| | | } |
| | | } |
| | | }, |
| | | async created() { |
| | | async activated() { |
| | | await this.fetchTeamList() |
| | | |
| | | this.resetForm() |
| | | if (this.$route.query.id) { |
| | | getDetail({ id: this.$route.query.id }).then(res => { |
| | | this.form = res |
| | | }) |
| | | } |
| | | }, |
| | | activated() { |
| | | console.log("activated") |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | if (this.$route.query.id && !this.cacheForm) { |
| | | getDetail({ id: this.$route.query.id }).then(res => { |
| | | this.form = res |
| | | |
| | | if (res.strainCode) { |
| | | const parts = res.strainCode.split('-'); |
| | | if (parts.length > 1) { |
| | | const seq = parts.pop(); |
| | | this.displayStrainSeq = seq.replace(/^0+/, ''); |
| | | this.form.strainCode = parts.join('-'); |
| | | } else { |
| | | this.form.strainCode = res.strainCode; |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | deactivated() { |
| | | console.log("deactivated") |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | watch: { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 处理输入:只允许数字 |
| | | handleSeqInput(value) { |
| | | console.log('输入值:', value); |
| | | |
| | | // 如果是空字符串,清空所有 |
| | | if (value === '') { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | return; |
| | | } |
| | | |
| | | // 只保留数字,限制3位 |
| | | let numStr = value.replace(/\D/g, '').slice(0, 3); |
| | | |
| | | if (numStr) { |
| | | const num = parseInt(numStr); |
| | | if (!isNaN(num) && num >= 0 && num <= 999) { |
| | | // 存储时去除前导零 |
| | | this.form.strainSeq = String(num); |
| | | // 显示时保留用户输入的内容(不补零,让用户看到自己输入的内容) |
| | | this.displayStrainSeq = numStr; |
| | | } |
| | | } else { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | |
| | | console.log('存储值:', this.form.strainSeq); |
| | | console.log('显示值:', this.displayStrainSeq); |
| | | }, |
| | | |
| | | // 失去焦点时:补零到3位 |
| | | formatSeq() { |
| | | console.log('失去焦点, 当前值:', this.form.strainSeq); |
| | | |
| | | if (this.form.strainSeq) { |
| | | const num = parseInt(this.form.strainSeq); |
| | | if (!isNaN(num) && num >= 0 && num <= 999) { |
| | | // 保持存储值为数字字符串 |
| | | this.form.strainSeq = String(num); |
| | | // 显示时补零到3位 |
| | | this.displayStrainSeq = String(num).padStart(3, '0'); |
| | | } else { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | } else { |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | |
| | | console.log('格式化后存储值:', this.form.strainSeq); |
| | | console.log('格式化后显示值:', this.displayStrainSeq); |
| | | }, |
| | | |
| | | // 获取焦点时:显示原始数字(去除前导零,便于编辑) |
| | | handleFocus() { |
| | | console.log('获取焦点, 当前值:', this.form.strainSeq); |
| | | |
| | | if (this.form.strainSeq) { |
| | | // 显示原始数字,去除前导零 |
| | | this.displayStrainSeq = this.form.strainSeq; |
| | | } else { |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | }, |
| | | getFullStrainCode() { |
| | | const prefix = this.form.strainCode || ''; |
| | | const seq = this.displayStrainSeq || ''; |
| | | if (prefix && seq) { |
| | | const paddedSeq = String(seq).padStart(3, '0'); |
| | | return `${prefix}-${paddedSeq}`; |
| | | } |
| | | return prefix; |
| | | }, |
| | | // 获取项目组列表 |
| | | async fetchTeamList() { |
| | | if (this.teamList.length > 0) return // 已有数据不再重复请求 |
| | |
| | | }) |
| | | }, |
| | | async handleSignatureConfirm(signatureImage) { |
| | | const fullStrainCode = this.getFullStrainCode(); |
| | | let requestData = { |
| | | projectId: this.form.projectId, |
| | | strainCode: this.form.strainCode, |
| | | strainCode: fullStrainCode, |
| | | strainName: this.form.strainName, |
| | | strainSource: this.form.strainSource, |
| | | appraisalMethod: this.form.appraisalMethod, |
| | |
| | | .strain-form { |
| | | padding: 0 40px; |
| | | |
| | | // 菌种编号表单项样式 |
| | | .strain-code-form-item { |
| | | // 关键:让表单项占满宽度 |
| | | flex: 1; |
| | | min-width: 280px; |
| | | |
| | | :deep(.el-form-item__content) { |
| | | display: flex; |
| | | align-items: center; |
| | | width: 100%; |
| | | line-height: 36px; |
| | | } |
| | | } |
| | | |
| | | .strain-code-wrapper { |
| | | display: flex; |
| | | align-items: center; |
| | | gap: 8px; |
| | | width: 100%; |
| | | flex: 1; |
| | | |
| | | .strain-code-input { |
| | | flex: 1; // 改为 flex:1 自适应 |
| | | min-width: 0; // 防止溢出 |
| | | |
| | | :deep(.el-input__inner) { |
| | | height: 36px; |
| | | line-height: 36px; |
| | | border-radius: 4px; |
| | | width: 100%; |
| | | } |
| | | } |
| | | |
| | | .strain-code-separator { |
| | | color: #909399; |
| | | font-size: 16px; |
| | | font-weight: bold; |
| | | user-select: none; |
| | | flex-shrink: 0; |
| | | line-height: 36px; |
| | | padding: 0 2px; |
| | | } |
| | | |
| | | .strain-seq-input { |
| | | width: 90px; // 固定宽度 |
| | | flex-shrink: 0; // 不被压缩 |
| | | |
| | | :deep(.el-input__inner) { |
| | | height: 36px; |
| | | line-height: 36px; |
| | | text-align: center; |
| | | padding: 0 5px; |
| | | border-radius: 4px; |
| | | width: 100%; |
| | | |
| | | &::-webkit-inner-spin-button, |
| | | &::-webkit-outer-spin-button { |
| | | -webkit-appearance: none; |
| | | margin: 0; |
| | | } |
| | | -moz-appearance: textfield; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .form-row { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="菌种编号" prop="strainCode"> |
| | | <el-input v-model="form.strainCode" placeholder="请输入"></el-input> |
| | | <el-form-item label="菌种编号" prop="strainCode" class="strain-code-form-item"> |
| | | <!-- <el-input v-model="form.strainCode" placeholder="请输入"></el-input>--> |
| | | <div class="strain-code-wrapper"> |
| | | <el-input |
| | | v-model="form.strainCode" |
| | | placeholder="请输入前缀" |
| | | class="strain-code-input" |
| | | /> |
| | | <span class="strain-code-separator">-</span> |
| | | <el-input |
| | | :value="displayStrainSeq" |
| | | placeholder="序号" |
| | | class="strain-seq-input" |
| | | maxlength="3" |
| | | @input="handleSeqInput" |
| | | @blur="formatSeq" |
| | | @focus="handleFocus" |
| | | /> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="菌种名称" prop="strainName"> |
| | | <el-input v-model="form.strainName" placeholder="请输入"></el-input> |
| | |
| | | batchForm: { |
| | | count: '' |
| | | }, |
| | | displayStrainSeq: '', |
| | | cacheForm: null, |
| | | form: { |
| | | projectId: '', |
| | |
| | | } |
| | | } |
| | | }, |
| | | async mounted() { |
| | | async activated() { |
| | | await this.fetchTeamList(); |
| | | |
| | | this.form = { |
| | |
| | | preservationMethod: '', |
| | | remark: '' |
| | | } |
| | | if (this.$route.query.id) { |
| | | |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | |
| | | if (this.$route.query.id && !this.cacheForm) { |
| | | getDetail({id: this.$route.query.id}).then(res => { |
| | | this.form = res |
| | | |
| | | if (res.strainCode) { |
| | | const parts = res.strainCode.split('-'); |
| | | if (parts.length > 1) { |
| | | const seq = parts.pop(); |
| | | this.displayStrainSeq = seq.replace(/^0+/, ''); |
| | | this.form.strainCode = parts.join('-'); |
| | | } else { |
| | | this.form.strainCode = res.strainCode; |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | }, |
| | | watch: { |
| | | '$route.query.id'() { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 处理输入:只允许数字 |
| | | handleSeqInput(value) { |
| | | console.log('输入值:', value); |
| | | |
| | | // 如果是空字符串,清空所有 |
| | | if (value === '') { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | return; |
| | | } |
| | | |
| | | // 只保留数字,限制3位 |
| | | let numStr = value.replace(/\D/g, '').slice(0, 3); |
| | | |
| | | if (numStr) { |
| | | const num = parseInt(numStr); |
| | | if (!isNaN(num) && num >= 0 && num <= 999) { |
| | | // 存储时去除前导零 |
| | | this.form.strainSeq = String(num); |
| | | // 显示时保留用户输入的内容(不补零,让用户看到自己输入的内容) |
| | | this.displayStrainSeq = numStr; |
| | | } |
| | | } else { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | |
| | | console.log('存储值:', this.form.strainSeq); |
| | | console.log('显示值:', this.displayStrainSeq); |
| | | }, |
| | | |
| | | // 失去焦点时:补零到3位 |
| | | formatSeq() { |
| | | console.log('失去焦点, 当前值:', this.form.strainSeq); |
| | | |
| | | if (this.form.strainSeq) { |
| | | const num = parseInt(this.form.strainSeq); |
| | | if (!isNaN(num) && num >= 0 && num <= 999) { |
| | | // 保持存储值为数字字符串 |
| | | this.form.strainSeq = String(num); |
| | | // 显示时补零到3位 |
| | | this.displayStrainSeq = String(num).padStart(3, '0'); |
| | | } else { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | } else { |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | |
| | | console.log('格式化后存储值:', this.form.strainSeq); |
| | | console.log('格式化后显示值:', this.displayStrainSeq); |
| | | }, |
| | | |
| | | // 获取焦点时:显示原始数字(去除前导零,便于编辑) |
| | | handleFocus() { |
| | | console.log('获取焦点, 当前值:', this.form.strainSeq); |
| | | |
| | | if (this.form.strainSeq) { |
| | | // 显示原始数字,去除前导零 |
| | | this.displayStrainSeq = this.form.strainSeq; |
| | | } else { |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | }, |
| | | getFullStrainCode() { |
| | | const prefix = this.form.strainCode || ''; |
| | | const seq = this.displayStrainSeq || ''; |
| | | if (prefix && seq) { |
| | | const paddedSeq = String(seq).padStart(3, '0'); |
| | | return `${prefix}-${paddedSeq}`; |
| | | } |
| | | return prefix; |
| | | }, |
| | | // 获取项目组列表 |
| | | async fetchTeamList() { |
| | | if (this.teamList.length > 0) return // 已有数据不再重复请求 |
| | |
| | | }) |
| | | }, |
| | | async handleSignatureConfirm(signatureImage) { |
| | | const fullStrainCode = this.getFullStrainCode(); |
| | | let requestData = { |
| | | projectId: this.form.projectId, |
| | | strainCode: this.form.strainCode, |
| | | strainCode: fullStrainCode, |
| | | strainName: this.form.strainName, |
| | | strainSource: this.form.strainSource, |
| | | appraisalMethod: this.form.appraisalMethod, |
| | |
| | | .strain-form { |
| | | padding: 0 40px; |
| | | |
| | | // 菌种编号表单项样式 |
| | | .strain-code-form-item { |
| | | // 关键:让表单项占满宽度 |
| | | flex: 1; |
| | | min-width: 280px; |
| | | |
| | | :deep(.el-form-item__content) { |
| | | display: flex; |
| | | align-items: center; |
| | | width: 100%; |
| | | line-height: 36px; |
| | | } |
| | | } |
| | | |
| | | .strain-code-wrapper { |
| | | display: flex; |
| | | align-items: center; |
| | | gap: 8px; |
| | | width: 100%; |
| | | flex: 1; |
| | | |
| | | .strain-code-input { |
| | | flex: 1; // 改为 flex:1 自适应 |
| | | min-width: 0; // 防止溢出 |
| | | |
| | | :deep(.el-input__inner) { |
| | | height: 36px; |
| | | line-height: 36px; |
| | | border-radius: 4px; |
| | | width: 100%; |
| | | } |
| | | } |
| | | |
| | | .strain-code-separator { |
| | | color: #909399; |
| | | font-size: 16px; |
| | | font-weight: bold; |
| | | user-select: none; |
| | | flex-shrink: 0; |
| | | line-height: 36px; |
| | | padding: 0 2px; |
| | | } |
| | | |
| | | .strain-seq-input { |
| | | width: 90px; // 固定宽度 |
| | | flex-shrink: 0; // 不被压缩 |
| | | |
| | | :deep(.el-input__inner) { |
| | | height: 36px; |
| | | line-height: 36px; |
| | | text-align: center; |
| | | padding: 0 5px; |
| | | border-radius: 4px; |
| | | width: 100%; |
| | | |
| | | &::-webkit-inner-spin-button, |
| | | &::-webkit-outer-spin-button { |
| | | -webkit-appearance: none; |
| | | margin: 0; |
| | | } |
| | | -moz-appearance: textfield; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .form-row { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="菌种编号" prop="strainCode"> |
| | | <el-input v-model="form.strainCode" placeholder="请输入"></el-input> |
| | | <el-form-item label="菌种编号" prop="strainCode" class="strain-code-form-item"> |
| | | <!-- <el-input v-model="form.strainCode" placeholder="请输入"></el-input>--> |
| | | <div class="strain-code-wrapper"> |
| | | <el-input |
| | | v-model="form.strainCode" |
| | | placeholder="请输入前缀" |
| | | class="strain-code-input" |
| | | /> |
| | | <span class="strain-code-separator">-</span> |
| | | <el-input |
| | | :value="displayStrainSeq" |
| | | placeholder="序号" |
| | | class="strain-seq-input" |
| | | maxlength="3" |
| | | @input="handleSeqInput" |
| | | @blur="formatSeq" |
| | | @focus="handleFocus" |
| | | /> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="菌种名称" prop="strainName"> |
| | | <el-input v-model="form.strainName" placeholder="请输入"></el-input> |
| | |
| | | batchForm: { |
| | | count: '' |
| | | }, |
| | | displayStrainSeq: '', // 显示用的序号(可能包含前导零) |
| | | cacheForm: null, |
| | | form: { |
| | | strainCode: '', |
| | |
| | | } |
| | | } |
| | | }, |
| | | async mounted() { |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | async activated() { |
| | | await this.fetchTeamList(); |
| | | |
| | | this.form = { |
| | |
| | | preservationMethod: '', |
| | | remark: '' |
| | | } |
| | | if (this.$route.query.id) { |
| | | |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | |
| | | if (this.$route.query.id && !this.cacheForm) { |
| | | getDetail({id: this.$route.query.id}).then(res => { |
| | | this.form = res |
| | | |
| | | if (res.strainCode) { |
| | | const parts = res.strainCode.split('-'); |
| | | if (parts.length > 1) { |
| | | const seq = parts.pop(); |
| | | this.displayStrainSeq = seq.replace(/^0+/, ''); |
| | | this.form.strainCode = parts.join('-'); |
| | | } else { |
| | | this.form.strainCode = res.strainCode; |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | }, |
| | | watch: { |
| | | '$route.query.id'() { |
| | | this.form = { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 处理输入:只允许数字 |
| | | handleSeqInput(value) { |
| | | console.log('输入值:', value); |
| | | |
| | | // 如果是空字符串,清空所有 |
| | | if (value === '') { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | return; |
| | | } |
| | | |
| | | // 只保留数字,限制3位 |
| | | let numStr = value.replace(/\D/g, '').slice(0, 3); |
| | | |
| | | if (numStr) { |
| | | const num = parseInt(numStr); |
| | | if (!isNaN(num) && num >= 0 && num <= 999) { |
| | | // 存储时去除前导零 |
| | | this.form.strainSeq = String(num); |
| | | // 显示时保留用户输入的内容(不补零,让用户看到自己输入的内容) |
| | | this.displayStrainSeq = numStr; |
| | | } |
| | | } else { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | |
| | | console.log('存储值:', this.form.strainSeq); |
| | | console.log('显示值:', this.displayStrainSeq); |
| | | }, |
| | | |
| | | // 失去焦点时:补零到3位 |
| | | formatSeq() { |
| | | console.log('失去焦点, 当前值:', this.form.strainSeq); |
| | | |
| | | if (this.form.strainSeq) { |
| | | const num = parseInt(this.form.strainSeq); |
| | | if (!isNaN(num) && num >= 0 && num <= 999) { |
| | | // 保持存储值为数字字符串 |
| | | this.form.strainSeq = String(num); |
| | | // 显示时补零到3位 |
| | | this.displayStrainSeq = String(num).padStart(3, '0'); |
| | | } else { |
| | | this.form.strainSeq = ''; |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | } else { |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | |
| | | console.log('格式化后存储值:', this.form.strainSeq); |
| | | console.log('格式化后显示值:', this.displayStrainSeq); |
| | | }, |
| | | |
| | | // 获取焦点时:显示原始数字(去除前导零,便于编辑) |
| | | handleFocus() { |
| | | console.log('获取焦点, 当前值:', this.form.strainSeq); |
| | | |
| | | if (this.form.strainSeq) { |
| | | // 显示原始数字,去除前导零 |
| | | this.displayStrainSeq = this.form.strainSeq; |
| | | } else { |
| | | this.displayStrainSeq = ''; |
| | | } |
| | | }, |
| | | getFullStrainCode() { |
| | | const prefix = this.form.strainCode || ''; |
| | | const seq = this.displayStrainSeq || ''; |
| | | if (prefix && seq) { |
| | | const paddedSeq = String(seq).padStart(3, '0'); |
| | | return `${prefix}-${paddedSeq}`; |
| | | } |
| | | return prefix; |
| | | }, |
| | | // 获取项目组列表 |
| | | async fetchTeamList() { |
| | | if (this.teamList.length > 0) return // 已有数据不再重复请求 |
| | |
| | | }) |
| | | }, |
| | | async handleSignatureConfirm(signatureImage) { |
| | | const fullStrainCode = this.getFullStrainCode(); |
| | | let requestData = { |
| | | projectId: this.form.projectId, |
| | | strainCode: this.form.strainCode, |
| | | strainCode: fullStrainCode, |
| | | strainName: this.form.strainName, |
| | | strainSource: this.form.strainSource, |
| | | appraisalMethod: this.form.appraisalMethod, |
| | |
| | | .strain-form { |
| | | padding: 0 40px; |
| | | |
| | | // 菌种编号表单项样式 |
| | | .strain-code-form-item { |
| | | // 关键:让表单项占满宽度 |
| | | flex: 1; |
| | | min-width: 280px; |
| | | |
| | | :deep(.el-form-item__content) { |
| | | display: flex; |
| | | align-items: center; |
| | | width: 100%; |
| | | line-height: 36px; |
| | | } |
| | | } |
| | | |
| | | .strain-code-wrapper { |
| | | display: flex; |
| | | align-items: center; |
| | | gap: 8px; |
| | | width: 100%; |
| | | flex: 1; |
| | | |
| | | .strain-code-input { |
| | | flex: 1; // 改为 flex:1 自适应 |
| | | min-width: 0; // 防止溢出 |
| | | |
| | | :deep(.el-input__inner) { |
| | | height: 36px; |
| | | line-height: 36px; |
| | | border-radius: 4px; |
| | | width: 100%; |
| | | } |
| | | } |
| | | |
| | | .strain-code-separator { |
| | | color: #909399; |
| | | font-size: 16px; |
| | | font-weight: bold; |
| | | user-select: none; |
| | | flex-shrink: 0; |
| | | line-height: 36px; |
| | | padding: 0 2px; |
| | | } |
| | | |
| | | .strain-seq-input { |
| | | width: 90px; // 固定宽度 |
| | | flex-shrink: 0; // 不被压缩 |
| | | |
| | | :deep(.el-input__inner) { |
| | | height: 36px; |
| | | line-height: 36px; |
| | | text-align: center; |
| | | padding: 0 5px; |
| | | border-radius: 4px; |
| | | width: 100%; |
| | | |
| | | &::-webkit-inner-spin-button, |
| | | &::-webkit-outer-spin-button { |
| | | -webkit-appearance: none; |
| | | margin: 0; |
| | | } |
| | | -moz-appearance: textfield; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .form-row { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | |
| | | count: '' |
| | | }, |
| | | displayStrainSeq: '', // 显示用的序号(可能包含前导零) |
| | | cacheForm: null, |
| | | form: { |
| | | projectId: '', |
| | | strainCode: '', |
| | |
| | | } |
| | | } |
| | | }, |
| | | async mounted() { |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | async activated() { |
| | | console.log('mounted') |
| | | await this.fetchTeamList(); |
| | | |
| | | this.form = { |
| | |
| | | remark: '' |
| | | } |
| | | this.displayStrainSeq = 0 |
| | | if (this.$route.query.id) { |
| | | |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | |
| | | if (this.$route.query.id && !this.cacheForm) { |
| | | getDetail({id: this.$route.query.id}).then(res => { |
| | | this.form = {...res} |
| | | |
| | |
| | | <el-card class="top-card"> |
| | | <el-row :gutter="24" class="top-info-row"> |
| | | <el-col :span="6" class="info-col"> |
| | | <div class="info-item"> |
| | | <span class="label">菌种来源:</span>{{ detail.strainSource }} |
| | | <div class="info-item source-item"> |
| | | <span class="label">菌种来源:</span> |
| | | <el-tooltip |
| | | :content="detail.strainSource || '暂无数据'" |
| | | placement="top" |
| | | :disabled="!detail.strainSource || detail.strainSource.length < 30" |
| | | popper-class="source-tooltip" |
| | | effect="dark" |
| | | > |
| | | <span class="source-text">{{ detail.strainSource || '暂无数据' }}</span> |
| | | </el-tooltip> |
| | | </div> |
| | | <div class="info-item"> |
| | | <span class="label">鉴别菌株编号:</span>{{ detail.identifyingStrainCode }} |
| | |
| | | flex-shrink: 0; |
| | | } |
| | | |
| | | |
| | | // 或者直接覆盖所有 .el-tooltip__popper |
| | | /deep/ .source-tooltip { |
| | | max-width: 320px !important; |
| | | min-width: 120px !important; |
| | | word-break: break-word; |
| | | line-height: 1.6; |
| | | padding: 10px 14px; |
| | | font-size: 13px; |
| | | } |
| | | |
| | | .source-item { |
| | | flex: 1; |
| | | min-width: 0; |
| | | |
| | | .source-text { |
| | | flex: 1; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | color: #303133; |
| | | cursor: pointer; |
| | | padding: 0 4px; |
| | | |
| | | &:hover { |
| | | color: #409EFF; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .sign-col { |
| | | align-items: center; |
| | | text-align: center; |
| | |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | if (this.$route.query.id) { |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | |
| | | if (this.$route.query.id && this.cacheForm) { |
| | | detail({ id: this.$route.query.id }).then(res => { |
| | | if (res) { |
| | | // 这里根据实际接口返回字段做适配 |
| | |
| | | }, |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | }, |
| | | methods: { |
| | | getProjectData(data) { |
| | |
| | | if (id) { |
| | | // 编辑 |
| | | edit({ ...submitData, id }).then(() => { |
| | | this.cacheForm = null |
| | | this.$router.back(); |
| | | }); |
| | | } else { |
| | | // 新增 |
| | | add(submitData).then(() => { |
| | | this.cacheForm = null |
| | | this.$router.back(); |
| | | }); |
| | | } |
| | | } else { |
| | | // 存草稿 |
| | | add(submitData).then(() => { |
| | | this.cacheForm = null |
| | | this.$router.back(); |
| | | }); |
| | | } |
| | |
| | | components: { EditConditionDialog, DetailConditionDialog }, |
| | | data() { |
| | | return { |
| | | cacheForm: null, |
| | | detail: { |
| | | strainSource: '', |
| | | identifyingStrainCode: '', |
| | |
| | | } |
| | | }, |
| | | }, |
| | | mounted() { |
| | | this.getDetail() |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.detail = this.cacheForm; |
| | | } |
| | | if (this.$route.query.id && !this.cacheForm) { |
| | | this.getDetail(); |
| | | } |
| | | }, |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.detail)); |
| | | }, |
| | | methods: { |
| | | getFullUrl(url) { |
| | |
| | | if (valid) { |
| | | this.detail.list = this.tableData || [] |
| | | this.detail.purpose = this.detail.purpose.join(',') |
| | | this.detail.isDraft = 0 |
| | | confirm({...this.detail}).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success('保存成功'); |
| | | this.cacheForm = null |
| | | this.$router.back() |
| | | } else { |
| | | this.$message.error(res.msg); |
| | |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="200"> |
| | | <template #default="{ row }"> |
| | | <el-button type="text" v-if="row.status == 1 && roleType == 3 && currentType != 'draft'" |
| | | <el-button type="text" v-if="row.status == 1 && roleType == 3" |
| | | style="margin-right: 10px;" |
| | | @click="$router.push('/strain/validation/confirm-detail?id=' + row.id)">确认</el-button> |
| | | <el-button type="text" style="margin-right: 10px;" v-if="roleType == 4" |
| | |
| | | this.searchData(); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | |
| | | activated() { |
| | | this.searchData(); |
| | | }, |
| | | }; |
| | |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | if (this.$route.query.id) { |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | |
| | | if (this.$route.query.id && !this.cacheForm) { |
| | | detail({ id: this.$route.query.id }).then(res => { |
| | | if (res) { |
| | | // 这里根据实际接口返回字段做适配 |
| | |
| | | }, |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | }, |
| | | |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | } |
| | | }, |
| | | methods: { |
| | | getProjectData(data) { |
| | |
| | | result: '', |
| | | purpose: [] |
| | | }, |
| | | activeTab: 'conditions', |
| | | rules: { |
| | | result: [ |
| | | { required: true, message: '请输入实验结论', trigger: 'blur' } |
| | |
| | | { conditions: '发酵时间', record: '', workmanship: '' }, |
| | | { conditions: '检测数据及结果', record: '', workmanship: '' } |
| | | ], |
| | | tableData: [ |
| | | { conditions: '平板培养基', record: '', workmanship: '' }, |
| | | { conditions: '培养温度', record: '', workmanship: '' }, |
| | | { conditions: '培养时间', record: '', workmanship: '' }, |
| | | { conditions: '摇瓶培养基', record: '', workmanship: '' }, |
| | | { conditions: '接种量', record: '', workmanship: '' }, |
| | | { conditions: '培养时间', record: '', workmanship: '' }, |
| | | { conditions: '发酵时间', record: '', workmanship: '' }, |
| | | { conditions: '检测数据及结果', record: '', workmanship: '' } |
| | | ], |
| | | tableData: [], |
| | | dialogVisible: false, |
| | | dialogIsEdit: false, |
| | | dialogIsFixed: false, |
| | | dialogValue: {}, |
| | | dialogIndex: null, |
| | | detailDialogVisible: false, |
| | | detailDialogValue: {} |
| | | detailDialogValue: {}, |
| | | |
| | | cacheForm: null, |
| | | cacheFormtableData: null, |
| | | isFirstLoad: true, |
| | | isLoading: false, |
| | | } |
| | | }, |
| | | filters: { |
| | |
| | | return '' |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.getDetail() |
| | | // ========== 只使用 activated ========== |
| | | activated() { |
| | | console.log('activated, isFirstLoad:', this.isFirstLoad) |
| | | |
| | | // 1. 首次加载 - 初始化数据并请求 |
| | | if (this.isFirstLoad) { |
| | | this.isFirstLoad = false |
| | | // 初始化表格数据(显示默认行) |
| | | this.tableData = this.initialTableData.map(item => ({ ...item })) |
| | | |
| | | if (this.$route.query.id) { |
| | | this.getDetail() |
| | | } |
| | | return |
| | | } |
| | | |
| | | // 2. 从缓存恢复数据(非首次加载) |
| | | if (this.cacheForm) { |
| | | this.detail = JSON.parse(JSON.stringify(this.cacheForm)) |
| | | this.tableData = JSON.parse(JSON.stringify(this.cacheFormtableData)) |
| | | this.restorePurpose() |
| | | } |
| | | |
| | | // 3. 如果路由参数变化,重新加载数据 |
| | | if (this.$route.query.id && this.detail.id && this.$route.query.id !== String(this.detail.id)) { |
| | | this.getDetail() |
| | | } |
| | | }, |
| | | deactivated() { |
| | | // 缓存当前数据 |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.detail)) |
| | | this.cacheFormtableData = JSON.parse(JSON.stringify(this.tableData)) |
| | | console.log('deactivated - 数据已缓存') |
| | | }, |
| | | // ========== 移除 mounted,或保留仅用于调试 ========== |
| | | mounted() { |
| | | // 不做任何初始化,所有逻辑都在 activated 中 |
| | | console.log('mounted - 仅用于调试,无初始化逻辑') |
| | | }, |
| | | // ========== 方法 ========== |
| | | methods: { |
| | | getFullUrl(url) { |
| | | if (url) { |
| | |
| | | } |
| | | return '' |
| | | }, |
| | | getDetail() { |
| | | detail({ id: this.$route.query.id }).then(res => { |
| | | this.detail = { |
| | | ...res, |
| | | handleSignature: res.handleSignature || '', |
| | | purpose: res.purpose || [] |
| | | } |
| | | }) |
| | | |
| | | restorePurpose() { |
| | | if (!this.detail.purpose) { |
| | | this.detail.purpose = [] |
| | | return |
| | | } |
| | | |
| | | let purposeArray = [] |
| | | if (typeof this.detail.purpose === 'string') { |
| | | purposeArray = this.detail.purpose.split(',').map(item => Number(item.trim())).filter(num => !isNaN(num)) |
| | | } else if (Array.isArray(this.detail.purpose)) { |
| | | purposeArray = this.detail.purpose |
| | | } |
| | | this.detail.purpose = purposeArray |
| | | }, |
| | | |
| | | getDetail() { |
| | | if (this.isLoading) { |
| | | console.log('正在加载中,跳过重复请求') |
| | | return |
| | | } |
| | | |
| | | const id = this.$route.query.id |
| | | if (!id) { |
| | | console.warn('缺少 id 参数') |
| | | return |
| | | } |
| | | |
| | | this.isLoading = true |
| | | console.log('开始请求详情数据, id:', id) |
| | | |
| | | detail({ id }) |
| | | .then(res => { |
| | | console.log('详情数据返回:', res) |
| | | |
| | | // 处理 purpose |
| | | let purposeArray = [] |
| | | if (res.purpose) { |
| | | if (typeof res.purpose === 'string') { |
| | | purposeArray = res.purpose.split(',').map(item => Number(item.trim())).filter(num => !isNaN(num)) |
| | | } else if (Array.isArray(res.purpose)) { |
| | | purposeArray = res.purpose |
| | | } |
| | | } |
| | | |
| | | // 处理 tableData |
| | | const tableList = res.list && res.list.length > 0 ? res.list : this.initialTableData.map(item => ({ ...item })) |
| | | |
| | | // 更新数据 |
| | | this.detail = { |
| | | ...res, |
| | | handleSignature: res.handleSignature || '', |
| | | purpose: purposeArray || [] |
| | | } |
| | | this.tableData = tableList |
| | | |
| | | // 更新缓存 |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.detail)) |
| | | this.cacheFormtableData = JSON.parse(JSON.stringify(this.tableData)) |
| | | }) |
| | | .catch(err => { |
| | | console.error('获取详情失败:', err) |
| | | this.$message.error('加载数据失败,请重试') |
| | | |
| | | // 加载失败时使用初始数据 |
| | | this.tableData = this.initialTableData.map(item => ({ ...item })) |
| | | }) |
| | | .finally(() => { |
| | | this.isLoading = false |
| | | }) |
| | | }, |
| | | |
| | | handleAdd() { |
| | | this.dialogVisible = true |
| | | this.dialogIsEdit = false |
| | |
| | | this.dialogValue = {} |
| | | this.dialogIndex = null |
| | | }, |
| | | |
| | | handleEdit(row) { |
| | | const idx = this.tableData.indexOf(row) |
| | | this.dialogVisible = true |
| | |
| | | this.dialogValue = { ...row } |
| | | this.dialogIndex = idx |
| | | }, |
| | | |
| | | handleDetail(row) { |
| | | this.detailDialogVisible = true |
| | | this.detailDialogValue = { ...row } |
| | | }, |
| | | |
| | | handleSave() { |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | this.detail.list = this.tableData || [] |
| | | this.detail.purpose = this.detail.purpose.join(',') |
| | | this.detail.isDraft = 0 |
| | | confirm({ ...this.detail }).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success('保存成功') |
| | | this.cacheForm = null |
| | | this.cacheFormtableData = null |
| | | this.$router.back() |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | this.$message.error(res.msg || '保存失败') |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | handleDraft() { |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | //todo 存稿逻辑 |
| | | this.detail.list = this.tableData || [] |
| | | this.detail.purpose = this.detail.purpose.join(',') |
| | | console.log('this.detail: ',this.detail) |
| | | |
| | | saveDraft({ ...this.detail }).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success('保存成功') |
| | | this.$message.success('存稿成功') |
| | | this.cacheForm = null |
| | | this.cacheFormtableData = null |
| | | this.$router.back() |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | this.$message.error(res.msg || '存稿失败') |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | handleDialogOk(val) { |
| | | if (this.dialogIsEdit && this.dialogIndex !== null) { |
| | | this.$set(this.tableData, this.dialogIndex, val) |
| | |
| | | this.tableData.push(val) |
| | | } |
| | | }, |
| | | |
| | | getRowClassName({ rowIndex }) { |
| | | return rowIndex < this.initialTableData?.length ? 'fixed-row' : '' |
| | | } |
| | |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="200"> |
| | | <template #default="{ row }"> |
| | | <el-button style="margin-right: 10px" type="text" v-if="row.status == 1 && roleType == 3&¤tType != 'draft'" |
| | | <el-button style="margin-right: 10px" type="text" v-if="row.status == 1 && roleType == 3" |
| | | @click="$router.push('/strain/validation/confirm-detail?id=' + row.id)">确认</el-button> |
| | | <el-button style="margin-right: 10px" type="text" v-if="roleType == 4" @click="handleDetail(row)">详情</el-button> |
| | | <el-button style="margin-right: 10px" type="text" v-if="roleType != 4" @click="handleDetail2(row)">详情</el-button> |
| | |
| | | } |
| | | }, |
| | | }, |
| | | async mounted() { |
| | | async activated() { |
| | | await this.fetchTeamList(); |
| | | await this.searchData(); |
| | | }, |
| | |
| | | approver: "", |
| | | approveTime: "" |
| | | }, |
| | | cacheForm: null, |
| | | cacheData: null, |
| | | projectData: [], // 存储选中的项目组数据 |
| | | fileList: [], // 附件列表 |
| | | showChoose: false, |
| | |
| | | } |
| | | }, |
| | | deactivated() { |
| | | this.cacheForm = JSON.parse(JSON.stringify(this.form)); |
| | | // 缓存所有数据 |
| | | this.cacheData = { |
| | | form: JSON.parse(JSON.stringify(this.form)), |
| | | fileList: JSON.parse(JSON.stringify(this.fileList)), |
| | | assessmentTable: JSON.parse(JSON.stringify(this.assessmentTable)), |
| | | selectedMember: this.selectedMember ? JSON.parse(JSON.stringify(this.selectedMember)) : null, |
| | | projectData: JSON.parse(JSON.stringify(this.projectData)), |
| | | reportContent: this.$refs.materialEditor ? this.$refs.materialEditor.getContent() : '' |
| | | }; |
| | | }, |
| | | |
| | | activated() { |
| | | if (this.cacheForm) { |
| | | this.form = this.cacheForm; |
| | | if (this.cacheData) { |
| | | // 恢复表单数据 |
| | | this.form = JSON.parse(JSON.stringify(this.cacheData.form)); |
| | | // 恢复文件列表 |
| | | this.fileList = JSON.parse(JSON.stringify(this.cacheData.fileList || [])); |
| | | // 恢复考核表数据 |
| | | this.assessmentTable = JSON.parse(JSON.stringify(this.cacheData.assessmentTable || [])); |
| | | // 恢复选中的成员 |
| | | this.selectedMember = this.cacheData.selectedMember ? JSON.parse(JSON.stringify(this.cacheData.selectedMember)) : null; |
| | | // 恢复项目数据 |
| | | this.projectData = JSON.parse(JSON.stringify(this.cacheData.projectData || [])); |
| | | // 恢复编辑器内容(需要在nextTick中设置) |
| | | this.$nextTick(() => { |
| | | if (this.$refs.materialEditor && this.cacheData.reportContent) { |
| | | this.$refs.materialEditor.setContent(this.cacheData.reportContent); |
| | | } |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 没有缓存时,如果有id则加载详情 |
| | | if (this.$route.query.id) { |
| | | this.getDetailData(); |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | window.scrollTo(0, 0); |
| | | }); |
| | | |
| | | if (this.$route.query.id) { |
| | | if (this.$route.query.id && !this.cacheData) { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 👇 添加这个方法 |
| | | getDetailData() { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | |
| | | this.form = { |
| | | ...this.form, |
| | | ...data, |
| | | processData: [] |
| | | }; |
| | | |
| | | let arr = data.evaluate.split(',') |
| | | this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : []) |
| | | this.assessmentTable = this.assessmentTable.map((item, index) => { |
| | | item.selectedScore = Number(arr[index]) |
| | | return item |
| | | }) |
| | | |
| | | this.selectedMember = [{ |
| | | nickName: data.experimentName, |
| | | userId: data.experimentId |
| | | }] |
| | | |
| | | this.projectData = data.projectTeam ? |
| | | [{ ...data.projectTeam, staffName: data.projectTeam.staff || '' }] : |
| | | []; |
| | | |
| | | // 设置编辑器内容 |
| | | if (this.$refs.materialEditor && data.reportContent) { |
| | | this.$refs.materialEditor.setContent(data.reportContent); |
| | | } |
| | | }).catch(err => { |
| | | this.$message.error('获取详情失败'); |
| | | }); |
| | | }, |
| | | handlePreview(file) { |
| | | if (file && file.url) { |
| | | // 判断是否为图片文件 |
| | |
| | | this.submitLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('编辑成功'); |
| | | this.$router.back() |
| | | this.cacheData = null; |
| | | this.$router.back() |
| | | } else { |
| | | this.$message.error(res.msg || '编辑失败'); |
| | | this.submitLoading = false; |
| | |
| | | this.submitLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('发送成功'); |
| | | this.$router.push('/strainReportLibrary/reportLibraryOne'); |
| | | this.cacheData = null; |
| | | this.$router.push('/strainReportLibrary/reportLibraryOne'); |
| | | } else { |
| | | this.$message.error(res.msg || '发送失败'); |
| | | this.submitLoading = false; |
| | |
| | | mounted() { |
| | | this.getLists() |
| | | }, |
| | | activated() { |
| | | this.getLists() |
| | | }, |
| | | methods: { |
| | | viewDetail(row) { |
| | | this.obj = row |
| | |
| | | components: { AiEditor, ChooseProject, SelectMember }, |
| | | data() { |
| | | return { |
| | | cacheData: null, // 👈 添加这一行 |
| | | form: { |
| | | planName: "", |
| | | planCode: "", |
| | |
| | | return this.assessmentTable.reduce((sum, row) => sum + Number(row.selectedScore), 0) |
| | | } |
| | | }, |
| | | // 👇 添加这两个钩子 |
| | | activated() { |
| | | if (this.cacheData) { |
| | | // 恢复表单数据 |
| | | this.form = JSON.parse(JSON.stringify(this.cacheData.form)); |
| | | // 恢复文件列表 |
| | | this.fileList = JSON.parse(JSON.stringify(this.cacheData.fileList || [])); |
| | | // 恢复考核表数据 |
| | | this.assessmentTable = JSON.parse(JSON.stringify(this.cacheData.assessmentTable || [])); |
| | | // 恢复选中的成员 |
| | | this.selectedMember = this.cacheData.selectedMember ? JSON.parse(JSON.stringify(this.cacheData.selectedMember)) : null; |
| | | // 恢复项目数据 |
| | | this.projectData = JSON.parse(JSON.stringify(this.cacheData.projectData || [])); |
| | | // 恢复编辑器内容 |
| | | this.$nextTick(() => { |
| | | if (this.$refs.materialEditor && this.cacheData.reportContent) { |
| | | this.$refs.materialEditor.setContent(this.cacheData.reportContent); |
| | | } |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 没有缓存时,如果有id则加载详情 |
| | | if (this.$route.query.id) { |
| | | this.getDetailData(); |
| | | } |
| | | }, |
| | | |
| | | deactivated() { |
| | | // 缓存所有数据 |
| | | this.cacheData = { |
| | | form: JSON.parse(JSON.stringify(this.form)), |
| | | fileList: JSON.parse(JSON.stringify(this.fileList)), |
| | | assessmentTable: JSON.parse(JSON.stringify(this.assessmentTable)), |
| | | selectedMember: this.selectedMember ? JSON.parse(JSON.stringify(this.selectedMember)) : null, |
| | | projectData: JSON.parse(JSON.stringify(this.projectData)), |
| | | reportContent: this.$refs.materialEditor ? this.$refs.materialEditor.getContent() : '' |
| | | }; |
| | | }, |
| | | mounted() { |
| | | // 滚动到页面顶部 |
| | | this.$nextTick(() => { |
| | | window.scrollTo(0, 0); |
| | | }); |
| | | if (this.$route.query.id) { |
| | | if (this.$route.query.id && !this.cacheData) { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | this.form = { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 👇 添加这个方法 |
| | | getDetailData() { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | this.form = { |
| | | ...this.form, |
| | | ...data, |
| | | processData: [] |
| | | }; |
| | | |
| | | let arr = []; |
| | | if (data.evaluate) { |
| | | arr = data.evaluate.split(','); |
| | | } else { |
| | | arr = this.assessmentTable.map(() => 0); |
| | | } |
| | | |
| | | this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : []); |
| | | |
| | | this.assessmentTable = this.assessmentTable.map((item, index) => { |
| | | item.selectedScore = Number(arr[index] ?? 0); |
| | | return item; |
| | | }); |
| | | |
| | | this.selectedMember = [{ |
| | | nickName: data.experimentName, |
| | | userId: data.experimentId |
| | | }]; |
| | | |
| | | this.projectData = data.projectTeam ? |
| | | [{ ...data.projectTeam, staffName: data.projectTeam.staff || '' }] : |
| | | []; |
| | | |
| | | // 设置编辑器内容 |
| | | if (this.$refs.materialEditor && data.reportContent) { |
| | | this.$refs.materialEditor.setContent(data.reportContent); |
| | | } |
| | | }).catch(err => { |
| | | this.$message.error('获取详情失败'); |
| | | }); |
| | | }, |
| | | handlePreview(file) { |
| | | if (file && file.url) { |
| | | // 判断是否为图片文件 |
| | |
| | | this.submitLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('编辑成功'); |
| | | this.cacheData = null; // 👈 添加这一行 |
| | | this.$router.back() |
| | | } |
| | | }).catch(() => { |
| | |
| | | this.submitLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('发送成功'); |
| | | this.cacheData = null; // 👈 添加这一行 |
| | | this.$router.push('/strainReportLibrary/reportLibraryFour'); |
| | | } |
| | | }).catch(() => { |
| | |
| | | const params = { |
| | | isDraft: 1, |
| | | projectId: this.projectData[0].id, |
| | | experimentId: this.selectedMember[0].userId, |
| | | // experimentId: this.selectedMember[0].userId, |
| | | enclosureUrl: this.fileList.length && JSON.stringify(this.fileList), |
| | | // reportCode: this.form.reportCode, |
| | | reportContent: this.$refs.materialEditor.getContent(), |
| | |
| | | this.submitLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('编辑成功'); |
| | | this.cacheData = null; // 👈 添加这一行 |
| | | this.$router.back() |
| | | } |
| | | }).catch(() => { |
| | |
| | | this.draftLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('保存成功'); |
| | | this.cacheData = null; // 👈 添加这一行 |
| | | this.$router.push('/strainReportLibrary/reportLibraryFour'); |
| | | } |
| | | }).catch(() => { |
| | |
| | | }, |
| | | mounted() { |
| | | this.getLists() |
| | | },activated() { |
| | | this.getLists() |
| | | }, |
| | | methods: { |
| | | viewEvaluate() { |
| | |
| | | components: { AiEditor, ChooseProject, SelectMember }, |
| | | data() { |
| | | return { |
| | | cacheData: null, |
| | | form: { |
| | | planName: "", |
| | | planCode: "", |
| | |
| | | return this.assessmentTable.reduce((sum, row) => sum + Number(row.selectedScore), 0) |
| | | } |
| | | }, |
| | | // 👇 添加这两个钩子 |
| | | activated() { |
| | | if (this.cacheData) { |
| | | // 恢复表单数据 |
| | | this.form = JSON.parse(JSON.stringify(this.cacheData.form)); |
| | | // 恢复文件列表 |
| | | this.fileList = JSON.parse(JSON.stringify(this.cacheData.fileList || [])); |
| | | // 恢复考核表数据 |
| | | this.assessmentTable = JSON.parse(JSON.stringify(this.cacheData.assessmentTable || [])); |
| | | // 恢复选中的成员 |
| | | this.selectedMember = this.cacheData.selectedMember ? JSON.parse(JSON.stringify(this.cacheData.selectedMember)) : null; |
| | | // 恢复项目数据 |
| | | this.projectData = JSON.parse(JSON.stringify(this.cacheData.projectData || [])); |
| | | // 恢复编辑器内容 |
| | | this.$nextTick(() => { |
| | | if (this.$refs.materialEditor && this.cacheData.reportContent) { |
| | | this.$refs.materialEditor.setContent(this.cacheData.reportContent); |
| | | } |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 没有缓存时,如果有id则加载详情 |
| | | if (this.$route.query.id) { |
| | | this.getDetailData(); |
| | | } |
| | | }, |
| | | deactivated() { |
| | | // 缓存所有数据 |
| | | this.cacheData = { |
| | | form: JSON.parse(JSON.stringify(this.form)), |
| | | fileList: JSON.parse(JSON.stringify(this.fileList)), |
| | | assessmentTable: JSON.parse(JSON.stringify(this.assessmentTable)), |
| | | selectedMember: this.selectedMember ? JSON.parse(JSON.stringify(this.selectedMember)) : null, |
| | | projectData: JSON.parse(JSON.stringify(this.projectData)), |
| | | reportContent: this.$refs.materialEditor ? this.$refs.materialEditor.getContent() : '' |
| | | }; |
| | | }, |
| | | mounted() { |
| | | // 滚动到页面顶部 |
| | | this.$nextTick(() => { |
| | | window.scrollTo(0, 0); |
| | | }); |
| | | if (this.$route.query.id) { |
| | | if (this.$route.query.id && !this.cacheData) { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | this.form = { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 👇 添加这个方法 |
| | | getDetailData() { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | this.form = { |
| | | ...this.form, |
| | | ...data, |
| | | processData: [] |
| | | }; |
| | | |
| | | // 添加空值判断 |
| | | let arr = []; |
| | | if (data.evaluate) { |
| | | arr = data.evaluate.split(','); |
| | | } else { |
| | | arr = this.assessmentTable.map(() => 0); |
| | | } |
| | | |
| | | this.selectedMember = [{ |
| | | nickName: data.experimentName, |
| | | userId: data.experimentId |
| | | }]; |
| | | this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : []); |
| | | |
| | | this.assessmentTable = this.assessmentTable.map((item, index) => { |
| | | item.selectedScore = Number(arr[index] ?? 0); |
| | | return item; |
| | | }); |
| | | |
| | | this.projectData = data.projectTeam ? |
| | | [{ ...data.projectTeam, staffName: data.projectTeam.staff || '' }] : |
| | | []; |
| | | |
| | | // 设置编辑器内容 |
| | | if (this.$refs.materialEditor && data.reportContent) { |
| | | this.$refs.materialEditor.setContent(data.reportContent); |
| | | } |
| | | }).catch(err => { |
| | | console.log(err); |
| | | this.$message.error('获取详情失败'); |
| | | }); |
| | | }, |
| | | handlePreview(file) { |
| | | if (file && file.url) { |
| | | // 判断是否为图片文件 |
| | |
| | | if (res.code == 200) { |
| | | this.$message.success('编辑成功'); |
| | | this.$router.back() |
| | | this.cacheData = null; |
| | | } else { |
| | | this.$message.error(res.message || '编辑失败'); |
| | | } |
| | |
| | | if (res.code == 200) { |
| | | this.$message.success('发送成功'); |
| | | this.$router.back() |
| | | this.cacheData = null; |
| | | } else { |
| | | this.$message.error(res.message || '发送失败'); |
| | | } |
| | |
| | | mounted() { |
| | | this.getLists() |
| | | }, |
| | | activated() { |
| | | this.getLists() |
| | | }, |
| | | methods: { |
| | | viewEvaluate() { |
| | | this.obj.viewDetail = true |
| | |
| | | <script> |
| | | import AiEditor from '@/components/AiEditor' |
| | | import ChooseProject from '@/components/chooseProject/index.vue' |
| | | import { customUploadRequest, getFullUrl, downloadFileByUrl, getAllocateIp, isImageFile } from "@/utils/utils"; |
| | | import {customUploadRequest, downloadFileByUrl, getAllocateIp, getFullUrl, isImageFile} from "@/utils/utils"; |
| | | import SelectMember from '@/components/SelectMember' |
| | | import { add, getDetail, update } from './service' |
| | | import {add, getDetail, update} from './service' |
| | | |
| | | export default { |
| | | components: { AiEditor, ChooseProject, SelectMember }, |
| | |
| | | }, |
| | | status: "1", |
| | | remark: "", |
| | | queryForm: { |
| | | cacheData: null, // 👈 添加这一行 |
| | | queryForm: { |
| | | |
| | | }, |
| | | assessmentTable: [ |
| | |
| | | return this.assessmentTable.reduce((sum, row) => sum + Number(row.selectedScore), 0) |
| | | } |
| | | }, |
| | | // 👇 添加这两个钩子 |
| | | activated() { |
| | | if (this.cacheData) { |
| | | // 恢复表单数据 |
| | | this.form = JSON.parse(JSON.stringify(this.cacheData.form)); |
| | | // 恢复文件列表 |
| | | this.fileList = JSON.parse(JSON.stringify(this.cacheData.fileList || [])); |
| | | // 恢复考核表数据 |
| | | this.assessmentTable = JSON.parse(JSON.stringify(this.cacheData.assessmentTable || [])); |
| | | // 恢复选中的成员 |
| | | this.selectedMember = this.cacheData.selectedMember ? JSON.parse(JSON.stringify(this.cacheData.selectedMember)) : null; |
| | | // 恢复项目数据 |
| | | this.projectData = JSON.parse(JSON.stringify(this.cacheData.projectData || [])); |
| | | // 恢复编辑器内容 |
| | | this.$nextTick(() => { |
| | | if (this.$refs.materialEditor && this.cacheData.reportContent) { |
| | | this.$refs.materialEditor.setContent(this.cacheData.reportContent); |
| | | } |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 没有缓存时,如果有id则加载详情 |
| | | if (this.$route.query.id) { |
| | | this.getDetailData(); |
| | | } |
| | | }, |
| | | deactivated() { |
| | | // 缓存所有数据 |
| | | this.cacheData = { |
| | | form: JSON.parse(JSON.stringify(this.form)), |
| | | fileList: JSON.parse(JSON.stringify(this.fileList)), |
| | | assessmentTable: JSON.parse(JSON.stringify(this.assessmentTable)), |
| | | selectedMember: this.selectedMember ? JSON.parse(JSON.stringify(this.selectedMember)) : null, |
| | | projectData: JSON.parse(JSON.stringify(this.projectData)), |
| | | reportContent: this.$refs.materialEditor ? this.$refs.materialEditor.getContent() : '' |
| | | }; |
| | | }, |
| | | mounted() { |
| | | // 滚动到页面顶部 |
| | | this.$nextTick(() => { |
| | | window.scrollTo(0, 0); |
| | | }); |
| | | if (this.$route.query.id) { |
| | | if (this.$route.query.id && !this.cacheData) { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | this.form = { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 👇 添加这个方法 |
| | | getDetailData() { |
| | | getDetail(this.$route.query.id).then(res => { |
| | | const data = res.data || res; |
| | | this.form = { |
| | | ...this.form, |
| | | ...data, |
| | | processData: [] |
| | | }; |
| | | |
| | | let arr = []; |
| | | if (data.evaluate) { |
| | | arr = data.evaluate.split(','); |
| | | } else { |
| | | arr = this.assessmentTable.map(() => 0); |
| | | } |
| | | |
| | | this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : []); |
| | | |
| | | this.assessmentTable = this.assessmentTable.map((item, index) => { |
| | | item.selectedScore = Number(arr[index] ?? 0); |
| | | return item; |
| | | }); |
| | | |
| | | this.selectedMember = [{ |
| | | nickName: data.experimentName, |
| | | userId: data.experimentId |
| | | }]; |
| | | |
| | | this.projectData = data.projectTeam ? |
| | | [{ ...data.projectTeam, staffName: data.projectTeam.staff || '' }] : |
| | | []; |
| | | |
| | | // 设置编辑器内容 |
| | | if (this.$refs.materialEditor && data.reportContent) { |
| | | this.$refs.materialEditor.setContent(data.reportContent); |
| | | } |
| | | }).catch(err => { |
| | | this.$message.error('获取详情失败'); |
| | | }); |
| | | }, |
| | | handlePreview(file) { |
| | | if (file && file.url) { |
| | | // 判断是否为图片文件 |
| | |
| | | if (res.code == 200) { |
| | | this.$message.success('编辑成功'); |
| | | this.$router.back() |
| | | this.cacheData = null; |
| | | } |
| | | }).catch(() => { |
| | | this.submitLoading = false; |
| | |
| | | if (res.code == 200) { |
| | | this.$message.success('发送成功'); |
| | | this.$router.push('/strainReportLibrary/reportLibraryThree'); |
| | | this.cacheData = null; |
| | | } else { |
| | | this.$message.error(res.msg || '发送失败'); |
| | | } |
| | |
| | | }, |
| | | saveData() { |
| | | if (this.saveLoading) return; |
| | | this.saveLoading = true; |
| | | this.$refs.form.validate(async (valid) => { |
| | | if (!valid) { this.saveLoading = false; return; } |
| | | let str = [] |
| | | this.saveLoading = true; |
| | | this.$refs.form.validate(async (valid) => { |
| | | if (!valid) { |
| | | this.saveLoading = false; |
| | | return; |
| | | } |
| | | console.log('5'); |
| | | let str = []; |
| | | str = this.assessmentTable.map(item => { |
| | | return item.selectedScore |
| | | }) |
| | | console.log('6'); |
| | | |
| | | try { |
| | | |
| | | const params = { |
| | | isDraft: 1, |
| | | projectId: this.projectData[0].id, |
| | | experimentId: this.selectedMember[0].userId, |
| | | // experimentId: this.selectedMember[0].userId, |
| | | enclosureUrl: this.fileList.length && JSON.stringify(this.fileList), |
| | | // reportCode: this.form.reportCode, |
| | | reportContent: this.$refs.materialEditor.getContent(), |
| | |
| | | evaluate: str.join(','), |
| | | reportType: 3 |
| | | }; |
| | | console.log('7'); |
| | | add(params).then(res => { |
| | | if (res.code == 200) { |
| | | console.log('8', res); |
| | | if (res.code == 200) { |
| | | this.$message.success('保存成功'); |
| | | this.$router.back() |
| | | } else { |
| | | console.log('接口报错', res.msg); |
| | | this.$message.error(res.msg || '保存失败'); |
| | | } |
| | | }).catch(() => { |
| | | this.$message.error('保存失败'); |
| | | }).finally(() => { |
| | | this.saveLoading = false; |
| | | console.log('报错:') |
| | | this.saveLoading = false; |
| | | }); |
| | | } catch (e) { |
| | | this.$message.error('保存失败'); |
| | |
| | | }, |
| | | mounted() { |
| | | this.getLists() |
| | | },activated() { |
| | | this.getLists() |
| | | }, |
| | | methods: { |
| | | viewEvaluate() { |
| | |
| | | created() { |
| | | this.fetchData() |
| | | }, |
| | | activated() { |
| | | this.fetchData() |
| | | }, |
| | | methods: { |
| | | handleSizeChange(val) { |
| | | this.queryForm.pageSize = val |
| | |
| | | created() { |
| | | this.getListData() |
| | | }, |
| | | activated() { |
| | | this.getListData() |
| | | }, |
| | | mounted() { }, |
| | | methods: { |
| | | add() { |
| | |
| | | this.getRoleList() |
| | | this.getListData() |
| | | }, |
| | | activated() { |
| | | this.getRoleList() |
| | | this.getListData() |
| | | }, |
| | | mounted() { }, |
| | | methods: { |
| | | // getTypeList() { |