chore: install prettier
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
>
|
||||
<div
|
||||
:class="['is-clickable p-3', i !== 0 && 'mt-2', getStyle(v)]"
|
||||
style="width: 120px; border-radius: 4px;"
|
||||
style="width: 120px; border-radius: 4px"
|
||||
v-for="(v, i) in tabsArray"
|
||||
:key="i"
|
||||
@click="changeTab(v)"
|
||||
@@ -17,11 +17,14 @@
|
||||
</div>
|
||||
|
||||
<!-- Tab Content -->
|
||||
<div
|
||||
<div
|
||||
:class="`column pl-4 ${viewport < 2 ? 'px-0' : 'pr-0 py-0'}`"
|
||||
style="min-width: 0"
|
||||
>
|
||||
<div v-if="isLoading" class="has-text-centered">
|
||||
<div
|
||||
v-if="isLoading"
|
||||
class="has-text-centered"
|
||||
>
|
||||
<span class="icon is-large">
|
||||
<SvgIcon v-bind="{ name: 'loading.svg', type: 'primary', size: 18 }" />
|
||||
</span>
|
||||
@@ -58,10 +61,10 @@ const tabsArray = computed(() => {
|
||||
if (Array.isArray(props.tabs)) {
|
||||
return props.tabs;
|
||||
}
|
||||
if (typeof props.tabs === 'object' && props.tabs !== null) {
|
||||
if (typeof props.tabs === "object" && props.tabs !== null) {
|
||||
return Object.keys(props.tabs)
|
||||
.sort()
|
||||
.map(key => props.tabs[key]);
|
||||
.map((key) => props.tabs[key]);
|
||||
}
|
||||
return [];
|
||||
});
|
||||
@@ -80,11 +83,13 @@ const isVietnamese = computed(() => lang.value === "vi");
|
||||
const viewport = computed(() => store.viewport);
|
||||
|
||||
const record = ref(props.row || {});
|
||||
const activeTab = ref(tabsArray.value.find(t => t.active === true || t.active === 'true')?.code || tabsArray.value[0]?.code || '');
|
||||
const activeTab = ref(
|
||||
tabsArray.value.find((t) => t.active === true || t.active === "true")?.code || tabsArray.value[0]?.code || "",
|
||||
);
|
||||
const tabData = ref(null);
|
||||
const isLoading = ref(false);
|
||||
|
||||
const activeComponent = computed(() => tabsArray.value.find(t => t.code === activeTab.value));
|
||||
const activeComponent = computed(() => tabsArray.value.find((t) => t.code === activeTab.value));
|
||||
|
||||
const componentProps = computed(() => {
|
||||
const baseProps = {
|
||||
@@ -100,7 +105,7 @@ const componentProps = computed(() => {
|
||||
if (record.value) {
|
||||
for (const key in tabSpecificProps) {
|
||||
const value = tabSpecificProps[key];
|
||||
if (typeof value === 'string' && value.startsWith('row.')) {
|
||||
if (typeof value === "string" && value.startsWith("row.")) {
|
||||
const recordKey = value.substring(4);
|
||||
processedProps[key] = record.value[recordKey];
|
||||
} else {
|
||||
@@ -112,14 +117,18 @@ const componentProps = computed(() => {
|
||||
return { ...baseProps, ...processedProps };
|
||||
});
|
||||
|
||||
watch(activeTab, async (newTabCode) => {
|
||||
const tabConfig = tabsArray.value.find(t => t.code === newTabCode);
|
||||
if (tabConfig && tabConfig.api) {
|
||||
await fetchTabData(tabConfig);
|
||||
} else {
|
||||
tabData.value = null;
|
||||
}
|
||||
}, { immediate: true });
|
||||
watch(
|
||||
activeTab,
|
||||
async (newTabCode) => {
|
||||
const tabConfig = tabsArray.value.find((t) => t.code === newTabCode);
|
||||
if (tabConfig && tabConfig.api) {
|
||||
await fetchTabData(tabConfig);
|
||||
} else {
|
||||
tabData.value = null;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
async function fetchTabData(tabConfig) {
|
||||
isLoading.value = true;
|
||||
@@ -136,16 +145,16 @@ async function fetchTabData(tabConfig) {
|
||||
let params = $copy(tabConfig.api.params);
|
||||
for (const key in params.filter) {
|
||||
const value = params.filter[key];
|
||||
if (typeof value === 'string' && value.startsWith('record.')) {
|
||||
if (typeof value === "string" && value.startsWith("record.")) {
|
||||
const recordKey = value.substring(7);
|
||||
params.filter[key] = record.value[recordKey];
|
||||
}
|
||||
}
|
||||
conn.params = params;
|
||||
}
|
||||
|
||||
|
||||
const result = await $getapi([conn]);
|
||||
const apiResult = result.find(r => r.name === tabConfig.api.name);
|
||||
const apiResult = result.find((r) => r.name === tabConfig.api.name);
|
||||
if (apiResult && apiResult.data) {
|
||||
tabData.value = apiResult.data.rows;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user