范围删除

This commit is contained in:
Yuan 2023-08-23 10:47:05 +08:00
parent ad7a6db096
commit b2b8eb6c4f
2 changed files with 21 additions and 6 deletions

View File

@ -27,6 +27,12 @@ export async function getDeviceAreaList({
throw Error(resp.statusText); throw Error(resp.statusText);
} }
} }
export async function deleteDeviceArea(id: number) {
const resp = await api.delete(`/api/config/device/area/${id}`);
return resp;
}
export interface IAreaConfigItem { export interface IAreaConfigItem {
id?: number; id?: number;
lineId: number; lineId: number;

View File

@ -1,9 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { IAreaConfigListItem, getDeviceAreaList } from 'src/api/ConfigApi'; import {
IAreaConfigListItem,
getDeviceAreaList,
deleteDeviceArea,
} from 'src/api/ConfigApi';
import { ref } from 'vue'; import { ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import DraggableDialog from './common/DraggableDialog.vue'; import DraggableDialog from './common/DraggableDialog.vue';
import { QTable } from 'quasar'; import { QTable } from 'quasar';
import { errorNotify } from 'src/utils/CommonNotify';
const lineId = useRoute().params.id as string; const lineId = useRoute().params.id as string;
const tableRef = ref<QTable>(); const tableRef = ref<QTable>();
@ -57,6 +62,14 @@ const props = defineProps<{
function onEdit(row: IAreaConfigListItem) { function onEdit(row: IAreaConfigListItem) {
props.onEditClick(row); props.onEditClick(row);
} }
function deleteData(row: IAreaConfigListItem) {
console.log(row);
try {
deleteDeviceArea(row.id);
} catch (err) {
errorNotify('删除失败:', err);
}
}
</script> </script>
<template> <template>
@ -80,11 +93,7 @@ function onEdit(row: IAreaConfigListItem) {
<q-td :props="props"> <q-td :props="props">
<div class="q-gutter-sm row justify-center"> <div class="q-gutter-sm row justify-center">
<q-btn color="primary" label="编辑" @click="onEdit(props.row)" /> <q-btn color="primary" label="编辑" @click="onEdit(props.row)" />
<!-- <q-btn <q-btn color="red" label="删除" @click="deleteData(props.row)" />
color="red"
label="删除"
@click="deleteData(props.row)"
/> -->
</div> </div>
</q-td> </q-td>
</template> </template>