jws-frontend/src/components/04_product-service/BasicInfoProduct.vue

238 lines
6.1 KiB
Vue
Raw Normal View History

2024-06-14 14:45:17 +07:00
<script setup lang="ts">
2024-07-30 05:29:36 +00:00
import { QSelect } from 'quasar';
2024-07-10 12:52:27 +07:00
import { getRole } from 'src/services/keycloak';
2024-08-09 15:06:41 +07:00
import { selectFilterOptionRefMod } from 'stores/utils';
2024-07-02 17:01:05 +07:00
import { ref, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
const { locale } = useI18n({ useScope: 'global' });
2024-06-19 13:50:45 +07:00
const remark = defineModel<string>('remark', { default: '' });
2024-08-14 14:54:44 +07:00
const detail = defineModel<string>('detail', { default: '' });
2024-06-18 16:31:56 +07:00
const process = defineModel<number>('process');
2024-06-14 14:45:17 +07:00
const name = defineModel<string>('name');
const code = defineModel<string>('code');
const registeredBranchId = defineModel<string>('registeredBranchId');
const codeOption = ref<{ id: string; name: string }[]>([]);
2024-07-26 10:46:23 +00:00
const optionsBranch = defineModel<{ id: string; name: string }[]>(
'optionsBranch',
2024-07-30 05:29:36 +00:00
{ default: [] },
2024-07-26 10:46:23 +00:00
);
2024-07-02 17:01:05 +07:00
2024-07-26 10:46:23 +00:00
defineProps<{
2024-06-14 14:45:17 +07:00
dense?: boolean;
outlined?: boolean;
readonly?: boolean;
isType?: boolean;
}>();
2024-07-02 17:01:05 +07:00
onMounted(async () => {
const resultOption = await fetch('/option/option.json');
const option = await resultOption.json();
if (locale.value === 'en-US') {
codeOption.value = option.eng.typeProduct;
}
if (locale.value === 'th-th') {
codeOption.value = option.tha.typeProduct;
}
});
2024-07-26 10:46:23 +00:00
const codeOptions = ref<Record<string, unknown>[]>([]);
const codeFilter = selectFilterOptionRefMod(codeOption, codeOptions, 'label');
const branchOptions = ref<Record<string, unknown>[]>([]);
const branchFilter = selectFilterOptionRefMod(
optionsBranch,
branchOptions,
'name',
);
2024-06-14 14:45:17 +07:00
</script>
<template>
2024-08-09 10:56:27 +00:00
<div class="row col-12">
<div class="col-12 q-pb-sm text-weight-bold text-body1 row items-center">
<q-icon
flat
size="xs"
class="q-pa-sm rounded q-mr-sm"
color="info"
name="mdi-office-building-outline"
style="background-color: var(--surface-3)"
/>
{{ $t(`formDialogTitleInformation`) }}
</div>
2024-06-19 10:34:20 +07:00
2024-08-09 10:56:27 +00:00
<div class="col-12 row q-col-gutter-sm">
<q-select
2024-07-08 16:27:44 +07:00
outlined
2024-08-09 10:56:27 +00:00
clearable
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
input-debounce="0"
class="col-3"
v-model="code"
id="select-br-id"
option-label="label"
option-value="value"
lazy-rules="ondemand"
:dense="dense"
2024-06-21 08:49:20 +00:00
:readonly="readonly"
2024-08-09 10:56:27 +00:00
:options="codeOptions"
:label="$t('productCode')"
:hide-dropdown-icon="readonly"
:rules="[(val: string) => !!val]"
@filter="codeFilter"
2024-06-21 08:49:20 +00:00
>
2024-08-09 10:56:27 +00:00
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select
outlined
clearable
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
input-debounce="0"
class="col-3"
option-value="id"
option-label="name"
lazy-rules="ondemand"
id="input-source-nationality"
v-model="registeredBranchId"
:dense="dense"
:readonly="readonly"
:options="branchOptions"
:hide-dropdown-icon="readonly"
:label="$t('registeredBranch')"
:rules="[
(val) => {
const roles = getRole() || [];
const isSpecialRole = ['admin', 'system', 'head_of_admin'].some(
(role) => roles.includes(role),
);
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
},
]"
@filter="branchFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-input
lazy-rules="ondemand"
for="input-name"
:dense="dense"
outlined
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="$t('productName')"
v-model="name"
/>
<q-input
lazy-rules="ondemand"
for="input-process"
:dense="dense"
outlined
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-3"
:label="$t('productProcessingTime')"
v-model="process"
type="number"
/>
2024-08-14 14:54:44 +07:00
<!-- <q-input
2024-08-09 10:56:27 +00:00
lazy-rules="ondemand"
for="input-detail"
:dense="dense"
outlined
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
type="textarea"
class="col-12"
:label="$t('serviceDetail')"
v-model="detail"
2024-08-14 14:54:44 +07:00
/> -->
2024-08-09 10:56:27 +00:00
<div class="col-12">
<q-field
class="full-width"
outlined
2024-06-21 08:49:20 +00:00
:readonly="readonly"
2024-08-09 10:56:27 +00:00
:borderless="readonly"
:label="$t('detail')"
stack-label
dense
>
<q-editor
dense
2024-08-14 14:54:44 +07:00
v-model="detail"
2024-08-09 10:56:27 +00:00
min-height="5rem"
class="full-width q-mt-sm q-mb-xs"
:flat="!readonly"
:readonly="readonly"
:toolbar-color="
readonly ? 'disabled' : $q.dark.isActive ? 'white' : ''
"
:toolbar-toggle-color="readonly ? 'disabled' : 'primary'"
style="
cursor: auto;
color: var(--foreground);
border-color: var(--surface-3);
"
/>
</q-field>
</div>
2024-08-14 14:54:44 +07:00
<q-input
2024-08-09 10:56:27 +00:00
lazy-rules="ondemand"
2024-08-14 14:54:44 +07:00
for="input-remark"
2024-08-09 10:56:27 +00:00
:dense="dense"
outlined
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
type="textarea"
class="col-12"
:label="$t('formDialogInputRemark')"
2024-08-14 14:54:44 +07:00
v-model="remark"
/>
2024-06-14 14:45:17 +07:00
</div>
</div>
</template>
2024-06-19 13:50:45 +07:00
<style scoped>
.q-editor__toolbar {
border-bottom: none !important;
}
2024-06-21 08:49:20 +00:00
:deep(.q-editor__toolbar.row.no-wrap.scroll-x) {
2024-06-24 07:59:24 +00:00
background-color: var(--surface-2) !important;
2024-06-21 08:49:20 +00:00
}
2024-06-25 10:45:56 +00:00
:deep(.q-editor__toolbar) {
border-color: var(--surface-3) !important;
}
2024-06-19 13:50:45 +07:00
</style>