Commit 18fd1882 authored by “yiyousong”'s avatar “yiyousong”

feat:新增应用配置文件上传

parent 3b78c024
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
<!-- 应用集市 --> <!-- 应用集市 -->
<div class="app-market"> <div class="app-market">
<a-tabs default-active-key="1"> <a-tabs default-active-key="1">
<a-button
type="primary"
v-permission="[1]"
slot="tabBarExtraContent"
@click="handleUpload"
>上传配置文件</a-button
>
<a-tab-pane key="1" tab="终端应用"> <a-tab-pane key="1" tab="终端应用">
<TerminalApp></TerminalApp> <TerminalApp></TerminalApp>
</a-tab-pane> </a-tab-pane>
...@@ -9,19 +16,62 @@ ...@@ -9,19 +16,62 @@
<MoveApp></MoveApp> <MoveApp></MoveApp>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
<!-- 上传配置文件弹窗 -->
<a-modal
v-model="visible"
title="配置文件上传"
@ok="handleOk"
@cancel="handleClose"
>
<a-form-model
:model="form"
:label-col="{ span: 4 }"
:wrapper-col="{ span: 20 }"
ref="form"
:rules="rules"
>
<a-form-model-item label="上传文件" prop="filePath">
<a-upload
name="file"
:action="api + 'base/file/commonupload'"
:multiple="false"
:file-list="fileList"
@change="handleChangeFile"
accept="application/x-zip-compressed"
>
<a-button type="primary">
<a-icon type="upload" /> .zip文件
</a-button>
</a-upload>
</a-form-model-item>
</a-form-model>
</a-modal>
</div> </div>
</template> </template>
<script> <script>
import TerminalApp from "./components/TerminalApp.vue"; import TerminalApp from "./components/TerminalApp.vue";
import MoveApp from "./components/MoveApp.vue"; import MoveApp from "./components/MoveApp.vue";
import { commonConfig } from "@/services/market";
export default { export default {
components: { components: {
TerminalApp, TerminalApp,
MoveApp, MoveApp,
}, },
data() { data() {
return {}; return {
api: process.env.VUE_APP_API_BASE_URL + "/",
visible: false,
form: {
filePath: "",
},
fileList: [],
rules: {
filePath: [
{ required: true, message: "文件不能为空", trigger: "change" },
],
},
};
}, },
// 进入路有前 // 进入路有前
beforeRouteEnter(to, from, text) { beforeRouteEnter(to, from, text) {
...@@ -32,6 +82,43 @@ export default { ...@@ -32,6 +82,43 @@ export default {
} }
text(); text();
}, },
methods: {
handleUpload() {
this.visible = true;
},
handleOk() {
this.$refs.form.validate(async (valid) => {
if (valid) {
let res = await commonConfig(this.form);
let { code, msg } = res.data;
if (code === 1) {
this.$message.success(msg);
this.handleClose();
}
}
});
},
handleChangeFile(info) {
let fileList = [...info.fileList];
fileList = fileList.slice(-1);
fileList = fileList.map((file) => {
if (file.response) {
file.url = file.response.url;
}
return file;
});
this.fileList = fileList;
if (this.fileList.length) {
this.form.filePath = this.fileList[0].url;
} else {
this.form.filePath = "";
}
},
handleClose() {
this.fileList = [];
this.visible = false;
},
},
}; };
</script> </script>
...@@ -40,6 +127,9 @@ export default { ...@@ -40,6 +127,9 @@ export default {
width: 100%; width: 100%;
padding: 15px; padding: 15px;
} }
/deep/.ant-form-item {
align-items: flex-start;
}
/deep/.ant-tabs { /deep/.ant-tabs {
height: 100%; height: 100%;
background-color: #fff; background-color: #fff;
......
...@@ -61,6 +61,11 @@ ...@@ -61,6 +61,11 @@
(current - 1) * size + index + 1 (current - 1) * size + index + 1
}}</span> }}</span>
<!-- 图片 -->
<template slot="img" slot-scope="text">
<img width="40" :src="api + text.img" />
</template>
<!-- 操作 --> <!-- 操作 -->
<template slot="action" slot-scope="text"> <template slot="action" slot-scope="text">
<a-space size="middle"> <a-space size="middle">
...@@ -100,6 +105,7 @@ export default { ...@@ -100,6 +105,7 @@ export default {
}, },
data() { data() {
return { return {
api: process.env.VUE_APP_API_BASE_URL + "/",
appId: this.$route.query.id, appId: this.$route.query.id,
loading: false, loading: false,
current: 1, current: 1,
...@@ -134,10 +140,17 @@ export default { ...@@ -134,10 +140,17 @@ export default {
return v.isList; return v.isList;
}) })
.map((v) => { .map((v) => {
return { if (v.fieldCode === "img") {
title: v.fieldName, return {
dataIndex: v.fieldCode, title: v.fieldName,
}; scopedSlots: { customRender: "img" },
};
} else {
return {
title: v.fieldName,
dataIndex: v.fieldCode,
};
}
}); });
return [index, ...arr, action]; return [index, ...arr, action];
}, },
......
...@@ -293,7 +293,6 @@ export default { ...@@ -293,7 +293,6 @@ export default {
}, },
// 上传应用 // 上传应用
handleChangeFile(info) { handleChangeFile(info) {
console.log(info);
let fileList = [...info.fileList]; let fileList = [...info.fileList];
fileList = fileList.slice(-1); fileList = fileList.slice(-1);
fileList = fileList.map((file) => { fileList = fileList.map((file) => {
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</div> </div>
<a-upload <a-upload
v-else-if="v.fieldType == 'upload'" v-else-if="v.fieldType == 'upload'"
:action="api2 + 'file/commonupload'" :action="api + 'base/file/commonupload'"
:multiple="false" :multiple="false"
:file-list="v.fileList" :file-list="v.fileList"
@change=" @change="
...@@ -113,10 +113,7 @@ export default { ...@@ -113,10 +113,7 @@ export default {
}, },
data() { data() {
return { return {
api: process.env.VUE_APP_API_BASE_URL.includes("base") api: process.env.VUE_APP_API_BASE_URL + "/",
? process.env.VUE_APP_API_BASE_URL.replace("base", "")
: process.env.VUE_APP_API_BASE_URL,
api2: process.env.VUE_APP_API_BASE_URL + "/",
labelCol: { labelCol: {
span: 2, span: 2,
}, },
......
...@@ -280,6 +280,7 @@ module.exports = { ...@@ -280,6 +280,7 @@ module.exports = {
delete: `${BASE_URL}/base/app/delete`, delete: `${BASE_URL}/base/app/delete`,
distribute: `${BASE_URL}/base/app/appDistribute`, distribute: `${BASE_URL}/base/app/appDistribute`,
clone: `${BASE_URL}/base/app/cloneAppsBySites`, clone: `${BASE_URL}/base/app/cloneAppsBySites`,
common: `${BASE_URL}/base/app/appCommonDistribute`,
}, },
// 应用数据 // 应用数据
dataset: { dataset: {
......
...@@ -36,6 +36,10 @@ export async function cloneApp(data) { ...@@ -36,6 +36,10 @@ export async function cloneApp(data) {
export async function deployApp(data) { export async function deployApp(data) {
return request(App.distribute, METHOD.POST, data); return request(App.distribute, METHOD.POST, data);
} }
// 基础配置文件部署
export async function commonConfig(data) {
return request(App.common, METHOD.POST, data);
}
/** /**
* 应用数据 * 应用数据
......
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