diff --git a/web-vue/src/pages/dispatch/list.vue b/web-vue/src/pages/dispatch/list.vue index 8ca129e5b..5ebe98e99 100644 --- a/web-vue/src/pages/dispatch/list.vue +++ b/web-vue/src/pages/dispatch/list.vue @@ -50,8 +50,8 @@ - - + + @@ -74,15 +74,15 @@ @change="handleChange" /> --> - + 节点: @@ -91,7 +91,14 @@ 项目: - + {{ project.name }} @@ -112,7 +119,7 @@ - + @@ -330,13 +337,13 @@ export default { list_expanded: {}, linkDispatchVisible: false, editDispatchVisible: false, - editDispatchDialogTitle: '', dispatchVisible: false, drawerTitle: "", drawerFileVisible: false, drawerConsoleVisible: false, nodeNameList: [], dispatchList: [], + totalProjectNum: 0, columns: [ { title: "分发 ID", dataIndex: "id", width: 100, ellipsis: true, scopedSlots: { customRender: "id" } }, { title: "分发名称", dataIndex: "name", width: 150, ellipsis: true, scopedSlots: { customRender: "name" } }, @@ -353,12 +360,13 @@ export default { { title: "操作", dataIndex: "child-operation", scopedSlots: { customRender: "child-operation" }, width: 200, align: "left" }, ], rules: { - id: [{ required: true, message: "Please input dispatch id", trigger: "blur" }], - name: [{ required: true, message: "Please input dispatch name", trigger: "blur" }], - projectId: [{ required: true, message: "Please select project", trigger: "blur" }], - runMode: [{ required: true, message: "Please select project runMode", trigger: "blur" }], - whitelistDirectory: [{ required: true, message: "Please select project access path", trigger: "blur" }], - lib: [{ required: true, message: "Please input project lib", trigger: "blur" }], + id: [{ required: true, message: "请输入项目ID", trigger: "blur" }], + name: [{ required: true, message: "请输入项目名称", trigger: "blur" }], + projectId: [{ required: true, message: "请选择项目", trigger: "blur" }], + runMode: [{ required: true, message: "请选择项目运行方式", trigger: "blur" }], + whitelistDirectory: [{ required: true, message: "请选择项目白名单路径", trigger: "blur" }], + lib: [{ required: true, message: "请输入项目文件夹", trigger: "blur" }], + afterOpt: [{ required: true, message: "请选择发布后操作", trigger: "blur" }], }, }; }, @@ -518,6 +526,12 @@ export default { if (!valid) { return false; } + // 校验分发节点数据 + if (this.dispatchList.length === 0) { + return this.$message.error('请添加分发节点!'); + } else if (this.dispatchList.length < 2) { + return this.$message.error('至少选择2个节点项目'); + } // 设置 reqId this.temp.reqId = this.reqId; // 提交 @@ -545,11 +559,11 @@ export default { type: "add", id: "", name: "", - afterOpt: "", - runMode: "", + afterOpt: undefined, + runMode: undefined, mainClass: "", javaExtDirsCp: "", - whitelistDirectory: "", + whitelistDirectory: undefined, lib: "", nodeIdList: [], }; @@ -560,7 +574,6 @@ export default { this.loadAccesList(); this.loadReqId(); this.editDispatchVisible = true; - this.editDispatchDialogTitle = '创建分发项目'; this.$nextTick(() => { this.$refs["editDispatchForm"].resetFields(); setTimeout(() => { @@ -612,7 +625,6 @@ export default { this.loadAccesList(); this.loadReqId(); this.editDispatchVisible = true; - this.editDispatchDialogTitle = '编辑分发项目'; }); }, // 添加副本 @@ -820,7 +832,7 @@ export default { onConsoleClose() { this.drawerConsoleVisible = false; }, - //加载节点以及项目 + // 加载节点以及项目 loadNodeList() { this.nodeList = []; getNodeProjectList().then((res) => { @@ -832,8 +844,11 @@ export default { title: node.name, key: node.id, disabled: true, + projectPlaceholder: '请选择项目', + projectDisabled: true, }; node.projects.forEach((project) => { + ++this.totalProjectNum; // 如果项目 ID 存在就不用继续添加 const index = this.projectList.findIndex((p) => p.id === project.id); if (index === -1) { @@ -858,33 +873,42 @@ export default { } }); }, - //选择节点 + // 选择节点 handleNodeListChange(value, index) { + if (this.nodeNameList[value].projects.length === 0) { + this.dispatchList[index].placeholder = '此节点暂无项目'; + this.dispatchList[index].disabled = true; + } else { + this.dispatchList[index].placeholder = '请选择项目'; + this.dispatchList[index].disabled = false; + } //this.projectNameList = this.nodeNameList[value].projects; this.nodeNameList[value].openStatus = false; this.dispatchList[index].project = this.nodeNameList[value].projects; this.dispatchList[index].nodeId = this.nodeNameList[value].id; this.dispatchList[index].index = value; }, - //选择项目 + // 选择项目 handleProjectChange(value, index) { this.dispatchList[index].projectId = value; this.temp["node_" + this.dispatchList[index].nodeId] = value; }, - //添加分发 + // 添加分发 addDispachList() { - this.dispatchList.push({ nodeId: "", projectId: "", index: "", project: [], status: true }); + if (this.dispatchList.length >= this.totalProjectNum) + return this.$message.error('已无更多节点项目,请先创建项目') + this.dispatchList.push({ nodeId: "", projectId: "", index: "", project: [], status: true, placeholder: '请先选择节点', disabled: true }); }, - //删除分发 + // 删除分发 delDispachList(value) { if (this.dispatchList[value].index !== "") { this.nodeNameList[this.dispatchList[value].index].openStatus = true; } - //this.dispatchList.splice(value,1); delete this.temp[`node_${this.dispatchList[value].nodeId}`]; this.dispatchList[value].status = false; + this.dispatchList.splice(value, 1); }, - //清理缓存 + // 清理缓存 clearDispatchList() { this.dispatchList = []; for (let node in this.nodeNameList) { diff --git a/web-vue/src/pages/node/node-layout/project/project-list.vue b/web-vue/src/pages/node/node-layout/project/project-list.vue index 4c93c1033..5719f757c 100644 --- a/web-vue/src/pages/node/node-layout/project/project-list.vue +++ b/web-vue/src/pages/node/node-layout/project/project-list.vue @@ -325,11 +325,11 @@ export default { { title: "操作", dataIndex: "operation", scopedSlots: { customRender: "operation" }, width: 120 }, ], rules: { - id: [{ required: true, message: "Please input project id", trigger: "blur" }], - name: [{ required: true, message: "Please input project name", trigger: "blur" }], - runMode: [{ required: true, message: "Please select project runMode", trigger: "blur" }], - whitelistDirectory: [{ required: true, message: "Please select project access path", trigger: "blur" }], - lib: [{ required: true, message: "Please input project lib", trigger: "blur" }], + id: [{ required: true, message: "请输入项目ID", trigger: "blur" }], + name: [{ required: true, message: "请输入项目名称", trigger: "blur" }], + runMode: [{ required: true, message: "请选择项目运行方式", trigger: "blur" }], + whitelistDirectory: [{ required: true, message: "请选择项目白名单路径", trigger: "blur" }], + lib: [{ required: true, message: "请输入项目文件夹", trigger: "blur" }], }, }; },