pull/842/head
parent
7a196bddd5
commit
c5893f0ed3
|
|
@ -0,0 +1,57 @@
|
||||||
|
import request from '@/config/axios'
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
|
/** 客户宝塔信息信息 */
|
||||||
|
export interface Info {
|
||||||
|
id: number; // 主键ID
|
||||||
|
customerName?: string; // 客户名称
|
||||||
|
baotaUrl?: string; // 宝塔面板URL
|
||||||
|
username?: string; // 宝塔面板账号
|
||||||
|
password?: string; // 宝塔面板密码(建议加密存储)
|
||||||
|
rootUsername?: string; // 服务器root账号
|
||||||
|
rootPassword?: string; // 服务器root密码(建议加密存储)
|
||||||
|
mysqlUsername?: string; // MySQL账号
|
||||||
|
mysqlPassword?: string; // MySQL密码(建议加密存储)
|
||||||
|
redisPassword?: string; // Redis密码(建议加密存储)
|
||||||
|
publicIp?: string; // 公网IP(支持IPv4/IPv6)
|
||||||
|
remark: string; // 备注
|
||||||
|
status?: number; // 状态(0正常 1停用)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 客户宝塔信息 API
|
||||||
|
export const InfoApi = {
|
||||||
|
// 查询客户宝塔信息分页
|
||||||
|
getInfoPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/baota/info/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询客户宝塔信息详情
|
||||||
|
getInfo: async (id: number) => {
|
||||||
|
return await request.get({ url: `/baota/info/get?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增客户宝塔信息
|
||||||
|
createInfo: async (data: Info) => {
|
||||||
|
return await request.post({ url: `/baota/info/create`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改客户宝塔信息
|
||||||
|
updateInfo: async (data: Info) => {
|
||||||
|
return await request.put({ url: `/baota/info/update`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除客户宝塔信息
|
||||||
|
deleteInfo: async (id: number) => {
|
||||||
|
return await request.delete({ url: `/baota/info/delete?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 批量删除客户宝塔信息 */
|
||||||
|
deleteInfoList: async (ids: number[]) => {
|
||||||
|
return await request.delete({ url: `/baota/info/delete-list?ids=${ids.join(',')}` })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出客户宝塔信息 Excel
|
||||||
|
exportInfo: async (params) => {
|
||||||
|
return await request.download({ url: `/baota/info/export-excel`, params })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,186 @@
|
||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="100px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-form-item label="客户名称" prop="customerName">
|
||||||
|
<el-input v-model="formData.customerName" placeholder="请输入客户名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="宝塔面板URL" prop="baotaUrl">
|
||||||
|
<el-input v-model="formData.baotaUrl" placeholder="请输入宝塔面板URL" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="宝塔面板账号" prop="username">
|
||||||
|
<el-input v-model="formData.username" placeholder="请输入宝塔面板账号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="宝塔面板密码" prop="password">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.password"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入宝塔面板密码"
|
||||||
|
show-password
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="服务器root账号" prop="rootUsername">
|
||||||
|
<el-input v-model="formData.rootUsername" placeholder="请输入服务器root账号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="服务器root密码" prop="rootPassword">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.rootPassword"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入服务器root密码"
|
||||||
|
show-password
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="MySQL账号" prop="mysqlUsername">
|
||||||
|
<el-input v-model="formData.mysqlUsername" placeholder="请输入MySQL账号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="MySQL密码" prop="mysqlPassword">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.mysqlPassword"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入MySQL密码"
|
||||||
|
show-password
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="Redis密码" prop="redisPassword">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.redisPassword"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入Redis密码"
|
||||||
|
show-password
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="公网IP" prop="publicIp">
|
||||||
|
<el-input v-model="formData.publicIp" placeholder="请输入公网IP" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-radio-group v-model="formData.status">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { InfoApi, Info } from '@/api/baota/baotainfo'
|
||||||
|
|
||||||
|
/** 客户宝塔信息 表单 */
|
||||||
|
defineOptions({ name: 'InfoForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
customerName: undefined,
|
||||||
|
baotaUrl: undefined,
|
||||||
|
username: undefined,
|
||||||
|
password: undefined,
|
||||||
|
rootUsername: undefined,
|
||||||
|
rootPassword: undefined,
|
||||||
|
mysqlUsername: undefined,
|
||||||
|
mysqlPassword: undefined,
|
||||||
|
redisPassword: undefined,
|
||||||
|
publicIp: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
status: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
customerName: [{ required: true, message: '客户名称不能为空', trigger: 'blur' }],
|
||||||
|
baotaUrl: [{ required: true, message: '宝塔面板URL不能为空', trigger: 'blur' }],
|
||||||
|
username: [{ required: true, message: '宝塔面板账号不能为空', trigger: 'blur' }],
|
||||||
|
password: [{ required: true, message: '宝塔面板密码不能为空', trigger: 'blur' }],
|
||||||
|
rootUsername: [{ required: true, message: '服务器root账号不能为空', trigger: 'blur' }],
|
||||||
|
rootPassword: [{ required: true, message: '服务器root密码不能为空', trigger: 'blur' }],
|
||||||
|
mysqlUsername: [{ required: true, message: 'MySQL账号不能为空', trigger: 'blur' }],
|
||||||
|
mysqlPassword: [{ required: true, message: 'MySQL密码不能为空', trigger: 'blur' }],
|
||||||
|
redisPassword: [{ required: true, message: 'Redis密码不能为空', trigger: 'blur' }],
|
||||||
|
publicIp: [{ required: true, message: '公网IP不能为空', trigger: 'blur' }],
|
||||||
|
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
// 修改时,设置数据
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await InfoApi.getInfo(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
const submitForm = async () => {
|
||||||
|
// 校验表单
|
||||||
|
await formRef.value.validate()
|
||||||
|
// 提交请求
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as Info
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await InfoApi.createInfo(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await InfoApi.updateInfo(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
customerName: undefined,
|
||||||
|
baotaUrl: undefined,
|
||||||
|
username: undefined,
|
||||||
|
password: undefined,
|
||||||
|
rootUsername: undefined,
|
||||||
|
rootPassword: undefined,
|
||||||
|
mysqlUsername: undefined,
|
||||||
|
mysqlPassword: undefined,
|
||||||
|
redisPassword: undefined,
|
||||||
|
publicIp: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
status: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,397 @@
|
||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
|
<el-form-item label="客户名称" prop="customerName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.customerName"
|
||||||
|
placeholder="请输入客户名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="宝塔面板URL" prop="baotaUrl">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.baotaUrl"
|
||||||
|
placeholder="请输入宝塔面板URL"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="公网IP" prop="publicIp">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.publicIp"
|
||||||
|
placeholder="请输入公网IP"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.remark"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.status"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" prop="createTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.createTime"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-220px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
v-hasPermi="['baota:info:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['baota:info:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
:disabled="isEmpty(checkedIds)"
|
||||||
|
@click="handleDeleteBatch"
|
||||||
|
v-hasPermi="['baota:info:delete']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:delete" class="mr-5px" /> 批量删除
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table
|
||||||
|
row-key="id"
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
@selection-change="handleRowCheckboxChange"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
|
<el-table-column label="主键ID" align="center" prop="id" />
|
||||||
|
<el-table-column label="客户名称" align="center" prop="customerName" />
|
||||||
|
<el-table-column label="宝塔面板URL" align="center" prop="baotaUrl" min-width="200">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-link
|
||||||
|
:href="scope.row.baotaUrl"
|
||||||
|
target="_blank"
|
||||||
|
type="primary"
|
||||||
|
:underline="false"
|
||||||
|
>
|
||||||
|
{{ scope.row.baotaUrl }}
|
||||||
|
</el-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="宝塔面板账号" align="center" prop="username" />
|
||||||
|
<el-table-column label="宝塔面板密码" align="center" prop="password" min-width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input
|
||||||
|
v-model="scope.row.password"
|
||||||
|
:type="scope.row.showPassword ? 'text' : 'password'"
|
||||||
|
readonly
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<template #suffix>
|
||||||
|
<Icon
|
||||||
|
:icon="scope.row.showPassword ? 'ep:hide' : 'ep:view'"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="togglePasswordVisibility(scope.row, 'showPassword')"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="服务器root账号" align="center" prop="rootUsername" />
|
||||||
|
<el-table-column label="服务器root密码" align="center" prop="rootPassword" min-width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input
|
||||||
|
v-model="scope.row.rootPassword"
|
||||||
|
:type="scope.row.showRootPassword ? 'text' : 'password'"
|
||||||
|
readonly
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<template #suffix>
|
||||||
|
<Icon
|
||||||
|
:icon="scope.row.showRootPassword ? 'ep:hide' : 'ep:view'"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="togglePasswordVisibility(scope.row, 'showRootPassword')"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="MySQL账号" align="center" prop="mysqlUsername" />
|
||||||
|
<el-table-column label="MySQL密码" align="center" prop="mysqlPassword" min-width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input
|
||||||
|
v-model="scope.row.mysqlPassword"
|
||||||
|
:type="scope.row.showMysqlPassword ? 'text' : 'password'"
|
||||||
|
readonly
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<template #suffix>
|
||||||
|
<Icon
|
||||||
|
:icon="scope.row.showMysqlPassword ? 'ep:hide' : 'ep:view'"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="togglePasswordVisibility(scope.row, 'showMysqlPassword')"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="Redis密码" align="center" prop="redisPassword" min-width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input
|
||||||
|
v-model="scope.row.redisPassword"
|
||||||
|
:type="scope.row.showRedisPassword ? 'text' : 'password'"
|
||||||
|
readonly
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<template #suffix>
|
||||||
|
<Icon
|
||||||
|
:icon="scope.row.showRedisPassword ? 'ep:hide' : 'ep:view'"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="togglePasswordVisibility(scope.row, 'showRedisPassword')"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="公网IP" align="center" prop="publicIp" min-width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-link
|
||||||
|
:href="getIpUrl(scope.row.publicIp)"
|
||||||
|
target="_blank"
|
||||||
|
type="primary"
|
||||||
|
:underline="false"
|
||||||
|
>
|
||||||
|
{{ scope.row.publicIp }}
|
||||||
|
</el-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center" min-width="120px">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['baota:info:update']"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['baota:info:delete']"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<InfoForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { isEmpty } from '@/utils/is'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { InfoApi, Info } from '@/api/baota/baotainfo'
|
||||||
|
import InfoForm from './InfoForm.vue'
|
||||||
|
|
||||||
|
/** 客户宝塔信息 列表 */
|
||||||
|
defineOptions({ name: 'BaotaInfo' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const list = ref<Info[]>([]) // 列表的数据
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
customerName: undefined,
|
||||||
|
baotaUrl: undefined,
|
||||||
|
publicIp: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
status: undefined,
|
||||||
|
createTime: []
|
||||||
|
})
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await InfoApi.getInfoPage(queryParams)
|
||||||
|
// 为每一行添加密码显示控制属性
|
||||||
|
list.value = data.list.map(item => ({
|
||||||
|
...item,
|
||||||
|
showPassword: false,
|
||||||
|
showRootPassword: false,
|
||||||
|
showMysqlPassword: false,
|
||||||
|
showRedisPassword: false
|
||||||
|
}))
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加/修改操作 */
|
||||||
|
const formRef = ref()
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
// 发起删除
|
||||||
|
await InfoApi.deleteInfo(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除客户宝塔信息 */
|
||||||
|
const handleDeleteBatch = async () => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
await InfoApi.deleteInfoList(checkedIds.value);
|
||||||
|
checkedIds.value = [];
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList();
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([])
|
||||||
|
const handleRowCheckboxChange = (records: Info[]) => {
|
||||||
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
// 导出的二次确认
|
||||||
|
await message.exportConfirm()
|
||||||
|
// 发起导出
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await InfoApi.exportInfo(queryParams)
|
||||||
|
download.excel(data, '客户宝塔信息.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 切换密码可见性 */
|
||||||
|
const togglePasswordVisibility = (row: any, field: string) => {
|
||||||
|
row[field] = !row[field]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取IP访问URL */
|
||||||
|
const getIpUrl = (ip: string) => {
|
||||||
|
if (!ip) return '#'
|
||||||
|
// 如果IP中包含http/https,直接返回
|
||||||
|
if (ip.startsWith('http://') || ip.startsWith('https://')) {
|
||||||
|
return ip
|
||||||
|
}
|
||||||
|
// 否则添加http://前缀
|
||||||
|
return `http://${ip}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue