feat:删除设备单元
This commit is contained in:
1 parent
1aabaa95ba
commit
a1f98f94de
3 files changed
+13
-283
No files matched your search
@@ -20,25 +20,19 @@
|
|||||||
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
|
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
|
||||||
@sort-change="sortChangeHandle">
|
@sort-change="sortChangeHandle">
|
||||||
<el-table-column type="selection" width="40" align="center" />
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
<el-table-column type="index" label="#" width="40" />
|
<el-table-column type="index" label="#" width="80" />
|
||||||
<el-table-column prop="deviceName" label="设备名称" show-overflow-tooltip />
|
<el-table-column prop="deviceCode" align="left" min-width="100" label="设备编码" />
|
||||||
<el-table-column prop="deviceCode" label="设备编码" show-overflow-tooltip />
|
<el-table-column prop="deviceName" align="left" min-width="150" label="设备名称" />
|
||||||
<el-table-column prop="deviceSn" label="设备唯一标识码" show-overflow-tooltip />
|
<el-table-column prop="deviceIp" align="left" min-width="150" label="ip" />
|
||||||
<el-table-column prop="deviceCategory" label="设备大类(字典)" show-overflow-tooltip />
|
<el-table-column prop="devicePort" align="left" min-width="100" label="端口" />
|
||||||
<el-table-column prop="deviceType" label="设备小类(字典)" show-overflow-tooltip />
|
<el-table-column prop="deviceCategory" align="left" min-width="100" label="设备大类" />
|
||||||
<el-table-column prop="deviceManufacturer" label="厂商类型(字典)" show-overflow-tooltip />
|
<el-table-column prop="deviceType" align="left" min-width="100" label="设备小类" />
|
||||||
<el-table-column prop="deviceModel" label="设备型号(字典)" show-overflow-tooltip />
|
<el-table-column prop="deviceManufacturer" align="left" min-width="100" label="厂商类型" />
|
||||||
<el-table-column prop="deviceIp" label="设备ip" show-overflow-tooltip />
|
<el-table-column prop="deviceModel" align="left" min-width="100" label="设备型号" />
|
||||||
<el-table-column prop="devicePort" label="设备端口 取值范围:0 ~ 65535" show-overflow-tooltip />
|
<el-table-column prop="ownerCode" align="left" min-width="150" label="设备所属组织" />
|
||||||
<el-table-column prop="ownerCode" label="设备所属组织" show-overflow-tooltip />
|
<el-table-column prop="isOnline" align="left" min-width="100" label="状态" />
|
||||||
<el-table-column prop="memo" label="设备描述" show-overflow-tooltip />
|
<el-table-column prop="isSync" align="left" min-width="100" label="同步状态" />
|
||||||
<el-table-column prop="isOnline" label="isOnline(字典)" show-overflow-tooltip />
|
<el-table-column label="操作" fixed="right" width="150">
|
||||||
<el-table-column prop="mapId" label="光栅图" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="gpsX" label="经度" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="gpsY" label="纬度" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="sortOrder" label="排序" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="isSync" label="是否为同步" show-overflow-tooltip />
|
|
||||||
<el-table-column label="操作" width="150">
|
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button icon="edit-pen" text type="primary" v-auth="'admin_deviceManage_edit'"
|
<el-button icon="edit-pen" text type="primary" v-auth="'admin_deviceManage_edit'"
|
||||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
|
|
||||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
|
||||||
<el-row :gutter="24">
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="设备id" prop="deviceId">
|
|
||||||
<el-input v-model="form.deviceId" placeholder="请输入设备id" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="单元类型(字典)" prop="unitType">
|
|
||||||
<el-input v-model="form.unitType" placeholder="请输入单元类型(字典)" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="设备编码" prop="unitSeq">
|
|
||||||
<el-input v-model="form.unitSeq" placeholder="请输入设备编码" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="单元扩展信息(json)" prop="unitExt">
|
|
||||||
<el-input v-model="form.unitExt" placeholder="请输入单元扩展信息(json)" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="能力集" prop="capability">
|
|
||||||
<el-input v-model="form.capability" placeholder="请输入能力集" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="单元描述" prop="memo">
|
|
||||||
<el-input v-model="form.memo" placeholder="请输入单元描述" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="排序" prop="sortOrder">
|
|
||||||
<el-input v-model="form.sortOrder" placeholder="请输入排序" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="mb20">
|
|
||||||
<el-form-item label="是否为同步" prop="isSync">
|
|
||||||
<el-input v-model="form.isSync" placeholder="请输入是否为同步" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span class="dialog-footer">
|
|
||||||
<el-button @click="visible = false">取消</el-button>
|
|
||||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts" name="DeviceUnitDialog">
|
|
||||||
import { useDict } from '/@/hooks/dict';
|
|
||||||
import { useMessage } from "/@/hooks/message";
|
|
||||||
import { getObj, addObj, putObj } from '/@/api/device/deviceUnit'
|
|
||||||
import { rule } from '/@/utils/validate';
|
|
||||||
const emit = defineEmits(['refresh']);
|
|
||||||
|
|
||||||
// 定义变量内容
|
|
||||||
const dataFormRef = ref();
|
|
||||||
const visible = ref(false)
|
|
||||||
const loading = ref(false)
|
|
||||||
// 定义字典
|
|
||||||
|
|
||||||
// 提交表单数据
|
|
||||||
const form = reactive({
|
|
||||||
id: '',
|
|
||||||
deviceId: '',
|
|
||||||
unitType: '',
|
|
||||||
unitSeq: '',
|
|
||||||
unitExt: '',
|
|
||||||
capability: '',
|
|
||||||
memo: '',
|
|
||||||
sortOrder: '',
|
|
||||||
isSync: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
// 定义校验规则
|
|
||||||
const dataRules = ref({
|
|
||||||
})
|
|
||||||
|
|
||||||
// 打开弹窗
|
|
||||||
const openDialog = (id: string) => {
|
|
||||||
visible.value = true
|
|
||||||
form.id = ''
|
|
||||||
|
|
||||||
// 重置表单数据
|
|
||||||
nextTick(() => {
|
|
||||||
dataFormRef.value?.resetFields();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取deviceUnit信息
|
|
||||||
if (id) {
|
|
||||||
form.id = id
|
|
||||||
getdeviceUnitData(id)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 提交
|
|
||||||
const onSubmit = async () => {
|
|
||||||
const valid = await dataFormRef.value.validate().catch(() => { });
|
|
||||||
if (!valid) return false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
loading.value = true;
|
|
||||||
form.id ? await putObj(form) : await addObj(form);
|
|
||||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
|
||||||
visible.value = false;
|
|
||||||
emit('refresh');
|
|
||||||
} catch (err: any) {
|
|
||||||
useMessage().error(err.msg);
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 初始化表单数据
|
|
||||||
const getdeviceUnitData = (id: string) => {
|
|
||||||
// 获取数据
|
|
||||||
loading.value = true
|
|
||||||
getObj(id).then((res: any) => {
|
|
||||||
Object.assign(form, res.data)
|
|
||||||
}).finally(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
// 暴露变量
|
|
||||||
defineExpose({
|
|
||||||
openDialog
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="layout-padding">
|
|
||||||
<div class="layout-padding-auto layout-padding-view">
|
|
||||||
<el-row>
|
|
||||||
<div class="mb8" style="width: 100%">
|
|
||||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
|
||||||
v-auth="'admin_deviceUnit_add'">
|
|
||||||
新 增
|
|
||||||
</el-button>
|
|
||||||
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'admin_deviceUnit_del'"
|
|
||||||
@click="handleDelete(selectObjs)">
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
<right-toolbar v-model:showSearch="showSearch" :export="'admin_deviceUnit_export'" @exportExcel="exportExcel"
|
|
||||||
class="ml10 mr20" style="float: right;" @queryTable="getDataList"></right-toolbar>
|
|
||||||
</div>
|
|
||||||
</el-row>
|
|
||||||
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
|
||||||
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
|
|
||||||
@sort-change="sortChangeHandle">
|
|
||||||
<el-table-column type="selection" width="40" align="center" />
|
|
||||||
<el-table-column type="index" label="#" width="40" />
|
|
||||||
<el-table-column prop="deviceId" label="设备id" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="unitType" label="单元类型(字典)" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="unitSeq" label="设备编码" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="unitExt" label="单元扩展信息(json)" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="capability" label="能力集" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="memo" label="单元描述" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="sortOrder" label="排序" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="isSync" label="是否为同步" show-overflow-tooltip />
|
|
||||||
<el-table-column label="操作" width="150">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button icon="edit-pen" text type="primary" v-auth="'admin_deviceUnit_edit'"
|
|
||||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
|
||||||
<el-button icon="delete" text type="primary" v-auth="'admin_deviceUnit_del'"
|
|
||||||
@click="handleDelete([scope.row.id])">删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 编辑、新增 -->
|
|
||||||
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts" name="systemDeviceUnit">
|
|
||||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
|
||||||
import { fetchList, delObjs } from "/@/api/device/deviceUnit";
|
|
||||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
|
||||||
import { useDict } from '/@/hooks/dict';
|
|
||||||
|
|
||||||
// 引入组件
|
|
||||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
|
||||||
// 定义查询字典
|
|
||||||
|
|
||||||
// 定义变量内容
|
|
||||||
const formDialogRef = ref()
|
|
||||||
// 搜索变量
|
|
||||||
const queryRef = ref()
|
|
||||||
const showSearch = ref(true)
|
|
||||||
// 多选变量
|
|
||||||
const selectObjs = ref([]) as any
|
|
||||||
const multiple = ref(true)
|
|
||||||
|
|
||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
||||||
queryForm: {},
|
|
||||||
pageList: fetchList
|
|
||||||
})
|
|
||||||
|
|
||||||
// table hook
|
|
||||||
const {
|
|
||||||
getDataList,
|
|
||||||
currentChangeHandle,
|
|
||||||
sizeChangeHandle,
|
|
||||||
sortChangeHandle,
|
|
||||||
downBlobFile,
|
|
||||||
tableStyle
|
|
||||||
} = useTable(state)
|
|
||||||
|
|
||||||
// 清空搜索条件
|
|
||||||
const resetQuery = () => {
|
|
||||||
// 清空搜索条件
|
|
||||||
queryRef.value?.resetFields()
|
|
||||||
// 清空多选
|
|
||||||
selectObjs.value = []
|
|
||||||
getDataList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导出excel
|
|
||||||
const exportExcel = () => {
|
|
||||||
downBlobFile('/admin/deviceUnit/export', Object.assign(state.queryForm, { ids: selectObjs }), 'deviceUnit.xlsx')
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多选事件
|
|
||||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
|
||||||
selectObjs.value = objs.map(({ id }) => id);
|
|
||||||
multiple.value = !objs.length;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除操作
|
|
||||||
const handleDelete = async (ids: string[]) => {
|
|
||||||
try {
|
|
||||||
await useMessageBox().confirm('此操作将永久删除');
|
|
||||||
} catch {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await delObjs(ids);
|
|
||||||
getDataList();
|
|
||||||
useMessage().success('删除成功');
|
|
||||||
} catch (err: any) {
|
|
||||||
useMessage().error(err.msg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
Reference in new issue
Block a user