| | |
| | | <template> |
| | | <div> |
| | | <div class="header-title" style="width: 100%;"> |
| | | <div class="header-title-left"> |
| | | <img src="@/assets/public/headercard.png" /> |
| | | <div>所属项目组</div> |
| | | </div> |
| | | <div class="header-title-right"> |
| | | <el-button @click="showChoose = true" :disabled="!!$route.query.id" class="el-icon-circle-plus-outline" type="primary"> |
| | | 选择项目组</el-button> |
| | | </div> |
| | | </div> |
| | | <Table :height="null" :queryForm="queryForm" :total="0" :data="projectData" style="margin-bottom: 20px"> |
| | | <template> |
| | | <el-table-column prop="teamName" label="项目组名称" /> |
| | | <el-table-column prop="personCharge" label="项目负责人" /> |
| | | <el-table-column prop="staff" label="项目组成员" /> |
| | | <el-table-column prop="createTime" label="创建时间" /> |
| | | </template> |
| | | </Table> |
| | | <el-form :model="form" :rules="rules" ref="pedigreeForm" label-position="top" class="strain-form"> |
| | | <div class="card"> |
| | | <div class="form-items-row"> |
| | |
| | | {{ row.status === 1 ? "保存" : "废弃" }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="菌种入库时间/菌种废弃时间" prop="storageTime" /> |
| | | <el-table-column label="菌种入库时间/菌种废弃时间" prop="createTime" /> |
| | | <el-table-column label="操作" v-if="roleType == 2"> |
| | | <template #default="{ row }"> |
| | | <el-button type="text" @click="handleConfirm(row)">确认入库</el-button> |
| | |
| | | <div class="header"> |
| | | <div class="title">菌种传代生产谱系图</div> |
| | | <div class="option-btn"> |
| | | <el-button type="primary" class="el-icon-plus" @click="addNode" v-if="roleType == 3 || roleType == 1"> |
| | | <el-button type="primary" class="el-icon-plus" @click="addNode" :disabled="editBoolean" v-if="!isReadOnly && (roleType == 3 || roleType == 1)"> |
| | | <!-- v-if="$route.query.type != 1" --> |
| | | 新增</el-button> |
| | | <el-button type="primary" v-if="roleType == 3 || roleType == 1" |
| | | <el-button type="primary" v-if="!isReadOnly && (roleType == 3 || roleType == 1)" :disabled="editBoolean" |
| | | @click="setGenerationPlan">设置传代计划数</el-button> |
| | | <el-button type="primary" @click="showDetail">详情</el-button> |
| | | <el-button type="primary" @click="handleEdit" v-if="roleType == 1 || roleType == 3">编辑</el-button> |
| | | <el-button type="primary" @click="handleDelete" v-if="roleType == 1 || roleType == 3">删除</el-button> |
| | | <el-button type="primary" @click="handleEdit" v-if="!isReadOnly && (roleType == 1 || roleType == 3)" :disabled="editBoolean">编辑</el-button> |
| | | <el-button type="primary" @click="handleDelete" v-if="!isReadOnly && (roleType == 1 || roleType == 3)" :disabled="editBoolean">删除</el-button> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="strain-flow-chart"> |
| | | <div id="mountNode"></div> |
| | | <div ref="mountNode" class="mount-node"></div> |
| | | </div> |
| | | <div v-if="roleType == 1 || roleType == 3"> |
| | | <el-button type="primary" @click="handleSubmit('1')" style="width: 150px">保存</el-button> |
| | | <el-button type="primary" @click="handleSubmit('2')" style="width: 150px; margin-left: 20px">提交</el-button> |
| | | <div v-if="!isReadOnly && (roleType == 1 || roleType == 3)"> |
| | | <el-button type="primary" @click="handleSubmit('1')" style="width: 150px" :disabled="editBoolean">保存</el-button> |
| | | <el-button type="primary" @click="handleSubmit('2')" style="width: 150px; margin-left: 20px" :disabled="editBoolean">提交</el-button> |
| | | </div> |
| | | </div> |
| | | </el-form> |
| | | |
| | | <AddAncestor ref="addAncestor" @addNodeSign="addNodeSign" /> |
| | | <PlanForm ref="planForm" @addNodeSign="addNodeSign" /> |
| | | <AddSublevelForm ref="addSublevelForm" @addNodeSign="addNodeSign" /> |
| | | <ConfirmStorageDialog name="接种操作人签字" :visible.sync="confirmStorageDialogVisible" |
| | | <AddAncestor :key="pageInstanceKey" ref="addAncestor" @addNodeSign="addNodeSign" /> |
| | | <PlanForm :key="pageInstanceKey" ref="planForm" @addNodeSign="addNodeSign" /> |
| | | <AddSublevelForm :key="pageInstanceKey" ref="addSublevelForm" @addNodeSign="addNodeSign" /> |
| | | <ConfirmStorageDialog :key="`signature-${pageInstanceKey}`" name="接种操作人签字" :visible.sync="confirmStorageDialogVisible" |
| | | @confirm="handleSignatureConfirm" /> |
| | | <!-- 菌种工程师 --> |
| | | <ConfirmStorageDialog name="菌种保藏人签字" text="是否确认该项菌种信息入库" :visible.sync="storageVisible" |
| | | <ConfirmStorageDialog :key="`storage-${pageInstanceKey}`" name="菌种保藏人签字" text="是否确认该项菌种信息入库" :visible.sync="storageVisible" |
| | | @confirm="handleSignatureConfirm1" /> |
| | | <!-- 传代数审批 --> |
| | | <ApprovalCount ref="approvalCount" @addNodeSign="sureApprovalCountSign" /> |
| | | <ApprovalCount :key="`approval-${pageInstanceKey}`" ref="approvalCount" @addNodeSign="sureApprovalCountSign" /> |
| | | <chooseProject :key="`project-${pageInstanceKey}`" @submit="getProjectData" :show="showChoose" @close="showChoose = false"></chooseProject> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | confirmCount, |
| | | } from "./service"; |
| | | import ApprovalCount from "./progenitorComponents/approvalCount.vue"; |
| | | import ChooseProject from "@/components/chooseProject/index.vue"; |
| | | |
| | | export default { |
| | | name: "AddPedigree", |
| | | components: { |
| | | ChooseProject, |
| | | PlanForm, |
| | | AddAncestor, |
| | | AddSublevelForm, |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | showChoose: false, |
| | | projectData: [], // 存储选中的项目组数据 |
| | | queryForm: { |
| | | pageSize: 10, |
| | | pageNum: 1, |
| | |
| | | tableData: [], |
| | | confirmStorageDialogVisible: false, |
| | | storageVisible: false, |
| | | editBoolean: false,//编辑控制 |
| | | total: 0, |
| | | current: 1, |
| | | size: 10, |
| | |
| | | pageSize: 10, |
| | | pageNum: 1, |
| | | }, |
| | | activeRouteKey: "", |
| | | graphLoadId: 0, |
| | | pageInstanceKey: 0, |
| | | }; |
| | | }, |
| | | computed: { |
| | | isReadOnly() { |
| | | return this.$route.path.includes('detail') || this.$route.query.mode === 'detail'; |
| | | }, |
| | | canAddNode() { |
| | | // 如果没有节点,可以新增母代 |
| | | if (this.graphData.nodes.length === 0) { |
| | |
| | | return false; |
| | | }, |
| | | }, |
| | | created() { |
| | | watch: { |
| | | '$route': { |
| | | immediate: true, |
| | | handler(to) { |
| | | if (!["AddProgenitor", "DetailProgenitor"].includes(to.name)) { |
| | | return; |
| | | } |
| | | console.log('变动'); |
| | | const routeKey = to.fullPath; |
| | | const routeChanged = this.activeRouteKey && this.activeRouteKey !== routeKey; |
| | | this.activeRouteKey = routeKey; |
| | | if (routeChanged || !to.query.id) { |
| | | this.resetPageState(); |
| | | } |
| | | if (this.graph && to.query.id) { |
| | | this.reloadData(); |
| | | } |
| | | |
| | | this.editBoolean = this.shouldDisableEditing(to.query); |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.resetMountNode(); |
| | | if (this.$route.query.id) { |
| | | this.reloadData(); |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.initGraph(); |
| | | this.initEvents(); |
| | | }, |
| | | beforeDestroy() { |
| | | this.graph?.destroy(); |
| | | window.removeEventListener("resize", this.handleResize); |
| | | this.destroyGraph(); |
| | | }, |
| | | methods: { |
| | | shouldDisableEditing(query = this.$route.query) { |
| | | const status = query && query.status; |
| | | return Number(this.roleType) !== 1 |
| | | && status !== undefined |
| | | && status !== null |
| | | && status !== "" |
| | | && Number(status) !== 1; |
| | | }, |
| | | destroyGraph() { |
| | | window.removeEventListener("resize", this.handleResize); |
| | | if (this.graph && !this.graph.get("destroyed")) { |
| | | this.graph.destroy(); |
| | | } |
| | | this.graph = null; |
| | | |
| | | const container = this.$refs.mountNode; |
| | | if (container) { |
| | | while (container.firstChild) { |
| | | container.removeChild(container.firstChild); |
| | | } |
| | | } |
| | | }, |
| | | resetMountNode() { |
| | | this.destroyGraph(); |
| | | if (!this.$refs.mountNode) return; |
| | | this.initGraph(); |
| | | this.initEvents(); |
| | | }, |
| | | resetPageState() { |
| | | this.pageInstanceKey += 1; |
| | | this.form = { |
| | | strainCode: "", |
| | | strainName: "", |
| | | generationType: "2", |
| | | }; |
| | | this.projectData = []; |
| | | this.tableData = []; |
| | | this.newTableData = []; |
| | | this.total = 0; |
| | | this.current = 1; |
| | | this.size = 10; |
| | | this.newTotal = 0; |
| | | this.newCurrent = 1; |
| | | this.newSize = 10; |
| | | this.queryForm = { pageSize: 10, pageNum: 1 }; |
| | | this.newQueryForm = { pageSize: 10, pageNum: 1 }; |
| | | this.showChoose = false; |
| | | this.dialogVisible = false; |
| | | this.confirmStorageDialogVisible = false; |
| | | this.storageVisible = false; |
| | | this.nodeData = {}; |
| | | this.nodeType = ""; |
| | | this.isAddingNode = false; |
| | | this.showDiscarded = false; |
| | | this.editBoolean = this.shouldDisableEditing(); |
| | | this.resetGraphData(); |
| | | this.$nextTick(() => { |
| | | this.$refs.pedigreeForm && this.$refs.pedigreeForm.clearValidate(); |
| | | }); |
| | | }, |
| | | resetGraphData() { |
| | | this.graphLoadId += 1; |
| | | this.graphData = { |
| | | nodes: [], |
| | | edges: [], |
| | | }; |
| | | this.selectedNode = null; |
| | | this.nodeCount = 0; |
| | | |
| | | if (this.graph) { |
| | | this.graph.changeData({ nodes: [], edges: [] }); |
| | | this.graph.render(); |
| | | } |
| | | }, |
| | | getProjectData(data) { |
| | | this.projectData = [data]; // 将选中的项目组数据存储到数组中 |
| | | this.showChoose = false; |
| | | this.form.projectId = this.projectData[0].id; |
| | | }, |
| | | handleDelete() { |
| | | console.log('handleDelete selectedNode', this.selectedNode) |
| | | if (!this.selectedNode) { |
| | |
| | | this.$message.warning("谱系图已提交,不能删除"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | this.$confirm("确定删除该节点吗?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | |
| | | // 前端删除节点方法 |
| | | deleteNodeFromGraph(nodeId) { |
| | | // 递归删除节点 |
| | |
| | | |
| | | // 执行删除 |
| | | const deleted = deleteNodeRecursive(this.graphData.nodes, nodeId); |
| | | |
| | | |
| | | if (deleted) { |
| | | // 清空选中节点 |
| | | this.selectedNode = null; |
| | | |
| | | |
| | | // 转换树形数据为G6可用的格式 |
| | | const convertToG6Data = (nodes) => { |
| | | const g6Nodes = []; |
| | |
| | | |
| | | if (nodeModel.label === "祖代") { |
| | | this.$refs.addAncestor.openInitData({ |
| | | id: nodeModel.id, |
| | | ...nodeModel.data, |
| | | formStatus: "edit", |
| | | }); |
| | |
| | | } |
| | | }, |
| | | async reloadData() { |
| | | this.getList(); |
| | | this.getNewList(); |
| | | this.resetPageState(); |
| | | this.resetMountNode(); |
| | | const graphLoadId = this.graphLoadId; |
| | | const routeKey = this.$route.fullPath; |
| | | await this.getList(); |
| | | await this.getNewList(); |
| | | if (graphLoadId !== this.graphLoadId || routeKey !== this.$route.fullPath) { |
| | | return; |
| | | } |
| | | if (!this.$route.query.id) { |
| | | return |
| | | } |
| | | getDetail({ id: this.$route.query.id }).then((res) => { |
| | | console.log("详情数据", res); |
| | | if (graphLoadId !== this.graphLoadId || routeKey !== this.$route.fullPath) { |
| | | return; |
| | | } |
| | | this.projectData = res.tprojectTeamList |
| | | const detailData = res.pedigreeChartParentAllDetailDTO; |
| | | // 设置基础表单数据 |
| | | this.form = { |
| | |
| | | // 递归处理节点数据,构建树形结构 |
| | | function processNode(node, parentType = null) { |
| | | // label 逻辑与新增时保持一致 |
| | | let roleType= JSON.parse(sessionStorage.getItem("userInfo")).roleType || 1 |
| | | let roleType= Number(JSON.parse(sessionStorage.getItem("userInfo")).roleType || 1) |
| | | let label = ""; |
| | | if (node.type === 2) { |
| | | label = "传代计划数"; |
| | |
| | | } |
| | | |
| | | if (node.children && node.children.length > 0) { |
| | | // 根据子节点的 codeStatus 和 roleType 决定是否处理子节点 |
| | | // codeStatus == 2: 处理 |
| | | // codeStatus == 1 且 roleType == 3: 处理 |
| | | // codeStatus == 1 且 roleType != 3: 不处理(过滤掉) |
| | | // 审批人需要查看完整谱系,包括仍处于保存状态的节点。 |
| | | processedNode.children = node.children |
| | | .filter((child) => child.codeStatus == 2 || (child.codeStatus == 1 && roleType == 3)) |
| | | .filter((child) => roleType === 2 || child.codeStatus == 2 || (child.codeStatus == 1 && roleType === 3)) |
| | | .map((child) => processNode(child, node.type)); |
| | | } |
| | | return processedNode; |
| | |
| | | this.$nextTick(() => { |
| | | console.log('this.graphData.nodes',this.graphData.nodes) |
| | | if (this.graph && this.graphData.nodes.length > 0) { |
| | | // 转换树形数据为G6可用的格式 |
| | | const convertToG6Data = (nodes) => { |
| | | const g6Nodes = []; |
| | | const g6Edges = []; |
| | | |
| | | const processNode = (node, parentId = null) => { |
| | | g6Nodes.push({ |
| | | id: node.id, |
| | | label: node.label, |
| | | number: node.number, |
| | | data: node.data, |
| | | isDiscarded: node.isDiscarded, |
| | | style: node.style, |
| | | planCount: node.planCount, |
| | | currentCount: node.currentCount, |
| | | }); |
| | | |
| | | if (parentId) { |
| | | g6Edges.push({ |
| | | source: parentId, |
| | | target: node.id, |
| | | style: { |
| | | stroke: "rgba(4, 156, 154, 1)", |
| | | lineWidth: 1, |
| | | }, |
| | | }); |
| | | } |
| | | |
| | | if (node.children && node.children.length > 0) { |
| | | node.children.forEach((child) => processNode(child, node.id)); |
| | | } |
| | | }; |
| | | |
| | | nodes.forEach((node) => processNode(node)); |
| | | return { nodes: g6Nodes, edges: g6Edges }; |
| | | }; |
| | | |
| | | const g6Data = convertToG6Data(this.graphData.nodes); |
| | | const g6Data = this.convertToG6Data(this.graphData.nodes); |
| | | this.graph.changeData(g6Data); |
| | | this.graph.render(); |
| | | this.graph.fitView(); |
| | |
| | | }); |
| | | }); |
| | | }, |
| | | // 转换树形数据为G6可用的格式 |
| | | convertToG6Data(nodes) { |
| | | const g6Nodes = []; |
| | | const g6Edges = []; |
| | | |
| | | const processNode = (node, parentId = null) => { |
| | | g6Nodes.push({ |
| | | id: node.id, |
| | | label: node.label, |
| | | number: node.number, |
| | | data: node.data, |
| | | isDiscarded: node.isDiscarded, |
| | | style: node.style, |
| | | planCount: node.planCount, |
| | | currentCount: node.currentCount, |
| | | }); |
| | | |
| | | if (parentId) { |
| | | g6Edges.push({ |
| | | source: parentId, |
| | | target: node.id, |
| | | style: { |
| | | stroke: "rgba(4, 156, 154, 1)", |
| | | lineWidth: 1, |
| | | }, |
| | | }); |
| | | } |
| | | |
| | | if (node.children && node.children.length > 0) { |
| | | node.children.forEach((child) => processNode(child, node.id)); |
| | | } |
| | | }; |
| | | |
| | | nodes.forEach((node) => processNode(node)); |
| | | return { nodes: g6Nodes, edges: g6Edges }; |
| | | }, |
| | | addNodeSign(value, type) { |
| | | this.nodeData = value; |
| | | //todo 同步画布数据 nodeData.strainType |
| | | this.nodeType = type; |
| | | // this.$refs.addAncestor.closeDialog() |
| | | this.$refs.addSublevelForm.closeDialog(); |
| | |
| | | edit({ ...baseData, id: this.$route.query.id }).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message.success("编辑成功"); |
| | | this.$router.back(); |
| | | this.$closeCurrentView('/strain/pedigree-vhart'); |
| | | } |
| | | }); |
| | | return; |
| | |
| | | add(baseData).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message.success("保存成功"); |
| | | this.$router.back(); |
| | | this.$closeCurrentView('/strain/pedigree-vhart'); |
| | | } |
| | | }); |
| | | } |
| | |
| | | // 实现存草稿逻辑 |
| | | }, |
| | | handleCancel() { |
| | | this.$router.back(); |
| | | this.$closeCurrentView('/strain/pedigree-vhart'); |
| | | }, |
| | | handleSignatureConfirm(signatureImage) { |
| | | this.confirmStorageDialogVisible = false; |
| | |
| | | } |
| | | }, |
| | | handleAddParent(value) { |
| | | console.log('value编辑 编辑修改', value); |
| | | console.log('handleAddParent 编辑修改', value); |
| | | if (value.formStatus == "edit") { |
| | | updateChild({ ...value, codeStatus: '1' }).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message.success("操作成功"); |
| | | this.$refs.addAncestor.closeDialog(); |
| | | this.reloadData(); |
| | | |
| | | // this.reloadData(); |
| | | // 1. 如果是编辑模式(前端编辑),先删除旧节点 |
| | | if (this.selectedNode) { |
| | | // 删除旧节点 |
| | | this.deleteNodeFromGraph(this.selectedNode.id); |
| | | } |
| | | } |
| | | }); |
| | | return; |
| | | // return; |
| | | } |
| | | if (this.$route.query.id) { |
| | | value.pedigreeChartId = this.$route.query.id; |
| | |
| | | } |
| | | }, |
| | | initGraph() { |
| | | const container = document.getElementById("mountNode"); |
| | | const container = this.$refs.mountNode; |
| | | if (!container) return; |
| | | const width = container.scrollWidth; |
| | | const height = container.scrollHeight || 600; |
| | | |
| | |
| | | }); |
| | | |
| | | this.graph = new G6.Graph({ |
| | | container: "mountNode", |
| | | container, |
| | | width, |
| | | height, |
| | | fitView: true, |
| | |
| | | evt.preventDefault(); // 阻止默认触摸行为 |
| | | const node = evt.item; |
| | | const nodeModel = node.getModel(); |
| | | // 如果节点已废弃,不允许任何操作 |
| | | if (!nodeModel.isDiscarded) { |
| | | this.$message.warning("该节点已废弃,不能进行操作"); |
| | | return; |
| | | } |
| | | // 如果节点已废弃,不允许任何操作 放开 |
| | | // if (!nodeModel.isDiscarded) { |
| | | // this.$message.warning("该节点已废弃,不能进行操作"); |
| | | // return; |
| | | // } |
| | | // 更新选中节点 |
| | | this.selectedNode = nodeModel; |
| | | // 更新节点选中状态 |
| | |
| | | }, |
| | | handleResize() { |
| | | if (this.graph) { |
| | | const container = document.getElementById("mountNode"); |
| | | const container = this.$refs.mountNode; |
| | | if (!container) return; |
| | | const width = container.scrollWidth; |
| | | const height = container.scrollHeight || 600; |
| | | this.graph.changeSize(width, height); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | .header-title { |
| | | display: flex; |
| | | align-items: center; |
| | | flex-wrap: wrap; |
| | | gap: 13px; |
| | | |
| | | .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; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | .strain-form { |
| | | width: 100%; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | #mountNode { |
| | | .mount-node { |
| | | flex: 1; |
| | | width: 100%; |
| | | min-height: 500px; |