Browse Source

33333

shibei_master
dai 3 years ago
parent
commit
ae87421a48
  1. 143
      src/views/modules/shequzhili/xiangmu/cpts/project-info.vue

143
src/views/modules/shequzhili/xiangmu/cpts/project-info.vue

@ -58,13 +58,14 @@
{{ item.name }}
</div>
</fold-text>
<el-popover
placement="bottom"
width="400"
height="400"
v-model="visibleCatePanel"
>
<div class="f" style="height: 200px">
<div class="f" style="min-height: 120px">
<h2>更改分类</h2>
<el-cascader
v-model="selectedCateData"
@ -97,6 +98,56 @@
{{ item.name }}
</div>
</fold-text>
<el-popover
placement="bottom"
width="400"
height="400"
v-model="visibleTagPanel"
>
<div class="f" style="min-height: 120px">
<h2>更改标签</h2>
<el-select
v-model="selectedTagData"
multiple
allow-create
filterable
placeholder="请选择"
@change="handleTagChange"
>
<el-option-group label="自定义标签">
<el-option
v-for="item in tagOptions.customized"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-option-group>
<el-option-group label="常用标签">
<el-option
v-for="item in tagOptions.defaulted"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-option-group>
</el-select>
<el-button
style="margin-left: 10px"
size="small"
type="danger"
@click="updateProjectTag"
>确定</el-button
>
</div>
<div slot="reference">
<el-button size="small" type="">更改</el-button>
</div>
</el-popover>
</div>
</div>
@ -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);
}

Loading…
Cancel
Save