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

186 lines
4.3 KiB
Vue
Raw Normal View History

2024-06-14 14:45:17 +07:00
<script setup lang="ts">
2024-07-10 12:52:27 +07:00
import { getRole } from 'src/services/keycloak';
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-06-14 14:45:17 +07:00
const detail = defineModel<string>('detail');
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-02 17:01:05 +07:00
const props = defineProps<{
2024-06-14 14:45:17 +07:00
dense?: boolean;
outlined?: boolean;
readonly?: boolean;
separator?: boolean;
isType?: boolean;
optionsBranch: { id: string; name: string }[];
2024-06-14 14:45:17 +07:00
}>();
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:57:31 +07:00
if (!!props.optionsBranch) {
registeredBranchId.value = props.optionsBranch[0].id;
}
2024-07-02 17:01:05 +07:00
});
2024-06-14 14:45:17 +07:00
</script>
<template>
2024-06-21 08:49:20 +00:00
<div class="col-3 app-text-muted">
{{ $t(`formDialogTitleInformation`) }}
</div>
2024-06-20 13:21:28 +07:00
2024-06-21 08:49:20 +00:00
<div class="col-9 row q-col-gutter-md">
2024-07-02 17:01:05 +07:00
<q-select
id="select-br-id"
2024-06-21 08:49:20 +00:00
:dense="dense"
2024-07-02 17:01:05 +07:00
outlined
2024-06-21 08:49:20 +00:00
:readonly="readonly"
2024-07-02 17:01:05 +07:00
:hide-dropdown-icon="readonly"
emit-value
map-options
options-dense
clearable
2024-06-21 08:49:20 +00:00
hide-bottom-space
class="col-3"
v-model="code"
2024-07-02 17:01:05 +07:00
:label="$t('productCode')"
option-label="label"
option-value="value"
:options="codeOption"
:rules="[(val: string) => !!val]"
2024-06-21 08:49:20 +00:00
/>
2024-06-19 10:34:20 +07:00
<q-select
id="input-source-nationality"
:dense="dense"
outlined
:readonly="readonly"
:hide-dropdown-icon="readonly"
hide-bottom-space
emit-value
map-options
options-dense
:label="$t('registeredBranch')"
2024-07-26 10:57:31 +07:00
class="col-3"
option-label="name"
option-value="id"
v-model="registeredBranchId"
:options="optionsBranch"
2024-07-10 12:52:27 +07:00
:rules="[
2024-07-26 10:57:31 +07:00
(val) => {
const roles = getRole() || [];
const isSpecialRole = ['admin', 'system', 'head_of_admin'].some(
(role) => roles.includes(role),
);
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
},
]"
clearable
/>
2024-06-21 08:49:20 +00:00
<q-input
for="input-name"
:dense="dense"
2024-07-08 16:27:44 +07:00
outlined
2024-06-21 08:49:20 +00:00
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
2024-06-21 08:49:20 +00:00
:label="$t('productName')"
v-model="name"
/>
2024-06-19 10:34:20 +07:00
2024-06-21 08:49:20 +00:00
<q-input
for="input-detail"
:dense="dense"
2024-07-08 16:27:44 +07:00
outlined
2024-06-21 08:49:20 +00:00
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
type="textarea"
class="col-12"
:label="$t('serviceDetail')"
v-model="detail"
autogrow
/>
2024-06-19 10:34:20 +07:00
2024-06-21 08:49:20 +00:00
<div class="col-12">
<q-field
class="full-width"
2024-07-08 16:27:44 +07:00
outlined
2024-06-21 08:49:20 +00:00
:readonly="readonly"
:borderless="readonly"
:label="$t('detail')"
stack-label
dense
>
<q-editor
2024-06-20 13:21:28 +07:00
dense
2024-06-21 08:49:20 +00:00
v-model="remark"
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'"
2024-06-25 10:45:56 +00:00
style="
cursor: auto;
color: var(--foreground);
border-color: var(--surface-3);
"
2024-06-21 08:49:20 +00:00
/>
</q-field>
2024-06-14 14:45:17 +07:00
</div>
2024-06-21 08:49:20 +00:00
<q-input
for="input-process"
:dense="dense"
2024-07-08 16:27:44 +07:00
outlined
2024-06-21 08:49:20 +00:00
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-4"
2024-07-09 10:16:30 +07:00
:label="$t('productProcessingTime')"
2024-06-21 08:49:20 +00:00
v-model="process"
type="number"
/>
2024-06-14 14:45:17 +07:00
</div>
2024-06-21 08:49:20 +00:00
2024-06-14 14:45:17 +07:00
<q-separator
v-if="separator"
2024-06-21 08:49:20 +00:00
class="col-12 q-mb-md"
style="padding-block: 0.5px; margin-top: 32px"
2024-06-14 14:45:17 +07:00
/>
</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>