fix: refs #7936 update select model-value WIP
gitea/salix-front/pipeline/pr-master This commit looks good
Details
gitea/salix-front/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
b447df7217
commit
8843318b66
|
@ -294,7 +294,7 @@ async function onScroll({ to, direction, from, index }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({ opts: myOptions });
|
defineExpose({ opts: myOptions, vnSelectRef });
|
||||||
|
|
||||||
function handleKeyDown(event) {
|
function handleKeyDown(event) {
|
||||||
if (event.key === 'Tab' && !event.shiftKey) {
|
if (event.key === 'Tab' && !event.shiftKey) {
|
||||||
|
@ -346,7 +346,6 @@ function getCaption(opt) {
|
||||||
:emit-value="nullishToTrue($attrs['emit-value'])"
|
:emit-value="nullishToTrue($attrs['emit-value'])"
|
||||||
:map-options="nullishToTrue($attrs['map-options'])"
|
:map-options="nullishToTrue($attrs['map-options'])"
|
||||||
:use-input="nullishToTrue($attrs['use-input'])"
|
:use-input="nullishToTrue($attrs['use-input'])"
|
||||||
:hide-selected="nullishToTrue($attrs['hide-selected'])"
|
|
||||||
:fill-input="nullishToTrue($attrs['fill-input'])"
|
:fill-input="nullishToTrue($attrs['fill-input'])"
|
||||||
ref="vnSelectRef"
|
ref="vnSelectRef"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useRole } from 'src/composables/useRole';
|
import { useRole } from 'src/composables/useRole';
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
const value = defineModel({ type: [String, Number, Object] });
|
const value = defineModel({ type: [String, Number, Object] });
|
||||||
|
const select = ref(null);
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
rolesAllowedToCreate: {
|
rolesAllowedToCreate: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
@ -33,10 +34,13 @@ const isAllowedToCreate = computed(() => {
|
||||||
if ($props.acls.length) return acl.hasAny($props.acls);
|
if ($props.acls.length) return acl.hasAny($props.acls);
|
||||||
return role.hasAny($props.rolesAllowedToCreate);
|
return role.hasAny($props.rolesAllowedToCreate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineExpose({ vnSelectDialogRef: select });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
ref="select"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
@update:model-value="(...args) => emit('update:modelValue', ...args)"
|
@update:model-value="(...args) => emit('update:modelValue', ...args)"
|
||||||
|
|
|
@ -33,15 +33,19 @@ defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function test(row) {
|
||||||
|
console.log('test', row);
|
||||||
|
return `${row.id}: ${row.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
name: 'expense',
|
name: 'expense',
|
||||||
label: t('Expense'),
|
label: t('Expense'),
|
||||||
field: (row) => row.expenseFk,
|
|
||||||
options: expenses.value,
|
options: expenses.value,
|
||||||
model: 'expenseFk',
|
model: 'expenseFk',
|
||||||
optionValue: 'id',
|
optionValue: 'id',
|
||||||
optionLabel: (row) => `${row.id}: ${row.name}`,
|
optionLabel: (row) => test(row),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
|
@ -119,6 +123,8 @@ function taxRate(invoiceInTax) {
|
||||||
return ((taxTypeSage / 100) * taxableBase).toFixed(2);
|
return ((taxTypeSage / 100) * taxableBase).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const expensesRef = ref();
|
||||||
|
const exponseShow = ref(false);
|
||||||
function autocompleteExpense(evt, row, col) {
|
function autocompleteExpense(evt, row, col) {
|
||||||
const val = evt.target.value;
|
const val = evt.target.value;
|
||||||
if (!val) return;
|
if (!val) return;
|
||||||
|
@ -127,9 +133,17 @@ function autocompleteExpense(evt, row, col) {
|
||||||
const lookup = expenses.value.find(
|
const lookup = expenses.value.find(
|
||||||
({ id }) => id == useAccountShortToStandard(param)
|
({ id }) => id == useAccountShortToStandard(param)
|
||||||
);
|
);
|
||||||
|
if (lookup) {
|
||||||
if (lookup) row[col.model] = lookup;
|
row[col.model] = lookup?.id;
|
||||||
|
expensesRef.value.showItem = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatOpt = (row, { model, options }, prop) => {
|
||||||
|
const obj = row[model];
|
||||||
|
const option = options.find(({ id }) => id == obj);
|
||||||
|
return option ? `${obj}:${option[prop]}` : '';
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -167,15 +181,19 @@ function autocompleteExpense(evt, row, col) {
|
||||||
<template #body-cell-expense="{ row, col }">
|
<template #body-cell-expense="{ row, col }">
|
||||||
<QTd>
|
<QTd>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
|
ref="expensesRef"
|
||||||
v-model="row[col.model]"
|
v-model="row[col.model]"
|
||||||
:options="col.options"
|
:options="col.options"
|
||||||
:option-value="col.optionValue"
|
:option-value="col.optionValue"
|
||||||
:option-label="col.optionLabel"
|
|
||||||
:filter-options="['id', 'name']"
|
:filter-options="['id', 'name']"
|
||||||
:tooltip="t('Create a new expense')"
|
:tooltip="t('Create a new expense')"
|
||||||
@keydown.tab="autocompleteExpense($event, row, col)"
|
@keydown.tab="autocompleteExpense($event, row, col)"
|
||||||
|
@input-value="(data) => (row[col.model] = undefined)"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #selected-item="scope">
|
||||||
|
A{{ scope.opt.id }}B</template
|
||||||
|
>
|
||||||
|
<!-- <template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
{{ `${scope.opt.id}: ${scope.opt.name}` }}
|
{{ `${scope.opt.id}: ${scope.opt.name}` }}
|
||||||
</QItem>
|
</QItem>
|
||||||
|
@ -184,7 +202,7 @@ function autocompleteExpense(evt, row, col) {
|
||||||
<CreateNewExpenseForm
|
<CreateNewExpenseForm
|
||||||
@on-data-saved="$refs.expensesRef.fetch()"
|
@on-data-saved="$refs.expensesRef.fetch()"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template> -->
|
||||||
</VnSelectDialog>
|
</VnSelectDialog>
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue