โครงสร้าง => refactor code
This commit is contained in:
parent
007df38109
commit
1412ea630b
13 changed files with 369 additions and 408 deletions
|
|
@ -4,8 +4,9 @@ import { useQuasar } from "quasar";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/**
|
||||
* importType
|
||||
*/
|
||||
import type {
|
||||
FormDataNewStructure,
|
||||
FormNewStructureRef,
|
||||
|
|
@ -13,18 +14,29 @@ import type {
|
|||
HistoryType,
|
||||
} from "@/modules/02_organizationalNew/interface/index/Main";
|
||||
|
||||
/** importComponents*/
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/**
|
||||
* importStore
|
||||
*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
|
||||
|
||||
/**
|
||||
* use
|
||||
*/
|
||||
const $q = useQuasar();
|
||||
const store = useOrganizational();
|
||||
const { dialogConfirm, showLoader, success, hideLoader, messageError } =
|
||||
useCounterMixin();
|
||||
|
||||
/**
|
||||
* props
|
||||
*/
|
||||
const modal = defineModel<boolean>("newStructure", { required: true });
|
||||
const status = defineModel<boolean>("status", { required: true });
|
||||
const type = defineModel<string>("type", { default: "NEW" });
|
||||
|
||||
const props = defineProps({
|
||||
fetchActive: {
|
||||
type: Function,
|
||||
|
|
@ -51,8 +63,6 @@ const typeOp = ref<DataOption[]>([
|
|||
name: "ทำสำเนาโครงสร้าง ตำแหน่ง และคนครอง",
|
||||
},
|
||||
]);
|
||||
const orgRevisionOpMain = ref<DataOption[]>([]);
|
||||
const orgRevisionOp = ref<DataOption[]>([]);
|
||||
|
||||
const orgRevisionNameRef = ref<Object | null>(null);
|
||||
const typeRef = ref<Object | null>(null);
|
||||
|
|
@ -64,14 +74,18 @@ const formData = reactive<FormDataNewStructure>({
|
|||
typeDraft: "",
|
||||
});
|
||||
|
||||
/** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */
|
||||
/**
|
||||
* maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ
|
||||
*/
|
||||
const objectRef: FormNewStructureRef = {
|
||||
orgRevisionName: orgRevisionNameRef,
|
||||
type: typeRef,
|
||||
orgRevisionId: orgRevisionIdRef,
|
||||
};
|
||||
|
||||
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
|
||||
/**
|
||||
* ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม
|
||||
*/
|
||||
function validateForm() {
|
||||
const hasError = [];
|
||||
for (const key in objectRef) {
|
||||
|
|
@ -88,7 +102,9 @@ function validateForm() {
|
|||
}
|
||||
}
|
||||
|
||||
/** ฟังชั่น บันทึก */
|
||||
/**
|
||||
* ฟังชั่น บันทึก
|
||||
*/
|
||||
function onSubmit() {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
|
|
@ -120,6 +136,9 @@ function onSubmit() {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังชั่น ปิด popup
|
||||
*/
|
||||
function close() {
|
||||
modal.value = false;
|
||||
formData.orgRevisionId = "";
|
||||
|
|
@ -127,20 +146,18 @@ function close() {
|
|||
formData.typeDraft = "";
|
||||
}
|
||||
|
||||
async function fetchOrgRevision() {
|
||||
/**
|
||||
* เรียกข้อมูล
|
||||
*/
|
||||
function fetchOrgRevision() {
|
||||
showLoader();
|
||||
await http
|
||||
http
|
||||
.get(config.API.organizationHistoryNew)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result.filter(
|
||||
(e: HistoryType) => e.orgRevisionIsDraft === false
|
||||
);
|
||||
if (data) {
|
||||
// const listOption = data.map((e: HistoryType) => ({
|
||||
// id: e.orgRevisionId,
|
||||
// name: e.orgRevisionName,
|
||||
// }));
|
||||
// orgRevisionOpMain.value = listOption;
|
||||
const currentStr = await data.find(
|
||||
(x: any) => x.orgRevisionIsCurrent === true
|
||||
);
|
||||
|
|
@ -155,20 +172,6 @@ async function fetchOrgRevision() {
|
|||
});
|
||||
}
|
||||
|
||||
// function filterSelector(val: any, update: Function, refData: string) {
|
||||
// switch (refData) {
|
||||
// case "orgRevisionId":
|
||||
// update(() => {
|
||||
// orgRevisionOp.value = orgRevisionOpMain.value.filter(
|
||||
// (v: DataOption) => v.name.indexOf(val) > -1
|
||||
// );
|
||||
// });
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
watch(
|
||||
() => modal.value,
|
||||
() => {
|
||||
|
|
@ -218,36 +221,6 @@ watch(
|
|||
lazy-rules
|
||||
/>
|
||||
</div>
|
||||
<!-- <div class="col-6" v-if="type !== 'NEW'">
|
||||
<q-select
|
||||
for="#orgRevisionId"
|
||||
ref="orgRevisionIdRef"
|
||||
dense
|
||||
hide-bottom-space
|
||||
outlined
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
emit-value
|
||||
map-options
|
||||
v-model="formData.orgRevisionId"
|
||||
:options="orgRevisionOp"
|
||||
label="เลือกโครงสร้าง"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกโครงการสร้าง'}`]"
|
||||
lazy-rules
|
||||
use-input
|
||||
@filter="(inputValue:any,
|
||||
doneFn:Function) => filterSelector(inputValue, doneFn,'orgRevisionId'
|
||||
) "
|
||||
>
|
||||
<template v-slot:no-option>
|
||||
<q-item>
|
||||
<q-item-section class="text-grey-5">
|
||||
ไม่พบข้อมูล
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
</div> -->
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue