Merge branch 'dev/phatt' into develop

This commit is contained in:
puriphatt 2024-04-10 19:12:23 +07:00
commit aeb55aa3fe
2 changed files with 33 additions and 25 deletions

View file

@ -38,7 +38,7 @@ const color = ['pink', 'purple'];
<div class="column justify-around stat-card-content"> <div class="column justify-around stat-card-content">
<div class="col-4 text-h5 text-weight-bold">{{ v.amount }}</div> <div class="col-4 text-h5 text-weight-bold">{{ v.amount }}</div>
<div class="text-weight-bold">{{ $t(v.label) }}</div> <div class="text-weight-bold">{{ v.label }}</div>
</div> </div>
</app-box> </app-box>
</div> </div>

View file

@ -114,11 +114,6 @@ const userOption = ref<UserOption>({
brOpts: [], brOpts: [],
}); });
const brOpts = ref([
{ label: '0000000001-1', value: '1' },
{ label: '0000000001-2', value: '2' },
]);
const selectorList = [ const selectorList = [
{ label: 'personnelSelector1', count: 0 }, { label: 'personnelSelector1', count: 0 },
{ label: 'personnelSelector2', count: 0 }, { label: 'personnelSelector2', count: 0 },
@ -159,7 +154,7 @@ async function fetchBrOption(id: string) {
const res = await branchStore.fetchById(id, { const res = await branchStore.fetchById(id, {
includeSubBranch: true, includeSubBranch: true,
}); });
if (res) { if (res.branch) {
res.branch.map((item) => { res.branch.map((item) => {
userOption.value.brOpts.push({ userOption.value.brOpts.push({
label: item.code, label: item.code,
@ -215,10 +210,11 @@ async function openDialog(id?: string) {
: null; : null;
formData.value.responsibleArea = foundUser.responsibleArea; formData.value.responsibleArea = foundUser.responsibleArea;
userId.value = foundUser.id; userId.value = foundUser.id;
hqId.value = foundUser.branch[0].id; hqId.value = foundUser.branch[0].headOfficeId as string;
brId.value = foundUser.branch; brId.value = foundUser.branch[0].id;
code.value = foundUser.code; code.value = foundUser.code;
isEdit.value = true; isEdit.value = true;
console.log(hqId.value);
} }
} }
} }
@ -235,17 +231,26 @@ function onClose() {
} }
async function onSubmit() { async function onSubmit() {
try { console.log('enter');
if (isEdit.value === true && userId.value) { if (isEdit.value === true && userId.value) {
await userStore.editById(userId.value, formData.value); console.log('edit');
} else { await userStore.editById(userId.value, formData.value);
formData.value.keycloakId = await createKeycloak(); } else {
await userStore.create(formData.value); console.log('post');
formData.value.keycloakId = await createKeycloak();
if (formData.value.keycloakId) {
const result = await userStore.create(formData.value);
console.log('Result after create:', result);
console.log('bb');
if (result) {
console.log('hi3');
console.log(result.id);
// await branchStore.addUser(result.id, userId.value);
}
} }
} finally {
modal.value = false;
await userStore.fetchList();
} }
onClose();
userStore.fetchList();
} }
async function onDelete(id: string) { async function onDelete(id: string) {
@ -268,8 +273,9 @@ function mapUserType(label: string) {
onMounted(async () => { onMounted(async () => {
await userStore.fetchList({ includeBranch: true }); await userStore.fetchList({ includeBranch: true });
typeStats.value = await userStore.typeStats(); typeStats.value = await userStore.typeStats();
if ((await branchStore.userStats(formData.value.userType)) !== false) { const res = await branchStore.userStats(formData.value.userType);
userStats.value = await branchStore.userStats(formData.value.userType); if (res) {
userStats.value = res;
} }
}); });
@ -277,8 +283,9 @@ watch(
() => selectorLabel.value, () => selectorLabel.value,
async (label) => { async (label) => {
mapUserType(label); mapUserType(label);
if ((await branchStore.userStats(label)) !== false) { const res = await branchStore.userStats(label);
userStats.value = await branchStore.userStats(label); if (res) {
userStats.value = res;
} }
}, },
); );
@ -311,7 +318,8 @@ watch(
<AppBox bordered class="column full-width"> <AppBox bordered class="column full-width">
<div class="row q-pb-lg justify-between items-center"> <div class="row q-pb-lg justify-between items-center">
<div class="text-weight-bold text-subtitle1"> <div class="text-weight-bold text-subtitle1">
{{ $t('personnelStatTitle') + $t(selectorLabel) }} {{ $t('personnelStatTitle') }}
{{ selectorLabel === '' ? '' : $t(selectorLabel) }}
</div> </div>
<q-btn <q-btn
dense dense
@ -457,9 +465,9 @@ watch(
option-label="label" option-label="label"
option-value="value" option-value="value"
v-model="formData.userRole" v-model="formData.userRole"
:options="brOpts" :options="genderOpts"
:rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']"
/> />
<!-- :rules="[(val: string) => !!val || 'กรุณาเลือกสิทธิ์ผู้ใช้งาน']" -->
<q-input <q-input
dense dense
outlined outlined