@@ -20,6 +20,9 @@ const showTabTitleFlag = ref(true)
2020// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
2121let currentInstance
2222import _ from ' lodash'
23+ import SQPreview from ' @/views/dashboard/preview/SQPreview.vue'
24+ import { useI18n } from ' vue-i18n'
25+ const { t } = useI18n ()
2326
2427const emits = defineEmits ([' parentAddItemBox' ])
2528
@@ -117,16 +120,7 @@ const beforeHandleCommand = (item: any, param: any) => {
117120 param: param ,
118121 }
119122}
120-
121- const titleStyle = (itemName : string ) => {
122- if (editableTabsValue .value === itemName ) {
123- return {}
124- } else {
125- return {}
126- }
127- }
128-
129- const isEditMode = computed (() => true )
123+ const isEditMode = computed (() => props .showPosition === ' canvas' )
130124
131125const addTabItem = (item : CanvasItem ) => {
132126 // do addTabItem
@@ -144,8 +138,34 @@ const addTabItem = (item: CanvasItem) => {
144138 refInstance .addItemToBox (newTabItem )
145139}
146140
141+ function sureCurTitle() {
142+ state .curItem .title = state .textarea
143+ state .dialogVisible = false
144+ }
145+
146+ const titleValid = computed (() => {
147+ return !! state .textarea && !! state .textarea .trim ()
148+ })
149+
150+ const titleStyle = (itemName : string ) => {
151+ let style = {}
152+ if (editableTabsValue .value === itemName ) {
153+ style = {
154+ fontSize: ' 16px' ,
155+ }
156+ } else {
157+ style = {
158+ fontSize: ' 14px' ,
159+ }
160+ }
161+ return style
162+ }
163+
147164onMounted (() => {
148165 currentInstance = getCurrentInstance ()
166+ if (configItem .value .propValue .length > 0 ) {
167+ editableTabsValue .value = configItem .value .propValue [0 ].name
168+ }
149169})
150170
151171defineExpose ({
@@ -166,7 +186,6 @@ defineExpose({
166186 :hide-title =" !showTabTitleFlag"
167187 @tab-add =" addTab"
168188 >
169- <!-- {{ configItem.collisionActive }} & {{ configItem.moveInActive }}${{ configItem.moveOutActive }}-->
170189 <template v-for =" tabItem in configItem .propValue " :key =" tabItem .name " >
171190 <el-tab-pane
172191 class =" el-tab-pane-custom"
@@ -185,21 +204,18 @@ defineExpose({
185204 @command =" handleCommand"
186205 >
187206 <span class =" el-dropdown-link" >
188- <el-icon v-if =" isEditMode" ><ArrowDown /></el-icon >
207+ <el-icon v-if =" isEditMode" style = " margin-top : 5 px " ><ArrowDown /></el-icon >
189208 </span >
190209 <template #dropdown >
191210 <el-dropdown-menu >
192211 <el-dropdown-item :command =" beforeHandleCommand('editTitle', tabItem)" >
193- edit
194- </el-dropdown-item >
195- <el-dropdown-item :command =" beforeHandleCommand('copyCur', tabItem)" >
196- copy
212+ {{ t('dashboard.edit') }}
197213 </el-dropdown-item >
198214 <el-dropdown-item
199215 v-if =" configItem.propValue.length > 1"
200216 :command =" beforeHandleCommand('deleteCur', tabItem)"
201217 >
202- delete
218+ {{ t('dashboard. delete') }}
203219 </el-dropdown-item >
204220 </el-dropdown-menu >
205221 </template >
@@ -216,7 +232,16 @@ defineExpose({
216232 class =" tab-content-custom"
217233 :class =" { 'switch-hidden': editableTabsValue !== tabItem.name }"
218234 >
235+ <SQPreview
236+ v-if =" showPosition === 'preview'"
237+ :ref =" 'tabPreviewRef_' + index"
238+ class =" tab-dashboard-preview"
239+ :component-data =" tabItem.componentData"
240+ :canvas-view-info =" canvasViewInfo"
241+ :base-matrix-count =" tabBaseMatrixCount"
242+ ></SQPreview >
219243 <DashboardEditor
244+ v-else
220245 :ref =" 'tabEditorRef_' + index"
221246 class =" tab-dashboard-editor-main"
222247 :canvas-component-data =" tabItem.componentData"
@@ -230,10 +255,35 @@ defineExpose({
230255 </DashboardEditor >
231256 </div >
232257 </custom-tab >
258+ <el-dialog
259+ v-model =" state.dialogVisible"
260+ :title =" t('dashboard.edit_title')"
261+ :append-to-body =" true"
262+ width =" 30%"
263+ :show-close =" false"
264+ :close-on-click-modal =" false"
265+ center
266+ >
267+ <el-input v-model =" state.textarea" maxlength =" 50" :placeholder =" t('common.input_content')" />
268+ <template #footer >
269+ <span class =" dialog-footer" >
270+ <el-button @click =" state.dialogVisible = false" >{{ t('common.cancel') }}</el-button >
271+ <el-button :disabled =" !titleValid" type =" primary" @click =" sureCurTitle" >{{
272+ t('common.confirm')
273+ }}</el-button >
274+ </span >
275+ </template >
276+ </el-dialog >
233277 </div >
234278</template >
235279
236280<style scoped lang="less">
281+ ::v- deep(.ed-tabs__header ) {
282+ margin : 0 24px 0 12px !important ;
283+ }
284+ ::v- deep(.ed-tabs__nav-scroll ) {
285+ margin : 0 12px !important ;
286+ }
237287.ed-dropdown-link {
238288 margin-top : 3px !important ;
239289}
@@ -245,6 +295,10 @@ defineExpose({
245295 margin : 2px !important ; // border size
246296}
247297
298+ .tab-dashboard-preview {
299+ background : #ffffff !important ;
300+ }
301+
248302.tab-dashboard-editor-main {
249303 height : 100% !important ;
250304}
@@ -258,4 +312,13 @@ defineExpose({
258312 overflow : visible !important ;
259313 }
260314}
315+
316+ .custom-tab-title {
317+ padding : 0 8px 0 4px !important ;
318+ }
319+
320+ .switch-hidden {
321+ opacity : 0 ;
322+ z-index : -1 ;
323+ }
261324 </style >
0 commit comments