updated
This commit is contained in:
parent
ba728ea000
commit
ee9442702f
11 changed files with 212 additions and 88 deletions
|
|
@ -42,7 +42,9 @@ const $q = useQuasar();
|
|||
const id = ref<string>(route.params.id as string);
|
||||
const isSave = ref<boolean>(false); // มีการแก้ไขรอบันทึก
|
||||
const respondentType = ref<string>("");
|
||||
const organization = ref<DataOption>();
|
||||
const organizationId = ref<string>("");
|
||||
const organizationName = ref<string>("");
|
||||
const consideredAgency = ref<string>("");
|
||||
const organizationOption = ref<DataOption[]>([]);
|
||||
/** ตัวแปร ref สำหรับแสดง validate */
|
||||
|
|
@ -83,18 +85,37 @@ const objectdisciplinary: FormRef = {
|
|||
};
|
||||
|
||||
/** function เรียกรายชื่อหน่วยงาน*/
|
||||
async function fetchOrganization() {
|
||||
/** ดึงข้อมูล active */
|
||||
async function getActive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.typeOc())
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
organizationOption.value = data.map((e: DataOptionRes) => ({
|
||||
id: e.organizationId,
|
||||
name: e.organizationName,
|
||||
getOc(res.data.result.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function getOc(activeId: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByid(activeId))
|
||||
.then(async (res) => {
|
||||
organizationOption.value = await res.data.result.map((item: any) => ({
|
||||
id: item.orgTreeId,
|
||||
name: item.orgName,
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -103,24 +124,6 @@ async function selectComplainant(val: string) {
|
|||
consideredAgency.value = "";
|
||||
}
|
||||
|
||||
/** ฟังชั่นตรวจสอบความถูกต้องก่อน บันทึก */
|
||||
function validateForm() {
|
||||
const hasError = [];
|
||||
for (const key in objectdisciplinary) {
|
||||
if (Object.prototype.hasOwnProperty.call(objectdisciplinary, key)) {
|
||||
const property = objectdisciplinary[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
countNum.value = 1;
|
||||
onSubmit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชั่นสำหรับบันทึกข้อมูล ระบบจะแสดง dialog ให้ยืนยันการบันทึก
|
||||
* หากยืนยันจะส่งข้อมูลไปบันทึกที่ api
|
||||
|
|
@ -163,7 +166,14 @@ watch(
|
|||
formData.year = props.data.resultYear ?? 0;
|
||||
mainStore.rowsAdd = props.data.persons;
|
||||
await fetchDatadetail();
|
||||
await fetchOrganization();
|
||||
await getActive();
|
||||
|
||||
organizationId.value = props.data.organizationId;
|
||||
organizationName.value = props.data.organization;
|
||||
organization.value = {
|
||||
id: props.data.organizationId,
|
||||
name: props.data.organization,
|
||||
};
|
||||
} else if (countNum.value === 2) {
|
||||
formData.disciplineDisciplinary_DocResults =
|
||||
props.data.disciplineDisciplinary_DocResults;
|
||||
|
|
@ -270,7 +280,12 @@ function updatemodalPersonal(modal: boolean) {
|
|||
<q-separator />
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="validateForm" class="col-12 row">
|
||||
<q-form
|
||||
greedy
|
||||
@submit.prevent
|
||||
@validation-success="onSubmit"
|
||||
class="col-12 row"
|
||||
>
|
||||
<div class="col-12 row">
|
||||
<div class="col-sm-12 col-md-9 row no-wrap">
|
||||
<div class="col-12 q-pa-md">
|
||||
|
|
@ -306,11 +321,12 @@ function updatemodalPersonal(modal: boolean) {
|
|||
</q-select>
|
||||
</div>
|
||||
<div
|
||||
class="col-xs-12 col-sm-3"
|
||||
class="col-xs-12 col-sm-4"
|
||||
v-if="respondentType === 'ORGANIZATION'"
|
||||
id="organizationId"
|
||||
>
|
||||
<q-select
|
||||
readonly
|
||||
for="inputOffice"
|
||||
name="organizationId"
|
||||
ref="organizationIdRef"
|
||||
|
|
@ -319,11 +335,10 @@ function updatemodalPersonal(modal: boolean) {
|
|||
outlined
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
emit-value
|
||||
map-options
|
||||
v-model="organizationId"
|
||||
v-model="organization"
|
||||
:options="organizationOption"
|
||||
label="เลือกสำนักงาน"
|
||||
label="หน่วยงานที่ถูกร้องเรียน"
|
||||
/>
|
||||
</div>
|
||||
<div class="row col-12" v-if="respondentType === 'PERSON'">
|
||||
|
|
@ -598,7 +613,7 @@ function updatemodalPersonal(modal: boolean) {
|
|||
>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</q-form>
|
||||
</div>
|
||||
|
||||
<PopupPersonal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue