Files
profitManage/src/views/disRevenue/resource/register/index.vue
2025-08-28 18:55:38 +08:00

186 lines
7.4 KiB
Vue

<template>
<div class="app-container pageTopForm">
<el-form :model="queryParams" ref="queryRef" v-show="showSearch" :inline="true" label-width="auto">
<el-form-item label="名称" prop="nameKey">
<el-col>
<el-input
v-model="queryParams.resourceName"
placeholder="请输入交换机名称/服务器名称"
clearable
size="mini"
style="width: 220px"
@keyup.enter="handleQuery"
/>
</el-col>
</el-form-item>
<el-form-item>
<el-button type="primary" size="mini" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 表格数据 -->
<TableList :columns="columns" :config="config" :queryParams="queryParams" :tableList="roleList" @fnClick="callback" @fnRenderList="getList" @value-change="handleValueChange">
<!-- 资源类型 -->
<template #tempType="{ row, column }">
<dict-tag :options="dict.type.rm_register_resource_type" :value="row.resourceType"/>
</template>
<!-- 端口 -->
<template #tempPort="{ row, column }">
<dict-tag :options="dict.type.rm_register_port" :value="row.resourcePort"/>
</template>
<!-- 协议 -->
<template #tempProtocol="{ row, column }">
<dict-tag :options="dict.type.rm_register_protocol" :value="row.protocol"/>
</template>
<!-- 注册状态 -->
<template #tempStatus="{ row, column }">
<dict-tag :options="dict.type.rm_register_status" :value="row.registrationStatus"/>
</template>
<!-- 在线状态 -->
<template #tempOnlineStatus="{ row, column }">
<dict-tag :options="dict.type.rm_register_online_state" :value="row.onlineStatus"/>
</template>
</TableList>
</div>
</template>
<script setup name="Register">
import {listHandle, updateregisterType} from "@/api/disRevenue/resource"
import TableList from "@/components/table/index.vue"
export default {
name: 'RegisterIndex',
components: {TableList},
dicts: ['rm_register_resource_type', 'rm_register_protocol', 'rm_register_status', 'rm_register_port', 'rm_register_online_state'],
data() {
return {
roleList: [],
loading: true,
showSearch: true,
ids: [],
single: true,
meltiple: true,
// 列显隐信息
columns: {
id: { label: `ID`},
hardwareSn: { label: `硬件SN`,width: '120', visible: true },
resourceType: { label: `资源类型`, width: '120', slotName: 'tempType', visible: true },
resourceName: { label: `资源名称`, visible: true },
ipAddress: { label: `IP地址`, visible: true },
resourcePort: { label: `端口`, slotName: 'tempPort', visible: true },
protocol: { label: `协议`, width: '120', slotName: 'tempProtocol', visible: true },
registrationStatus: { label: `注册状态`, slotName: 'tempStatus', visible: true },
onlineStatus: { label: `在线状态`, slotName: 'tempOnlineStatus', visible: true }
},
config: {
searcherForm: [
{label: '交换机名称', prop: 'roleName', type: 'selset', options: []}
],
tableButton: {
top: [
{content: '新增', fnCode: 'add', type: 'primary', icon: 'el-icon-plus', hasPermi: 'disRevenue:resource:register:add'},
{content: '导出', fnCode: 'export', type: 'warning', icon: 'el-icon-download', hasPermi: 'disRevenue:resource:register:export'},
],
line: [
{content: '修改', fnCode: 'edit', type: 'text', icon: 'el-icon-edit', hasPermi: 'disRevenue:resource:register:edit'},
{content: '注册', fnCode: 'enroll', showName: 'registrationStatus', showVal: '0', type: 'text', icon: 'el-icon-circle-check', hasPermi: 'disRevenue:resource:register:enroll'},
{content: '取消注册', fnCode: 'unenroll', showName: 'registrationStatus', showVal: '1', type: 'text', icon: 'el-icon-circle-close', hasPermi: 'disRevenue:resource:register:unenroll'},
]
}
},
queryParams: {
pageNum: 1,
pageSize: 10,
total: 0
}
}
},
created() {
this.getList();
},
methods: {
// 处理子组件传递的新值
handleValueChange(newValue) {
// 父组件更新自身数据,实现同步
this.showSearch = newValue;
// console.log('父组件拿到新值:', newValue);
},
/** 查询角色列表 */
getList() {
this.loading = true
listHandle(this.addDateRange(this.queryParams)).then(response => {
this.roleList = response.rows;
this.queryParams.total = response.total;
this.loading = false;
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.$refs['queryRef'].resetFields();
this.queryParams = {pageNum: 1, pageSize: 10,total: 0};
// this.resetForm("queryRef");
this.handleQuery();
},
/** 多选框选中数据 */
handleSelectionChange(selection) {
this.ids = selection.map(item => item.roleId);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
callback(result, rowData, selectChange) {
if (result && result.fnCode) {
switch (result.fnCode) {
case 'add':
this.$router.push("/disRevenue/resource/register/edit/index")
break;
case 'edit':
this.$router.push({
path:'/disRevenue/resource/register/edit/index/',
query: {id: rowData.id}
});
break;
case 'enroll':
rowData['registrationStatus'] = '1';
updateregisterType(rowData).then(res => {
this.$modal.msgSuccess("注册成功!");
this.getList();
});
break;
case 'unenroll':
rowData['registrationStatus'] = '0';
updateregisterType(rowData).then(res => {
this.$modal.msgSuccess("取消注册成功!");
this.getList();
});
break;
case 'export':
let dataList = [];
Object.keys(this.columns).forEach(item => {
if (item.visible) {
dataList.push(item.prop);
}
});
this.download("/system/registration/export", {
properties: dataList,
}, `资源管理_${new Date().getTime()}.xlsx`);
break;
default:
}
}
}
}
}
</script>
<style scoped>
</style>