<template>
|
<div class="system-role-container">
|
<el-card shadow="hover">
|
<div class="system-user-search mb15">
|
<div class="basic-line">
|
<span>巡检点名称:</span>
|
<el-input class="input-box" v-model="inspectPointData.params.code" placeholder="巡检点名称" clearable> </el-input>
|
</div>
|
<div class="basic-line">
|
<span>所属区域名称:</span>
|
<el-select class="input-box" v-model="inspectPointData.params.regionId" placeholder="所属区域名称" filterable>
|
<el-option v-for="item in regionNameList" :key="item.id" :label="item.region" :value="item.id"></el-option>
|
</el-select>
|
</div>
|
<el-button size="default" type="primary" class="ml10" v-throttle @click="handleSearch">
|
<el-icon>
|
<ele-Search />
|
</el-icon>
|
查询
|
</el-button>
|
<el-button size="default" type="success" class="ml10" @click="onOpenDialogRef('新增', '')">
|
<el-icon>
|
<ele-FolderAdd />
|
</el-icon>
|
新增巡检点
|
</el-button>
|
</div>
|
<el-table :data="inspectPointData.data" style="width: 100%">
|
<el-table-column type="index" label="序号" width="60" />
|
<el-table-column prop="code" label="巡检点名称" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="regionName" label="所属设备区域" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="rfidName" label="关联RFID" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="createUserName" label="创建人" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="gmtCreate" label="创建时间" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="lastEditUserName" label="最后修改人" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="gmtModitify" label="最后修改时间" show-overflow-tooltip></el-table-column>
|
<el-table-column label="操作" width="150">
|
<template #default="scope">
|
<el-button size="small" text type="primary" :icon="Edit" @click="onOpenDialogRef('修改', scope.row)">修改</el-button>
|
<el-button size="small" text type="danger" :icon="Delete" @click="onDelProductionDevice(scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<br />
|
<el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="inspectPointData.params.pageIndex" background v-model:page-size="inspectPointData.params.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="inspectPointData.total" class="page-position"> </el-pagination>
|
<br />
|
<br />
|
</el-card>
|
<inspectPointDialog ref="inspectPointDialogRef" @refreshInspectPoint="initInspectPointTableData" />
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
import inspectPointDialog from './components/inspectPointDialog.vue';
|
import { inspectPointApi } from '/@/api/intellectInspectSystem/inspectPointManage';
|
import { facilityAreaApi } from '/@/api/intellectInspectSystem/facilityAreaManage';
|
import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue';
|
import { RFIDApi } from '/@/api/intellectInspectSystem/RFID';
|
|
// 定义接口来定义对象的类型
|
interface TableData {
|
quota: string;
|
quotaUnit: string;
|
quotaType: string;
|
createUserName: string;
|
gmtCreate: string;
|
lastEditUserName: string;
|
gmtModitify: string;
|
}
|
interface TableDataState {
|
inspectPointData: {
|
data: Array<TableData>;
|
total: number;
|
loading: boolean;
|
params: {
|
pageIndex: number;
|
pageSize: number;
|
code: string | null;
|
regionId: number;
|
};
|
};
|
regionNameList: Array<regionNameState>;
|
RFIDList: [];
|
}
|
|
interface regionNameState {}
|
|
export default defineComponent({
|
name: 'productionDevice',
|
components: { inspectPointDialog, Edit, Delete },
|
setup() {
|
const inspectPointDialogRef = ref();
|
const state = reactive<TableDataState>({
|
inspectPointData: {
|
data: [],
|
total: 0,
|
loading: false,
|
params: {
|
pageIndex: 1,
|
pageSize: 10,
|
code: null,
|
regionId: 1
|
}
|
},
|
regionNameList: [],
|
RFIDList: []
|
});
|
// 初始化表格数据
|
const initInspectPointTableData = async () => {
|
let res = await inspectPointApi().getInspectPointList(state.inspectPointData.params);
|
if (res.data.code === '200') {
|
state.inspectPointData.data = res.data.data.records;
|
state.inspectPointData.total = res.data.data.total;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
//获取所有设施区域名称
|
const initFacilityAreaType = async () => {
|
let res = await facilityAreaApi().getAllFacilityAreaList();
|
if (res.data.code === '200') {
|
state.regionNameList = JSON.parse(JSON.stringify(res.data.data));
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
//获取所有RFID名称
|
const initRFIDList = async () => {
|
let res = await RFIDApi().getAllRFIDList();
|
if (res.data.code === '200') {
|
state.RFIDList = JSON.parse(JSON.stringify(res.data.data));
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
// 打开弹窗
|
const onOpenDialogRef = (type: string, value: any) => {
|
inspectPointDialogRef.value.openInspectPointDialog(type, value, state.regionNameList, state.RFIDList);
|
};
|
// 删除
|
const onDelProductionDevice = (row: any) => {
|
ElMessageBox.confirm(`此操作将永久删除该巡检点:“${row.code}”,是否继续?`, '提示', {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(async () => {
|
let res = await inspectPointApi().deleteInspectPoint({ id: row.id });
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
duration: 2000,
|
message: '删除成功'
|
});
|
await initInspectPointTableData();
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
})
|
.catch(() => {});
|
};
|
|
const handleSearch = () => {
|
initInspectPointTableData();
|
};
|
// 分页改变
|
const onHandleSizeChange = (val: number) => {
|
state.inspectPointData.params.pageSize = val;
|
initInspectPointTableData();
|
};
|
// 分页改变
|
const onHandleCurrentChange = (val: number) => {
|
state.inspectPointData.params.pageIndex = val;
|
initInspectPointTableData();
|
};
|
// 页面加载时
|
onMounted(() => {
|
initInspectPointTableData();
|
initFacilityAreaType();
|
initRFIDList();
|
});
|
|
return {
|
Edit,
|
Delete,
|
handleSearch,
|
onOpenDialogRef,
|
onHandleSizeChange,
|
onDelProductionDevice,
|
onHandleCurrentChange,
|
inspectPointDialog,
|
inspectPointDialogRef,
|
initInspectPointTableData,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|
|
<style scoped></style>
|