|
@@ -11,18 +11,21 @@
|
|
|
</ui-group>
|
|
|
</template>
|
|
|
<ui-group title="标签列表" class="tagging-list">
|
|
|
+ <template #header>
|
|
|
+ <StyleTypeSelect v-model:value="type" all count />
|
|
|
+ </template>
|
|
|
<template #icon>
|
|
|
- <ui-icon
|
|
|
+ <ui-icon
|
|
|
ctrl
|
|
|
- :class="{active: showSearch}"
|
|
|
- type="search"
|
|
|
- @click="showSearch = !showSearch"
|
|
|
+ :class="{ active: showSearch }"
|
|
|
+ type="search"
|
|
|
+ @click="showSearch = !showSearch"
|
|
|
style="margin-right: 20px"
|
|
|
/>
|
|
|
- <ui-icon
|
|
|
+ <ui-icon
|
|
|
ctrl
|
|
|
- :type="custom.showTaggings ? 'eye-s' : 'eye-n'"
|
|
|
- @click="custom.showTaggings = !custom.showTaggings"
|
|
|
+ :type="custom.showTaggings ? 'eye-s' : 'eye-n'"
|
|
|
+ @click="custom.showTaggings = !custom.showTaggings"
|
|
|
/>
|
|
|
</template>
|
|
|
<ui-group-option v-if="showSearch">
|
|
@@ -32,93 +35,104 @@
|
|
|
</template>
|
|
|
</ui-input>
|
|
|
</ui-group-option>
|
|
|
- <TagingSign
|
|
|
- v-for="tagging in filterTaggings"
|
|
|
- :key="tagging.id"
|
|
|
- :tagging="tagging"
|
|
|
+ <TagingSign
|
|
|
+ v-for="tagging in filterTaggings"
|
|
|
+ :key="tagging.id"
|
|
|
+ :tagging="tagging"
|
|
|
:selected="selectTagging === tagging"
|
|
|
@edit="editTagging = tagging"
|
|
|
@delete="deleteTagging(tagging)"
|
|
|
- @select="selected => selectTagging = selected ? tagging : null"
|
|
|
+ @select="(selected) => (selectTagging = selected ? tagging : null)"
|
|
|
@fixed="fixedTagging(tagging)"
|
|
|
/>
|
|
|
</ui-group>
|
|
|
</RightFillPano>
|
|
|
|
|
|
- <Edit
|
|
|
- v-if="editTagging"
|
|
|
- :data="editTagging"
|
|
|
- @quit="editTagging = null"
|
|
|
+ <Edit
|
|
|
+ v-if="editTagging"
|
|
|
+ :data="editTagging"
|
|
|
+ @quit="editTagging = null"
|
|
|
@save="saveHandler"
|
|
|
/>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import Edit from './edit.vue'
|
|
|
-import TagingSign from './sign.vue'
|
|
|
-import { RightFillPano } from '@/layout'
|
|
|
-import { useViewStack } from '@/hook'
|
|
|
-import { computed, ref } from 'vue';
|
|
|
-import { router, RoutesName } from '@/router'
|
|
|
-import { custom } from '@/env'
|
|
|
-import {
|
|
|
- taggings,
|
|
|
- getTaggingStyle,
|
|
|
- Tagging,
|
|
|
- autoSaveTaggings,
|
|
|
+import Edit from "./edit.vue";
|
|
|
+import TagingSign from "./sign.vue";
|
|
|
+import StyleTypeSelect from "./style-type-select.vue";
|
|
|
+import { RightFillPano } from "@/layout";
|
|
|
+import { useViewStack } from "@/hook";
|
|
|
+import { computed, ref } from "vue";
|
|
|
+import { router, RoutesName } from "@/router";
|
|
|
+import { custom } from "@/env";
|
|
|
+import {
|
|
|
+ taggings,
|
|
|
+ getTaggingStyle,
|
|
|
+ Tagging,
|
|
|
+ autoSaveTaggings,
|
|
|
createTagging,
|
|
|
getTaggingPositions,
|
|
|
taggingPositions,
|
|
|
isOld,
|
|
|
save,
|
|
|
- getTagging
|
|
|
-} from '@/store'
|
|
|
+ getTagging,
|
|
|
+ TaggingStyle,
|
|
|
+} from "@/store";
|
|
|
|
|
|
-const showSearch = ref(false)
|
|
|
-const keyword = ref('')
|
|
|
-const filterTaggings = computed(() => taggings.value.filter(tagging => tagging.title.includes(keyword.value)))
|
|
|
+const showSearch = ref(false);
|
|
|
+const type = ref<TaggingStyle["typeId"]>(-1);
|
|
|
+const keyword = ref("");
|
|
|
+const filterTaggings = computed(() =>
|
|
|
+ taggings.value.filter((tagging) => {
|
|
|
+ if (!tagging.title.includes(keyword.value)) return false;
|
|
|
+ if (type.value === -1) return true;
|
|
|
+ const style = getTaggingStyle(tagging.styleId);
|
|
|
+ return style?.typeId === type.value;
|
|
|
+ })
|
|
|
+);
|
|
|
|
|
|
-const editTagging = ref<Tagging | null>(null)
|
|
|
+const editTagging = ref<Tagging | null>(null);
|
|
|
const saveHandler = (tagging: Tagging) => {
|
|
|
if (!editTagging.value) return;
|
|
|
if (!getTagging(editTagging.value.id)) {
|
|
|
- taggings.value.push(tagging)
|
|
|
- const style = getTaggingStyle(tagging.styleId)
|
|
|
+ taggings.value.push(tagging);
|
|
|
+ const style = getTaggingStyle(tagging.styleId);
|
|
|
if (style) {
|
|
|
- style.lastUse = 1
|
|
|
+ style.lastUse = 1;
|
|
|
}
|
|
|
} else {
|
|
|
- Object.assign(editTagging.value, tagging)
|
|
|
+ Object.assign(editTagging.value, tagging);
|
|
|
}
|
|
|
-
|
|
|
- editTagging.value = null
|
|
|
-}
|
|
|
+
|
|
|
+ editTagging.value = null;
|
|
|
+};
|
|
|
|
|
|
const deleteTagging = (tagging: Tagging) => {
|
|
|
- const index = taggings.value.indexOf(tagging)
|
|
|
- const positions = getTaggingPositions(tagging)
|
|
|
- taggingPositions.value = taggingPositions.value.filter(position => !positions.includes(position))
|
|
|
- taggings.value.splice(index, 1)
|
|
|
-}
|
|
|
+ const index = taggings.value.indexOf(tagging);
|
|
|
+ const positions = getTaggingPositions(tagging);
|
|
|
+ taggingPositions.value = taggingPositions.value.filter(
|
|
|
+ (position) => !positions.includes(position)
|
|
|
+ );
|
|
|
+ taggings.value.splice(index, 1);
|
|
|
+};
|
|
|
|
|
|
const fixedTagging = async (tagging: Tagging) => {
|
|
|
if (isOld.value) {
|
|
|
- await save()
|
|
|
+ await save();
|
|
|
}
|
|
|
- router.push({ name: RoutesName.taggingPosition, params: { id: tagging.id } })
|
|
|
-}
|
|
|
+ router.push({ name: RoutesName.taggingPosition, params: { id: tagging.id } });
|
|
|
+};
|
|
|
|
|
|
-
|
|
|
-const selectTagging = ref<Tagging | null>(null)
|
|
|
-useViewStack(autoSaveTaggings)
|
|
|
+const selectTagging = ref<Tagging | null>(null);
|
|
|
+useViewStack(autoSaveTaggings);
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
- .active {
|
|
|
- color: var(--color-main-normal) !important;
|
|
|
- }
|
|
|
+.active {
|
|
|
+ color: var(--color-main-normal) !important;
|
|
|
+}
|
|
|
|
|
|
- .tagging-list {
|
|
|
- padding-bottom: 30px;
|
|
|
- }
|
|
|
-</style>
|
|
|
+.tagging-list {
|
|
|
+ padding-bottom: 30px;
|
|
|
+}
|
|
|
+</style>
|