fix(command): disable button delete

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-03-13 14:01:33 +07:00
parent 4f0237d42e
commit 6ef832d84b

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, reactive, ref } from "vue";
import { onMounted, reactive, ref, computed } from "vue";
import { useQuasar, type QTableProps } from "quasar";
import { useRoute } from "vue-router";
@ -37,6 +37,12 @@ const props = defineProps({
formCommandList: { type: Object, required: true },
});
const isCanDelete = computed(
() => (role: string) =>
rows.value.filter((row) => row.roleName === "เจ้าหน้าที่ดำเนินการ")
.length === 1 && role === "เจ้าหน้าที่ดำเนินการ"
); //
const commandId = ref<string>(route.params.id.toString()); //ID
const commandCode = ref<string>(""); //
const createdUserId = ref<string>(""); //ID
@ -597,14 +603,12 @@ onMounted(async () => {
<q-btn
icon="mdi-delete"
:color="
props.row.roleName === 'เจ้าหน้าที่ดำเนินการ'
? 'grey'
: 'red'
isCanDelete(props.row.roleName) ? 'grey' : 'red'
"
flat
dense
round
:disable="props.row.roleName === 'เจ้าหน้าที่ดำเนินการ'"
:disable="isCanDelete(props.row.roleName)"
@click.prevent.stop="onDeleteData(props.row.id)"
>
<q-tooltip>ลบขอม</q-tooltip>