2024-09-13 16:34:15 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<el-card class="list-query" shadow="hover">
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form inline label-width="80px">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
|
|
|
|
<el-button type="danger" @click="toAdd">{{ T('Add') }}</el-button>
|
2024-09-13 16:34:15 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
<el-card class="list-body" shadow="hover">
|
|
|
|
|
<el-table :data="listRes.list" v-loading="listRes.loading" border size="small">
|
|
|
|
|
<el-table-column prop="id" label="id" align="center"/>
|
|
|
|
|
<el-table-column prop="cpu" label="cpu" align="center"/>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-table-column prop="hostname" :label="T('Hostname')" align="center"/>
|
|
|
|
|
<el-table-column prop="memory" :label="T('Memory')" align="center"/>
|
|
|
|
|
<el-table-column prop="os" :label="T('Os')" align="center"/>
|
|
|
|
|
<el-table-column prop="username" :label="T('Username')" align="center"/>
|
|
|
|
|
<el-table-column prop="uuid" :label="T('Uuid')" align="center"/>
|
|
|
|
|
<el-table-column prop="version" :label="T('Version')" align="center"/>
|
|
|
|
|
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
|
|
|
|
<el-table-column prop="updated_at" :label="T('UpdatedAt')" align="center"/>
|
|
|
|
|
<el-table-column :label="T('Actions')" align="center" width="400">
|
2024-09-13 16:34:15 +08:00
|
|
|
<template #default="{row}">
|
|
|
|
|
<el-button type="success" @click="toWebClientLink(row)">Web-Client</el-button>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-button @click="toEdit(row)">{{ T('Edit') }}</el-button>
|
|
|
|
|
<el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>
|
2024-09-13 16:34:15 +08:00
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</el-card>
|
|
|
|
|
<el-card class="list-page" shadow="hover">
|
|
|
|
|
<el-pagination background
|
|
|
|
|
layout="prev, pager, next, sizes, jumper"
|
|
|
|
|
:page-sizes="[10,20,50,100]"
|
|
|
|
|
v-model:page-size="listQuery.page_size"
|
|
|
|
|
v-model:current-page="listQuery.page"
|
|
|
|
|
:total="listRes.total">
|
|
|
|
|
</el-pagination>
|
|
|
|
|
</el-card>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-dialog v-model="formVisible" :title="!formData.row_id?T('Create'):T('Update')" width="800">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
|
|
|
|
|
<el-form-item label="id" prop="id" required>
|
|
|
|
|
<el-input v-model="formData.id"></el-input>
|
|
|
|
|
</el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form-item :label="T('Username')" prop="username">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-input v-model="formData.username"></el-input>
|
|
|
|
|
</el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form-item :label="T('Hostname')" prop="hostname">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-input v-model="formData.hostname"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="cpu" prop="cpu">
|
|
|
|
|
<el-input v-model="formData.cpu"></el-input>
|
|
|
|
|
</el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form-item :label="T('Memory')" prop="memory">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-input v-model="formData.memory"></el-input>
|
|
|
|
|
</el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form-item :label="T('Os')" prop="os">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-input v-model="formData.os"></el-input>
|
|
|
|
|
</el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form-item :label="T('Uuid')" prop="uuid">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-input v-model="formData.uuid"></el-input>
|
|
|
|
|
</el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form-item :label="T('Version')" prop="version">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-input v-model="formData.version"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-button @click="formVisible = false">{{ T('Cancel') }}</el-button>
|
|
|
|
|
<el-button @click="submit" type="primary">{{ T('Submit') }}</el-button>
|
2024-09-13 16:34:15 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { onActivated, onMounted, reactive, ref, watch } from 'vue'
|
|
|
|
|
import { create, list, remove, update } from '@/api/peer'
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
import { toWebClientLink } from '@/utils/webclient'
|
2024-09-25 22:24:16 +08:00
|
|
|
import { T } from '@/utils/i18n'
|
2024-09-13 16:34:15 +08:00
|
|
|
|
|
|
|
|
const listRes = reactive({
|
|
|
|
|
list: [], total: 0, loading: false,
|
|
|
|
|
})
|
|
|
|
|
const listQuery = reactive({
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 10,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
listRes.loading = true
|
|
|
|
|
const res = await list(listQuery).catch(_ => false)
|
|
|
|
|
listRes.loading = false
|
|
|
|
|
if (res) {
|
|
|
|
|
listRes.list = res.data.list
|
|
|
|
|
listRes.total = res.data.total
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const handlerQuery = () => {
|
|
|
|
|
if (listQuery.page === 1) {
|
|
|
|
|
getList()
|
|
|
|
|
} else {
|
|
|
|
|
listQuery.page = 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const del = async (row) => {
|
2024-09-25 22:24:16 +08:00
|
|
|
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
|
|
|
|
confirmButtonText: T('Confirm'),
|
|
|
|
|
cancelButtonText: T('Cancel'),
|
2024-09-13 16:34:15 +08:00
|
|
|
type: 'warning',
|
|
|
|
|
}).catch(_ => false)
|
|
|
|
|
if (!cf) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const res = await remove({ row_id: row.row_id }).catch(_ => false)
|
|
|
|
|
if (res) {
|
2024-09-25 22:24:16 +08:00
|
|
|
ElMessage.success(T('OperationSuccess'))
|
2024-09-13 16:34:15 +08:00
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onMounted(getList)
|
|
|
|
|
onActivated(getList)
|
|
|
|
|
|
|
|
|
|
watch(() => listQuery.page, getList)
|
|
|
|
|
|
|
|
|
|
watch(() => listQuery.page_size, handlerQuery)
|
|
|
|
|
|
|
|
|
|
const platformList = [
|
|
|
|
|
{ label: 'Windows', value: 'Windows' },
|
|
|
|
|
{ label: 'Linux', value: 'Linux' },
|
|
|
|
|
{ label: 'Mac OS', value: 'Mac OS' },
|
|
|
|
|
{ label: 'Android', value: 'Android' },
|
|
|
|
|
]
|
|
|
|
|
const formVisible = ref(false)
|
|
|
|
|
const formData = reactive({
|
|
|
|
|
row_id: 0,
|
|
|
|
|
cpu: '',
|
|
|
|
|
hostname: '',
|
|
|
|
|
id: '',
|
|
|
|
|
memory: '',
|
|
|
|
|
os: '',
|
|
|
|
|
username: '',
|
|
|
|
|
uuid: '',
|
|
|
|
|
version: '',
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const toEdit = (row) => {
|
|
|
|
|
formVisible.value = true
|
|
|
|
|
//将row中的数据赋值给formData
|
|
|
|
|
Object.keys(formData).forEach(key => {
|
|
|
|
|
formData[key] = row[key]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const toAdd = () => {
|
|
|
|
|
formVisible.value = true
|
|
|
|
|
//重置formData
|
|
|
|
|
formData.row_id = 0
|
|
|
|
|
formData.cpu = ''
|
|
|
|
|
formData.hostname = ''
|
|
|
|
|
formData.id = ''
|
|
|
|
|
formData.memory = ''
|
|
|
|
|
formData.os = ''
|
|
|
|
|
formData.username = ''
|
|
|
|
|
formData.uuid = ''
|
|
|
|
|
formData.version = ''
|
|
|
|
|
}
|
|
|
|
|
const submit = async () => {
|
|
|
|
|
const api = formData.row_id ? update : create
|
|
|
|
|
const res = await api(formData).catch(_ => false)
|
|
|
|
|
if (res) {
|
2024-09-25 22:24:16 +08:00
|
|
|
ElMessage.success(T('OperationSuccess'))
|
2024-09-13 16:34:15 +08:00
|
|
|
formVisible.value = false
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.list-query .el-select {
|
|
|
|
|
--el-select-width: 160px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.colors {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.colorbox {
|
|
|
|
|
width: 50px;
|
|
|
|
|
height: 30px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.dot {
|
|
|
|
|
width: 10px;
|
|
|
|
|
height: 10px;
|
|
|
|
|
display: block;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|