updated redirect send command
This commit is contained in:
parent
7cd215369f
commit
3c0471e267
1 changed files with 40 additions and 24 deletions
|
|
@ -133,7 +133,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
/**
|
||||
* ฟังก์ชันสร้างคำสั่งใหม่
|
||||
*/
|
||||
function createCommand() {
|
||||
function createCommand(isRedirect: boolean) {
|
||||
dialogConfirm($q, async () => {
|
||||
const data = props.personsId;
|
||||
const body = {
|
||||
|
|
@ -147,9 +147,12 @@ function createCommand() {
|
|||
.post(config.API.command, body)
|
||||
.then(async (res) => {
|
||||
const id = await res.data.result;
|
||||
modal.value = false;
|
||||
clearValue();
|
||||
router.push(`/command/edit/${id}`);
|
||||
if (isRedirect) {
|
||||
router.push(`/command/edit/${id}`);
|
||||
} else {
|
||||
modal.value = false;
|
||||
clearValue();
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
|
|
@ -163,7 +166,7 @@ function createCommand() {
|
|||
/**
|
||||
* ฟังก์ชันเพิ่มคนเข้าไปในคำสั่งที่เป็นแบบร่าง
|
||||
*/
|
||||
function addPersonalToCommand() {
|
||||
function addPersonalToCommand(isRedirect: boolean) {
|
||||
dialogConfirm($q, async () => {
|
||||
const data = props.personsId;
|
||||
const body = {
|
||||
|
|
@ -177,7 +180,12 @@ function addPersonalToCommand() {
|
|||
// .then((res) => {
|
||||
// const id = res.data.result
|
||||
modal.value = false;
|
||||
router.push("/command/edit/18477dcd-2f14-4e49-8fca-a446164e8b59");
|
||||
if (isRedirect) {
|
||||
router.push("/command/edit/18477dcd-2f14-4e49-8fca-a446164e8b59");
|
||||
} else {
|
||||
modal.value = false;
|
||||
clearValue();
|
||||
}
|
||||
// router.push("/command/edit/" + id);
|
||||
// })
|
||||
// .catch((e) => {
|
||||
|
|
@ -189,11 +197,11 @@ function addPersonalToCommand() {
|
|||
});
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
function onSubmit(isRedirect: boolean) {
|
||||
if (selectCreate.value === "NEW") {
|
||||
createCommand();
|
||||
createCommand(isRedirect);
|
||||
} else {
|
||||
addPersonalToCommand();
|
||||
addPersonalToCommand(isRedirect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -288,18 +296,17 @@ watch(modal, () => {
|
|||
<q-card-section style="max-height: 50vh" class="scroll">
|
||||
<div class="row q-mb-md">
|
||||
<div class="col-12 q-gutter-md">
|
||||
<q-btn
|
||||
outline
|
||||
label="สร้างคำสั่งใหม่"
|
||||
:color="selectCreate == 'NEW' ? 'primary' : 'grey'"
|
||||
@click="changeTab('NEW')"
|
||||
/>
|
||||
|
||||
<q-btn
|
||||
outline
|
||||
label="เลือกคำสั่งที่เป็นแบบร่าง"
|
||||
:color="selectCreate == 'DRAF' ? 'primary' : 'grey'"
|
||||
@click="changeTab('DRAF')"
|
||||
<q-btn-toggle
|
||||
v-model="selectCreate"
|
||||
toggle-color="primary"
|
||||
color="white"
|
||||
text-color="black"
|
||||
spread
|
||||
no-caps
|
||||
:options="[
|
||||
{ label: 'สร้างคำสั่งใหม่', value: 'NEW' },
|
||||
{ label: 'เลือกคำสั่งที่เป็นแบบร่าง', value: 'DRAF' },
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -511,12 +518,21 @@ watch(modal, () => {
|
|||
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
label="บันทึก"
|
||||
@click="onSubmit"
|
||||
label="บันทึกและเลือกรายชื่อต่อ"
|
||||
@click="() => onSubmit(false)"
|
||||
:disable="selected.length == 0 && commandType == ''"
|
||||
color="blue"
|
||||
>
|
||||
<q-tooltip>บันทึกและเลือกรายชื่อต่อ</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
label="บันทึกและไปยังหน้าคำสั่ง"
|
||||
@click="() => onSubmit(true)"
|
||||
:disable="selected.length == 0 && commandType == ''"
|
||||
color="public"
|
||||
><q-tooltip>บันทึก</q-tooltip></q-btn
|
||||
>
|
||||
<q-tooltip>บันทึกและไปยังหน้าคำสั่ง</q-tooltip>
|
||||
</q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue