123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <template>
- <MainPanel>
- <template v-slot:header>
- <Header :count="selects.length" :title="`已标注照片(${sortPhotos.length})`">
- <ui-button
- :type="selectMode ? 'primary' : 'normal'"
- @click="selectMode = !selectMode"
- width="96px"
- style="margin-right: 16px"
- >
- {{ selectMode ? '取消' : '选择' }}
- </ui-button>
- <ui-button
- v-if="!selectMode"
- type="primary"
- @click="router.push({name: writeRouteName.photos})"
- width="96px"
- >
- 新增
- </ui-button>
- </Header>
- </template>
- <div class="type-photos-layout">
- <div class="type-photos" v-for="typePhoto in typePhotos" :key="typePhoto.type">
- <p class="type-title">{{ typePhoto.type }}</p>
- <Photos
- class="type-photos-content"
- v-model:active="active"
- v-model:selects="selects"
- :select-mode="selectMode"
- :data="typePhoto.photos"
- >
- <template v-slot="{data}">
- <p>{{ data.title || '默认标题' }}</p>
- </template>
- </Photos>
- </div>
- </div>
- <ActionMenus class="select-menus" :menus="selectMenus" dire="row" v-if="selects.length" />
- </MainPanel>
- <FillSlide :data="sortPhotos" v-model:active="active" @quit="active = null" v-if="active">
- <template v-slot:foot>
- <ActionMenus class="menus" :menus="menus" dire="row" />
- </template>
- </FillSlide>
- </template>
- <script setup lang="ts">
- import MainPanel from '@/components/main-panel/index.vue'
- import FillSlide from '@/components/fill-slide/index.vue'
- import ActionMenus from "@/components/group-button/index.vue";
- import {types, accidentPhotos, AccidentPhoto} from '@/store/accidentPhotos'
- import UiIcon from "@/components/base/components/icon/index.vue";
- import {router, writeRouteName} from '@/router'
- import {computed, reactive, ref, watchEffect} from "vue";
- import {Mode} from '@/views/graphic/menus'
- import UiButton from "@/components/base/components/button/index.vue";
- import Photos from "@/components/photos/index.vue";
- import Header from "@/components/photos/header.vue";
- import ButtonPane from "@/components/button-pane/index.vue";
- import {useConfirm} from "@/hook";
- import {roadPhotos} from "@/store/roadPhotos";
- const sortPhotos = computed(() => {
- const photos = [...accidentPhotos.value]
- return photos.sort((a, b) =>
- types.indexOf(a.type) - types.indexOf(b.type)
- )
- })
- const typePhotos = computed(() =>
- types
- .map(type => ({
- type,
- photos: sortPhotos.value.filter(data => data.type === type)
- }))
- .filter(data => data.photos.length)
- )
- const selectMode = ref(false)
- const selects = ref<AccidentPhoto[]>([])
- const active = ref<AccidentPhoto>()
- const menus = [
- {
- key: "edit",
- icon: "edit",
- text: "修改",
- onClick: () => gotoDraw()
- },
- {
- key: "del",
- icon: "del",
- text: "删除",
- onClick: () => delPhoto()
- }
- ]
- const selectMenus = reactive([
- {
- key: "gen",
- icon: "photo",
- text: "生成A4",
- disabled: computed(() => selects.value.length > 2),
- onClick: () => {
- const params = {
- id1: selects.value[0].id,
- id2: selects.value.length === 1 ? '-1' : selects.value[1].id
- }
- router.push({ name: writeRouteName.gena4, params})
- }
- },
- {
- key: "del",
- text: "删除",
- icon: "del",
- onClick: () => delSelects()
- },
- ])
- watchEffect(() => {
- if (!selectMode.value) {
- selects.value = []
- }
- })
- const delPhotoRaw = (accidentPhoto = active.value) => {
- const index = accidentPhotos.value.indexOf(accidentPhoto)
- const reset = active.value ? accidentPhotos.value.indexOf(active.value) : -1
- if (~index) {
- accidentPhotos.value.splice(index, 1)
- }
- if (~reset) {
- console.log(reset)
- if (reset >= accidentPhotos.value.length) {
- if (accidentPhotos.value.length) {
- active.value = accidentPhotos.value[accidentPhotos.value.length - 1]
- } else {
- active.value = null
- }
- } else {
- active.value = accidentPhotos.value[reset]
- }
- }
- }
- const delPhoto = async (photo = active.value) => {
- if (await useConfirm(`确定要删除此数据?`)) {
- delPhotoRaw(photo)
- }
- }
- const delSelects = async () => {
- if (await useConfirm(`确定要删除这${selects.value.length}项数据?`)) {
- while (selects.value.length) {
- delPhotoRaw(selects.value[0])
- selects.value.shift()
- }
- }
- }
- const gotoDraw = () => {
- router.push({
- name: writeRouteName.graphic,
- params: {mode: Mode.Photo, id: active.value.id, action: 'update'}
- })
- }
- </script>
- <style scoped lang="scss">
- .type-photos-layout {
- position: absolute;
- top: calc(var(--header-top) + var(--editor-head-height));
- left: 0;
- right: 0;
- bottom: 0;
- overflow-y: auto;
- background: #2E2E2E;
- padding: 25px 0;
- }
- .type-photos-content {
- position: static;
- overflow: initial;
- background: none;
- p {
- color: #fff;
- font-size: 14px;
- margin-top: 8px;
- }
- }
- .menus {
- left: 50%;
- transform: translateX(-50%);
- bottom: var(--boundMargin);
- }
- .fun-ctrl {
- color: #fff;
- font-size: 20px;
- transition: color .3s ease;
- .icon {
- position: absolute;
- transform: translateX(-50%);
- }
- }
- .del {
- left: 50%;
- transform: translateX(-50%);
- bottom: var(--boundMargin);
- }
- .type-title {
- padding: 0 24px 2px;
- font-size: 16px;
- }
- .select-menus {
- left: 50%;
- transform: translateX(-50%);
- bottom: var(--boundMargin);
- }
- </style>
|