代码优化
This commit is contained in:
@@ -2,41 +2,37 @@
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!-- 搜索 -->
|
||||
<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=":"
|
||||
size="small"
|
||||
class="date-item"
|
||||
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','app:add']"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
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 v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-input v-model="query.name" clearable placeholder="输入名称搜索" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
||||
<el-date-picker
|
||||
v-model="query.createTime"
|
||||
:default-time="['00:00:00','23:59:59']"
|
||||
type="daterange"
|
||||
range-separator=":"
|
||||
size="small"
|
||||
class="date-item"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
/>
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
slot="left"
|
||||
v-permission="['admin','app:add']"
|
||||
:disabled="!currentRow"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="copy"
|
||||
>复制</el-button>
|
||||
</crudOperation>
|
||||
</div>
|
||||
<!--表单组件-->
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="800px">
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" 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="部署后的文件或者目录名称,用于备份" />
|
||||
@@ -61,72 +57,58 @@
|
||||
</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>
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table v-loading="loading" :data="data" highlight-current-row 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 prop="backupPath" label="备份目录" />
|
||||
<el-table-column prop="createTime" label="创建日期">
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row style="width: 100%" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column v-if="columns.visible('name')" prop="name" label="应用名称" />
|
||||
<el-table-column v-if="columns.visible('port')" prop="port" label="端口号" />
|
||||
<el-table-column v-if="columns.visible('uploadPath')" prop="uploadPath" label="上传目录" />
|
||||
<el-table-column v-if="columns.visible('deployPath')" prop="deployPath" label="部署目录" />
|
||||
<el-table-column v-if="columns.visible('backupPath')" prop="backupPath" label="备份目录" />
|
||||
<el-table-column v-if="columns.visible('createTime')" prop="createTime" label="创建日期">
|
||||
<template slot-scope="scope">
|
||||
<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">
|
||||
<el-table-column v-permission="['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']"
|
||||
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>
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</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"
|
||||
/>
|
||||
<pagination />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crud from '@/mixins/crud'
|
||||
import crudApp from '@/api/mnt/app'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
// crud交由presenter持有
|
||||
const defaultCrud = CRUD({ title: '应用', url: 'api/app', crudMethod: { ...crudApp }})
|
||||
const defaultForm = { id: null, name: null, port: 8080, uploadPath: '/opt/upload', deployPath: '/opt/app', backupPath: '/opt/backup', startScript: null, deployScript: null }
|
||||
export default {
|
||||
mixins: [crud],
|
||||
name: 'App',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
return {
|
||||
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
|
||||
permission: {
|
||||
add: ['admin', 'app:add'],
|
||||
edit: ['admin', 'app:edit'],
|
||||
del: ['admin', 'app:del']
|
||||
},
|
||||
rules: {
|
||||
name: [
|
||||
@@ -153,23 +135,17 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
beforeInit() {
|
||||
this.url = 'api/app'
|
||||
return true
|
||||
},
|
||||
copy() {
|
||||
this.isAdd = true
|
||||
this.dialog = true
|
||||
this.form = this.currentRow
|
||||
for (const key in this.currentRow) {
|
||||
this.form[key] = this.currentRow[key]
|
||||
}
|
||||
this.form.id = null
|
||||
this.form.createTime = null
|
||||
this.crud.toAdd()
|
||||
},
|
||||
handleCurrentChange(row) {
|
||||
this.currentRow = row
|
||||
this.currentRow = JSON.parse(JSON.stringify(row))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,32 +2,27 @@
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!-- 搜索 -->
|
||||
<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="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="showAddFormDialog"
|
||||
>新增
|
||||
</el-button>
|
||||
<el-button
|
||||
v-permission="['admin','database:add']"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="warning"
|
||||
icon="el-icon-upload"
|
||||
@click="execute"
|
||||
>执行脚本
|
||||
</el-button>
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-input v-model="query.blurry" clearable placeholder="模糊搜索" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
slot="right"
|
||||
v-permission="['admin','database:add']"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="warning"
|
||||
icon="el-icon-upload"
|
||||
@click="execute"
|
||||
>执行脚本
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
</div>
|
||||
<!--表单组件-->
|
||||
<eForm ref="execute" :database-info="currentRow" />
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="530px">
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" 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" />
|
||||
@@ -44,62 +39,57 @@
|
||||
</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>
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table v-loading="loading" :data="data" highlight-current-row stripe style="width: 100%" @current-change="handleCurrentChange">
|
||||
<el-table-column prop="name" label="数据库名称" width="180" />
|
||||
<el-table-column prop="jdbcUrl" label="连接地址" />
|
||||
<el-table-column prop="userName" label="用户名" width="100" />
|
||||
<el-table-column v-if="checkPermission(['admin','database:edit','database:del'])" label="操作" width="150px" align="center">
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row stripe style="width: 100%" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column v-if="columns.visible('name')" prop="name" label="数据库名称" />
|
||||
<el-table-column v-if="columns.visible('jdbcUrl')" prop="jdbcUrl" label="连接地址" />
|
||||
<el-table-column v-if="columns.visible('userName')" prop="userName" label="用户名" />
|
||||
<el-table-column v-permission="['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="showEditFormDialog(scope.row)" />
|
||||
<el-popover
|
||||
:ref="scope.row.id"
|
||||
v-permission="['admin','database: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>
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</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"
|
||||
/>
|
||||
<pagination />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crud from '@/mixins/crud'
|
||||
import crudDatabase from '@/api/mnt/database'
|
||||
import { testDbConnect } from '@/api/mnt/connect'
|
||||
import eForm from './execute'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
// crud交由presenter持有
|
||||
const defaultCrud = CRUD({ title: '数据库', url: 'api/database', crudMethod: { ...crudDatabase }})
|
||||
const defaultForm = { id: null, name: null, jdbcUrl: null, userName: null, pwd: null }
|
||||
export default {
|
||||
components: { eForm },
|
||||
mixins: [crud],
|
||||
name: 'DataBase',
|
||||
components: { eForm, pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
return {
|
||||
title: '数据库',
|
||||
crudMethod: { ...crudDatabase },
|
||||
currentRow: {},
|
||||
selectIndex: '',
|
||||
databaseInfo: '',
|
||||
form: { id: null, name: null, jdbcUrl: null, userName: null, pwd: null },
|
||||
loading: false,
|
||||
permission: {
|
||||
add: ['admin', 'database:add'],
|
||||
edit: ['admin', 'database:edit'],
|
||||
del: ['admin', 'database:del']
|
||||
},
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入数据库名称', trigger: 'blur' }
|
||||
@@ -116,27 +106,14 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
beforeInit() {
|
||||
this.url = 'api/database'
|
||||
return true
|
||||
},
|
||||
testConnectDatabase() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
testDbConnect(this.form).then((res) => {
|
||||
this.loading = false
|
||||
this.$notify({
|
||||
title: res ? '连接成功' : '连接失败',
|
||||
type: res ? 'success' : 'error',
|
||||
duration: 2500
|
||||
})
|
||||
crud.notify(res ? '连接成功' : '连接失败', res ? 'success' : 'error')
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
|
||||
@@ -2,78 +2,79 @@
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!-- 搜索 -->
|
||||
<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=":"
|
||||
size="small"
|
||||
class="date-item"
|
||||
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','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-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 v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-input v-model="query.appName" clearable placeholder="输入应用名称查询" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
||||
<el-date-picker
|
||||
v-model="query.createTime"
|
||||
:default-time="['00:00:00','23:59:59']"
|
||||
type="daterange"
|
||||
range-separator=":"
|
||||
size="small"
|
||||
class="date-item"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
/>
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<crudOperation :permission="permission">
|
||||
<template slot="right">
|
||||
<el-button
|
||||
v-permission="['admin','deploy:add']"
|
||||
:disabled="!selectIndex"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-upload"
|
||||
@click="sysRestore"
|
||||
>系统还原
|
||||
</el-button>
|
||||
<el-button
|
||||
v-permission="['admin','deploy:add']"
|
||||
:disabled="!selectIndex"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-upload"
|
||||
@click="serverStatus"
|
||||
>状态查询
|
||||
</el-button>
|
||||
<el-button
|
||||
v-permission="['admin','deploy:add']"
|
||||
:disabled="!selectIndex"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="success"
|
||||
icon="el-icon-upload"
|
||||
@click="startServer"
|
||||
>启动
|
||||
</el-button>
|
||||
<el-button
|
||||
v-permission="['admin','deploy:add']"
|
||||
:disabled="!selectIndex"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-upload"
|
||||
@click="stopServer"
|
||||
>停止
|
||||
</el-button>
|
||||
<el-button
|
||||
v-permission="['admin','deploy:add']"
|
||||
:disabled="!selectIndex"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="warning"
|
||||
icon="el-icon-upload"
|
||||
@click="deploy"
|
||||
>一键部署
|
||||
</el-button>
|
||||
</template>
|
||||
</crudOperation>
|
||||
</div>
|
||||
<!--表单组件-->
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="500px">
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" 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">
|
||||
@@ -87,78 +88,60 @@
|
||||
</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>
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</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 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="创建日期">
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row stripe style="width: 100%" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column v-if="columns.visible('app.name')" prop="app.name" label="应用名称" />
|
||||
<el-table-column v-if="columns.visible('servers')" prop="servers" label="服务器列表" />
|
||||
<el-table-column v-if="columns.visible('createTime')" prop="createTime" label="创建日期">
|
||||
<template slot-scope="scope">
|
||||
<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">
|
||||
<el-table-column v-permission="['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']"
|
||||
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>
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</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"
|
||||
/>
|
||||
<pagination />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crud from '@/mixins/crud'
|
||||
import crudDeploy from '@/api/mnt/deploy'
|
||||
import dForm from './deploy'
|
||||
import fForm from './sysRestore'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
// crud交由presenter持有
|
||||
const defaultCrud = CRUD({ title: '部署', url: 'api/deploy', crudMethod: { ...crudDeploy }})
|
||||
const defaultForm = { id: null, app: { id: null }, deploys: [] }
|
||||
export default {
|
||||
components: { dForm, fForm },
|
||||
mixins: [crud],
|
||||
components: { dForm, fForm, pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
return {
|
||||
title: '部署',
|
||||
crudMethod: { ...crudDeploy },
|
||||
currentRow: {},
|
||||
selectIndex: '',
|
||||
appName: '',
|
||||
urlHistory: '',
|
||||
times: 0,
|
||||
appId: '',
|
||||
deployId: '',
|
||||
apps: [],
|
||||
servers: [],
|
||||
form: {
|
||||
id: null,
|
||||
app: { id: null },
|
||||
deploys: []
|
||||
currentRow: {}, selectIndex: '', appName: '', urlHistory: '',
|
||||
times: 0, appId: '', deployId: '', apps: [], servers: [],
|
||||
permission: {
|
||||
add: ['admin', 'deploy:add'],
|
||||
edit: ['admin', 'deploy:edit'],
|
||||
del: ['admin', 'deploy:del']
|
||||
},
|
||||
rules: {
|
||||
'app.id': [
|
||||
@@ -170,32 +153,22 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
beforeInit() {
|
||||
this.url = 'api/deploy'
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
this.selectIndex = ''
|
||||
return true
|
||||
},
|
||||
// 打开新增弹窗前做的操作
|
||||
beforeShowAddForm() {
|
||||
this.initSelect()
|
||||
},
|
||||
// 打开编辑弹窗前做的操作
|
||||
beforeShowEditForm(data) {
|
||||
// 新增编辑前做的操作
|
||||
[CRUD.HOOK.beforeToCU](crud, form) {
|
||||
this.initSelect()
|
||||
const deploys = []
|
||||
data.deploys.forEach(function(deploy, index) {
|
||||
form.deploys.forEach(function(deploy, index) {
|
||||
deploys.push(deploy.id)
|
||||
})
|
||||
this.form.deploys = deploys
|
||||
},
|
||||
// 提交前
|
||||
beforeSubmitMethod() {
|
||||
[CRUD.HOOK.beforeSubmit]() {
|
||||
const deploys = []
|
||||
this.form.deploys.forEach(function(data, index) {
|
||||
const deploy = { id: data }
|
||||
@@ -205,19 +178,11 @@ export default {
|
||||
return true
|
||||
},
|
||||
deploy() {
|
||||
if (!this.selectIndex) {
|
||||
this.$message.error('请先选择服务')
|
||||
} else {
|
||||
this.$refs.deploy.dialog = true
|
||||
this.$refs.deploy.deployInfo = this.currentRow
|
||||
}
|
||||
this.$refs.deploy.dialog = true
|
||||
this.$refs.deploy.deployInfo = this.currentRow
|
||||
},
|
||||
sysRestore() {
|
||||
if (!this.selectIndex) {
|
||||
this.$message.error('请先选择服务')
|
||||
} else {
|
||||
this.$refs.sysRestore.dialog = true
|
||||
}
|
||||
this.$refs.sysRestore.dialog = true
|
||||
},
|
||||
handleCurrentChange(row) {
|
||||
this.currentRow = row
|
||||
@@ -228,46 +193,34 @@ export default {
|
||||
this.deployId = !row ? null : row.id
|
||||
},
|
||||
startServer() {
|
||||
if (!this.selectIndex) {
|
||||
this.$message.error('请先选择服务')
|
||||
} else {
|
||||
this.crudMethod.startServer(JSON.stringify(this.currentRow))
|
||||
.then(res => {
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('error:' + err.response.data.message)
|
||||
})
|
||||
}
|
||||
crudDeploy.startServer(JSON.stringify(this.currentRow))
|
||||
.then(res => {
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('error:' + err.response.data.message)
|
||||
})
|
||||
},
|
||||
stopServer() {
|
||||
if (!this.selectIndex) {
|
||||
this.$message.error('请先选择服务')
|
||||
} else {
|
||||
this.crudMethod.stopServer(JSON.stringify(this.currentRow))
|
||||
.then(res => {
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('error:' + err.response.data.message)
|
||||
})
|
||||
}
|
||||
crudDeploy.stopServer(JSON.stringify(this.currentRow))
|
||||
.then(res => {
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('error:' + err.response.data.message)
|
||||
})
|
||||
},
|
||||
serverStatus() {
|
||||
if (!this.selectIndex) {
|
||||
this.$message.error('请先选择服务')
|
||||
} else {
|
||||
this.crudMethod.serverStatus(JSON.stringify(this.currentRow))
|
||||
.then(res => {
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('error:' + err.response.data.message)
|
||||
})
|
||||
}
|
||||
crudDeploy.serverStatus(JSON.stringify(this.currentRow))
|
||||
.then(res => {
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('error:' + err.response.data.message)
|
||||
})
|
||||
},
|
||||
initSelect() {
|
||||
this.crudMethod.getApps().then(res => {
|
||||
crudDeploy.getApps().then(res => {
|
||||
this.apps = res.content
|
||||
})
|
||||
this.crudMethod.getServers().then(res => {
|
||||
crudDeploy.getServers().then(res => {
|
||||
this.servers = res.content
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
size="small"
|
||||
class="date-item"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
start-placeholder="部署开始日期"
|
||||
end-placeholder="部署结束日期"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
/>
|
||||
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
|
||||
</div>
|
||||
|
||||
@@ -2,17 +2,21 @@
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!-- 搜索 -->
|
||||
<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 v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-input v-model="query.blurry" clearable placeholder="输入搜索内容" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<crudOperation :permission="permission" />
|
||||
</div>
|
||||
<!--表格渲染-->
|
||||
<el-table v-loading="loading" :data="data" 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="100px" align="center">
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column v-if="columns.visible('appName')" prop="appName" label="应用名称" />
|
||||
<el-table-column v-if="columns.visible('ip')" prop="ip" label="部署IP" />
|
||||
<el-table-column v-if="columns.visible('deployDate')" prop="deployDate" label="部署时间" />
|
||||
<el-table-column v-if="columns.visible('deployUser')" prop="deployUser" label="部署人员" />
|
||||
<el-table-column v-permission="['admin','deployHistory:del']" label="操作" width="100px" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-popover
|
||||
:ref="scope.row.id"
|
||||
@@ -31,38 +35,51 @@
|
||||
</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"
|
||||
/>
|
||||
<pagination />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crud from '@/mixins/crud'
|
||||
import { del } from '@/api/mnt/deployHistory'
|
||||
|
||||
import CRUD, { presenter, header } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
// crud交由presenter持有
|
||||
const defaultCrud = CRUD({ title: '部署历史', url: 'api/deployHistory', crudMethod: { del }})
|
||||
export default {
|
||||
mixins: [crud],
|
||||
name: 'DeployHistory',
|
||||
components: { pagination, crudOperation, rrOperation },
|
||||
mixins: [presenter(defaultCrud), header()],
|
||||
data() {
|
||||
return {
|
||||
title: '部署历史',
|
||||
crudMethod: { del }
|
||||
delLoading: false,
|
||||
permission: {
|
||||
del: ['admin', 'deployHistory:del']
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
this.init()
|
||||
})
|
||||
this.crud.optShow = {
|
||||
add: false,
|
||||
edit: false,
|
||||
del: true,
|
||||
download: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
beforeInit() {
|
||||
this.url = 'api/deployHistory'
|
||||
return true
|
||||
delMethod(id) {
|
||||
this.delLoading = true
|
||||
del(id).then(() => {
|
||||
this.delLoading = false
|
||||
this.$refs[id].doClose()
|
||||
this.crud.dleChangePage(1)
|
||||
this.crud.delSuccessNotify()
|
||||
this.crud.toQuery()
|
||||
}).catch(() => {
|
||||
this.delLoading = false
|
||||
this.$refs[id].doClose()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,33 +2,26 @@
|
||||
<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=":"
|
||||
size="small"
|
||||
class="date-item"
|
||||
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 v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-input v-model="query.id" clearable placeholder="输入名称或IP搜索" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
||||
<el-date-picker
|
||||
v-model="query.createTime"
|
||||
:default-time="['00:00:00','23:59:59']"
|
||||
type="daterange"
|
||||
range-separator=":"
|
||||
size="small"
|
||||
class="date-item"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
/>
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<crudOperation :permission="permission" />
|
||||
</div>
|
||||
<!--表单组件-->
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :visible.sync="dialog" :title="getFormTitle()" width="470px">
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" 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" />
|
||||
@@ -48,66 +41,63 @@
|
||||
</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>
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table v-loading="loading" :data="data" 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="创建日期">
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column v-if="columns.visible('name')" prop="name" label="名称" />
|
||||
<el-table-column v-if="columns.visible('ip')" prop="ip" label="IP" />
|
||||
<el-table-column v-if="columns.visible('port')" prop="port" label="端口" />
|
||||
<el-table-column v-if="columns.visible('account')" prop="account" label="账号" />
|
||||
<el-table-column v-if="columns.visible('createTime')" 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">
|
||||
<el-table-column v-permission="['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>
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</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"
|
||||
/>
|
||||
<pagination />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crud from '@/mixins/crud'
|
||||
|
||||
import crudServer from '@/api/mnt/serverDeploy'
|
||||
import { testServerConnect } from '@/api/mnt/connect'
|
||||
import { validateIP } from '@/utils/validate'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
// crud交由presenter持有
|
||||
const defaultCrud = CRUD({ title: '服务器', url: 'api/serverDeploy', crudMethod: { ...crudServer }})
|
||||
const defaultForm = { id: null, name: null, ip: null, port: 22, account: 'root', password: null }
|
||||
export default {
|
||||
mixins: [crud],
|
||||
name: 'Server',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
return {
|
||||
title: '服务器',
|
||||
crudMethod: { ...crudServer },
|
||||
accountList: [],
|
||||
accountMap: {},
|
||||
form: { id: null, name: null, ip: null, port: 22, account: 'root', password: null },
|
||||
loading: false,
|
||||
permission: {
|
||||
add: ['admin', 'serverDeploy:add'],
|
||||
edit: ['admin', 'serverDeploy:edit'],
|
||||
del: ['admin', 'serverDeploy:del']
|
||||
},
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入名称', trigger: 'blur' }
|
||||
@@ -128,16 +118,7 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
async beforeInit() {
|
||||
this.url = 'api/serverDeploy'
|
||||
return true
|
||||
},
|
||||
testConnectServer() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
|
||||
Reference in New Issue
Block a user