|
@ -1,5 +1,5 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div> |
|
|
<div class="w-toolbar"> |
|
|
<div |
|
|
<div |
|
|
ref="containerRef" |
|
|
ref="containerRef" |
|
|
:class="'flex ' + (align === 'left' ? 'justify-start' : align === 'center' ? 'justify-center' : 'justify-end') + ' gap-x-[' + props.xGap + 'px]'" |
|
|
:class="'flex ' + (align === 'left' ? 'justify-start' : align === 'center' ? 'justify-center' : 'justify-end') + ' gap-x-[' + props.xGap + 'px]'" |
|
@ -9,12 +9,14 @@ |
|
|
<q-separator v-if="typeof btn.data === 'string' && btn.data === 'separator'" vertical class="class-action-item" /> |
|
|
<q-separator v-if="typeof btn.data === 'string' && btn.data === 'separator'" vertical class="class-action-item" /> |
|
|
<q-btn-dropdown |
|
|
<q-btn-dropdown |
|
|
v-else-if="Array.isArray(btn.data) && btn.data.length > 0" |
|
|
v-else-if="Array.isArray(btn.data) && btn.data.length > 0" |
|
|
:padding="dense ? '0px 0px' : undefined" |
|
|
|
|
|
unelevated |
|
|
unelevated |
|
|
|
|
|
:dense="dense" |
|
|
outline |
|
|
outline |
|
|
|
|
|
no-wrap |
|
|
|
|
|
no-caps |
|
|
v-bind="btn.data[0]" |
|
|
v-bind="btn.data[0]" |
|
|
:label="dense ? '' : btn.data[0].label" |
|
|
:label="dense ? '' : getLabel(btn.data[0].label)" |
|
|
:icon="dense ? undefined : btn.data[0].icon" |
|
|
:icon="dense ? undefined : getIcon(btn.data[0].icon)" |
|
|
:split="btn.data[0].click ? true : false" |
|
|
:split="btn.data[0].click ? true : false" |
|
|
:disable=" |
|
|
:disable=" |
|
|
btn.data[0].enableIf |
|
|
btn.data[0].enableIf |
|
@ -28,12 +30,13 @@ |
|
|
: false |
|
|
: false |
|
|
" |
|
|
" |
|
|
class="class-action-item" |
|
|
class="class-action-item" |
|
|
|
|
|
content-class="w-toolbar-btn-dropdown" |
|
|
@click="buttonClick(btn.data[0])" |
|
|
@click="buttonClick(btn.data[0])" |
|
|
> |
|
|
> |
|
|
<template v-if="dense" #label> |
|
|
<template v-if="dense" #label> |
|
|
<div :style="btn.data[0].click ? 'padding: 0px 8px' : 'padding: 0px 0px 0px 8px'"> |
|
|
<div :style="btn.data[0].click ? 'padding: 0px 8px' : 'padding: 0px 5px 0px 8px'"> |
|
|
<q-icon v-if="btn.data[0].icon" :name="btn.data[0].icon" size="xs"></q-icon> |
|
|
<q-icon v-if="btn.data[0].icon" :name="getIcon(btn.data[0].icon)" size="xs"></q-icon> |
|
|
<span style="padding-left: 3px">{{ btn.data[0].label }}</span> |
|
|
<span style="padding-left: 3px">{{ getLabel(btn.data[0].label) }}</span> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<q-list> |
|
|
<q-list> |
|
@ -46,6 +49,8 @@ |
|
|
:button="childrenBtn" |
|
|
:button="childrenBtn" |
|
|
:grid="grid" |
|
|
:grid="grid" |
|
|
:button-click="buttonClick" |
|
|
:button-click="buttonClick" |
|
|
|
|
|
:get-icon="getIcon" |
|
|
|
|
|
:get-label="getLabel" |
|
|
:dense="dense" |
|
|
:dense="dense" |
|
|
></ChildrenBtn> |
|
|
></ChildrenBtn> |
|
|
<q-item |
|
|
<q-item |
|
@ -66,7 +71,10 @@ |
|
|
@click="buttonClick(childrenBtn)" |
|
|
@click="buttonClick(childrenBtn)" |
|
|
> |
|
|
> |
|
|
<q-item-section> |
|
|
<q-item-section> |
|
|
<q-item-label><q-icon v-if="childrenBtn.icon" :name="childrenBtn.icon" left size="20px"></q-icon> {{ childrenBtn.label }}</q-item-label> |
|
|
<q-item-label |
|
|
|
|
|
><q-icon v-if="childrenBtn.icon" :name="getIcon(childrenBtn.icon)" left size="20px"></q-icon> |
|
|
|
|
|
{{ getLabel(childrenBtn.label) }}</q-item-label |
|
|
|
|
|
> |
|
|
</q-item-section> |
|
|
</q-item-section> |
|
|
</q-item> |
|
|
</q-item> |
|
|
</template> |
|
|
</template> |
|
@ -92,14 +100,14 @@ |
|
|
outline |
|
|
outline |
|
|
v-bind="btn.data" |
|
|
v-bind="btn.data" |
|
|
align="center" |
|
|
align="center" |
|
|
:icon="dense ? undefined : btn.data.icon" |
|
|
:icon="dense ? undefined : getIcon(btn.data.icon)" |
|
|
:label="dense ? '' : btn.data.label" |
|
|
:label="dense ? '' : getLabel(btn.data.label)" |
|
|
class="class-action-item" |
|
|
class="class-action-item" |
|
|
@click="buttonClick(btn.data)" |
|
|
@click="buttonClick(btn.data)" |
|
|
> |
|
|
> |
|
|
<div v-if="dense"> |
|
|
<div v-if="dense"> |
|
|
<q-icon v-if="btn.data.icon" :name="btn.data.icon" size="xs"></q-icon> |
|
|
<q-icon v-if="btn.data.icon" :name="getIcon(btn.data.icon)" size="xs"></q-icon> |
|
|
<span style="padding-left: 3px">{{ btn.data.label }}</span> |
|
|
<span style="padding-left: 3px">{{ getLabel(btn.data.label) }}</span> |
|
|
</div> |
|
|
</div> |
|
|
</q-btn> |
|
|
</q-btn> |
|
|
</template> |
|
|
</template> |
|
@ -110,13 +118,15 @@ |
|
|
unelevated |
|
|
unelevated |
|
|
outline |
|
|
outline |
|
|
label="" |
|
|
label="" |
|
|
|
|
|
no-wrap |
|
|
|
|
|
no-caps |
|
|
:icon="undefined" |
|
|
:icon="undefined" |
|
|
padding="0px 0px" |
|
|
|
|
|
:dense="dense" |
|
|
:dense="dense" |
|
|
class="class-action-item" |
|
|
class="class-action-item" |
|
|
|
|
|
content-class="w-toolbar-btn-dropdown" |
|
|
> |
|
|
> |
|
|
<template #label> |
|
|
<template #label> |
|
|
<div style="padding: 0px 8px"> |
|
|
<div style="padding: 0px 5px 0px 8px"> |
|
|
<span>{{ $t('more') }}</span> |
|
|
<span>{{ $t('more') }}</span> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
@ -128,6 +138,8 @@ |
|
|
:button="childrenBtn.data" |
|
|
:button="childrenBtn.data" |
|
|
:grid="grid" |
|
|
:grid="grid" |
|
|
:button-click="buttonClick" |
|
|
:button-click="buttonClick" |
|
|
|
|
|
:get-icon="getIcon" |
|
|
|
|
|
:get-label="getLabel" |
|
|
:dense="dense" |
|
|
:dense="dense" |
|
|
></ChildrenBtn> |
|
|
></ChildrenBtn> |
|
|
<q-item |
|
|
<q-item |
|
@ -149,7 +161,8 @@ |
|
|
> |
|
|
> |
|
|
<q-item-section> |
|
|
<q-item-section> |
|
|
<q-item-label |
|
|
<q-item-label |
|
|
><q-icon v-if="childrenBtn.data.icon" :name="childrenBtn.data.icon" left size="20px"></q-icon> {{ childrenBtn.data.label }}</q-item-label |
|
|
><q-icon v-if="childrenBtn.data.icon" :name="getIcon(childrenBtn.data.icon)" left size="20px"></q-icon> |
|
|
|
|
|
{{ getLabel(childrenBtn.data.label) }}</q-item-label |
|
|
> |
|
|
> |
|
|
</q-item-section> |
|
|
</q-item-section> |
|
|
</q-item> |
|
|
</q-item> |
|
@ -161,7 +174,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<script setup lang="ts"> |
|
|
<script setup lang="ts"> |
|
|
import { ref, reactive, computed, nextTick, onUpdated } from 'vue'; |
|
|
import { ref, reactive, computed, nextTick, onUpdated, watch } from 'vue'; |
|
|
import { eventBus } from '@/platform'; |
|
|
import { eventBus } from '@/platform'; |
|
|
import { Tools } from '@/platform/utils'; |
|
|
import { Tools } from '@/platform/utils'; |
|
|
import ChildrenBtn from './ChildrenBtn.vue'; |
|
|
import ChildrenBtn from './ChildrenBtn.vue'; |
|
@ -348,11 +361,6 @@ const moreActionsComputed = computed(() => { |
|
|
return moreActions.value; |
|
|
return moreActions.value; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// onUpdated(() => { |
|
|
|
|
|
// nextTick(() => { |
|
|
|
|
|
// console.info('buttons=====', props.buttons); |
|
|
|
|
|
// }); |
|
|
|
|
|
// }); |
|
|
|
|
|
eventBus.on('onLocaleChanged', () => { |
|
|
eventBus.on('onLocaleChanged', () => { |
|
|
nextTick(() => { |
|
|
nextTick(() => { |
|
|
extractButton(props.buttons); |
|
|
extractButton(props.buttons); |
|
@ -362,6 +370,15 @@ eventBus.on('onLocaleChanged', () => { |
|
|
isActionWidthInitializedRef.value = false; |
|
|
isActionWidthInitializedRef.value = false; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
// onUpdated(() => { |
|
|
|
|
|
// console.info('onupdated====', props.buttons); |
|
|
|
|
|
// }); |
|
|
|
|
|
// watch( |
|
|
|
|
|
// () => props.buttons.map((item) => item['label']), |
|
|
|
|
|
// (newVal, oldVal) => { |
|
|
|
|
|
// console.info('watch====', newVal); |
|
|
|
|
|
// }, |
|
|
|
|
|
// ); |
|
|
|
|
|
|
|
|
const loadingComputed = computed(() => { |
|
|
const loadingComputed = computed(() => { |
|
|
return function (btn) { |
|
|
return function (btn) { |
|
@ -372,6 +389,36 @@ const loadingComputed = computed(() => { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
const getIcon = (icon) => { |
|
|
|
|
|
if (Tools.isUndefinedOrNull(icon)) { |
|
|
|
|
|
return undefined; |
|
|
|
|
|
} else if (typeof icon === 'function') { |
|
|
|
|
|
return icon({ |
|
|
|
|
|
selected: firstSelectedComputed.value, |
|
|
|
|
|
selecteds: selectedComputed.value, |
|
|
|
|
|
ticked: firstTickedComputed.value, |
|
|
|
|
|
tickeds: tickedComputed.value, |
|
|
|
|
|
grid: props.grid, |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
return icon; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
const getLabel = (label) => { |
|
|
|
|
|
if (Tools.isUndefinedOrNull(label)) { |
|
|
|
|
|
return ''; |
|
|
|
|
|
} else if (typeof label === 'function') { |
|
|
|
|
|
return label({ |
|
|
|
|
|
selected: firstSelectedComputed.value, |
|
|
|
|
|
selecteds: selectedComputed.value, |
|
|
|
|
|
ticked: firstTickedComputed.value, |
|
|
|
|
|
tickeds: tickedComputed.value, |
|
|
|
|
|
grid: props.grid, |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
return label; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
const firstSelectedComputed = computed(() => { |
|
|
const firstSelectedComputed = computed(() => { |
|
|
if (Object.keys(props.grid).length > 0 && props.grid.getSelectedRows().length > 0) { |
|
|
if (Object.keys(props.grid).length > 0 && props.grid.getSelectedRows().length > 0) { |
|
|
return props.grid.getSelectedRows()[0]; |
|
|
return props.grid.getSelectedRows()[0]; |
|
@ -429,13 +476,16 @@ const buttonClick = async (button) => { |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang="css"> |
|
|
<style lang="css"> |
|
|
.q-btn.disabled { |
|
|
.w-toolbar-btn-dropdown .q-btn.disabled { |
|
|
opacity: 0.7 !important; |
|
|
opacity: 0.7 !important; |
|
|
color: #a8a8a8; |
|
|
color: #a8a8a8; |
|
|
} |
|
|
} |
|
|
.q-item.disabled { |
|
|
.w-toolbar-btn-dropdown .q-item.disabled { |
|
|
opacity: 0.6 !important; |
|
|
opacity: 0.6 !important; |
|
|
color: #a8a8a8; |
|
|
color: #a8a8a8; |
|
|
} |
|
|
} |
|
|
|
|
|
.w-toolbar .q-btn-dropdown__arrow { |
|
|
|
|
|
margin-left: 0px !important; |
|
|
|
|
|
} |
|
|
</style> |
|
|
</style> |
|
|