1) 修复类

1.1 修复'创建分发项目/关联项目'和'编辑分发项目/关联项目'时,对话框标题始终显示为'创建分发项目/关联项目'的bug
1.2 修复'关联项目'和'分发项目'下部分字段的placeholder无效的bug
1.3 修复'删除分发节点'时数据缓存问题

2) 优化类
2.1 增大'分发节点-节点'显示宽度,优化ip地址为12位时显示不全的特殊情况
2.2 优化添加'分发节点-节点-项目'的使用体验:在选择节点之前,项目按钮不可用并显示为'请先选择节点',若该节点下无项目placeholder显示为'此节点暂无项目'并且不可点击下拉框
2.3 部分字段新增及修改中文提示,提高可读性
2.4 提交关联项目时对分发节点数据进行预校验,如在发请求之前先判断'是否至少选择2个节点项目',减少请求错误率

3) 规范类
3.1 部分代码格式化及规范化
This commit is contained in:
def7 2021-09-22 00:36:41 +08:00
parent 4f40f8334d
commit 0e206e6299
2 changed files with 56 additions and 32 deletions

View File

@ -50,8 +50,8 @@
</template>
</a-table>
</a-table>
<!-- 添加关联项目 -->
<a-modal v-model="linkDispatchVisible" width="600px" title="编辑关联项目" @ok="handleLinkDispatchOk" :maskClosable="false" @cancel="clearDispatchList">
<!-- 添加/编辑关联项目 -->
<a-modal v-model="linkDispatchVisible" width="600px" :title="temp.type === 'edit' ? '编辑关联项目' : '添加关联项目'" @ok="handleLinkDispatchOk" :maskClosable="false" @cancel="clearDispatchList">
<a-form-model ref="linkDispatchForm" :rules="rules" :model="temp" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
<a-form-model-item label="分发 ID" prop="id">
<a-input v-model="temp.id" :disabled="temp.type === 'edit'" placeholder="创建之后不能修改" />
@ -74,15 +74,15 @@
@change="handleChange"
/>
</a-form-model-item> -->
<a-form-model-item label="分发节点" prop="name">
<a-form-model-item label="分发节点" required>
<a-list item-layout="horizontal" :data-source="dispatchList">
<a-list-item slot="renderItem" slot-scope="item, index" v-if="item.status">
<span>节点: </span>
<a-select
placeholder="请选择节点"
notFoundContent="暂无节点信息"
style="width: 130px"
:defaultValue="item.index"
style="width: 140px"
:defaultValue="item.index === '' ? undefined : item.index"
@change="(value) => handleNodeListChange(value, index)"
:disabled="item.index === '' ? false : !nodeNameList[item.index].openStatus"
>
@ -91,7 +91,14 @@
</a-select-option>
</a-select>
<span>项目: </span>
<a-select style="width: 130px" placeholder="请选择项目" :defaultValue="item.projectId" notFoundContent="暂无项目信息,重新其他项目" @change="(value) => handleProjectChange(value, index)">
<a-select
style="width: 150px"
:placeholder="dispatchList[index].placeholder"
:defaultValue="item.projectId === '' ? undefined : item.projectId"
notFoundContent="此节点暂无项目"
@change="(value) => handleProjectChange(value, index)"
:disabled="dispatchList[index].disabled"
>
<a-select-option :value="project.id" v-for="project in item.project" :key="project.id">
{{ project.name }}
</a-select-option>
@ -112,7 +119,7 @@
</a-form-model>
</a-modal>
<!-- 创建/编辑分发项目 -->
<a-modal v-model="editDispatchVisible" width="600px" :title="editDispatchDialogTitle" @ok="handleEditDispatchOk" :maskClosable="false">
<a-modal v-model="editDispatchVisible" width="600px" :title="temp.type === 'edit' ? '编辑分发项目' : '创建分发项目'" @ok="handleEditDispatchOk" :maskClosable="false">
<a-form-model ref="editDispatchForm" :rules="rules" :model="temp" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
<a-form-model-item label="项目 ID" prop="id">
<a-input v-model="temp.id" :disabled="temp.type === 'edit'" placeholder="创建之后不能修改" />
@ -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) {

View File

@ -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" }],
},
};
},