From 156e136377680ac2dd5ad89735b7273db6f6d1d5 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期六, 24 二月 2024 20:27:02 +0800 Subject: [PATCH] 远程部署功能完善 --- Source/UBCS-WEB/src/views/system/deploy.vue | 272 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 210 insertions(+), 62 deletions(-) diff --git a/Source/UBCS-WEB/src/views/system/deploy.vue b/Source/UBCS-WEB/src/views/system/deploy.vue index 2271e3b..cac5509 100644 --- a/Source/UBCS-WEB/src/views/system/deploy.vue +++ b/Source/UBCS-WEB/src/views/system/deploy.vue @@ -1,28 +1,40 @@ <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)">涓� 浼� + 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" + v-if="permissionList.editBtn" + icon="el-icon-edit" + size="small" + @click="handleEdit(row, index)" + > + 缂栬緫 </el-button> </template> <template slot-scope="{row}" @@ -34,56 +46,21 @@ <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"; export default { data() { return { - option: { - columnBtn:false, - height: 'auto', - calcHeight: 30, - tip: false, - searchShow: false, - border: true, - index: true, - viewBtn: false, - addBtn: false, - editBtn: false, - delBtn: false, - selection: true, - refreshBtn: false, - dialogClickModal: false, - column: [ - { - label: "瀹炰緥鍚嶇О", - prop: "name", - sortable: true, - }, - { - label: "杩愯鐘舵��", - prop: "status", - }, - { - label: "鍚姩鏃堕棿", - prop: "statusTimestamp", - }, - { - label: "绔彛鍙�", - prop: "port", - }, - { - label: "瀹炰緥鏁伴噺", - prop: "serviceNum", - width: 120, - }, - ] - }, data: [], + uploadDialogVisible: false, + loading: true, + isDisabled: true, + serviceName: "", } }, created() { @@ -94,16 +71,124 @@ return { upload: true, restart: true, - // viewBtn: this.vaildData(this.permission, true), + editBtn: true,// this.vaildData(this.permission, true), + addBtn: true, }; + }, + option(){ + return { + columnBtn:false, + height: 'auto', + calcHeight: 30, + tip: false, + searchShow: false, + border: true, + index: true, + viewBtn: false, + addBtn: true, + editBtn: false, + delBtn: false, + selection: true, + refreshBtn: false, + dialogClickModal: false, + column: [ + { + 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: "璇疯緭鍏ユ湇鍔ar瀛樻斁鐨勮矾寰�", + trigger: "blur" + }] + },{ + label: "鏃ュ織鏂囦欢瀛樻斁浣嶇疆", + prop: "logPath", + labelWidth: 140, + hide: true, + disabled: true, + rules: [{ + required: false, + message: "璇疯緭鍏ユ湇鍔ar瀛樻斁鐨勮矾寰�", + 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', + }, + ] + }, + ] + } }, }, 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); // 灏嗘椂闂磋浆鎹负鏈湴鏃堕棿 @@ -114,6 +199,7 @@ this.data.push(element) }); } + this.loading = false; //console.log(res.data.data); }); }, @@ -142,6 +228,68 @@ } } }, + // 鎺у埗绀轰緥鍚嶇О鏄惁鍙緭鍏� + 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 + }); + }); + }, } } -- Gitblit v1.9.3