refactor: add registered branch to product group

This commit is contained in:
Methapon Metanipat 2024-09-10 13:35:53 +07:00
parent 01c5592f7d
commit 67d360c92b
5 changed files with 92 additions and 144 deletions

View file

@ -1,6 +1,5 @@
<script setup lang="ts">
import { QSelect } from 'quasar';
import { getRole } from 'src/services/keycloak';
import useOptionStore from 'src/stores/options';
import { selectFilterOptionRefMod } from 'stores/utils';
import { ref, onMounted, watch } from 'vue';
@ -15,13 +14,8 @@ const process = defineModel<number>('process');
const name = defineModel<string>('name');
const code = defineModel<string>('code');
const expenseType = defineModel<string>('expenseType');
const registeredBranchId = defineModel<string>('registeredBranchId');
const codeOption = ref<{ id: string; name: string }[]>([]);
const optionsBranch = defineModel<{ id: string; name: string }[]>(
'optionsBranch',
{ default: [] },
);
defineProps<{
dense?: boolean;
@ -46,13 +40,6 @@ onMounted(async () => {
const codeOptions = ref<Record<string, unknown>[]>([]);
const codeFilter = selectFilterOptionRefMod(codeOption, codeOptions, 'label');
const branchOptions = ref<Record<string, unknown>[]>([]);
const branchFilter = selectFilterOptionRefMod(
optionsBranch,
branchOptions,
'name',
);
const expenseTypeOptions = ref<Record<string, unknown>[]>([]);
let expenseTypeFilter: (
value: string,
@ -128,51 +115,6 @@ watch(
</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-md-3 col-6"
option-value="id"
option-label="name"
id="input-source-nationality"
v-model="registeredBranchId"
:dense="dense"
:readonly="readonly"
:options="branchOptions"
:hide-dropdown-icon="readonly"
:label="$t('productService.product.registeredBranch')"
:rules="[
(val) => {
const roles = getRole() || [];
const isSpecialRole = ['admin', 'system', 'head_of_admin'].some(
(role) => roles.includes(role),
);
return (
isSpecialRole ||
!!val ||
$t('form.error.selectField', {
field: $t('productService.product.registeredBranch'),
})
);
},
]"
@filter="branchFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('general.noData') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-input
for="input-name"
@ -207,19 +149,6 @@ watch(
/>
</template>
</q-input>
<!-- <q-input
for="input-detail"
:dense="dense"
outlined
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
type="textarea"
class="col-12"
:label="$t('serviceDetail')"
v-model="detail"
/> -->
<q-select
outlined
clearable