fix(command): edit-salary

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-12-15 11:50:33 +07:00
parent 0372eb9726
commit d215283163
6 changed files with 534 additions and 13 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { ref, watch, computed, type PropType } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
@ -19,6 +19,7 @@ import type {
import type { DataListCommand } from "@/modules/18_command/interface/response/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogEditSalary from "@/modules/18_command/components/DialogEditSalary.vue";
const storeCommand = useCommandMainStore();
const router = useRouter();
@ -43,6 +44,10 @@ const props = defineProps({
},
});
const isSalary = computed(() => {
return !!commandOp.value.find((v) => v.id == commandType.value)?.isSalary;
});
const commandOp = ref<ListCommand[]>([]); //
const commandType = ref<string>(""); //
const commandNo = ref<string>(""); //
@ -130,6 +135,9 @@ const columns = ref<QTableProps["columns"]>([
const selectCreate = ref<string | null>("NEW"); // /
const modalSalary = ref<boolean>(false); //
const commandOrderId = ref<string>(""); //
/** ฟังก์ชันเรียกข้อมูลรายการคำสั่ง*/
async function getListCommandDraf() {
showLoader();
@ -191,12 +199,18 @@ function createCommand(isRedirect: boolean) {
.post(config.API.command + `/person`, body)
.then(async (res) => {
const id = await res.data.result;
commandOrderId.value = id;
modal.value = false;
if (isRedirect) {
router.push(`/command/edit/${id}`);
if (!isSalary.value) {
if (isRedirect) {
router.push(`/command/edit/${id}`);
} else {
clearValue();
props.fetchData(); // fetchData props
}
} else {
clearValue();
await props.fetchData(); // fetchData props
modal.value = false;
modalSalary.value = true;
}
})
.catch((e) => {
@ -237,12 +251,18 @@ function addPersonalToCommand(isRedirect: boolean) {
.post(config.API.command + `/person`, body)
.then(async (res) => {
const id = await res.data.result;
commandOrderId.value = id;
modal.value = false;
if (isRedirect) {
router.push(`/command/edit/${id}`);
if (!isSalary.value) {
if (isRedirect) {
router.push(`/command/edit/${id}`);
} else {
modal.value = false;
props.fetchData(); // fetchData props
}
} else {
modal.value = false;
await props.fetchData(); // fetchData props
modalSalary.value = true;
}
})
.catch((e) => {
@ -569,7 +589,7 @@ watch(
<q-card-actions align="right">
<q-btn
v-if="isHold"
v-if="isHold && !isSalary"
label="บันทึกและเลือกรายชื่อต่อ"
@click="() => onSubmit(false)"
:disable="
@ -580,7 +600,9 @@ watch(
<q-tooltip>นทกและเลอกรายชอต</q-tooltip>
</q-btn>
<q-btn
label="บันทึกและไปยังหน้าคำสั่ง"
:label="
!isSalary ? 'บันทึกและไปยังหน้าคำสั่ง' : 'บันทึกและไปยังหน้าแก้ไขเงินเดือน'
"
@click="() => onSubmit(true)"
:disable="
selectCreate == 'NEW' ? commandType == '' : selected.length == 0
@ -592,6 +614,19 @@ watch(
</q-card-actions>
</q-card>
</q-dialog>
<DialogEditSalary
v-model:modal="modalSalary"
:command-code="commandTypeCode || ''"
:command-id="
selectCreate === 'NEW'
? commandOrderId
: selected.length > 0
? selected[0].id
: ''
"
:fetch-data="fetchData"
/>
</template>
<style scoped></style>