This commit is contained in:
parent
4ecc8c213e
commit
1c86c874e0
|
@ -0,0 +1,18 @@
|
||||||
|
export default (param, value) => {
|
||||||
|
switch (param) {
|
||||||
|
case 'search':
|
||||||
|
return /^\d+$/.test(value)
|
||||||
|
? { id: value }
|
||||||
|
: {
|
||||||
|
or: [
|
||||||
|
{ name: { like: `%${value}%` } },
|
||||||
|
{ nickname: { like: `%${value}%` } },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
case 'name':
|
||||||
|
case 'nickname':
|
||||||
|
return { [param]: { like: `%${value}%` } };
|
||||||
|
case 'roleFk':
|
||||||
|
return { [param]: value };
|
||||||
|
}
|
||||||
|
};
|
|
@ -7,6 +7,8 @@ import AccountSummary from './Card/AccountSummary.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import AccountFilter from './AccountFilter.vue';
|
import AccountFilter from './AccountFilter.vue';
|
||||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
|
import exprBuilder from './AccountExprBuilder.js';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
|
@ -82,24 +84,6 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const exprBuilder = (param, value) => {
|
|
||||||
switch (param) {
|
|
||||||
case 'search':
|
|
||||||
return /^\d+$/.test(value)
|
|
||||||
? { id: value }
|
|
||||||
: {
|
|
||||||
or: [
|
|
||||||
{ name: { like: `%${value}%` } },
|
|
||||||
{ nickname: { like: `%${value}%` } },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
case 'name':
|
|
||||||
case 'nickname':
|
|
||||||
return { [param]: { like: `%${value}%` } };
|
|
||||||
case 'roleFk':
|
|
||||||
return { [param]: value };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,46 +1,26 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnSelectEnum from 'src/components/common/VnSelectEnum.vue';
|
import VnSelectEnum from 'src/components/common/VnSelectEnum.vue';
|
||||||
import FormModel from 'components/FormModel.vue';
|
import FormModel from 'components/FormModel.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import { ref, watch } from 'vue';
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const formModelRef = ref(null);
|
|
||||||
|
|
||||||
const accountFilter = {
|
|
||||||
where: { id: route.params.id },
|
|
||||||
fields: ['id', 'email', 'nickname', 'name', 'accountStateFk', 'packages', 'pickup'],
|
|
||||||
include: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.params.id,
|
|
||||||
() => formModelRef.value.reset()
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FormModel
|
<FormModel
|
||||||
ref="formModelRef"
|
ref="formModelRef"
|
||||||
url="VnUsers/preview"
|
:url-update="`VnUsers/${$route.params.id}/update-user`"
|
||||||
:url-update="`VnUsers/${route.params.id}/update-user`"
|
model="Account"
|
||||||
:filter="accountFilter"
|
|
||||||
model="Accounts"
|
|
||||||
auto-load
|
auto-load
|
||||||
@on-data-saved="formModelRef.fetch()"
|
@on-data-saved="$refs.formModelRef.fetch()"
|
||||||
>
|
>
|
||||||
<template #form="{ data }">
|
<template #form="{ data }">
|
||||||
<div class="q-gutter-y-sm">
|
<div class="q-gutter-y-sm">
|
||||||
<VnInput v-model="data.name" :label="t('account.card.nickname')" />
|
<VnInput v-model="data.name" :label="$t('account.card.nickname')" />
|
||||||
<VnInput v-model="data.nickname" :label="t('account.card.alias')" />
|
<VnInput v-model="data.nickname" :label="$t('account.card.alias')" />
|
||||||
<VnInput v-model="data.email" :label="t('globals.params.email')" />
|
<VnInput v-model="data.email" :label="$t('globals.params.email')" />
|
||||||
<VnSelect
|
<VnSelect
|
||||||
url="Languages"
|
url="Languages"
|
||||||
v-model="data.lang"
|
v-model="data.lang"
|
||||||
:label="t('account.card.lang')"
|
:label="$t('account.card.lang')"
|
||||||
option-value="code"
|
option-value="code"
|
||||||
option-label="code"
|
option-label="code"
|
||||||
/>
|
/>
|
||||||
|
@ -49,7 +29,7 @@ watch(
|
||||||
table="user"
|
table="user"
|
||||||
column="twoFactor"
|
column="twoFactor"
|
||||||
v-model="data.twoFactor"
|
v-model="data.twoFactor"
|
||||||
:label="t('account.card.twoFactor')"
|
:label="$t('account.card.twoFactor')"
|
||||||
option-value="code"
|
option-value="code"
|
||||||
option-label="code"
|
option-label="code"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnCard from 'components/common/VnCard.vue';
|
import VnCard from 'components/common/VnCard.vue';
|
||||||
import AccountDescriptor from './AccountDescriptor.vue';
|
import AccountDescriptor from './AccountDescriptor.vue';
|
||||||
|
import exprBuilder from '../AccountExprBuilder.js';
|
||||||
const { t } = useI18n();
|
import filter from './AccountFilter.js';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCard
|
<VnCard
|
||||||
|
url="VnUsers/preview"
|
||||||
|
:id-in-where="true"
|
||||||
data-key="Account"
|
data-key="Account"
|
||||||
|
:filter="filter"
|
||||||
:descriptor="AccountDescriptor"
|
:descriptor="AccountDescriptor"
|
||||||
search-data-key="AccountList"
|
search-data-key="AccountUsers"
|
||||||
:searchbar-props="{
|
:searchbar-props="{
|
||||||
url: 'VnUsers/preview',
|
url: 'VnUsers/preview',
|
||||||
label: t('account.search'),
|
label: $t('account.search'),
|
||||||
info: t('account.searchInfo'),
|
info: $t('account.searchInfo'),
|
||||||
|
exprBuilder,
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
import VnImg from 'src/components/ui/VnImg.vue';
|
import VnImg from 'src/components/ui/VnImg.vue';
|
||||||
|
import filter from './AccountFilter.js';
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
@ -21,12 +21,6 @@ const { t } = useI18n();
|
||||||
const entityId = computed(() => {
|
const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = {
|
|
||||||
where: { id: entityId },
|
|
||||||
fields: ['id', 'nickname', 'name', 'role'],
|
|
||||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
|
||||||
};
|
|
||||||
const hasAccount = ref(false);
|
const hasAccount = ref(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -41,8 +35,7 @@ const hasAccount = ref(false);
|
||||||
:url="`VnUsers/preview`"
|
:url="`VnUsers/preview`"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
module="Account"
|
module="Account"
|
||||||
@on-fetch="setData"
|
data-key="Account"
|
||||||
data-key="AccountId"
|
|
||||||
title="nickname"
|
title="nickname"
|
||||||
>
|
>
|
||||||
<template #menu>
|
<template #menu>
|
||||||
|
@ -69,7 +62,7 @@ const hasAccount = ref(false);
|
||||||
</template>
|
</template>
|
||||||
<template #body="{ entity }">
|
<template #body="{ entity }">
|
||||||
<VnLv :label="t('account.card.nickname')" :value="entity.name" />
|
<VnLv :label="t('account.card.nickname')" :value="entity.name" />
|
||||||
<VnLv :label="t('account.card.role')" :value="entity.role.name" />
|
<VnLv :label="t('account.card.role')" :value="entity.role?.name" />
|
||||||
</template>
|
</template>
|
||||||
<template #actions="{ entity }">
|
<template #actions="{ entity }">
|
||||||
<QCardActions class="q-gutter-x-md">
|
<QCardActions class="q-gutter-x-md">
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
export default {
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'email',
|
||||||
|
'nickname',
|
||||||
|
'name',
|
||||||
|
'accountStateFk',
|
||||||
|
'packages',
|
||||||
|
'pickup',
|
||||||
|
'role',
|
||||||
|
],
|
||||||
|
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||||
|
};
|
Loading…
Reference in New Issue