|
@@ -1,5 +1,9 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="conversation-board-tags">
|
|
<div class="conversation-board-tags">
|
|
|
|
|
+ <div class="board-tag" :class="{ 'is-active': is_all }" @click="handleClickAll">
|
|
|
|
|
+ <span>{{ $t('conversation.tag_all') }}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
<div
|
|
<div
|
|
|
v-for="(item, index) of list_labels"
|
|
v-for="(item, index) of list_labels"
|
|
|
class="board-tag"
|
|
class="board-tag"
|
|
@@ -13,28 +17,52 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, onMounted } from 'vue';
|
|
|
|
|
|
|
+import { ref, computed, onMounted } from 'vue';
|
|
|
|
|
|
|
|
import useTagList from './use-tag-list';
|
|
import useTagList from './use-tag-list';
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 单选版本
|
|
|
|
|
+ * 在V0的基础上,新增了一个 全部 按钮
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
const emits = defineEmits(['change']);
|
|
const emits = defineEmits(['change']);
|
|
|
|
|
|
|
|
const current_id = ref('');
|
|
const current_id = ref('');
|
|
|
|
|
|
|
|
|
|
+// 是否是所有
|
|
|
|
|
+// 当前未选中任何标签,即为所有
|
|
|
|
|
+const is_all = computed(() => {
|
|
|
|
|
+ return !current_id.value;
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 选择标签的某一项
|
|
|
|
|
+ * @param item
|
|
|
|
|
+ */
|
|
|
const handleClick = (item) => {
|
|
const handleClick = (item) => {
|
|
|
const target_id = item.labelId;
|
|
const target_id = item.labelId;
|
|
|
|
|
|
|
|
if (target_id === current_id.value) {
|
|
if (target_id === current_id.value) {
|
|
|
- // 已经选中了
|
|
|
|
|
|
|
+ // 已经选中了: 取消选中
|
|
|
current_id.value = '';
|
|
current_id.value = '';
|
|
|
} else {
|
|
} else {
|
|
|
- // 没有选中
|
|
|
|
|
|
|
+ // 没有选中: 选中操作
|
|
|
current_id.value = target_id;
|
|
current_id.value = target_id;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
emits('change', current_id.value);
|
|
emits('change', current_id.value);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 选择所有
|
|
|
|
|
+ */
|
|
|
|
|
+const handleClickAll = () => {
|
|
|
|
|
+ current_id.value = '';
|
|
|
|
|
+
|
|
|
|
|
+ emits('change', current_id.value);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const { getTagList, api_status, api_message, list_labels } = useTagList();
|
|
const { getTagList, api_status, api_message, list_labels } = useTagList();
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|