Commit a30aec8f authored by 赵啸非's avatar 赵啸非

添加检测是否首次安装

parent 36ec01f3
import axios from "axios";
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import Qs from "qs";
const JSONbig = require("json-bigint")({ storeAsString: true });
import cookie from "./cookie";
import httpErrorHandler from "./httpErrorHandler";
// loading框设置局部刷新,且所有请求完成后关闭loading框
let loading
let needLoadingRequestCount = 0 // 声明一个对象用于存储请求个数
function startLoading () {
loading = Vue.prototype.$loading({
lock: true,
customClass: 'createLoading', // 局部class名称
text: '服务加载中...',
background: 'rgba(0,0,0,0.5)',
target: document.querySelector('.loading-area') // 设置加载动画区域
})
}
function endLoading () {
loading.close()
}
function showFullScreenLoading () {
if (needLoadingRequestCount === 0) {
startLoading()
}
needLoadingRequestCount++
}
function hideFullScreenLoading () {
if (needLoadingRequestCount <= 0) return
needLoadingRequestCount--
if (needLoadingRequestCount === 0) {
endLoading()
}
}
const instance = axios.create({
baseURL: "/m",
//baseURL: process.env.VUE_APP_BASE_API,
......@@ -24,18 +56,30 @@ const instance = axios.create({
},
],
});
/**
* 请求拦截器
*/
instance.interceptors.request.use(
(config) => {
config.headers.Authorization = window.sessionStorage.getItem("token") || "";
if (config.isLoading == true) { // 如果配置了isLoading: false,则不显示loading
showFullScreenLoading()
}
return config;
},
(err) => {
hideFullScreenLoading()
return Promise.reject(err);
}
);
/**
* 响应拦截器
*/
instance.interceptors.response.use((response) => {
hideFullScreenLoading() // 响应成功关闭loading
return response.data;
}, httpErrorHandler);
......@@ -98,3 +142,5 @@ export function upload(url, option, config = {}) {
});
return uploadInstance.post(url, formdata, config);
}
export default (error) => {
if(error.message === '自动取消ajax操作') return Promise.reject(error);
if (!error.response) {
console.error(error);
......@@ -50,4 +51,3 @@ export default (error) => {
status,
});
}
\ No newline at end of file
......@@ -12,9 +12,19 @@
>导入项目文件包
</el-button>
<el-button
slot="table-head-left2"
style="margin-left: 10px"
type="primary"
class="addclass"
size="mini"
@click="batchDistribute"
>批量部署
</el-button>
</LayoutTable>
<drawer-show ref="drawerform" @ok="getData" />
......@@ -42,7 +52,7 @@
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" style="color: red" slot="tip">
<div class="el-upload_tip" style="color: red" slot="tip">
提示:仅允许导入“zip”或“.tar.gz”格式压缩文件!
</div>
</el-upload>
......@@ -80,7 +90,7 @@
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" style="color: red" slot="tip">
<div class="el-upload_tip" style="color: red" slot="tip">
提示:仅允许导入“zip”或“.tar.gz”格式压缩文件!
</div>
</el-upload>
......@@ -109,7 +119,6 @@
>{{ areaName }}</el-link
>
区域编码:{{ areaCode }} )</span
>
<el-divider></el-divider>
......@@ -170,16 +179,35 @@
console.log(res)
let reBool=res.data.resource
let projectBool=res.data.project
let siteCode=res.data.siteCode
if(reBool){
if(projectBool){
console.log("项目部署成功!")
if(!siteCode||siteCode===''||siteCode==='undefined'){
//弹出树页面
this.tree.open=true;
}else{
console.log("弹出项目初始引导页")
}
}else{
console.log("初始化基础项目!")
this.$post("/setup/project/projectDataInit", {},{isLoading:true})
.then((res) => {
if (res.code == 1) {
this.$message.success("基础项目应用部署启动成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
//判断是否已经更新站点等信息
}
}else{
//弹框引导页面
this.guide.open = true;
console.log("弹出资源引导页")
console.log("弹出项目初始引导页")
}
}
})
......@@ -188,7 +216,7 @@
});
//获取区域树
/* //获取区域树
this.$get("/base/area/getListByParentId", {
parentId: "0",
})
......@@ -203,7 +231,7 @@
})
.catch((error) => {
this.$message.error(error.message);
});
});*/
},
methods: {
......@@ -215,29 +243,25 @@
},
updateSiteConform() {
if(this.areaCode===''||this.areaCode==='undefined'){
this.$message.error("请选择需要创建站点的区域!");
return;
}
if(this.siteName===''||this.siteName==='undefined'){
this.$message.error("请选择需要创建站点的名称!");
return;
}
return; //todo
this.loading = true;
this.$post("/setup/project/site/updateSite", {
areaCode: this.areaCode,
siteName: this.siteName,
})
},{isLoading:true})
.then((res) => {
if (res.code == 1) {
this.$message.success("创建站点成功!");
this.getData();
this.tree.open = false;
//todo
// this.getData();
}
})
.catch((error) => {
......@@ -249,8 +273,8 @@
/** 导入 */
handleImport() {
this.upload.title = "项目文件包导入";
//this.upload.open = true;
this.tree.open=true
this.upload.open = true;
// this.tree.open=true
console.log(this.areaData)
},
/** 重写新增方法 */
......@@ -266,10 +290,10 @@
this.$refs.drawerform.view(row);
},
distribute(row) {
this.$post("/setup/project/distribute", row)
this.$post("/setup/project/distribute", row,{isLoading:true})
.then((res) => {
if (res.code == 1) {
this.$message.success("项目部署成功!");
//this.$message.success("项目部署成功!");
this.getData();
}
})
......@@ -278,11 +302,20 @@
});
},
dbConnect(row) {
this.$post("/setup/project/dbConnect", row)
batchDistribute(row) {
if(this.selection.length==0){
this.$message.error("请勾选需要部署的项目!");
return;
}
this.$post("/setup/project/batchDistribute", {
idList: this.selection,
},{isLoading:true})
.then((res) => {
if (res.code == 1) {
this.$message.success("数据库连接成功!");
this.$message.success("批量部署成功!");
this.getData();
}
})
......@@ -357,32 +390,7 @@
updateSite(row) {
//todo 更新站点区域信息 前提条件 是基础服务与门户服务已经运行
// this.$message.info("更新站点区域信息 前提条件 是基础服务与门户服务已经运行");
this.$prompt('请输入站点名称', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
let param={};
param['siteName']=value;
param['id']=row.id;
this.$post("/setup/project/site/add", param)
.then((res) => {
if (res.code == 1) {
this.$message.success("站点添加成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
}).catch(() => {
this.$message({
type: 'info',
message: '取消输入'
});
});
this.tree.open = true
},
updateSiteApp(row) {
......@@ -402,22 +410,25 @@
.catch((error) => {
this.$message.error(error.message);
});
},
updateSiteMatter(row) {
// this.$message.info("更新站点应用,前提条件需要提交站点id");
this.$confirm('更新站点事项,前提条件需要服务器可访问外网?', '提示', {
this.$confirm('更新站点事项,需要服务器可访问外网?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '更新成功!'
let param={};
param['id']=row.id;
this.$post("/setup/project/matter/update", param)
.then((res) => {
if (res.code == 1) {
this.$message.success(res.msg);
}
})
.catch((error) => {
this.$message.error(error.message);
});
}).catch(() => {
this.$message({
......@@ -455,6 +466,20 @@
this.guide.isUploading = false;
this.$refs.guide.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
console.log("response",response)
//todo进行项目初始化安装
if(response.code==1){
this.$post("/setup/project/projectDataInit", {},{isLoading:true})
.then((res) => {
if (res.code == 1) {
this.$message.success("基础项目应用部署启动成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
}
},
/** 提交上传文件 */
......@@ -463,7 +488,6 @@
},
async loadNode(node, resolve) {
console.log(11111111111,node)
if (node.areaLevel === 0) {
return;
}
......@@ -501,7 +525,7 @@
// 是否禁用上传
isUploading: false,
// 上传的地址
url: "/m/setup/project/importProjectData",
url: "/m/setup/project/importProjectDataInit",
},
tree: {
// 是否显示弹出层(设备导入)
......@@ -522,8 +546,16 @@
search: [
],
columns: [
{
type: "selection",
align: "center",
reserveSelection: true,
width: 60,
},
{type: "index",label: "序号",width: 50},
{label: "所属站点", prop: "siteName",width: 120},
{label: "项目产品名称", prop: "name"},
{label: "项目产品编码", prop: "projectCode"},
......@@ -547,7 +579,7 @@
{label: "项目类型", prop: "projectType",formatter: this.formatter},
{label: "项目状态", prop: "projectStatus",formatter: this.formatter},
{label: "项目状态", prop: "projectStatus",formatter: this.formatterStatus},
{label: "备注",width: 200, prop: "remark"},
{
......@@ -577,25 +609,10 @@
>
部署
</el-button>
<span> </span>
{row.projectType === 1 ? (
<el-button
size="mini"
type="text"
icon="el-icon-open"
onClick={() => {
this.dbConnect(row);
}}
>
数据库连接
</el-button>
) : (
""
)}
<span> </span>
{row.projectCode === 'base-manager' ? (
{row.projectCode === 'base-manager' &&row.projectCode === 'base-manager' ? (
<el-button
size="mini"
type="text"
......@@ -629,21 +646,6 @@
<span> </span>
{row.projectCode === 'base-manager' ? (
<el-button
size="mini"
type="text"
icon="el-icon-open"
onClick={() => {
this.updateSiteApp(row);
}}
>
站点应用部署
</el-button>
) : (
""
)}
{row.projectCode === 'base-manager' ? (
<el-button
size="mini"
......
......@@ -39,8 +39,8 @@ module.exports = {
proxy: {
"/m": {
// target: "http://192.168.0.98:11019",
target: 'http://127.0.0.1:18000',
// target: 'http://192.168.0.98:8081',
// target: 'http://127.0.0.1:18000',
target: 'http://192.168.0.250:18000',
changeOrigin: true,
secure: false
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment