<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="facilityAreaData.params.regionName" placeholder="设备区域名称" clearable> </el-input>
|
</div>
|
<div class="basic-line">
|
<span>设备区域类型:</span>
|
<el-select class="input-box" v-model="facilityAreaData.params.regionTypeId" placeholder="设备区域类型" filterable>
|
<el-option v-for="item in facilityAreaTypeList" :key="item.id" :label="item.regionType" :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="facilityAreaData.data" style="width: 100%">
|
<el-table-column type="index" label="序号" width="60" />
|
<el-table-column prop="region" label="设备区域名称" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="regionType" label="设备区域类型" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="createByUserName" 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="facilityAreaData.params.pageIndex"
|
background
|
v-model:page-size="facilityAreaData.params.pageSize"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="facilityAreaData.total"
|
class="page-position"
|
>
|
</el-pagination>
|
<br />
|
<br />
|
</el-card>
|
<facilityAreaDialog ref="facilityAreaDialogRef" @refreshFacilityArea="initFacilityAreaTableData" />
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
import facilityAreaDialog from './components/facilityAreaDialog.vue';
|
import { facilityAreaApi } from '/@/api/intellectInspectSystem/facilityAreaManage';
|
import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue';
|
|
// 定义接口来定义对象的类型
|
interface TableData {
|
quota: string;
|
quotaUnit: string;
|
quotaType: string;
|
createUserName: string;
|
gmtCreate: string;
|
lastEditUserName: string;
|
gmtModitify: string;
|
}
|
interface TableDataState {
|
facilityAreaData: {
|
data: Array<TableData>;
|
total: number;
|
loading: boolean;
|
params: {
|
pageIndex: number;
|
pageSize: number;
|
regionTypeId: number;
|
regionName: string | null;
|
};
|
};
|
facilityAreaTypeList: Array<facilityAreaTypeState>;
|
}
|
|
interface facilityAreaTypeState {
|
regionType: string;
|
id: number;
|
}
|
|
export default defineComponent({
|
name: 'facilityArea',
|
components: { facilityAreaDialog, Edit, Delete },
|
setup() {
|
const facilityAreaDialogRef = ref();
|
const state = reactive<TableDataState>({
|
facilityAreaData: {
|
data: [],
|
total: 0,
|
loading: false,
|
params: {
|
pageIndex: 1,
|
pageSize: 10,
|
regionTypeId: 1,
|
regionName: null
|
}
|
},
|
facilityAreaTypeList: []
|
});
|
// 初始化表格数据
|
const initFacilityAreaTableData = async () => {
|
let res = await facilityAreaApi().getFacilityAreaList(state.facilityAreaData.params);
|
if (res.data.code === '200') {
|
state.facilityAreaData.data = res.data.data.records;
|
state.facilityAreaData.total = res.data.data.total;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
//获取所有设施区域类型
|
const initFacilityAreaType = async () => {
|
let res = await facilityAreaApi().getFacilityAreaType();
|
if (res.data.code === '200') {
|
state.facilityAreaTypeList = res.data.data;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
// 打开生产装置弹窗
|
const onOpenDialogRef = (type: string, value: any) => {
|
facilityAreaDialogRef.value.openFacilityAreaDialog(type, value, state.facilityAreaTypeList);
|
};
|
// 删除角色
|
const onDelProductionDevice = (row: any) => {
|
ElMessageBox.confirm(`此操作将永久删除该条设备区域:“${row.region}”,是否继续?`, '提示', {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(async () => {
|
let res = await facilityAreaApi().deleteFacilityArea({ id: row.id });
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
duration: 2000,
|
message: '删除成功'
|
});
|
await initFacilityAreaTableData();
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
})
|
.catch(() => {});
|
};
|
|
const handleSearch = () => {
|
initFacilityAreaTableData();
|
};
|
// 分页改变
|
const onHandleSizeChange = (val: number) => {
|
state.facilityAreaData.params.pageSize = val;
|
initFacilityAreaTableData();
|
};
|
// 分页改变
|
const onHandleCurrentChange = (val: number) => {
|
state.facilityAreaData.params.pageIndex = val;
|
initFacilityAreaTableData();
|
};
|
// 页面加载时
|
onMounted(() => {
|
initFacilityAreaTableData();
|
initFacilityAreaType();
|
});
|
|
return {
|
Edit,
|
Delete,
|
handleSearch,
|
onOpenDialogRef,
|
onHandleSizeChange,
|
onDelProductionDevice,
|
onHandleCurrentChange,
|
facilityAreaDialog,
|
facilityAreaDialogRef,
|
initFacilityAreaTableData,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|
|
<style scoped></style>
|