|
@@ -1,12 +1,14 @@
|
|
<template>
|
|
<template>
|
|
- <ui-group-option class="sign">
|
|
|
|
|
|
+ <ui-group-option class="sign" :class="{active}">
|
|
<div class="content">
|
|
<div class="content">
|
|
<span class="cover" @click="fly">
|
|
<span class="cover" @click="fly">
|
|
<img :src="getResource(getFileUrl(view.cover))" alt="">
|
|
<img :src="getResource(getFileUrl(view.cover))" alt="">
|
|
</span>
|
|
</span>
|
|
<ui-input
|
|
<ui-input
|
|
|
|
+ class="view-title-input"
|
|
type="text"
|
|
type="text"
|
|
:modelValue="view.title"
|
|
:modelValue="view.title"
|
|
|
|
+ :maxlength="15"
|
|
@update:modelValue="(title: string) => $emit('updateTitle', title)"
|
|
@update:modelValue="(title: string) => $emit('updateTitle', title)"
|
|
v-show="isEditTitle"
|
|
v-show="isEditTitle"
|
|
ref="inputRef"
|
|
ref="inputRef"
|
|
@@ -14,7 +16,7 @@
|
|
/>
|
|
/>
|
|
<div class="title" v-show="!isEditTitle" @click="fly">
|
|
<div class="title" v-show="!isEditTitle" @click="fly">
|
|
<p>{{ view.title }}</p>
|
|
<p>{{ view.title }}</p>
|
|
- <span>{{ getModelTypeDesc(modelType as ModelType) }}</span>
|
|
|
|
|
|
+ <span> {{ getModelDesc(modelType as ModelType) }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="action" v-if="edit">
|
|
<div class="action" v-if="edit">
|
|
@@ -29,14 +31,15 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
-import { ref, computed } from 'vue'
|
|
|
|
|
|
+import { ref, computed, watchEffect } from 'vue'
|
|
import { useFocus } from 'bill/hook/useFocus'
|
|
import { useFocus } from 'bill/hook/useFocus'
|
|
-import { getResource } from '@/env'
|
|
|
|
-import { getFileUrl } from '@/utils'
|
|
|
|
-import { loadModel, getModelTypeDesc, ModelType } from '@/model'
|
|
|
|
|
|
+import { custom, getResource } from '@/env'
|
|
|
|
+import { deepIsRevise, getFileUrl } from '@/utils'
|
|
|
|
+import { loadModel, getModelDesc, ModelType, currentModel } from '@/model'
|
|
import { viewToModelType } from '@/store'
|
|
import { viewToModelType } from '@/store'
|
|
|
|
|
|
import type { View } from '@/store'
|
|
import type { View } from '@/store'
|
|
|
|
+import { Message } from 'bill/expose-common'
|
|
|
|
|
|
const props = withDefaults(
|
|
const props = withDefaults(
|
|
defineProps<{ view: View, edit?: boolean }>(),
|
|
defineProps<{ view: View, edit?: boolean }>(),
|
|
@@ -55,6 +58,14 @@ const menus = [
|
|
|
|
|
|
const inputRef = ref()
|
|
const inputRef = ref()
|
|
const isEditTitle = useFocus(computed(() => inputRef.value?.vmRef.root))
|
|
const isEditTitle = useFocus(computed(() => inputRef.value?.vmRef.root))
|
|
|
|
+
|
|
|
|
+watchEffect(() => {
|
|
|
|
+ if (!isEditTitle.value && !props.view.title.length) {
|
|
|
|
+ isEditTitle.value = true
|
|
|
|
+ Message.warning('视图名称不可为空')
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+
|
|
const actions = {
|
|
const actions = {
|
|
delete: () => emit('delete'),
|
|
delete: () => emit('delete'),
|
|
rename: () => isEditTitle.value = true
|
|
rename: () => isEditTitle.value = true
|
|
@@ -62,10 +73,21 @@ const actions = {
|
|
const modelType = viewToModelType(props.view)
|
|
const modelType = viewToModelType(props.view)
|
|
const fly = async () => {
|
|
const fly = async () => {
|
|
const sdk = await loadModel(modelType)
|
|
const sdk = await loadModel(modelType)
|
|
|
|
+ custom.currentView = props.view
|
|
sdk.setView(props.view.flyData)
|
|
sdk.setView(props.view.flyData)
|
|
}
|
|
}
|
|
|
|
+const active = computed(() => {
|
|
|
|
+ return custom.currentView === props.view && !deepIsRevise(currentModel.value, modelType)
|
|
|
|
+})
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" src="./style.scss" scoped>
|
|
<style lang="scss" src="./style.scss" scoped>
|
|
|
|
+</style>
|
|
|
|
+
|
|
|
|
+<style>
|
|
|
|
+ .view-title-input.ui-input .text.suffix input {
|
|
|
|
+ padding-right: 50px;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|