0
0
Fork 0

Compare commits

...

12 Commits

13 changed files with 2620 additions and 2 deletions

View File

@ -95,6 +95,7 @@ defineExpose({
getChanges, getChanges,
formData, formData,
vnPaginateRef, vnPaginateRef,
resetData,
}); });
onBeforeRouteLeave((to, from, next) => { onBeforeRouteLeave((to, from, next) => {

View File

@ -183,6 +183,12 @@ watch(
{ immediate: true } { immediate: true }
); );
watch(
() => $props.create,
(value) => (createForm.value = value),
{ immediate: true }
);
watch( watch(
() => route.query[$props.searchUrl], () => route.query[$props.searchUrl],
(val) => setUserParams(val) (val) => setUserParams(val)
@ -535,6 +541,7 @@ function handleScroll() {
<QBtn <QBtn
v-for="(btn, index) of col.actions" v-for="(btn, index) of col.actions"
v-show="btn.show ? btn.show(row) : true" v-show="btn.show ? btn.show(row) : true"
v-bind="row.attrs"
:key="index" :key="index"
:title="btn.title" :title="btn.title"
:icon="btn.icon" :icon="btn.icon"
@ -548,6 +555,7 @@ function handleScroll() {
(btn.show && btn.show(row)) ?? true ? 'visible' : 'hidden' (btn.show && btn.show(row)) ?? true ? 'visible' : 'hidden'
}`" }`"
@click="btn.action(row)" @click="btn.action(row)"
:disable="btn.disable ? btn.disable(row) : true"
/> />
</QTd> </QTd>
</template> </template>

View File

@ -128,7 +128,7 @@ const addFilter = async (filter, params) => {
async function fetch(params) { async function fetch(params) {
useArrayData(props.dataKey, params); useArrayData(props.dataKey, params);
arrayData.reset(['filter.skip', 'skip']); arrayData.reset(['filter.skip', 'skip', 'page']);
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
if (!store.hasMoreData) isLoading.value = false; if (!store.hasMoreData) isLoading.value = false;

1196
src/i18n/en/index.js Normal file

File diff suppressed because it is too large Load Diff

1198
src/i18n/es/index.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -277,6 +277,7 @@ globals:
medical: Mutual medical: Mutual
RouteExtendedList: Router RouteExtendedList: Router
wasteRecalc: Waste recaclulate wasteRecalc: Waste recaclulate
translations: Translations
operator: Operator operator: Operator
supplier: Supplier supplier: Supplier
created: Created created: Created

View File

@ -281,6 +281,7 @@ globals:
serial: Facturas por serie serial: Facturas por serie
medical: Mutua medical: Mutua
wasteRecalc: Recalcular mermas wasteRecalc: Recalcular mermas
translations: Traducciones
operator: Operario operator: Operario
supplier: Proveedor supplier: Proveedor
created: Fecha creación created: Fecha creación

View File

@ -93,12 +93,14 @@ const exprBuilder = (param, value) => {
:label="t('customer.basicData.phone')" :label="t('customer.basicData.phone')"
:rules="validate('client.phone')" :rules="validate('client.phone')"
clearable clearable
type="number"
v-model="data.phone" v-model="data.phone"
/> />
<VnInput <VnInput
:label="t('customer.basicData.mobile')" :label="t('customer.basicData.mobile')"
:rules="validate('client.mobile')" :rules="validate('client.mobile')"
clearable clearable
type="number"
v-model="data.mobile" v-model="data.mobile"
/> />
</VnRow> </VnRow>

View File

@ -0,0 +1,182 @@
<script setup>
import { ref } from 'vue';
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import VnTable from 'src/components/VnTable/VnTable.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import axios from 'axios';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchData from 'src/components/FetchData.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();
const columns = computed(() => [
{
align: 'left',
name: primaryKey,
label: t('primaryKey'),
create: true,
},
{
align: 'left',
name: 'en',
label: t('defaultLang(en)'),
},
{
align: 'left',
name: lang,
label: lang,
},
{
align: 'right',
label: '',
name: 'tableActions',
actions: [
{
title: t('View Summary'),
icon: 'save',
action: (row) => upsertI18n(row),
isPrimary: true,
disable: (row) => !row.hasChanges,
},
],
},
]);
const tableRef = ref({});
const langs = ref([]);
const tables = ref([]);
const lang = ref('es');
const primaryKey = computed(() => table.value.primaryKey);
const field = computed(() => table.value.field);
const table = ref();
const originalData = ref([]);
const url = computed(() => table.value?.tableName + 's');
async function loadTable(data) {
if (data) {
originalData.value = [];
tableRef.value.CrudModelRef.formData = [];
const newData = {};
for (const translation of data) {
if (!newData[translation[primaryKey.value]])
newData[translation[primaryKey.value]] = {};
newData[translation[primaryKey.value]][translation.lang] =
translation[field.value];
}
for (const currentData in newData) {
originalData.value.push({
[primaryKey.value]: currentData,
...newData[currentData],
});
tableRef.value.CrudModelRef.formData.push({
[primaryKey.value]: currentData,
...newData[currentData],
});
}
return;
}
tableRef.value.CrudModelRef.formData = JSON.parse(JSON.stringify(originalData.value));
}
function resetOriginalData() {
originalData.value = null;
}
async function upsertI18n(data) {
await axios.patch(url.value, {
[field.value]: data[lang.value],
[primaryKey.value]: data[primaryKey.value],
lang: lang.value,
});
const index = originalData.value.findIndex(
(t) => t[primaryKey.value] == data[primaryKey.value]
);
originalData.value[index] = data;
data.hasChanges = false;
}
</script>
<template>
<FetchData url="Languages" @on-fetch="(data) => (langs = data)" auto-load />
<FetchData
url="Applications/get-i18n-tables"
@on-fetch="(data) => (tables = data)"
auto-load
/>
<VnSubToolbar>
<template #st-data>
<VnSelect
:label="t('table')"
v-model="table"
:options="tables"
option-label="tableName"
option-value="tableName"
@update:model-value="resetOriginalData()"
:emit-value="false"
/>
<VnSelect
:label="t('lang')"
v-model="lang"
:options="langs"
option-label="code"
option-value="code"
@update:model-value="loadTable()"
/>
</template>
</VnSubToolbar>
<VnTable
ref="tableRef"
data-key="translations"
:url="url"
:columns="columns"
:filter="{ limit: 50 }"
:create="{
urlCreate: url,
title: 'Create translation',
onDataSaved: () => tableRef.reload(),
formInitialData: { lang: 'en' },
}"
:right-search="false"
@on-fetch="(data) => loadTable(data)"
:save-fn="upsertI18n"
:search-url="false"
>
<template #[`column-${lang}`]="{ row }">
<VnInput
v-model="row[lang]"
:clearable="false"
@keyup.enter="upsertI18n(row)"
@update:model-value="
(value) => {
row.hasChanges =
value !=
originalData.find((o) => o[primaryKey] == row[primaryKey])?.[
lang
];
}
"
/>
</template>
<template #more-create-dialog="{ data }">
<VnInput v-model="data[field]" :label="field" />
</template>
</VnTable>
</template>
<i18n>
es:
primaryKey: Clave primaria
defaultLang(en): Idioma por defecto(Eng)
secondLang: Idioma secundario
table: Tabla
lang: Idioma
en:
primaryKey: Primary key
defaultLang(en): Default language(Eng)
secondLang: Second language
table: Table
lang: Language
</i18n>

View File

@ -22,6 +22,7 @@ import Account from './account';
import Monitor from './monitor'; import Monitor from './monitor';
import MailAlias from './mailAlias'; import MailAlias from './mailAlias';
import Role from './role'; import Role from './role';
import TranslationsVn from './translationsVn.js';
export default [ export default [
Item, Item,
@ -48,4 +49,5 @@ export default [
MailAlias, MailAlias,
Monitor, Monitor,
Role, Role,
TranslationsVn,
]; ];

View File

@ -0,0 +1,16 @@
import { RouterView } from 'vue-router';
export default {
path: '/translations',
name: 'Translations',
meta: {
title: 'translations',
icon: 'history_edu',
moduleName: 'Translations',
},
component: RouterView,
menus: {
main: [],
card: [],
},
};

View File

@ -12,7 +12,7 @@ export default {
component: RouterView, component: RouterView,
redirect: { name: 'WorkerMain' }, redirect: { name: 'WorkerMain' },
menus: { menus: {
main: ['WorkerList', 'WorkerDepartment'], main: ['WorkerList', 'WorkerDepartment', 'TranslationsVn'],
card: [ card: [
'WorkerBasicData', 'WorkerBasicData',
'WorkerNotes', 'WorkerNotes',
@ -55,6 +55,15 @@ export default {
}, },
component: () => import('src/pages/Worker/WorkerDepartment.vue'), component: () => import('src/pages/Worker/WorkerDepartment.vue'),
}, },
{
path: 'translations',
name: 'TranslationsVn',
meta: {
title: 'translations',
icon: 'history_edu',
},
component: () => import('src/pages/Worker/TranslationsVn.vue'),
},
{ {
path: 'create', path: 'create',
name: 'WorkerCreate', name: 'WorkerCreate',

View File

@ -22,6 +22,7 @@ import zone from 'src/router/modules/zone';
import account from './modules/account'; import account from './modules/account';
import monitor from 'src/router/modules/monitor'; import monitor from 'src/router/modules/monitor';
import mailAlias from './modules/mailAlias'; import mailAlias from './modules/mailAlias';
import translationsVn from './modules/translationsVn';
const routes = [ const routes = [
{ {
@ -97,6 +98,7 @@ const routes = [
account, account,
role, role,
mailAlias, mailAlias,
translationsVn,
{ {
path: '/:catchAll(.*)*', path: '/:catchAll(.*)*',
name: 'NotFound', name: 'NotFound',