| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud :option="option" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | :page.sync="page" |
| | | :permission="permissionList" |
| | | :before-open="beforeOpen" |
| | | v-model="form" |
| | | ref="crud" |
| | | :cell-style="cellStyle" |
| | | :row-style="rowStyle" |
| | | @on-load="onLoad"> |
| | | <template slot-scope="scope" slot="menu"> |
| | | :table-loading="loading" |
| | | :data="data" |
| | | :page.sync="page" |
| | | :permission="permissionList" |
| | | :before-open="beforeOpen" |
| | | v-model="form" |
| | | ref="crud" |
| | | :cell-style="cellStyle" |
| | | :row-style="rowStyle" |
| | | @row-update="rowUpdate" |
| | | @row-save="addServiceInfo" |
| | | @on-load="onLoad"> |
| | | <template slot="menu" slot-scope="{ row, index }"> |
| | | <el-button type="text" |
| | | icon="el-icon-upload" |
| | | size="small" |
| | | v-if="permissionList.upload" |
| | | @click="handleDownload(scope.row)">上 传 |
| | | :disabled="row.name === 'ubcs-deploy'" |
| | | icon="el-icon-upload" |
| | | size="small" |
| | | v-if="permissionList.upload" |
| | | @click.native="importServiceJar(row)">上 传 |
| | | </el-button> |
| | | <el-button type="text" |
| | | icon="el-icon-refresh" |
| | | size="small" |
| | | v-if="permissionList.restart" |
| | | @click="test">重 启 |
| | | :disabled="row.name === 'ubcs-deploy'" |
| | | :icon="row.status === 'UP' ? 'el-icon-refresh':'el-icon-video-play'" |
| | | size="small" |
| | | v-if="permissionList.restart" |
| | | @click="cmdExecute(row)"> |
| | | {{ row.status === 'UP' ? '重 启': '启 动' }} |
| | | </el-button> |
| | | <el-button type="text" |
| | | :disabled="row.name === 'ubcs-deploy'" |
| | | v-if="permissionList.editBtn" |
| | | icon="el-icon-edit" |
| | | size="small" |
| | | @click="handleEdit(row, index)" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="{row}" |
| | |
| | | <el-tag>{{`${row.serviceNum}`}}</el-tag> |
| | | </template> |
| | | </avue-crud> |
| | | <uploadServiceJarDialog :serverName="serviceName" :visible.sync="uploadDialogVisible"></uploadServiceJarDialog> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getApplications } from "@/api/system/deploy"; |
| | | import moment from 'moment'; |
| | | import { getApplications,saveOrGetServiceConfInfo,saveOrUpdateServiceInfo,addSave,executeCmd } from "@/api/system/deploy"; |
| | | import moment from "moment"; |
| | | import {mapGetters} from "vuex"; |
| | | export default { |
| | | data() { |
| | | return { |
| | | option: { |
| | | data: [], |
| | | uploadDialogVisible: false, |
| | | loading: true, |
| | | isDisabled: true, |
| | | serviceName: "", |
| | | } |
| | | }, |
| | | created() { |
| | | |
| | | }, |
| | | computed: { |
| | | ...mapGetters(["permission"]), |
| | | permissionList() { |
| | | return { |
| | | upload: this.vaildData(this.permission.deploy.deploy_upload, false), |
| | | restart: this.vaildData(this.permission.deploy.deploy_restart, false), |
| | | editBtn: this.vaildData(this.permission.deploy.deploy_edit, false), |
| | | addBtn: this.vaildData(this.permission.deploy.deploy_add, false), |
| | | }; |
| | | }, |
| | | option(){ |
| | | return { |
| | | columnBtn:false, |
| | | height: 'auto', |
| | | calcHeight: 30, |
| | |
| | | border: true, |
| | | index: true, |
| | | viewBtn: false, |
| | | addBtn: false, |
| | | addBtn: true, |
| | | editBtn: false, |
| | | delBtn: false, |
| | | selection: true, |
| | |
| | | label: "实例名称", |
| | | prop: "name", |
| | | sortable: true, |
| | | }, |
| | | { |
| | | display: false, |
| | | }, { |
| | | label: "运行状态", |
| | | prop: "status", |
| | | }, |
| | | { |
| | | display: false, |
| | | }, { |
| | | label: "启动时间", |
| | | prop: "statusTimestamp", |
| | | }, |
| | | { |
| | | sortable: true, |
| | | display: false, |
| | | }, { |
| | | label: "端口号", |
| | | prop: "port", |
| | | }, |
| | | { |
| | | display: false, |
| | | }, { |
| | | label: "实例数量", |
| | | prop: "serviceNum", |
| | | width: 120, |
| | | display: false, |
| | | }, |
| | | |
| | | { |
| | | label: "实例名称", |
| | | prop: "serverName", |
| | | labelWidth: 140, |
| | | hide: true, |
| | | disabled: this.isDisabled, |
| | | },{ |
| | | label: "服务jar存放的路径", |
| | | prop: "serverPath", |
| | | labelWidth: 140, |
| | | hide: true, |
| | | rules: [{ |
| | | required: true, |
| | | message: "请输入服务jar存放的路径", |
| | | trigger: "blur" |
| | | }] |
| | | },{ |
| | | label: "日志文件存放位置", |
| | | prop: "logPath", |
| | | labelWidth: 140, |
| | | hide: true, |
| | | disabled: true, |
| | | rules: [{ |
| | | required: false, |
| | | message: "请输入服务jar存放的路径", |
| | | trigger: "blur" |
| | | }] |
| | | },{ |
| | | label: "文件备份路径", |
| | | prop: "fileBack", |
| | | labelWidth: 140, |
| | | hide: true, |
| | | rules: [{ |
| | | required: false, |
| | | message: "请输入文件备份路径", |
| | | trigger: "blur" |
| | | }] |
| | | }, |
| | | ], |
| | | group: [ |
| | | { |
| | | icon: 'el-icon-info', |
| | | label: '基础命令配置', |
| | | collapse: true, |
| | | labelWidth: 140, |
| | | prop: 'cmdCofig', |
| | | column: [ |
| | | { |
| | | label: '开始命令', |
| | | prop: 'startCmd', |
| | | }, { |
| | | label: '重启命令', |
| | | prop: 'restartCmd', |
| | | }, { |
| | | label: '停止命令', |
| | | prop: 'stopCmd', |
| | | }, |
| | | ] |
| | | }, |
| | | ] |
| | | }, |
| | | data: [], |
| | | } |
| | | }, |
| | | created() { |
| | | |
| | | }, |
| | | computed: { |
| | | permissionList() { |
| | | return { |
| | | upload: true, |
| | | restart: true, |
| | | // viewBtn: this.vaildData(this.permission, true), |
| | | }; |
| | | } |
| | | }, |
| | | }, |
| | | methods: { |
| | | |
| | | onLoad(){ |
| | | this.loading = true; |
| | | getApplications().then(res=>{ |
| | | let serviceData = res.data.data; |
| | | if(serviceData.length>0){ |
| | | // 先清空 |
| | | this.data = []; |
| | | serviceData.forEach(element => { |
| | | //console.log("element",element); |
| | | // 将时间转换为本地时间 |
| | |
| | | this.data.push(element) |
| | | }); |
| | | } |
| | | this.loading = false; |
| | | //console.log(res.data.data); |
| | | }); |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | // 控制示例名称是否可输入 |
| | | beforeOpen(done, type) { |
| | | // console.log(type) |
| | | if(type === "edit"){ |
| | | this.isDisabled = true; |
| | | }else { |
| | | this.isDisabled = false; |
| | | } |
| | | done(); |
| | | }, |
| | | // 关闭弹窗 |
| | | /** 导入 */ |
| | | importServiceJar(row) { |
| | | // console.log(row); |
| | | this.serviceName = row.name; |
| | | this.uploadDialogVisible = true; |
| | | }, |
| | | // 新增 |
| | | addServiceInfo(row, done, loading){ |
| | | addSave(row).then(() => { |
| | | this.onLoad(); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | }); |
| | | }, |
| | | // 编辑 |
| | | handleEdit(row) { |
| | | saveOrGetServiceConfInfo(row).then(res=>{ |
| | | // console.log(res.data.data); |
| | | // 请求后端接口,获取到该服务的基础配置信息 |
| | | this.$refs.crud.rowEdit(res.data.data, row.$index); |
| | | }) |
| | | }, |
| | | // 修改 |
| | | rowUpdate(row, index, done) { |
| | | saveOrUpdateServiceInfo(row).then(() => { |
| | | this.onLoad() |
| | | this.$message({ |
| | | type: "success", |
| | | message: "修改成功!" |
| | | }); |
| | | done() |
| | | }).catch(res => { |
| | | }) |
| | | }, |
| | | // 命令执行 |
| | | cmdExecute(row){ |
| | | // console.log(row); |
| | | executeCmd(row).then(res => { |
| | | this.onLoad() |
| | | this.$message({ |
| | | type: "success", |
| | | message: res.data.msg |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | } |
| | | } |