Files
myprojplanet_vite/src/components/CMySelect/CMySelect.vue

225 lines
6.7 KiB
Vue
Raw Normal View History

2021-09-16 21:08:02 +02:00
<template>
<div class="text-center">
<div v-if="multiselect_by_server">
<q-select
:model-value="myarrvalue"
2022-02-14 11:30:53 +01:00
@update:model-value="changeval"
v-bind="$attrs"
label-color="primary"
:label="label"
@filter="filterFn"
@filter-abort="abortFilterFn"
2022-01-23 23:25:19 +01:00
input-debounce="600"
rounded
outlined
multiple
options-dense
map-options
stack-label
emit-value
:readonly="sola_lettura"
:use-input="useinput"
:dense="dense"
:input-class="myclass"
:options="valori"
:option-value="optval"
2022-02-15 13:37:33 +01:00
options-selected-class="text-deep-blue"
class="combowidth"
2022-02-14 11:30:53 +01:00
style="min-width: 250px"
>
<template v-if="getIcon() && !sola_lettura" v-slot:prepend>
<q-icon :name="getIcon()" />
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
2022-02-21 18:14:38 +01:00
Digita il testo da cercare
</q-item-section>
</q-item>
</template>
<template v-slot:selected-item="scope">
<div v-if="scope.opt[fieldsTable.getLabelByTable(tablesel)]">
<q-chip
:removable="!sola_lettura"
dense
@remove="scope.removeAtIndex(scope.index)"
v-if="checkIfShowRec(scope.opt)"
color="white"
text-color="mycol"
class="q-my-none q-ml-xs q-mr-none"
>
<q-avatar color="primary" text-color="white" icon="" size="12px"/>
{{ scope.opt[fieldsTable.getLabelByTable(tablesel)] }}
</q-chip>
</div>
</template>
2022-01-20 01:17:21 +01:00
<template v-slot:option="{ itemProps, opt, selected, toggleOption }">
<q-item v-bind="itemProps">
<q-item-section>
<q-item-label>{{ opt[fieldsTable.getLabelByTable(tablesel)] }}</q-item-label>
</q-item-section>
<q-item-section side>
<q-toggle :model-value="selected" @update:model-value="toggleOption(opt)"/>
</q-item-section>
</q-item>
</template>
</q-select>
</div>
2022-01-23 23:25:19 +01:00
<div v-else-if="pickup">
2021-09-16 21:08:02 +02:00
<q-select
v-if="pickup"
:model-value="myvalue"
2022-02-14 11:30:53 +01:00
@update:model-value="changeval"
clearable
2022-02-14 11:30:53 +01:00
rounded
outlined
options-dense
use-input
input-debounce="300"
:dense="dense"
:input-class="myclass"
:options="valori"
:option-value="optval"
:option-label="optlab"
map-options
@filter="filterFn"
:label="label"
2022-02-14 11:30:53 +01:00
options-selected-class="text-deep-blue"
v-bind="$attrs"
2022-02-14 11:30:53 +01:00
class="combowidth"
>
<template v-if="getIcon()" v-slot:prepend>
<q-icon :name="getIcon()" />
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
2022-02-21 18:14:38 +01:00
Digita il testo da cercare
</q-item-section>
</q-item>
</template>
<template v-slot:option="scope">
<q-item v-bind="scope.itemProps">
<q-item-section>
<q-item-label> {{ tools.getValueByFunzOrVal(scope.opt,optlab) }}</q-item-label>
</q-item-section>
</q-item>
</template>
</q-select>
2022-01-23 23:25:19 +01:00
</div>
<div v-else-if="multiple">
<q-select
:multiple="true"
:model-value="myarrvalue"
label-color="primary"
:label="label"
@update:model-value="changeval"
rounded
outlined
2022-01-26 01:31:07 +01:00
@filter="filterFn"
2022-01-23 23:25:19 +01:00
v-bind="$attrs"
:input-class="myclass"
:use-input="useinput"
input-debounce="0"
@new-value="newvaluefuncfirst"
2022-01-23 23:25:19 +01:00
map-options
emit-value
stack-label
:options="valori"
2022-02-15 13:37:33 +01:00
options-selected-class="text-deep-blue"
2022-01-23 23:25:19 +01:00
:option-value="optval"
:option-label="optlab"
:dense="dense">
<template v-if="getIcon()" v-slot:prepend>
<q-icon :name="getIcon()" />
</template>
2022-01-23 23:25:19 +01:00
<template
v-slot:selected-item="scope">
<div v-if="tools.getValueByFunzOrVal(scope.opt,optlab)">
2022-01-23 23:25:19 +01:00
<q-chip
removable
dense
@remove="scope.removeAtIndex(scope.index)"
v-if="checkIfShowRec(scope.opt)"
color="white"
class="q-my-none q-ml-xs q-mr-none"
>
<q-avatar color="primary" text-color="white" :icon="scope.opt.icon ? scope.opt.icon : ''" size="12px"/>
{{ tools.getValueByFunzOrVal(scope.opt, optlab) }}
2022-01-23 23:25:19 +01:00
</q-chip>
</div>
</template>
<template
v-if="withToggle"
v-slot:option="{ itemProps, opt, selected, toggleOption }">
<q-item v-bind="itemProps">
<q-item-section>
<q-item-label>{{ tools.getValueByFunzOrVal(opt,optlab) }}</q-item-label>
2022-02-04 23:48:53 +01:00
<q-item-label v-if="'hint' in opt" class="hint">{{ opt['hint'] }}</q-item-label>
2022-01-23 23:25:19 +01:00
</q-item-section>
<q-item-section side>
<q-toggle :model-value="selected" @update:model-value="toggleOption(opt)"/>
2022-01-23 23:25:19 +01:00
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div v-else>
<q-select
2022-01-23 23:25:19 +01:00
:multiple="false"
2021-09-16 21:08:02 +02:00
rounded
outlined
:dense="dense"
:input-class="myclass"
:model-value="myvalue"
2021-12-11 00:25:35 +01:00
:options="valori"
2021-09-16 21:08:02 +02:00
:option-value="optval"
:option-label="optlab"
@update:model-value="changeval"
2022-01-26 01:31:07 +01:00
@filter="filterFn"
2021-09-16 21:08:02 +02:00
:label="label"
:use-input="useinput"
@new-value="newvaluefuncfirst"
2021-09-16 21:08:02 +02:00
emit-value
2022-02-14 11:30:53 +01:00
input-debounce="0"
2022-02-15 13:37:33 +01:00
options-selected-class="text-deep-blue"
2021-09-16 21:08:02 +02:00
map-options
2021-12-17 18:30:18 +01:00
v-bind="$attrs"
class="combowidth">
<template v-if="getIcon()" v-slot:prepend>
<q-icon :name="getIcon()" />
</template>
2021-12-17 18:30:18 +01:00
<template v-slot:option="scope">
<q-item v-bind="scope.itemProps">
<q-item-section avatar>
<q-icon :name="scope.opt.icon ? scope.opt.icon : ''"/>
</q-item-section>
<q-item-section>
<q-item-label>{{ tools.getValueByFunzOrVal(scope.opt,optlab) }}</q-item-label>
2022-02-04 23:48:53 +01:00
<q-item-label v-if="'hint' in scope.opt" class="hint">{{ scope.opt['hint'] }}</q-item-label>
2021-12-17 18:30:18 +01:00
</q-item-section>
</q-item>
</template>
2021-09-16 21:08:02 +02:00
</q-select>
2022-01-20 01:17:21 +01:00
2021-09-16 21:08:02 +02:00
</div>
</div>
</template>
<script lang="ts" src="./CMySelect.ts">
</script>
<style lang="scss" scoped>
@import './CMySelect.scss';
</style>