validate formPosition
This commit is contained in:
parent
cb56eb25af
commit
704b224775
1 changed files with 38 additions and 43 deletions
|
|
@ -234,12 +234,14 @@ async function fetchPosition(id: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dataLevel = ref<any>();
|
||||||
/** function เรียกรายการประเภทตำแหน่ง */
|
/** function เรียกรายการประเภทตำแหน่ง */
|
||||||
async function fetchType() {
|
async function fetchType() {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(config.API.orgPosType)
|
.get(config.API.orgPosType)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
dataLevel.value = res.data.result;
|
||||||
typeOpsMain.value = res.data.result.map((e: OptionType) => ({
|
typeOpsMain.value = res.data.result.map((e: OptionType) => ({
|
||||||
id: e.id,
|
id: e.id,
|
||||||
name: e.posTypeName,
|
name: e.posTypeName,
|
||||||
|
|
@ -255,24 +257,24 @@ async function fetchType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function เรียกรายการระดับตำแหน่ง */
|
/** function เรียกรายการระดับตำแหน่ง */
|
||||||
async function fetchLevel() {
|
// async function fetchLevel() {
|
||||||
showLoader();
|
// showLoader();
|
||||||
await http
|
// await http
|
||||||
.get(config.API.orgPosLevel)
|
// .get(config.API.orgPosLevel)
|
||||||
.then((res) => {
|
// .then((res) => {
|
||||||
levelOpsMain.value = res.data.result.map((e: OptionLevel) => ({
|
// levelOpsMain.value = res.data.result.map((e: OptionLevel) => ({
|
||||||
id: e.id,
|
// id: e.id,
|
||||||
name: e.posLevelName,
|
// name: e.posLevelName,
|
||||||
}));
|
// }));
|
||||||
levelOps.value = levelOpsMain.value;
|
// levelOps.value = levelOpsMain.value;
|
||||||
})
|
// })
|
||||||
.catch((err) => {
|
// .catch((err) => {
|
||||||
messageError($q, err);
|
// messageError($q, err);
|
||||||
})
|
// })
|
||||||
.finally(() => {
|
// .finally(() => {
|
||||||
hideLoader();
|
// hideLoader();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
/** function เรียกรายการตำแหน่งทางการบริหาร */
|
/** function เรียกรายการตำแหน่งทางการบริหาร */
|
||||||
async function fetchExecutive() {
|
async function fetchExecutive() {
|
||||||
|
|
@ -454,11 +456,22 @@ async function searchInput() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateSelectType(val: string) {
|
||||||
|
const listLevel = dataLevel.value.find((e: any) => e.id === val);
|
||||||
|
levelOpsMain.value = listLevel.posLevels.map((e: OptionLevel) => ({
|
||||||
|
id: e.id,
|
||||||
|
name: e.posLevelName,
|
||||||
|
}));
|
||||||
|
levelOps.value = levelOpsMain.value;
|
||||||
|
formPositionSelect.positionLevel = "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* คัดลอกข้อมูล
|
* คัดลอกข้อมูล
|
||||||
* @param data ข้อมูลตำแหน่ง
|
* @param data ข้อมูลตำแหน่ง
|
||||||
*/
|
*/
|
||||||
function copyDetiail(data: RowDetailPositions) {
|
function copyDetiail(data: RowDetailPositions) {
|
||||||
|
updateSelectType(data.posTypeId);
|
||||||
formPositionSelect.positionId = data.positionId;
|
formPositionSelect.positionId = data.positionId;
|
||||||
formPositionSelect.positionName = data.positionName;
|
formPositionSelect.positionName = data.positionName;
|
||||||
formPositionSelect.positionField = data.positionField;
|
formPositionSelect.positionField = data.positionField;
|
||||||
|
|
@ -485,13 +498,17 @@ watch(
|
||||||
() => {
|
() => {
|
||||||
if (props.modal === true) {
|
if (props.modal === true) {
|
||||||
fetchType();
|
fetchType();
|
||||||
fetchLevel();
|
// fetchLevel();
|
||||||
fetchExecutive();
|
fetchExecutive();
|
||||||
|
|
||||||
if (props.actionType === "ADD") {
|
if (props.actionType === "ADD") {
|
||||||
rowsPositionSelect.value = [];
|
rowsPositionSelect.value = [];
|
||||||
search.value = "";
|
search.value = "";
|
||||||
rows.value = [];
|
rows.value = [];
|
||||||
clearFormPositionSelect();
|
clearFormPositionSelect();
|
||||||
|
formData.prefixNo = "";
|
||||||
|
formData.positionNo = "";
|
||||||
|
formData.suffixNo = "";
|
||||||
} else {
|
} else {
|
||||||
props.rowId && fetchPosition(props.rowId);
|
props.rowId && fetchPosition(props.rowId);
|
||||||
}
|
}
|
||||||
|
|
@ -896,7 +913,7 @@ async function clearFormPositionSelect() {
|
||||||
:options="typeOps"
|
:options="typeOps"
|
||||||
emit-value
|
emit-value
|
||||||
dense
|
dense
|
||||||
@update:model-value="updateSelect"
|
@update:model-value="updateSelectType"
|
||||||
map-options
|
map-options
|
||||||
outlined
|
outlined
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
|
@ -916,10 +933,10 @@ async function clearFormPositionSelect() {
|
||||||
:class="inputEdit(isReadonly)"
|
:class="inputEdit(isReadonly)"
|
||||||
label="ระดับตำแหน่ง"
|
label="ระดับตำแหน่ง"
|
||||||
v-model="formPositionSelect.positionLevel"
|
v-model="formPositionSelect.positionLevel"
|
||||||
|
:disable="formPositionSelect.positionType === ''"
|
||||||
:options="levelOps"
|
:options="levelOps"
|
||||||
emit-value
|
emit-value
|
||||||
dense
|
dense
|
||||||
@update:model-value="updateSelect"
|
|
||||||
map-options
|
map-options
|
||||||
outlined
|
outlined
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
|
@ -942,21 +959,12 @@ async function clearFormPositionSelect() {
|
||||||
:options="executiveOps"
|
:options="executiveOps"
|
||||||
emit-value
|
emit-value
|
||||||
dense
|
dense
|
||||||
@update:model-value="updateSelect"
|
|
||||||
map-options
|
map-options
|
||||||
outlined
|
outlined
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:rules="
|
|
||||||
!isDisValidate
|
|
||||||
? [
|
|
||||||
(val) =>
|
|
||||||
!!val || `${'กรุณาเลือกตำแหน่งทางการบริหาร'}`,
|
|
||||||
]
|
|
||||||
: []
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
|
|
@ -970,14 +978,6 @@ async function clearFormPositionSelect() {
|
||||||
label="ด้านทางการบริหาร"
|
label="ด้านทางการบริหาร"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:rules="
|
|
||||||
!isDisValidate
|
|
||||||
? [
|
|
||||||
(val) =>
|
|
||||||
!!val || `${'กรุณากรอกด้านทางการบริหาร'}`,
|
|
||||||
]
|
|
||||||
: []
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
|
|
@ -991,11 +991,6 @@ async function clearFormPositionSelect() {
|
||||||
label="ด้าน/สาขา"
|
label="ด้าน/สาขา"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:rules="
|
|
||||||
!isDisValidate
|
|
||||||
? [(val) => !!val || `${'กรุณากรอกด้าน/สาขา'}`]
|
|
||||||
: []
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue