diff --git a/src/views/modules/shequzhili/xiangmu/cpts/project-info.vue b/src/views/modules/shequzhili/xiangmu/cpts/project-info.vue index a1a5d114..6a381a06 100644 --- a/src/views/modules/shequzhili/xiangmu/cpts/project-info.vue +++ b/src/views/modules/shequzhili/xiangmu/cpts/project-info.vue @@ -58,13 +58,14 @@ {{ item.name }} + -
+

更改分类

+ + +
+

更改标签

+ + + + + + + + + + + + + 确定 +
+
+ 更改 +
+
@@ -523,6 +574,9 @@ function iniData() { selectedCateData: [], projectTag: [], + tagOptions: [], + visibleTagPanel: false, + selectedTagData: [], }; } @@ -624,7 +678,6 @@ export default { }, selectedCateData(val) { const { cateOptions } = this; - console.log(cateOptions) this.projectCate = val .filter((arr) => arr.length > 0) .map((arr) => { @@ -632,10 +685,37 @@ export default { let ele2 = ele1.subCategory.find((item) => item.id == arr[1]); return { id: ele2.id, - name: ele1.name + '-' + ele2.name + name: ele1.name + "-" + ele2.name, }; }); }, + async selectedTagData(val) { + const { tagOptions } = this; + this.projectTag = await Promise.all( + val.map(async (id) => { + let ele = [...tagOptions.customized, ...tagOptions.defaulted].find( + (item) => item.id == id + ); + if (!ele) { + await this.createTag(id); + ele = [ + ...this.tagOptions.customized, + ...this.tagOptions.defaulted, + ].find((item) => item.name == id); + if (!ele) + return { + id: "", + name: ele.name, + }; + } + return { + id: ele.id, + name: ele.name, + }; + }) + ); + this.projectTag = this.projectTag.filter(item => item.id) + }, }, mounted() { @@ -1019,6 +1099,7 @@ export default { if (code === 0) { this.projectCate = data.categoryList; this.projectTag = data.tagList; + this.getTagOptions(); } else { this.$message.error(msg); } @@ -1056,6 +1137,62 @@ export default { if (code === 0) { this.$message.success("更改成功"); this.visibleCatePanel = false; + this.getTagOptions(); + } else { + this.$message.error(msg); + } + }, + + handleTagChange(val) { + console.log(val); + }, + + async createTag(tagName) { + const url = "/gov/issue/issuetags/add"; + + const { data, code, msg } = await requestPost(url, { + tagName, + }); + + if (code === 0) { + this.tagOptions.customized.push({ + name: tagName, + id: data.tagId, + }); + } else { + this.$message.error(msg); + } + }, + + async getTagOptions() { + const url = "/gov/issue/issueprojecttagdict/list"; + + const { data, code, msg } = await requestPost(url, { + categoryList: this.projectCate, + }); + + if (code === 0) { + this.tagOptions = { + customized: data.customized, + defaulted: data.defaulted, + }; + } else { + this.$message.error(msg); + } + }, + + async updateProjectTag() { + const url = "/gov/project/projecttags/save"; + const { projectTag } = this; + + const { data, code, msg } = await requestPost(url, { + projectId: this.projectIdCopy, + tagList: projectTag, + }); + + if (code === 0) { + this.$message.success("更改成功"); + this.visibleTagPanel = false; } else { this.$message.error(msg); }