|
@@ -1,21 +1,26 @@
|
|
|
<template>
|
|
|
<MainPanel>
|
|
|
<template v-slot:header>
|
|
|
- <Header type="return_l" :count="selects.length" :title="`已标注照片(${sortPhotos.length})`" :on-back="() => onBack()">
|
|
|
+ <Header
|
|
|
+ type="return_l"
|
|
|
+ :count="selects.length"
|
|
|
+ :title="`已标注照片(${sortPhotos.length})`"
|
|
|
+ :on-back="() => onBack()"
|
|
|
+ >
|
|
|
<ui-button
|
|
|
- :type="selectMode ? 'primary' : 'normal'"
|
|
|
- @click="selectMode = !selectMode"
|
|
|
- width="96px"
|
|
|
- style="margin-right: 16px"
|
|
|
- v-if="sortPhotos.length"
|
|
|
+ :type="selectMode ? 'primary' : 'normal'"
|
|
|
+ @click="selectMode = !selectMode"
|
|
|
+ width="96px"
|
|
|
+ style="margin-right: 16px"
|
|
|
+ v-if="sortPhotos.length"
|
|
|
>
|
|
|
- {{ selectMode ? '取消' : '选择' }}
|
|
|
+ {{ selectMode ? "取消" : "选择" }}
|
|
|
</ui-button>
|
|
|
<ui-button
|
|
|
- v-if="!selectMode"
|
|
|
- type="primary"
|
|
|
- @click="router.push({name: writeRouteName.photos})"
|
|
|
- width="96px"
|
|
|
+ v-if="!selectMode"
|
|
|
+ type="primary"
|
|
|
+ @click="router.push({ name: writeRouteName.photos })"
|
|
|
+ width="96px"
|
|
|
>
|
|
|
新增
|
|
|
</ui-button>
|
|
@@ -27,14 +32,14 @@
|
|
|
<div class="type-photos" v-for="typePhoto in typePhotos" :key="typePhoto.type">
|
|
|
<p class="type-title">{{ typePhoto.type }}</p>
|
|
|
<Photos
|
|
|
- class="type-photos-content accident-photos-content"
|
|
|
- :class="{max: typePhoto.photos.length > 4}"
|
|
|
- v-model:active="active"
|
|
|
- v-model:selects="selects"
|
|
|
- :select-mode="selectMode"
|
|
|
- :data="typePhoto.photos"
|
|
|
+ class="type-photos-content accident-photos-content"
|
|
|
+ :class="{ max: typePhoto.photos.length > 4 }"
|
|
|
+ v-model:active="active"
|
|
|
+ v-model:selects="selects"
|
|
|
+ :select-mode="selectMode"
|
|
|
+ :data="typePhoto.photos"
|
|
|
>
|
|
|
- <template v-slot="{data, index}">
|
|
|
+ <template v-slot="{ data, index }">
|
|
|
<p>{{ data.title || typePhoto.type.substring(0, 2) + (index + 1) }}</p>
|
|
|
</template>
|
|
|
</Photos>
|
|
@@ -43,46 +48,57 @@
|
|
|
<undata v-else undata-msg="无照片。请点击右上角按钮标注照片。" />
|
|
|
</div>
|
|
|
|
|
|
- <ActionMenus class="select-menus" :menus="selectMenus" dire="row" v-if="selects.length" />
|
|
|
+ <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">
|
|
|
+ <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>
|
|
|
+ <template v-slot:topRight>
|
|
|
+ <ui-icon type="del" @click="delPhoto(active)" />
|
|
|
+ </template>
|
|
|
</FillSlide>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import MainPanel from '@/components/main-panel/index.vue'
|
|
|
-import FillSlide from '@/components/fill-slide/index.vue'
|
|
|
+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 {router, writeRouteName} from '@/router'
|
|
|
-import {computed, onDeactivated, reactive, ref, watchEffect} from "vue";
|
|
|
-import {Mode} from '@/views/graphic/menus'
|
|
|
+import { types, accidentPhotos, AccidentPhoto } from "@/store/accidentPhotos";
|
|
|
+import { router, writeRouteName } from "@/router";
|
|
|
+import { computed, onDeactivated, 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 {useConfirm} from "@/hook";
|
|
|
+import { useConfirm } from "@/hook";
|
|
|
import Undata from "@/components/photos/undata.vue";
|
|
|
-import {api} from "@/store/sync";
|
|
|
-import {photos} from "@/store/photos";
|
|
|
+import { api } from "@/store/sync";
|
|
|
+import { photos } from "@/store/photos";
|
|
|
|
|
|
const sortPhotos = computed(() => {
|
|
|
- const photos = [...accidentPhotos.value]
|
|
|
- return photos.sort((a, b) =>
|
|
|
- types.indexOf(a.type) - types.indexOf(b.type)
|
|
|
- )
|
|
|
-})
|
|
|
+ const photos = [...accidentPhotos.value];
|
|
|
+ return photos.sort((a, b) => types.indexOf(a.type) - types.indexOf(b.type));
|
|
|
+});
|
|
|
const typePhotos = computed(() =>
|
|
|
types
|
|
|
- .map(type => ({
|
|
|
+ .map((type) => ({
|
|
|
type,
|
|
|
- photos: sortPhotos.value.filter(data => data.type === type)
|
|
|
+ photos: sortPhotos.value.filter((data) => data.type === type),
|
|
|
}))
|
|
|
- .filter(data => data.photos.length)
|
|
|
-)
|
|
|
+ .filter((data) => data.photos.length)
|
|
|
+);
|
|
|
const onBack = () => {
|
|
|
let back = router.currentRoute.value.query.back;
|
|
|
if (back) {
|
|
@@ -91,23 +107,17 @@ const onBack = () => {
|
|
|
api.closePage();
|
|
|
}
|
|
|
};
|
|
|
-const selectMode = ref(false)
|
|
|
-const selects = ref<AccidentPhoto[]>([])
|
|
|
-const active = ref<AccidentPhoto>()
|
|
|
+const selectMode = ref(false);
|
|
|
+const selects = ref<AccidentPhoto[]>([]);
|
|
|
+const active = ref<AccidentPhoto>();
|
|
|
const menus = [
|
|
|
{
|
|
|
key: "edit",
|
|
|
icon: "edit",
|
|
|
text: "修改",
|
|
|
- onClick: () => gotoDraw()
|
|
|
+ onClick: () => gotoDraw(),
|
|
|
},
|
|
|
- {
|
|
|
- key: "del",
|
|
|
- icon: "del",
|
|
|
- text: "删除",
|
|
|
- onClick: () => delPhoto()
|
|
|
- }
|
|
|
-]
|
|
|
+];
|
|
|
|
|
|
const selectMenus = reactive([
|
|
|
{
|
|
@@ -118,72 +128,70 @@ const selectMenus = reactive([
|
|
|
onClick: () => {
|
|
|
const params = {
|
|
|
id1: selects.value[0].id,
|
|
|
- id2: selects.value.length === 1 ? '-1' : selects.value[1].id
|
|
|
- }
|
|
|
- router.push({ name: writeRouteName.gena4, params})
|
|
|
- }
|
|
|
+ id2: selects.value.length === 1 ? "-1" : selects.value[1].id,
|
|
|
+ };
|
|
|
+ router.push({ name: writeRouteName.gena4, params });
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
key: "del",
|
|
|
text: "删除",
|
|
|
icon: "del",
|
|
|
- onClick: () => delSelects()
|
|
|
+ onClick: () => delSelects(),
|
|
|
},
|
|
|
-])
|
|
|
-
|
|
|
+]);
|
|
|
|
|
|
watchEffect(() => {
|
|
|
if (!selectMode.value) {
|
|
|
- selects.value = []
|
|
|
+ selects.value = [];
|
|
|
}
|
|
|
-})
|
|
|
+});
|
|
|
|
|
|
const delPhotoRaw = (accidentPhoto = active.value) => {
|
|
|
- const index = accidentPhotos.value.indexOf(accidentPhoto)
|
|
|
- const reset = active.value ? accidentPhotos.value.indexOf(active.value) : -1
|
|
|
+ const index = accidentPhotos.value.indexOf(accidentPhoto);
|
|
|
+ const reset = active.value ? accidentPhotos.value.indexOf(active.value) : -1;
|
|
|
if (~index) {
|
|
|
- accidentPhotos.value.splice(index, 1)
|
|
|
+ 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]
|
|
|
+ active.value = accidentPhotos.value[accidentPhotos.value.length - 1];
|
|
|
} else {
|
|
|
- active.value = null
|
|
|
+ active.value = null;
|
|
|
}
|
|
|
} else {
|
|
|
- active.value = accidentPhotos.value[reset]
|
|
|
+ active.value = accidentPhotos.value[reset];
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
const delPhoto = async (photo = active.value) => {
|
|
|
if (await useConfirm(`确定要删除此数据?`)) {
|
|
|
- delPhotoRaw(photo)
|
|
|
+ delPhotoRaw(photo);
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
const delSelects = async () => {
|
|
|
if (await useConfirm(`确定要删除这${selects.value.length}项数据?`)) {
|
|
|
while (selects.value.length) {
|
|
|
- delPhotoRaw(selects.value[0])
|
|
|
- selects.value.shift()
|
|
|
+ delPhotoRaw(selects.value[0]);
|
|
|
+ selects.value.shift();
|
|
|
}
|
|
|
if (!sortPhotos.value.length) {
|
|
|
- selectMode.value = false
|
|
|
+ selectMode.value = false;
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
const gotoDraw = () => {
|
|
|
router.push({
|
|
|
name: writeRouteName.graphic,
|
|
|
- params: {mode: Mode.Photo, id: active.value.id, action: 'update'}
|
|
|
- })
|
|
|
-}
|
|
|
+ params: { mode: Mode.Photo, id: active.value.id, action: "update" },
|
|
|
+ });
|
|
|
+};
|
|
|
|
|
|
onDeactivated(() => {
|
|
|
- active.value = null
|
|
|
-})
|
|
|
+ active.value = null;
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
@@ -194,7 +202,7 @@ onDeactivated(() => {
|
|
|
right: 0;
|
|
|
bottom: 0;
|
|
|
overflow-y: auto;
|
|
|
- background: #2E2E2E;
|
|
|
+ background: #2e2e2e;
|
|
|
padding: 25px 0;
|
|
|
}
|
|
|
|
|
@@ -209,7 +217,6 @@ onDeactivated(() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
.menus {
|
|
|
left: 50%;
|
|
|
transform: translateX(-50%);
|
|
@@ -218,7 +225,7 @@ onDeactivated(() => {
|
|
|
.fun-ctrl {
|
|
|
color: #fff;
|
|
|
font-size: 20px;
|
|
|
- transition: color .3s ease;
|
|
|
+ transition: color 0.3s ease;
|
|
|
|
|
|
.icon {
|
|
|
position: absolute;
|
|
@@ -237,7 +244,6 @@ onDeactivated(() => {
|
|
|
font-size: 16px;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
.select-menus {
|
|
|
left: 50%;
|
|
|
transform: translateX(-50%);
|
|
@@ -257,7 +263,6 @@ onDeactivated(() => {
|
|
|
.photo {
|
|
|
flex: none;
|
|
|
width: calc(calc(100% - 24px * 3) / 4);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
&.max:after {
|
|
@@ -279,5 +284,4 @@ onDeactivated(() => {
|
|
|
height: 200px;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
</style>
|