代码优化

This commit is contained in:
dqjdda
2019-11-25 16:49:16 +08:00
parent fcc28fdd6f
commit 882dc03e3c
57 changed files with 594 additions and 2130 deletions

View File

@@ -1,108 +0,0 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
:title="isAdd ? '新增' : '编辑'"
width="500px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="名称">
<el-input v-model="form.name" style="width: 370px" />
</el-form-item>
<el-form-item label="账号">
<el-input v-model="form.account" style="width: 370px" />
</el-form-item>
<el-form-item label="密码">
<el-input v-model="form.password" type="password" style="width: 370px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit } from '@/api/serverAccount'
export default {
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false,
dialog: false,
form: {
id: '',
name: '',
account: '',
password: ''
},
rules: {}
}
},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else this.doEdit()
},
doAdd() {
add(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
edit(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
name: '',
account: '',
password: ''
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -1,176 +0,0 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input
v-model="query.value"
clearable
placeholder="输入搜索内容"
style="width: 200px"
class="filter-item"
@keyup.enter.native="toQuery"
/>
<el-select
v-model="query.type"
clearable
placeholder="类型"
class="filter-item"
style="width: 130px"
>
<el-option
v-for="item in queryTypeOptions"
:key="item.key"
:label="item.display_name"
:value="item.key"
/>
</el-select>
<el-button
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="toQuery"
>搜索</el-button>
<!-- 新增 -->
<div style="display: inline-block;margin: 0px 2px">
<el-button
v-permission="['admin','serverAccount:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="add"
>新增</el-button>
</div>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd" />
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" style="width: 100%">
<el-table-column prop="name" label="名称" />
<el-table-column prop="account" label="账号" />
<el-table-column
v-if="checkPermission(['admin','serverAccount:edit','serverAccount:del'])"
label="操作"
width="150px"
align="center"
>
<template slot-scope="scope">
<el-button
v-permission="['admin','serverAccount:edit']"
size="mini"
type="primary"
icon="el-icon-edit"
@click="edit(scope.row)"
/>
<el-popover
:ref="scope.row.id"
v-permission="['admin','serverAccount:del']"
placement="top"
width="180"
>
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button
:loading="delLoading"
type="primary"
size="mini"
@click="subDelete(scope.row.id)"
>确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" />
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
:current-page="page + 1"
style="margin-top: 8px"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"
/>
</div>
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del } from '@/api/serverAccount'
import eForm from './form'
export default {
components: { eForm },
mixins: [initData],
data() {
return {
delLoading: false,
queryTypeOptions: [
{ key: 'name', display_name: '名称' },
{ key: 'account', display_name: '账号' }
]
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/serverAccount'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
const query = this.query
const type = query.type
const value = query.value
if (type && value) {
this.params[type] = value
}
return true
},
subDelete(id) {
this.delLoading = true
del(id)
.then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
})
.catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.form = {
id: data.id,
name: data.name,
account: data.account,
password: data.password
}
_this.dialog = true
}
}
}
</script>
<style scoped>
</style>

View File

@@ -1,180 +0,0 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
:title="isAdd ? '新增' : '编辑'"
width="800px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
<el-form-item label="应用名称" prop="name">
<el-input v-model="form.name" style="width: 670px" placeholder="部署后的文件或者目录名称,用于备份" />
</el-form-item>
<el-form-item label="应用端口" prop="port">
<el-input-number v-model="form.port" placeholder="例如8080" />
</el-form-item>
<el-form-item label="上传目录" prop="uploadPath">
<el-input
v-model="form.uploadPath"
style="width: 670px"
placeholder="例如: /opt/upload"
/>
</el-form-item>
<el-form-item label="部署目录" prop="deployPath">
<el-input
v-model="form.deployPath"
style="width: 670px"
placeholder="例如: /opt/app"
/>
</el-form-item>
<el-form-item label="备份目录" prop="backupPath">
<el-input
v-model="form.backupPath"
style="width: 670px"
placeholder="例如: /opt/backup"
/>
</el-form-item>
<el-form-item label="启动脚本" prop="startScript">
<el-input
v-model="form.startScript"
:rows="2"
type="textarea"
autosize
style="width: 670px"
placeholder=""
/>
</el-form-item>
<el-form-item label="部署脚本" prop="deployScript">
<el-input
v-model="form.deployScript"
:rows="2"
type="textarea"
autosize
style="width: 670px"
placeholder=""
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit } from '@/api/app'
export default {
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false,
dialog: false,
form: {
id: '',
name: '',
port: 8080,
uploadPath: '/opt/upload',
deployPath: '/opt/app',
backupPath: '/opt/backup',
startScript: '',
deployScript: ''
},
rules: {
name: [
{ required: true, message: '请输入应用名称', trigger: 'change' }
],
uploadPath: [
{ required: true, message: '请输入上传目录', trigger: 'change' }
],
deployPath: [
{ required: true, message: '请输入部署目录', trigger: 'change' }
],
backupPath: [
{ required: true, message: '请输入备份目录', trigger: 'change' }
],
startScript: [
{ required: true, message: '请输入启动脚本', trigger: 'change' }
],
deployScript: [
{ required: true, message: '请输入部署脚本', trigger: 'change' }
]
}
}
},
mounted() {},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.$refs['form'].validate(valid => {
if (valid) {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else this.doEdit()
} else {
this.$message.error('请将表单中的信息补充完整!')
}
})
},
doAdd() {
add(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
edit(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
name: '',
port: 8080,
uploadPath: '/opt/upload',
deployPath: '/opt/app',
backupPath: '/opt/backup',
startScript: '',
deployScript: ''
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -3,83 +3,83 @@
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input
v-model="query.value"
clearable
placeholder="输入搜索内容"
style="width: 200px"
class="filter-item"
@keyup.enter.native="toQuery"
<el-input v-model="query.name" clearable placeholder="输入名称搜索" style="width: 200px" class="filter-item" @keyup.enter.native="toQuery" />
<el-date-picker
v-model="query.createTime"
:default-time="['00:00:00','23:59:59']"
type="daterange"
range-separator=":"
class="el-range-editor--small date-item"
style="width: 220px;height: 30.5px"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
<el-select
v-model="query.type"
clearable
placeholder="类型"
class="filter-item"
style="width: 130px"
>
<el-option
v-for="item in queryTypeOptions"
:key="item.key"
:label="item.display_name"
:value="item.key"
/>
</el-select>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 新增 -->
<el-button
v-permission="['admin','app:add']"
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="toQuery"
>搜索</el-button>
<!-- 新增 -->
<div style="display: inline-block;margin: 0px 2px">
<el-button
v-permission="['admin','app:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="add"
>新增</el-button>
<el-button
v-permission="['admin','app:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="copy"
>复制新增</el-button>
</div>
type="primary"
icon="el-icon-plus"
@click="showAddFormDialog"
>新增</el-button>
<el-button
v-permission="['admin','app:add']"
:disabled="!currentRow"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="copy"
>复制新增</el-button>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd" />
<el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="800px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
<el-form-item label="应用名称" prop="name">
<el-input v-model="form.name" style="width: 670px" placeholder="部署后的文件或者目录名称,用于备份" />
</el-form-item>
<el-form-item label="应用端口" prop="port">
<el-input-number v-model.number="form.port" placeholder="例如8080" />
</el-form-item>
<el-form-item label="上传目录" prop="uploadPath">
<el-input v-model="form.uploadPath" style="width: 670px" placeholder="例如: /opt/upload" />
</el-form-item>
<el-form-item label="部署目录" prop="deployPath">
<el-input v-model="form.deployPath" style="width: 670px" placeholder="例如: /opt/app" />
</el-form-item>
<el-form-item label="备份目录" prop="backupPath">
<el-input v-model="form.backupPath" style="width: 670px" placeholder="例如: /opt/backup" />
</el-form-item>
<el-form-item label="启动脚本" prop="startScript">
<el-input v-model="form.startScript" :rows="3" type="textarea" autosize style="width: 670px" placeholder="" />
</el-form-item>
<el-form-item label="部署脚本" prop="deployScript">
<el-input v-model="form.deployScript" :rows="3" type="textarea" autosize style="width: 670px" placeholder="" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="submitMethod">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table
v-loading="loading"
:data="data"
highlight-current-row
size="small"
style="width: 100%"
@current-change="handleCurrentChange"
>
<el-table v-loading="loading" :data="data" highlight-current-row size="small" style="width: 100%" @current-change="handleCurrentChange">
<el-table-column prop="name" label="应用名称" />
<el-table-column prop="port" label="端口号" />
<el-table-column prop="uploadPath" label="上传目录" />
<el-table-column prop="deployPath" label="部署目录" />
<el-table-column
v-if="checkPermission(['admin','app:edit','app:del'])"
label="操作"
width="150px"
align="center"
>
<el-table-column prop="backupPath" label="备份目录" />
<el-table-column prop="createTime" label="创建日期">
<template slot-scope="scope">
<el-button
v-permission="['admin','app:edit']"
size="mini"
type="primary"
icon="el-icon-edit"
@click="edit(scope.row)"
/>
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['admin','app:edit','app:del'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button v-permission="['admin','app:edit']" size="mini" type="primary" icon="el-icon-edit" @click="showEditFormDialog(scope.row)" />
<el-popover
:ref="scope.row.id"
v-permission="['admin','app:del']"
@@ -89,12 +89,7 @@
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button
:loading="delLoading"
type="primary"
size="mini"
@click="subDelete(scope.row.id)"
>确定</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="delMethod(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" />
</el-popover>
@@ -114,18 +109,48 @@
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del } from '@/api/app'
import eForm from './form'
import crud from '@/mixins/crud'
import crudApp from '@/api/mnt/app'
export default {
components: { eForm },
mixins: [initData],
mixins: [crud],
data() {
return {
delLoading: false,
queryTypeOptions: [{ key: 'name', display_name: '应用名称' }],
currentRow: {}
title: '应用',
crudMethod: { ...crudApp },
currentRow: null,
form: {
id: null,
name: null,
port: 8080,
uploadPath: '/opt/upload',
deployPath: '/opt/app',
backupPath: '/opt/backup',
startScript: null,
deployScript: null
},
rules: {
name: [
{ required: true, message: '请输入应用名称', trigger: 'blur' }
],
port: [
{ required: true, message: '请输入应用端口', trigger: 'blur', type: 'number' }
],
uploadPath: [
{ required: true, message: '请输入上传目录', trigger: 'blur' }
],
deployPath: [
{ required: true, message: '请输入部署目录', trigger: 'blur' }
],
backupPath: [
{ required: true, message: '请输入备份目录', trigger: 'blur' }
],
startScript: [
{ required: true, message: '请输入启动脚本', trigger: 'blur' }
],
deployScript: [
{ required: true, message: '请输入部署脚本', trigger: 'blur' }
]
}
}
},
created() {
@@ -134,74 +159,14 @@ export default {
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/app'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
const query = this.query
const type = query.type
const value = query.value
if (type && value) {
this.params[type] = value
}
return true
},
subDelete(id) {
this.delLoading = true
del(id)
.then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
})
.catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
const _this = this.$refs.form
_this.form = {
id: '',
name: '',
port: 8080,
uploadPath: '/opt/upload',
deployPath: '/opt/app',
backupPath: '/opt/backup',
startScript: '',
deployScript: ''
}
},
copy() {
this.isAdd = true
this.$refs.form.dialog = true
const _this = this.$refs.form
_this.form = this.currentRow
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.form = {
id: data.id,
name: data.name,
port: data.port,
uploadPath: data.uploadPath,
deployPath: data.deployPath,
backupPath: data.backupPath,
startScript: data.startScript,
deployScript: data.deployScript
}
_this.dialog = true
this.dialog = true
this.form = this.currentRow
},
handleCurrentChange(row) {
this.currentRow = row

View File

@@ -1,134 +0,0 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
:title="isAdd ? '新增' : '编辑'"
width="600px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
<el-form-item label="数据库名称" prop="name">
<el-input v-model="form.name" style="width: 370px" />
</el-form-item>
<el-form-item label="jdbcUrl" prop="jdbcUrl">
<el-input v-model="form.jdbcUrl" style="width: 370px" />
</el-form-item>
<el-form-item label="用户名" prop="userName">
<el-input v-model="form.userName" style="width: 370px" />
</el-form-item>
<el-form-item label="数据库密码" prop="pwd">
<el-input v-model="form.pwd" type="password" style="width: 370px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit } from '@/api/database'
export default {
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false,
dialog: false,
form: {
id: '',
name: '',
jdbcUrl: '',
userName: '',
pwd: ''
},
rules: {
name: [
{ required: true, message: '请输入数据库名称', trigger: 'change' }
],
jdbcUrl: [
{ required: true, message: '请输入数据库连接地址', trigger: 'change' }
],
userName: [
{ required: true, message: '请输入用户名', trigger: 'change' }
],
pwd: [
{ required: true, message: '请输入数据库密码', trigger: 'change' }
]
}
}
},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.$refs['form'].validate(valid => {
if (valid) {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else {
this.doEdit()
}
} else {
this.$message.error('请将表单中的信息补充完整!')
}
})
},
doAdd() {
add(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
edit(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
name: '',
jdbcUrl: '',
userName: '',
pwd: ''
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -3,69 +3,47 @@
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input
v-model="query.value"
clearable
placeholder="输入搜索内容"
style="width: 200px"
class="filter-item"
@keyup.enter.native="toQuery"
/>
<el-select
v-model="query.type"
clearable
placeholder="类型"
class="filter-item"
style="width: 130px"
>
<el-option
v-for="item in queryTypeOptions"
:key="item.key"
:label="item.display_name"
:value="item.key"
/>
</el-select>
<el-input v-model="query.blurry" clearable placeholder="模糊搜索" style="width: 200px" class="filter-item" @keyup.enter.native="toQuery" />
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 新增 -->
<el-button
v-permission="['admin','database:add']"
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="toQuery"
>搜索</el-button>
<!-- 新增 -->
<div style="display: inline-block;margin: 0px 2px">
<el-button
v-permission="['admin','database:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="add"
>新增</el-button>
</div>
type="primary"
icon="el-icon-plus"
@click="showAddFormDialog"
>新增</el-button>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd" />
<el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="530px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
<el-form-item label="数据库名称" prop="name">
<el-input v-model="form.name" style="width: 370px" />
</el-form-item>
<el-form-item label="连接地址" prop="jdbcUrl">
<el-input v-model="form.jdbcUrl" style="width: 370px" />
</el-form-item>
<el-form-item label="用户名" prop="userName">
<el-input v-model="form.userName" style="width: 370px" />
</el-form-item>
<el-form-item label="密码" prop="pwd">
<el-input v-model="form.pwd" type="password" style="width: 370px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="submitMethod">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" style="width: 100%">
<!--<el-table-column prop="id" label="id" />-->
<el-table-column prop="name" label="数据库名称" />
<el-table-column prop="jdbcUrl" label="数据库连接地址" />
<el-table-column prop="jdbcUrl" label="连接地址" />
<el-table-column prop="userName" label="用户名" />
<el-table-column
v-if="checkPermission(['admin','database:edit','database:del'])"
label="操作"
width="150px"
align="center"
>
<el-table-column v-if="checkPermission(['admin','database:edit','database:del'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button
v-permission="['admin','database:edit']"
size="mini"
type="primary"
icon="el-icon-edit"
@click="edit(scope.row)"
/>
<el-button v-permission="['admin','database:edit']" size="mini" type="primary" icon="el-icon-edit" @click="showEditFormDialog(scope.row)" />
<el-popover
:ref="scope.row.id"
v-permission="['admin','database:del']"
@@ -75,12 +53,7 @@
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button
:loading="delLoading"
type="primary"
size="mini"
@click="subDelete(scope.row.id)"
>确定</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="delMethod(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" />
</el-popover>
@@ -100,20 +73,29 @@
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del } from '@/api/database'
import eForm from './form'
import crud from '@/mixins/crud'
import crudDataBase from '@/api//mnt/database'
export default {
components: { eForm },
mixins: [initData],
mixins: [crud],
data() {
return {
delLoading: false,
queryTypeOptions: [
{ key: 'name', display_name: '数据库名称' },
{ key: 'jdbcUrl', display_name: '数据库连接地址' }
]
title: '数据库',
crudMethod: { ...crudDataBase },
form: { id: null, name: null, jdbcUrl: null, userName: null, pwd: null },
rules: {
name: [
{ required: true, message: '请输入数据库名称', trigger: 'blur' }
],
jdbcUrl: [
{ required: true, message: '请输入数据库连接地址', trigger: 'blur' }
],
userName: [
{ required: true, message: '请输入用户名', trigger: 'blur' }
],
pwd: [
{ required: true, message: '请输入数据库密码', trigger: 'blur' }
]
}
}
},
created() {
@@ -122,54 +104,9 @@ export default {
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/database'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
const query = this.query
const type = query.type
const value = query.value
if (type && value) {
this.params[type] = value
}
return true
},
subDelete(id) {
this.delLoading = true
del(id)
.then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
})
.catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.form = {
id: data.id,
name: data.name,
jdbcUrl: data.jdbcUrl,
userName: data.userName,
pwd: data.pwd
}
_this.dialog = true
}
}
}

View File

@@ -1,11 +1,5 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
title="应用部署"
width="400px"
>
<el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialog" title="应用部署" width="400px">
<el-form ref="form" :model="form" :rules="rules" size="small">
<el-upload
:action="deployUploadApi"
@@ -31,7 +25,7 @@
</template>
<script>
import { add, edit, getApps, getServers } from '@/api/deploy'
import { add, edit, getApps, getServers } from '@/api/mnt/deploy'
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'
@@ -62,9 +56,6 @@ export default {
created() {
this.initWebSocket()
},
destroyed: function() {
this.webSocketClose()
},
mounted() {
this.initSelect()
},
@@ -144,9 +135,7 @@ export default {
})
},
handleSuccess(response, file, fileList) {
const uid = file.uid
const id = response.id
console.log(uid, id)
this.cancel()
},
// 监听上传失败
handleError(e, file, fileList) {
@@ -160,17 +149,8 @@ export default {
initWebSocket() {
const wsUri = process.env.VUE_APP_WS_API + '/webSocket/deploy'
this.websock = new WebSocket(wsUri)
this.websock.onopen = this.webSocketOnOpen
this.websock.onerror = this.webSocketOnError
this.websock.onmessage = this.webSocketOnMessage
this.websock.onclose = this.webSocketClose
},
webSocketOnOpen() {
this.$notify({
title: 'WebSocket连接成功',
type: 'success',
duration: 2500
})
},
webSocketOnError(e) {
this.$notify({
@@ -201,13 +181,6 @@ export default {
},
webSocketSend(agentData) {
this.websock.send(agentData)
},
webSocketClose(e) {
this.$notify({
title: 'WebSocket已经关闭',
type: 'info',
duration: 1000
})
}
}
}

View File

@@ -1,132 +0,0 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
:title="isAdd ? '新增' : '编辑'"
width="500px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="应用编号">
<el-select v-model="form.appId" placeholder="请选择" style="width: 370px">
<el-option v-for="item in apps" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="IP列表">
<el-select v-model="form.selectIp" multiple placeholder="请选择" style="width: 370px">
<el-option v-for="item in servers" :key="item.id" :label="item.id" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit, getApps, getServers } from '@/api/deploy'
export default {
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false,
dialog: false,
apps: [],
servers: [],
form: {
id: '',
appId: '',
ip: '',
selectIp: []
},
rules: {}
}
},
mounted() {
this.initSelect()
},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else this.doEdit()
},
joinIp() {
this.form.ip = ''
this.form.selectIp.forEach(ip => {
if (this.form.ip !== '') {
this.form.ip += ','
}
this.form.ip += ip
})
},
doAdd() {
this.joinIp()
add(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
this.joinIp()
edit(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
appId: '',
ip: '',
selectIp: []
}
},
initSelect() {
getApps().then(res => {
this.apps = res.content
})
getServers().then(res => {
this.servers = res.content
})
}
}
}
</script>
<style scoped>
</style>

View File

@@ -3,125 +3,109 @@
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input
v-model="query.value"
clearable
placeholder="输入搜索内容"
style="width: 200px"
class="filter-item"
@keyup.enter.native="toQuery"
<el-input v-model="query.appName" clearable placeholder="输入应用名称查询" style="width: 200px" class="filter-item" @keyup.enter.native="toQuery" />
<el-date-picker
v-model="query.createTime"
:default-time="['00:00:00','23:59:59']"
type="daterange"
range-separator=":"
class="el-range-editor--small date-item"
style="width: 220px;height: 30.5px"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
<el-select
v-model="query.type"
clearable
placeholder="类型"
class="filter-item"
style="width: 130px"
>
<el-option
v-for="item in queryTypeOptions"
:key="item.key"
:label="item.display_name"
:value="item.key"
/>
</el-select>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 新增 -->
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="showAddFormDialog"
>新增
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-upload"
@click="sysRestore"
>系统还原
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-upload"
@click="serverStatus"
>状态查询
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="toQuery"
>搜索
icon="el-icon-upload"
@click="startServer"
>启动
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="danger"
icon="el-icon-upload"
@click="stopServer"
>停止
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="warning"
icon="el-icon-upload"
@click="deploy"
>一键部署
</el-button>
<!-- 新增 -->
<div style="display: inline-block;margin: 0px 2px">
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="add"
>新增
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-upload"
@click="sysRestore"
>系统还原
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-upload"
@click="serverStatus"
>状态查询
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="success"
icon="el-icon-upload"
@click="startServer"
>启动
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="danger"
icon="el-icon-upload"
@click="stopServer"
>停止
</el-button>
<el-button
v-permission="['admin','deploy:add']"
class="filter-item"
size="mini"
type="warning"
icon="el-icon-upload"
@click="deploy"
>一键部署
</el-button>
</div>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd" />
<!-- 系统还原组件-->
<el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="应用" prop="app.id">
<el-select v-model.number="form.app.id" placeholder="请选择" style="width: 370px">
<el-option v-for="item in apps" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="服务器" prop="deploys">
<el-select v-model="form.deploys" multiple placeholder="请选择" style="width: 370px">
<el-option v-for="item in servers" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="submitMethod">确认</el-button>
</div>
</el-dialog>
<!--统还原组件-->
<fForm ref="sysRestore" :key="times" :app-name="appName" />
<dForm ref="deploy" />
<!--表格渲染-->
<el-table
v-loading="loading"
:data="data"
highlight-current-row
stripe
size="small"
style="width: 100%"
@current-change="handleCurrentChange"
>
<el-table-column :formatter="formatterAppId" prop="appId" label="应用名称" />
<el-table-column prop="ip" label="服务器列表" />
<el-table-column
v-if="checkPermission(['admin','deploy:edit','deploy:del'])"
label="操作"
width="150px"
align="center"
>
<el-table v-loading="loading" :data="data" highlight-current-row stripe size="small" style="width: 100%" @current-change="handleCurrentChange">
<el-table-column prop="app.name" label="应用名称" />
<el-table-column prop="servers" label="服务器列表" />
<el-table-column prop="createTime" label="创建日期">
<template slot-scope="scope">
<el-button
v-permission="['admin','deploy:edit']"
size="mini"
type="primary"
icon="el-icon-edit"
@click="edit(scope.row)"
/>
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['admin','deploy:edit','deploy:del'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button v-permission="['admin','deploy:edit']" size="mini" type="primary" icon="el-icon-edit" @click="showEditFormDialog(scope.row)" />
<el-popover
:ref="scope.row.id"
v-permission="['admin','deploy:del']"
@@ -131,13 +115,7 @@
<p>确定删除本条数据吗</p>
<div style="text-align: right;margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button
:loading="delLoading"
type="primary"
size="mini"
@click="subDelete(scope.row.id)"
>确定
</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="delMethod(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" />
</el-popover>
@@ -157,29 +135,39 @@
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del, stopServer, serverStatus, startServer } from '@/api/deploy'
import { queryApps } from '@/api/app'
import eForm from './form'
import crud from '@/mixins/crud'
import crudDeploy from '@/api/mnt/deploy'
import dForm from './deploy'
import fForm from './sysRestore'
export default {
components: { eForm, dForm, fForm },
mixins: [initData],
components: { dForm, fForm },
mixins: [crud],
data() {
return {
delLoading: false,
queryTypeOptions: [{ key: 'ip', display_name: '服务器列表' }],
appList: [],
appMap: {},
title: '部署',
crudMethod: { ...crudDeploy },
currentRow: {},
selectIndex: '',
appName: '111',
appName: '',
urlHistory: '',
times: 0,
appId: '',
deployId: ''
deployId: '',
apps: [],
servers: [],
form: {
id: null,
app: { id: null },
deploys: []
},
rules: {
'app.id': [
{ required: true, message: '应用不能为空', trigger: 'blur', type: 'number' }
],
deploys: [
{ required: true, message: '服务器不能为空', trigger: 'blur' }
]
}
}
},
created() {
@@ -188,51 +176,38 @@ export default {
})
},
methods: {
checkPermission,
async beforeInit() {
beforeInit() {
this.url = 'api/deploy'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
await queryApps({}).then(res => {
this.appList = res.content
this.appList.forEach(({ id, name }) => {
this.appMap[id] = name
})
})
const query = this.query
const type = query.type
const value = query.value
if (type && value) {
this.params[type] = value
}
return true
},
subDelete(id) {
this.delLoading = true
del(id)
.then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
})
.catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
// 打开新增弹窗前做的操作
beforeShowAddForm() {
this.initSelect()
},
// 打开编辑弹窗前做的操作
beforeShowEditForm(data) {
this.initSelect()
const deploys = []
data.deploys.forEach(function(deploy, index) {
deploys.push(deploy.id)
})
this.form.deploys = deploys
},
// 提交前
beforeSubmitMethod() {
const deploys = []
this.form.deploys.forEach(function(data, index) {
const deploy = { id: data }
deploys.push(deploy)
})
this.form.deploys = deploys
return true
},
deploy() {
if (this.selectIndex === '') {
this.$message.error('请先选择服务')
} else {
this.$refs.deploy.dialog = true
debugger
this.$refs.deploy.deployInfo = this.currentRow
}
},
@@ -240,31 +215,13 @@ export default {
if (this.selectIndex === '') {
this.$message.error('请先选择服务')
} else {
this.$refs.form.$emit('open')
this.$refs.sysRestore.dialog = true
}
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.form = {
id: data.id,
appId: data.appId,
ip: data.ip
}
_this.dialog = true
},
formatterAppId(row, column) {
return this.appMap[row.appId]
},
handleCurrentChange(row) {
this.currentRow = row
this.selectIndex = !row ? null : row.id
this.appName = !row ? null : this.appMap[row.appId]
this.appName = !row ? null : row.app.name
this.times = this.times + !row ? 0 : 1
this.appId = !row ? null : row.appId
this.deployId = !row ? null : row.id
@@ -273,7 +230,7 @@ export default {
if (this.selectIndex === '') {
this.$message.error('请先选择服务')
} else {
startServer(JSON.stringify(this.currentRow))
this.crudMethod.startServer(JSON.stringify(this.currentRow))
.then(res => {
})
.catch(err => {
@@ -285,7 +242,7 @@ export default {
if (this.selectIndex === '') {
this.$message.error('请先选择服务')
} else {
stopServer(JSON.stringify(this.currentRow))
this.crudMethod.stopServer(JSON.stringify(this.currentRow))
.then(res => {
})
.catch(err => {
@@ -297,13 +254,21 @@ export default {
if (this.selectIndex === '') {
this.$message.error('请先选择服务')
} else {
serverStatus(JSON.stringify(this.currentRow))
this.crudMethod.serverStatus(JSON.stringify(this.currentRow))
.then(res => {
})
.catch(err => {
console.log('error:' + err.response.data.message)
})
}
},
initSelect() {
this.crudMethod.getApps().then(res => {
this.apps = res.content
})
this.crudMethod.getServers().then(res => {
this.servers = res.content
})
}
}
}

View File

@@ -1,39 +1,23 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
title="系统还原"
width="800px"
>
<el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialog" title="系统还原" width="800px">
<!--工具栏-->
<div class="head-container">
<el-input
v-model="query.value"
clearable
placeholder="输入部署时间"
style="width: 200px"
class="filter-item"
@keyup.enter.native="toQuery"
<el-date-picker
v-model="query.createTime"
:default-time="['00:00:00','23:59:59']"
type="daterange"
range-separator=":"
class="el-range-editor--small date-item"
style="width: 240px;height: 30.5px"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="部署开始日期"
end-placeholder="部署结束日期"
/>
<el-button
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="toQuery"
>搜索
</el-button>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
</div>
<el-form size="small" label-width="80px">
<!--表格渲染-->
<el-table
v-loading="loading"
:data="data"
size="small"
style="width: 100%"
@row-click="showRow"
>
<el-table v-loading="loading" :data="data" size="small" style="width: 100%" @row-click="showRow">
<el-table-column width="30px">
<template slot-scope="scope">
<el-radio v-model="radio" :label="scope.$index" />
@@ -41,19 +25,17 @@
</el-table-column>
<el-table-column prop="appName" label="应用名称" />
<el-table-column prop="ip" label="部署IP" />
<el-table-column prop="deployDate" label="部署时间" />
<el-table-column prop="deployDate" label="部署时间">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.deployDate) }}</span>
</template>
</el-table-column>
<el-table-column prop="deployUser" label="部署人员" />
</el-table>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button
v-permission="['admin','deploy:add']"
:loading="loading"
type="primary"
@click="doSubmit"
>确认
</el-button>
<el-button v-permission="['admin','deploy:add']" :loading="submitLoading" type="primary" @click="doSubmit">确认</el-button>
</div>
<!--分页组件-->
<el-pagination
@@ -68,11 +50,10 @@
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { reducte } from '@/api/deployHistory'
import crud from '@/mixins/crud'
import { reducte } from '@/api/mnt/deployHistory'
export default {
mixins: [initData],
mixins: [crud],
props: {
appName: {
type: String,
@@ -81,7 +62,7 @@ export default {
},
data() {
return {
loading: false,
submitLoading: false,
dialog: false,
history: [],
radio: '',
@@ -95,51 +76,38 @@ export default {
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/deployHistory'
this.deployId = this.$parent.deployId
debugger
if (this.deployId === '') {
return false
}
const sort = 'deployDate,desc'
this.params = {
page: this.page,
size: this.size,
sort: sort,
deployId: this.$parent.deployId
}
const query = this.query
const type = 'deployDate'
const value = query.value
this.params[type] = value
this.sort = 'deployDate,desc'
this.params['deployId'] = this.deployId
return true
},
formatterAppId(row, column) {
return this.appNames
},
showRow(row) {
this.radio = this.data.indexOf(row)
this.selectIndex = row.id
},
cancel() {
this.dialog = false
this.loading = false
this.submitLoading = false
},
doSubmit() {
if (this.selectIndex === '') {
this.$message.error('请选择要还原的备份')
} else {
this.submitLoading = true
reducte(JSON.stringify(this.data[this.radio]))
.then(res => {
this.dialog = false
this.loading = false
this.submitLoading = false
this.appNames = ''
this.$parent.init()
})
.catch(err => {
this.loading = false
this.submitLoading = false
console.log('error:' + err.response.data.message)
})
}

View File

@@ -1,133 +0,0 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
:title="isAdd ? '新增' : '编辑'"
width="500px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="应用名称" prop="appName">
<el-input v-model="form.appName" style="width: 370px" />
</el-form-item>
<el-form-item label="部署IP" prop="ip">
<el-input v-model="form.ip" style="width: 370px" />
</el-form-item>
<el-form-item label="部署时间" prop="deployDate">
<el-input v-model="form.deployDate" style="width: 370px" />
</el-form-item>
<el-form-item label="部署人员" prop="deployUser">
<el-input v-model="form.deployUser" style="width: 370px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit } from '@/api/deployHistory'
export default {
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false,
dialog: false,
form: {
id: '',
appName: '',
ip: '',
deployDate: '',
deployUser: ''
},
rules: {
id: [{ required: true, message: '请输入编号', trigger: 'change' }],
appName: [
{ required: true, message: '请输入应用名称', trigger: 'change' }
],
ip: [{ required: true, message: '请输入部署IP', trigger: 'change' }],
deployDate: [
{ required: true, message: '请输入部署时间', trigger: 'change' }
],
deployUser: [
{ required: true, message: '请输入部署人员', trigger: 'change' }
]
}
}
},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.$refs['form'].validate(valid => {
if (valid) {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else {
this.doEdit()
}
} else {
this.$message.error('请将表单中的信息补充完整!')
}
})
},
doAdd() {
add(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
edit(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
appName: '',
ip: '',
deployDate: '',
deployUser: ''
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -3,50 +3,16 @@
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input
v-model="query.value"
clearable
placeholder="输入搜索内容"
style="width: 200px"
class="filter-item"
@keyup.enter.native="toQuery"
/>
<el-select
v-model="query.type"
clearable
placeholder="类型"
class="filter-item"
style="width: 130px"
>
<el-option
v-for="item in queryTypeOptions"
:key="item.key"
:label="item.display_name"
:value="item.key"
/>
</el-select>
<el-button
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="toQuery"
>搜索</el-button>
<el-input v-model="query.blurry" clearable placeholder="输入搜索内容" style="width: 200px" class="filter-item" @keyup.enter.native="toQuery" />
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd" />
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" style="width: 100%">
<el-table-column prop="appName" label="应用名称" />
<el-table-column prop="ip" label="部署IP" />
<el-table-column prop="deployDate" label="部署时间" />
<el-table-column prop="deployUser" label="部署人员" />
<el-table-column
v-if="checkPermission(['admin','deployHistory:del'])"
label="操作"
width="150px"
align="center"
>
<el-table-column v-if="checkPermission(['admin','deployHistory:del'])" label="操作" width="100px" align="center">
<template slot-scope="scope">
<el-popover
:ref="scope.row.id"
@@ -57,12 +23,7 @@
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button
:loading="delLoading"
type="primary"
size="mini"
@click="subDelete(scope.row.id)"
>确定</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="delMethod(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" />
</el-popover>
@@ -82,22 +43,15 @@
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del } from '@/api/deployHistory'
import eForm from './form'
import crud from '@/mixins/crud'
import { del } from '@/api/mnt/deployHistory'
export default {
components: { eForm },
mixins: [initData],
mixins: [crud],
data() {
return {
delLoading: false,
queryTypeOptions: [
{ key: 'appName', display_name: '应用名称' },
{ key: 'ip', display_name: '部署IP' },
{ key: 'deployUser', display_name: '部署人员' }
]
title: '部署历史',
crudMethod: { del }
}
},
created() {
@@ -106,54 +60,9 @@ export default {
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/deployHistory'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
const query = this.query
const type = query.type
const value = query.value
if (type && value) {
this.params[type] = value
}
return true
},
subDelete(id) {
this.delLoading = true
del(id)
.then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
})
.catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.form = {
id: data.id,
appName: data.appName,
ip: data.ip,
deployDate: data.deployDate,
deployUser: data.deployUser
}
_this.dialog = true
}
}
}

View File

@@ -0,0 +1,146 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input v-model="query.id" clearable placeholder="输入名称或IP搜索" style="width: 200px" class="filter-item" @keyup.enter.native="toQuery" />
<el-date-picker
v-model="query.createTime"
:default-time="['00:00:00','23:59:59']"
type="daterange"
range-separator=":"
class="el-range-editor--small date-item"
style="width: 220px;height: 30.5px"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 新增 -->
<el-button
v-permission="['admin','serverDeploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="showAddFormDialog"
>新增</el-button>
</div>
<!--表单组件-->
<el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="470px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="55px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" style="width: 370px" />
</el-form-item>
<el-form-item label="IP" prop="ip">
<el-input v-model="form.ip" style="width: 370px" />
</el-form-item>
<el-form-item label="端口" prop="port">
<el-input-number v-model.number="form.port" controls-position="right" style="width: 370px;" />
</el-form-item>
<el-form-item label="账号" prop="account">
<el-input v-model="form.account" style="width: 370px" />
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="form.password" type="password" style="width: 370px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="submitMethod">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" style="width: 100%">
<el-table-column prop="name" label="名称" />
<el-table-column prop="ip" label="IP" />
<el-table-column prop="port" label="端口" />
<el-table-column prop="account" label="账号" />
<el-table-column prop="createTime" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['admin','serverDeploy:edit','serverDeploy:del'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button v-permission="['admin','serverDeploy:edit']" size="mini" type="primary" icon="el-icon-edit" @click="showEditFormDialog(scope.row)" />
<el-popover
:ref="scope.row.id"
v-permission="['admin','serverDeploy:del']"
placement="top"
width="180"
>
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="delMethod(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" />
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
:current-page="page + 1"
style="margin-top: 8px"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"
/>
</div>
</template>
<script>
import crud from '@/mixins/crud'
import crudServer from '@/api/mnt/serverDeploy'
import { validateIP } from '@/utils/validate'
export default {
mixins: [crud],
data() {
return {
title: '服务器',
crudMethod: { ...crudServer },
accountList: [],
accountMap: {},
form: { id: null, name: null, ip: null, port: 22, account: 'root', password: null },
rules: {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' }
],
ip: [
{ required: true, message: '请输入IP', trigger: 'blur' },
{ validator: validateIP, trigger: 'change' }
],
port: [
{ required: true, message: '请输入端口', trigger: 'blur', type: 'number' }
],
account: [
{ required: true, message: '请输入账号', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' }
]
}
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
async beforeInit() {
this.url = 'api/serverDeploy'
return true
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/deep/ .el-input-number .el-input__inner {
text-align: left;
}
</style>

View File

@@ -1,137 +0,0 @@
<template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="dialog"
:title="isAdd ? '新增' : '编辑'"
width="500px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
<el-form-item label="服务器IP" prop="id">
<el-input v-model="form.id" :disabled="!isAdd" style="width: 370px" />
</el-form-item>
<el-form-item label="服务器账号" prop="accountId">
<el-select
v-model="form.accountId"
clearable
placeholder="选择对应账号"
class="filter-item"
style="width: 370px"
>
<el-option
v-for="item in accountList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit } from '@/api/serverDeploy'
import { validateIP } from '@/utils/validate'
export default {
props: {
isAdd: {
type: Boolean,
required: true
},
accountList: {
type: Array,
required: true
}
},
data() {
return {
loading: false,
dialog: false,
form: {
id: '',
accountId: ''
},
rules: {
id: [
{ required: true, message: '请输入IP', trigger: 'change' },
{ validator: validateIP, trigger: 'change' }
],
accountId: [
{ required: true, message: '请选择账号', trigger: 'change' }
]
}
}
},
mounted() {},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.$refs['form'].validate(valid => {
if (valid) {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else {
this.doEdit()
}
} else {
this.$message.error('请将表单中的信息补充完整!')
}
})
},
doAdd() {
add(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
edit(this.form)
.then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
})
.catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
accountId: ''
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -1,183 +0,0 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input
v-model="query.value"
clearable
placeholder="输入搜索内容"
style="width: 200px"
class="filter-item"
@keyup.enter.native="toQuery"
/>
<el-select
v-model="query.type"
clearable
placeholder="类型"
class="filter-item"
style="width: 130px"
>
<el-option
v-for="item in queryTypeOptions"
:key="item.key"
:label="item.display_name"
:value="item.key"
/>
</el-select>
<el-button
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="toQuery"
>搜索</el-button>
<!-- 新增 -->
<div style="display: inline-block;margin: 0px 2px">
<el-button
v-permission="['admin','serverDeploy:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="add"
>新增</el-button>
</div>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd" :account-list="accountList" />
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" style="width: 100%">
<el-table-column prop="id" label="服务器IP" />
<el-table-column :formatter="accountTranslate" prop="accountId" label="服务器账号" />
<el-table-column
v-if="checkPermission(['admin','serverDeploy:edit','serverDeploy:del'])"
label="操作"
width="150px"
align="center"
>
<template slot-scope="scope">
<el-button
v-permission="['admin','serverDeploy:edit']"
size="mini"
type="primary"
icon="el-icon-edit"
@click="edit(scope.row)"
/>
<el-popover
:ref="scope.row.id"
v-permission="['admin','serverDeploy:del']"
placement="top"
width="180"
>
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button
:loading="delLoading"
type="primary"
size="mini"
@click="subDelete(scope.row.id)"
>确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" />
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
:current-page="page + 1"
style="margin-top: 8px"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"
/>
</div>
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del } from '@/api/serverDeploy'
import { queryServerAccount } from '@/api/serverAccount'
import eForm from './form'
export default {
components: { eForm },
mixins: [initData],
data() {
return {
delLoading: false,
queryTypeOptions: [{ key: 'id', display_name: '服务器IP' }],
accountList: [],
accountMap: {}
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
checkPermission,
async beforeInit() {
this.url = 'api/serverDeploy'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
const query = this.query
const type = query.type
const value = query.value
await queryServerAccount({}).then(res => {
this.accountList = res.content
this.accountList.forEach(({ id, name }) => {
this.accountMap[id] = name
})
})
if (type && value) {
this.params[type] = value
}
return true
},
accountTranslate(row, column) {
return this.accountMap[row.accountId]
},
subDelete(id) {
this.delLoading = true
del(id)
.then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
})
.catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.form = {
id: data.id,
accountId: data.accountId
}
_this.dialog = true
}
}
}
</script>
<style scoped>
</style>