|
@@ -32,11 +32,25 @@
|
|
|
<div class="tag-manager-box">
|
|
|
<div class="left-area">
|
|
|
<span class="tag-manager-title">常用标签 </span>
|
|
|
- <span class="tag-manager-text" @click="editCommonTags()">
|
|
|
+ <span class="tag-manager-text" :style="{ color: closable ? '#165dff' : '' }" @click="editCommonTags()">
|
|
|
<SvgIcon icon-class="setup" size="14" />管理
|
|
|
</span>
|
|
|
+ <span
|
|
|
+ class="tag-manager-text"
|
|
|
+ :style="{ color: editLanguage ? '#165dff' : '' }"
|
|
|
+ @click="editCommonTagsLanguage"
|
|
|
+ >
|
|
|
+ <SvgIcon icon-class="lang" size="14" />设置多语言
|
|
|
+ </span>
|
|
|
</div>
|
|
|
<div class="right-area">
|
|
|
+ <MultilingualFill
|
|
|
+ v-if="multilingualVisible"
|
|
|
+ :visible.sync="multilingualVisible"
|
|
|
+ :text="editMultilingualTags.name"
|
|
|
+ :translations="editMultilingualTags.mult_language_list"
|
|
|
+ @SubmitTranslation="handleMultilingualTranslation"
|
|
|
+ />
|
|
|
<el-upload
|
|
|
class=""
|
|
|
action="no"
|
|
@@ -60,7 +74,7 @@
|
|
|
effect="plain"
|
|
|
size="medium"
|
|
|
:closable="closable"
|
|
|
- style="cursor: pointer"
|
|
|
+ :style="{ cursor: 'pointer', 'background-color': editLanguage ? '#F2F3F3' : '' }"
|
|
|
@close="handleCloseCommonTag(tag.id)"
|
|
|
@click="viewToDynamicTags(i)"
|
|
|
>
|
|
@@ -89,7 +103,7 @@
|
|
|
<script>
|
|
|
import { fileUpload } from '@/api/app';
|
|
|
import { getLabelData, labelColorList } from '@/views/book/courseware/data/label';
|
|
|
-import { AddLabel, DeleteLabel, PageQueryLabelList, ImportLabel } from '@/api/project.js';
|
|
|
+import { AddLabel, DeleteLabel, PageQueryLabelList, ImportLabel, UpdateLabel } from '@/api/project.js';
|
|
|
import ModuleMixin from '../../common/ModuleMixin';
|
|
|
export default {
|
|
|
name: 'LabelPage',
|
|
@@ -107,6 +121,8 @@ export default {
|
|
|
total_count: 0,
|
|
|
loading: false,
|
|
|
labelName: '',
|
|
|
+ editLanguage: false, // 编辑多语言
|
|
|
+ editMultilingualTags: {},
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -125,6 +141,11 @@ export default {
|
|
|
// 显示编辑标签图标
|
|
|
editCommonTags() {
|
|
|
this.closable = !this.closable;
|
|
|
+ this.editLanguage = false;
|
|
|
+ },
|
|
|
+ editCommonTagsLanguage() {
|
|
|
+ this.editLanguage = !this.editLanguage;
|
|
|
+ this.closable = false;
|
|
|
},
|
|
|
// 删除常用标签
|
|
|
handleCloseCommonTag(id) {
|
|
@@ -135,6 +156,7 @@ export default {
|
|
|
})
|
|
|
.then(() => {
|
|
|
DeleteLabel({ id }).then(() => {
|
|
|
+ this.data.dynamicTags = this.data.dynamicTags.filter((p) => p.id !== id);
|
|
|
this.getLabelList();
|
|
|
this.$message.success('删除成功!');
|
|
|
});
|
|
@@ -157,16 +179,16 @@ export default {
|
|
|
if (label_color === 'random') label_color = this.getRandomColor();
|
|
|
let dynamicTags = this.data.dynamicTags;
|
|
|
if (inputValue) {
|
|
|
- // 检查是否已存在相同标签(不区分大小写)
|
|
|
+ // 检查是否已存在相同标签
|
|
|
const existingTag = dynamicTags.find((tag) => tag.name === inputValue);
|
|
|
if (existingTag) {
|
|
|
this.$message.warning('常用标签已包含该标签,无需重复添加');
|
|
|
} else {
|
|
|
- dynamicTags.push({
|
|
|
- name: inputValue,
|
|
|
- color: label_color,
|
|
|
- });
|
|
|
- this.addLabel(inputValue);
|
|
|
+ // dynamicTags.push({
|
|
|
+ // name: inputValue,
|
|
|
+ // color: label_color,
|
|
|
+ // });
|
|
|
+ this.addLabel(inputValue, label_color);
|
|
|
}
|
|
|
}
|
|
|
this.inputVisible = false;
|
|
@@ -174,22 +196,29 @@ export default {
|
|
|
},
|
|
|
// 点击常用标签显示到动态标签里
|
|
|
viewToDynamicTags(index) {
|
|
|
+ let commonTagId = this.commonTags[index].id;
|
|
|
+ let commonTagName = this.commonTags[index].name;
|
|
|
+ if (this.closable) return;
|
|
|
+ if (this.editLanguage) {
|
|
|
+ this.openDialogLanguage(commonTagId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.data.dynamicTags.length >= 16) {
|
|
|
this.$message.warning('最多添加16个标签!');
|
|
|
return false;
|
|
|
}
|
|
|
// 检查是否已存在相同标签(不区分大小写)
|
|
|
- let dynamicTags = this.data.dynamicTags;
|
|
|
- let commonTag = this.commonTags[index].name;
|
|
|
- const existingTag = dynamicTags.find((tag) => tag.name === commonTag);
|
|
|
+ const existingTag = this.data.dynamicTags.find((tag) => tag.name === commonTagName);
|
|
|
if (existingTag) {
|
|
|
this.$message.warning('组件标签已包含该标签,无需重复加入');
|
|
|
} else {
|
|
|
let label_color = this.data.property.label_color;
|
|
|
if (label_color === 'random') label_color = this.getRandomColor();
|
|
|
this.data.dynamicTags.push({
|
|
|
- name: commonTag,
|
|
|
+ name: commonTagName,
|
|
|
color: label_color,
|
|
|
+ id: commonTagId,
|
|
|
+ mult_language_list: this.commonTags[index].mult_language_list || [],
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -222,11 +251,19 @@ export default {
|
|
|
this.getLabelList();
|
|
|
},
|
|
|
// 存储标签到系统
|
|
|
- addLabel(name) {
|
|
|
+ addLabel(name, color) {
|
|
|
AddLabel({ name })
|
|
|
- .then(() => {
|
|
|
+ .then((res) => {
|
|
|
this.cur_page = 1;
|
|
|
this.getLabelList();
|
|
|
+ if (color) {
|
|
|
+ this.data.dynamicTags.push({
|
|
|
+ name: name,
|
|
|
+ color: color,
|
|
|
+ id: res.id,
|
|
|
+ mult_language_list: [],
|
|
|
+ });
|
|
|
+ }
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
console.error(e);
|
|
@@ -265,6 +302,39 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 多语言弹窗
|
|
|
+ openDialogLanguage(commonTagId) {
|
|
|
+ this.multilingualVisible = true;
|
|
|
+ let en = { mult_language_list: [] };
|
|
|
+ if (this.commonTags.some((p) => p.id === commonTagId)) {
|
|
|
+ en = this.commonTags.find((p) => p.id === commonTagId);
|
|
|
+ en.mult_language_list.map((p) => (p.translation = p.name));
|
|
|
+ }
|
|
|
+ this.editMultilingualTags = en;
|
|
|
+ },
|
|
|
+ // 提交多语言译文
|
|
|
+ handleMultilingualTranslation(translations) {
|
|
|
+ let data = this.editMultilingualTags;
|
|
|
+ if (!translations.some((p) => p.type === 'ZH')) {
|
|
|
+ translations.push({ translation: data.name, type: 'ZH' });
|
|
|
+ }
|
|
|
+ data['mult_language_list'] = translations.map((p) => {
|
|
|
+ return { name: p.translation, type: p.type };
|
|
|
+ });
|
|
|
+ UpdateLabel(data)
|
|
|
+ .then(() => {
|
|
|
+ this.$message.success('设置成功!');
|
|
|
+ this.cur_page = 1;
|
|
|
+ let _index = this.data.dynamicTags.findIndex((p) => p.id === data.id);
|
|
|
+ if (_index > -1) {
|
|
|
+ this.$set(this.data.dynamicTags, _index, data);
|
|
|
+ }
|
|
|
+ this.getLabelList();
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.error(e);
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|