แก้ API

This commit is contained in:
STW_TTTY\stwtt 2024-09-02 16:04:53 +07:00
parent d78b7db124
commit 459428979b
12 changed files with 37 additions and 33 deletions

View file

@ -33,7 +33,8 @@ export default {
kpiEvaluation, kpiEvaluation,
kpiEvaluationUser, kpiEvaluationUser,
kpiPlan, kpiPlan,
kpiPlanById: (id: string) => `${kpiPlan}/edit/${id}`, kpiPlanByIdEdit: (id: string) => `${kpiPlan}/edit/${id}`,
kpiPlanById: (id: string) => `${kpiPlan}/${id}`,
/** role */ /** role */
kpiRole, kpiRole,

View file

@ -92,7 +92,7 @@ function fetchOrganizationActive() {
function fetchTreeStrategy() { function fetchTreeStrategy() {
showLoader(); showLoader();
http http
.get(config.API.devStrategy) .get(config.API.devStrategy + `/edit`)
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
nodeplan.value = data; nodeplan.value = data;
@ -127,7 +127,7 @@ function fetchTreeAgency(id: string) {
function fetchDataById(id: string) { function fetchDataById(id: string) {
showLoader(); showLoader();
http http
.get(config.API.kpiPlanById(id)) .get(config.API.kpiPlanByIdEdit(id))
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
year.value = Number(data.year); year.value = Number(data.year);

View file

@ -127,7 +127,7 @@ function selectAgency() {
/** บันทึกข้อมูล */ /** บันทึกข้อมูล */
function onSubmit() { function onSubmit() {
const url = id.value const url = id.value
? config.API.kpiRoleMainEdit + `/${id.value}` ? config.API.kpiRoleMainList + `/${id.value}`
: config.API.kpiRoleMainList; : config.API.kpiRoleMainList;
const body = { const body = {

View file

@ -85,7 +85,7 @@ async function fetchData() {
await http await http
.get( .get(
config.API.kpiGroup + config.API.kpiGroup +
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}` `/edit?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}`
) )
.then(async (res) => { .then(async (res) => {
total.value = res.data.result.total; total.value = res.data.result.total;

View file

@ -98,7 +98,7 @@ async function getData() {
http http
.get( .get(
config.API.kpiLink + config.API.kpiLink +
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}` `/edit?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}`
) )
.then((res) => { .then((res) => {
total.value = res.data.result.total; total.value = res.data.result.total;
@ -210,7 +210,7 @@ async function onEdit(data: any) {
function getDataEdit(id: string) { function getDataEdit(id: string) {
showLoader(); showLoader();
http http
.get(config.API.kpiLink + `/${id}`) .get(config.API.kpiLink + `/edit/${id}`)
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
groupName.value = { groupName.value = {

View file

@ -57,7 +57,7 @@ function onSubmit() {
function getData() { function getData() {
showLoader(); showLoader();
http http
.get(config.API.kpiEvaluation) .get(config.API.kpiEvaluation+`/edit`)
.then((res) => { .then((res) => {
dataLevel.value = res.data.result.data; dataLevel.value = res.data.result.data;
}) })

View file

@ -115,7 +115,7 @@ function onClickDelete(id: string) {
dialogRemove($q, () => { dialogRemove($q, () => {
showLoader(); showLoader();
http http
.delete(config.API.kpiSpecial + `/edit/${id}`) .delete(config.API.kpiSpecial + `/${id}`)
.then(() => { .then(() => {
fetchList(); fetchList();
success($q, "ลบข้อมูลสำเร็จ"); success($q, "ลบข้อมูลสำเร็จ");

View file

@ -58,7 +58,7 @@ const titleDialog = ref<string>("");
function fetchDataTree() { function fetchDataTree() {
showLoader(); showLoader();
http http
.get(config.API.devStrategy) .get(config.API.devStrategy + `/edit`)
.then((res) => { .then((res) => {
const data: DataStrategic[] = res.data.result; const data: DataStrategic[] = res.data.result;
nodes.value = data; nodes.value = data;
@ -154,7 +154,7 @@ function onSubmit() {
}; };
try { try {
const method = isStatusEdit.value ? "patch" : "post"; const method = isStatusEdit.value ? "patch" : "post";
await http[method](config.API.devStrategy+`/edit`, formData); await http[method](config.API.devStrategy, formData);
fetchDataTree(); fetchDataTree();
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
} catch (err) { } catch (err) {

View file

@ -100,8 +100,8 @@ const roundOp = ref<DataOption[]>([
{ id: "OCT", name: "รอบตุลาคม" }, { id: "OCT", name: "รอบตุลาคม" },
]); ]);
function fetchList() { async function fetchList() {
http await http
.post(config.API.kpiRoleMainList + `/search-edit`, { .post(config.API.kpiRoleMainList + `/search-edit`, {
// ?page=${formFilter.page}&pageSize=${formFilter.pageSize}&period=${formFilter.round}&position=${formFilter.position}&keyword=${formFilter.keyword}&year=${formFilter.year} // ?page=${formFilter.page}&pageSize=${formFilter.pageSize}&period=${formFilter.round}&position=${formFilter.position}&keyword=${formFilter.keyword}&year=${formFilter.year}
keyword: formFilter.keyword, keyword: formFilter.keyword,
@ -118,13 +118,13 @@ function fetchList() {
total.value = res.data.result.total; total.value = res.data.result.total;
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize); maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
rows.value = data; rows.value = data;
hideLoader();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
})
.finally(() => {
hideLoader(); hideLoader();
}); })
.finally(() => {});
} }
function onClickAddOrView(status: boolean = false, id: string = "") { function onClickAddOrView(status: boolean = false, id: string = "") {
@ -141,7 +141,7 @@ function onClickDelete(id: number) {
dialogRemove($q, () => { dialogRemove($q, () => {
showLoader(); showLoader();
http http
.delete(config.API.kpiRoleMainEdit + `/${id}`) .delete(config.API.kpiRoleMainList + `/${id}`)
.then(() => { .then(() => {
success($q, "ลบข้อมูลสำเร็จ"); success($q, "ลบข้อมูลสำเร็จ");
fetchList(); fetchList();
@ -187,9 +187,9 @@ function filterOption(val: any, update: Function) {
} }
/** ดึงข้อมูลตำแหน่ง */ /** ดึงข้อมูลตำแหน่ง */
function getOptions() { async function getOptions() {
showLoader(); showLoader();
http await http
.get(config.API.orgSalaryPosition) .get(config.API.orgSalaryPosition)
.then((res) => { .then((res) => {
const dataOp = res.data.result; const dataOp = res.data.result;
@ -210,13 +210,13 @@ function getOptions() {
positionMainOp.value.push(...filteredData); positionMainOp.value.push(...filteredData);
positionOp.value.push(...filteredData); positionOp.value.push(...filteredData);
hideLoader();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
})
.finally(() => {
hideLoader(); hideLoader();
}); })
.finally(() => {});
} }
function setModel(val: string) { function setModel(val: string) {
@ -244,8 +244,8 @@ function onClickHistory(id: string) {
}); });
} }
function getTotal() { async function getTotal() {
http await http
.post(config.API.indicatorSummary) .post(config.API.indicatorSummary)
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;

View file

@ -148,7 +148,7 @@ async function fetchAssigned() {
async function getCriteria() { async function getCriteria() {
await http await http
.get(config.API.KpiEvaluationInfo) .get(config.API.KpiEvaluationInfo+`/edit`)
.then(async (res) => { .then(async (res) => {
const data = await res.data.result.data; const data = await res.data.result.data;
dataListCriteria.value = data; dataListCriteria.value = data;

View file

@ -257,10 +257,10 @@ function clickList(id: string, isData: boolean = false) {
showLoader(); showLoader();
const url = const url =
numpage.value === 1 numpage.value === 1
? config.API.kpiPlan ? config.API.kpiPlan + `/edit`
: numpage.value === 2 : numpage.value === 2
? config.API.kpiRole ? config.API.kpiRole + `/edit`
: config.API.kpiSpecial; : config.API.kpiSpecial + `/edit`;
http http
.get(`${url}/${id}`) .get(`${url}/${id}`)
.then((res) => { .then((res) => {
@ -341,7 +341,7 @@ function closeDialog() {
formFilter.page = 1; formFilter.page = 1;
formFilter.pageSize = 20; formFilter.pageSize = 20;
isStatusEdit.value = false isStatusEdit.value = false;
checkDetail.value = false; checkDetail.value = false;
} }
@ -427,7 +427,6 @@ watch(
fetchListPlan(); fetchListPlan();
isStatusEdit.value && fetchListPlanByid(kpiUserPlannedId.value); isStatusEdit.value && fetchListPlanByid(kpiUserPlannedId.value);
checkDetail.value && fetchListPlanByid(kpiUserPlannedId.value); checkDetail.value && fetchListPlanByid(kpiUserPlannedId.value);
} else if (numpage.value === 2) { } else if (numpage.value === 2) {
fetchListRole(); fetchListRole();
isStatusEdit.value && fetchRoleByid(kpiUserPlannedId.value); isStatusEdit.value && fetchRoleByid(kpiUserPlannedId.value);
@ -992,9 +991,13 @@ const title = computed(() => {
</div> </div>
</div> </div>
</q-card-section> </q-card-section>
<q-separator v-if="!checkDetail"/> <q-separator v-if="!checkDetail" />
<q-card-actions v-if="!checkDetail" align="right" class="bg-white text-teal"> <q-card-actions
v-if="!checkDetail"
align="right"
class="bg-white text-teal"
>
<q-btn label="บันทึก" color="secondary" type="submit" <q-btn label="บันทึก" color="secondary" type="submit"
><q-tooltip>นทกขอม</q-tooltip></q-btn ><q-tooltip>นทกขอม</q-tooltip></q-btn
> >

View file

@ -294,7 +294,7 @@ function fetchData() {
function fetchTree() { function fetchTree() {
showLoader(); showLoader();
http http
.get(config.API.devStrategy) .get(config.API.devStrategy+`/edit`)
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
nodes.value = data; nodes.value = data;