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

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

parent 3b78c024
......@@ -2,6 +2,13 @@
<!-- 应用集市 -->
<div class="app-market">
<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="终端应用">
<TerminalApp></TerminalApp>
</a-tab-pane>
......@@ -9,19 +16,62 @@
<MoveApp></MoveApp>
</a-tab-pane>
</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>
</template>
<script>
import TerminalApp from "./components/TerminalApp.vue";
import MoveApp from "./components/MoveApp.vue";
import { commonConfig } from "@/services/market";
export default {
components: {
TerminalApp,
MoveApp,
},
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) {
......@@ -32,6 +82,43 @@ export default {
}
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>
......@@ -40,6 +127,9 @@ export default {
width: 100%;
padding: 15px;
}
/deep/.ant-form-item {
align-items: flex-start;
}
/deep/.ant-tabs {
height: 100%;
background-color: #fff;
......
......@@ -61,6 +61,11 @@
(current - 1) * size + index + 1
}}</span>
<!-- 图片 -->
<template slot="img" slot-scope="text">
<img width="40" :src="api + text.img" />
</template>
<!-- 操作 -->
<template slot="action" slot-scope="text">
<a-space size="middle">
......@@ -100,6 +105,7 @@ export default {
},
data() {
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
appId: this.$route.query.id,
loading: false,
current: 1,
......@@ -134,10 +140,17 @@ export default {
return v.isList;
})
.map((v) => {
return {
title: v.fieldName,
dataIndex: v.fieldCode,
};
if (v.fieldCode === "img") {
return {
title: v.fieldName,
scopedSlots: { customRender: "img" },
};
} else {
return {
title: v.fieldName,
dataIndex: v.fieldCode,
};
}
});
return [index, ...arr, action];
},
......
......@@ -293,7 +293,6 @@ export default {
},
// 上传应用
handleChangeFile(info) {
console.log(info);
let fileList = [...info.fileList];
fileList = fileList.slice(-1);
fileList = fileList.map((file) => {
......
......@@ -55,7 +55,7 @@
</div>
<a-upload
v-else-if="v.fieldType == 'upload'"
:action="api2 + 'file/commonupload'"
:action="api + 'base/file/commonupload'"
:multiple="false"
:file-list="v.fileList"
@change="
......@@ -113,10 +113,7 @@ export default {
},
data() {
return {
api: process.env.VUE_APP_API_BASE_URL.includes("base")
? process.env.VUE_APP_API_BASE_URL.replace("base", "")
: process.env.VUE_APP_API_BASE_URL,
api2: process.env.VUE_APP_API_BASE_URL + "/",
api: process.env.VUE_APP_API_BASE_URL + "/",
labelCol: {
span: 2,
},
......
......@@ -280,6 +280,7 @@ module.exports = {
delete: `${BASE_URL}/base/app/delete`,
distribute: `${BASE_URL}/base/app/appDistribute`,
clone: `${BASE_URL}/base/app/cloneAppsBySites`,
common: `${BASE_URL}/base/app/appCommonDistribute`,
},
// 应用数据
dataset: {
......
......@@ -36,6 +36,10 @@ export async function cloneApp(data) {
export async function deployApp(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