Commit 79eb2e3c authored by wanli's avatar wanli

update

parent 5e559b46
......@@ -21,7 +21,7 @@ class Apps(db.Entity):
app_version = Optional(str, default="")
app_url = Optional(str, default="")
category = Optional(str, default="")
app_icon = Optional("Annex", reverse="app_icon", cascade_delete=True)
app_icon = Optional("Annex", reverse="app_icon")
app_desc = Optional(str, default="")
app_annex = Set("Annex", reverse="app", cascade_delete=True)
app_user = Optional("AppUser", reverse="app", cascade_delete=True)
......
<template>
<div class="app-container">
<el-form :inline="true" ref="form" :model="form" size="mini">
<el-form-item><el-button type="warning" @click="onAdd">添加应用</el-button></el-form-item>
<el-form-item
><el-button type="warning" @click="onAdd"
>添加应用</el-button
></el-form-item
>
<!-- <el-form-item><el-button type="success" @click="onAddFramework">添加系统页面</el-button></el-form-item> -->
<!-- <el-form-item><el-button type="success" @click="onAddFramework">上传JSON配置文件</el-button></el-form-item> -->
</el-form>
......@@ -61,9 +65,14 @@
label="更新者"
width="150"
></el-table-column>
<el-table-column label="操作" align="center" min-width="180" fixed="right">
<el-table-column
label="操作"
align="center"
min-width="180"
fixed="right"
>
<template slot-scope="scope">
<el-button
<el-button
size="mini"
type="primary"
@click="handleBuild(scope.$index, scope.row)"
......@@ -97,24 +106,54 @@
></el-pagination>
</div>
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%">
<el-form :model="post" status-icon ref="post" size="medium" label-width="100px">
<el-form
:model="post"
status-icon
ref="post"
size="medium"
label-width="100px"
>
<el-form-item label="应用排序" prop="sort">
<el-input type="number" v-model.number="post.sort" autocomplete="off"></el-input>
<el-input
type="number"
v-model.number="post.sort"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item label="应用名称" prop="app_name">
<el-input type="text" v-model="post.app_name" autocomplete="off"></el-input>
<el-input
type="text"
v-model="post.app_name"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item label="应用版本号" prop="app_version">
<el-input type="text" v-model="post.app_version" autocomplete="off"></el-input>
<el-input
type="text"
v-model="post.app_version"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item label="应用路径" prop="app_url">
<el-input type="text" v-model="post.app_url" autocomplete="off"></el-input>
<el-input
type="text"
v-model="post.app_url"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item label="应用类别" prop="category">
<el-input type="text" v-model="post.category" autocomplete="off"></el-input>
<el-input
type="text"
v-model="post.category"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item label="应用描述" prop="app_desc">
<el-input type="text" v-model="post.app_desc" autocomplete="off"></el-input>
<el-input
type="text"
v-model="post.app_desc"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item label="应用Logo" prop="app_icon">
<el-upload
......@@ -132,6 +171,7 @@
<el-form-item label="应用文件" prop="app_files">
<el-upload
drag
ref="upload"
:action="`${window.location.protocol}//${window.location.host}/api/v1/evm_store/upload`"
:on-remove="handleRemove"
:on-success="handleUploadSuccess"
......@@ -143,56 +183,77 @@
将文件拖到此处,或<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
.evue和资源文件
<el-button size="small" type="text" @click="clear"
>清空上传</el-button
>
</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" size="medium" plain @click="submitForm('post')">提交</el-button>
<el-button type="success" size="medium" plain @click="onReset('form')">重置</el-button>
<el-button
type="primary"
size="medium"
plain
@click="submitForm('post')"
>提交</el-button
>
<el-button type="success" size="medium" plain @click="onReset('form')"
>重置</el-button
>
<el-button size="medium" @click="dialogVisible = false">关闭</el-button>
</div>
</el-dialog>
<el-dialog title="添加系统页面" :visible.sync="frameworkDialog">
<el-form :model="form" label-width="100px">
<el-form-item label="页面名称">
<el-input v-model="framework.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="页面路径">
<el-input v-model="framework.url" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动描述">
<el-input v-model="framework.desc" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动类型">
<el-input v-model="framework.type" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="资源文件" prop="app_icon">
<el-upload
drag
multiple
name="binfile"
:action="`${window.location.protocol}//${window.location.host}/api/v1/evm_store/upload`"
:on-remove="handleFrameworkRemove"
:on-success="handleFrameworkSuccess"
:file-list="fileList"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="frameworkDialog = false">取 消</el-button>
<el-button type="primary" @click="addFramework">确 定</el-button>
</div>
<el-form :model="form" label-width="100px">
<el-form-item label="页面名称">
<el-input v-model="framework.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="页面路径">
<el-input v-model="framework.url" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动描述">
<el-input v-model="framework.desc" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动类型">
<el-input v-model="framework.type" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="资源文件" prop="app_icon">
<el-upload
drag
multiple
name="binfile"
:action="`${window.location.protocol}//${window.location.host}/api/v1/evm_store/upload`"
:on-remove="handleFrameworkRemove"
:on-success="handleFrameworkSuccess"
:file-list="fileList"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
只能上传jpg/png文件,且不超过500kb
</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="frameworkDialog = false">取 消</el-button>
<el-button type="primary" @click="addFramework">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getAppsList, deleteApp, addApp, updateApp, getBuildApp, addFramework } from "@/api/app-store";
import {
getAppsList,
deleteApp,
addApp,
updateApp,
getBuildApp,
addFramework,
} from "@/api/app-store";
import { mapTrim, checkURL, download } from "@/utils/index";
export default {
......@@ -211,13 +272,13 @@ export default {
pagenum: 1,
},
framework: {
name: null,
url: null,
desc: null,
type: null,
assets: {
files: []
}
name: null,
url: null,
desc: null,
type: null,
assets: {
files: [],
},
},
currentIndex: 0,
currentValue: null,
......@@ -225,14 +286,14 @@ export default {
dialogTitle: "",
dialogVisible: false,
post: {
sort: 0,
app_name: null,
app_version: null,
app_icon: null,
app_url: null,
category: null,
app_desc: null,
app_files: [],
sort: 0,
app_name: null,
app_version: null,
app_icon: null,
app_url: null,
category: null,
app_desc: null,
app_files: [],
},
};
},
......@@ -240,6 +301,9 @@ export default {
window: () => window,
},
methods: {
clear() {
this.$refs.upload.clearFiles();
},
fetchData(params) {
this.isLoading = true;
getAppsList(params)
......@@ -256,29 +320,33 @@ export default {
});
},
handleSizeChange(e) {
this.form.pagesize = e;
this.fetchData(mapTrim(this.form));
this.form.pagesize = e;
this.fetchData(mapTrim(this.form));
},
handleCurrentChange(e) {
this.form.pagenum = e;
this.fetchData(mapTrim(this.form));
this.form.pagenum = e;
this.fetchData(mapTrim(this.form));
},
handleBuild(index, row) {
console.log(index)
getBuildApp(row.uuid).then(res => {
download(res.data.app_name, res.data.app_path)
this.$message.success(res.message)
}).catch(err => {
console.log(err)
this.$message.error(err.message)
console.log(index);
getBuildApp(row.uuid)
.then((res) => {
download(res.data.app_name, res.data.app_path);
this.$message.success(res.message);
})
.catch((err) => {
console.log(err);
this.$message.error(err.message);
});
},
handleEdit(index, row) {
this.post = Object.assign(row);
this.currentIndex = index;
this.currentValue = row;
this.dialogTitle = "编辑";
this.dialogVisible = true;
this.post = Object.assign(row);
this.fileList = [];
this.imageUrl = null;
this.currentIndex = index;
this.currentValue = row;
this.dialogTitle = "编辑";
this.dialogVisible = true;
},
handleDelete(index, row) {
this.$alert(
......@@ -306,49 +374,49 @@ export default {
);
},
handleUploadSuccess(res) {
if (res.code == 200) {
if (!checkURL(res.data.filepath))
res.data.filepath = `${window.location.origin}/${res.data.filepath}`
this.post.app_files.push(res.data)
}
if (res.code == 200) {
if (!checkURL(res.data.filepath))
res.data.filepath = `${window.location.origin}/${res.data.filepath}`;
this.post.app_files.push(res.data);
}
},
handleAvatarSuccess(res, file) {
if (res.code == 200) {
if (!checkURL(res.data.filepath))
res.data.filepath = `${window.location.origin}/${res.data.filepath}`
this.post.app_icon = res.data
}
this.imageUrl = URL.createObjectURL(file.raw);
if (res.code == 200) {
if (!checkURL(res.data.filepath))
res.data.filepath = `${window.location.origin}/${res.data.filepath}`;
this.post.app_icon = res.data;
}
this.imageUrl = URL.createObjectURL(file.raw);
},
beforeAvatarUpload() {
// const isJPG = file.type === "image/jpeg";
// const isLt2M = file.size / 1024 / 1024 < 2;
// const isJPG = file.type === "image/jpeg";
// const isLt2M = file.size / 1024 / 1024 < 2;
// if (!isJPG) {
// this.$message.error("上传头像图片只能是 JPG 格式!");
// }
// if (!isLt2M) {
// this.$message.error("上传头像图片大小不能超过 2MB!");
// }
// return isJPG && isLt2M;
return true;
// if (!isJPG) {
// this.$message.error("上传头像图片只能是 JPG 格式!");
// }
// if (!isLt2M) {
// this.$message.error("上传头像图片大小不能超过 2MB!");
// }
// return isJPG && isLt2M;
return true;
},
handleAvatarRemove(file) {
console.log(file);
this.imageUrl = null;
console.log(file);
this.imageUrl = null;
},
handleRemove(file) {
for(let i = 0; i < this.post.app_files.length; i++) {
if (this.post.app_files[i].uuid == file.response.data.uuid) {
this.post.app_files.splice(i, 1);
break;
}
for (let i = 0; i < this.post.app_files.length; i++) {
if (this.post.app_files[i].uuid == file.response.data.uuid) {
this.post.app_files.splice(i, 1);
break;
}
console.log(file);
}
console.log(file);
},
handleFrameworkRemove() {},
handleFrameworkSuccess(res) {
this.framework.assets.files.push(res.data)
this.framework.assets.files.push(res.data);
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {
......@@ -383,15 +451,17 @@ export default {
});
},
addFramework() {
addFramework(this.framework).then(res => {
this.$message.success(res.message)
this.frameworkDialog = false
}).catch(err => {
this.$message.error(err.message)
addFramework(this.framework)
.then((res) => {
this.$message.success(res.message);
this.frameworkDialog = false;
})
.catch((err) => {
this.$message.error(err.message);
});
},
onAddFramework() {
this.frameworkDialog = true;
this.frameworkDialog = true;
},
onAdd() {
this.dialogTitle = "添加";
......
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