project loading

This commit is contained in:
Captain.B 2020-02-19 14:11:49 +08:00
parent 618846c73a
commit 63759b9f4f
2 changed files with 6 additions and 11 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="project-container"> <div class="project-container">
<div class="main-content"> <div class="main-content">
<el-card> <el-card v-loading="result.loading">
<div slot="header"> <div slot="header">
<el-row type="flex" justify="space-between" align="middle"> <el-row type="flex" justify="space-between" align="middle">
<span class="title"> <span class="title">
@ -70,7 +70,7 @@
data() { data() {
return { return {
createVisible: false, createVisible: false,
loading: false, result: {},
btnTips: "添加项目", btnTips: "添加项目",
condition: "", condition: "",
items: [], items: [],
@ -87,7 +87,7 @@
} }
}, },
mounted() { mounted() {
// this.list(); this.list();
}, },
destroyed() { destroyed() {
this.createVisible = false; this.createVisible = false;
@ -104,14 +104,12 @@
submit(formName) { submit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.loading = true;
let saveType = "add"; let saveType = "add";
if (this.form.id) { if (this.form.id) {
saveType = "update" saveType = "update"
} }
this.$post("/project/" + saveType, this.form, () => { this.result = this.$post("/project/" + saveType, this.form, () => {
this.createVisible = false; this.createVisible = false;
this.loading = false;
this.list(); this.list();
Message.success('保存成功'); Message.success('保存成功');
}); });
@ -136,7 +134,7 @@
}, },
list() { list() {
let url = "/project/list/" + this.currentPage + '/' + this.pageSize; let url = "/project/list/" + this.currentPage + '/' + this.pageSize;
this.$post(url, {}, (response) => { this.result = this.$post(url, {}, (response) => {
this.items = response.data; this.items = response.data;
}) })
}, },

View File

@ -13,7 +13,7 @@
</span> </span>
</el-row> </el-row>
</div> </div>
<el-table :data="items" style="width: 100%" v-loading="loading"> <el-table :data="items" style="width: 100%">
<el-table-column prop="name" label="名称"/> <el-table-column prop="name" label="名称"/>
<el-table-column prop="description" label="描述"/> <el-table-column prop="description" label="描述"/>
<el-table-column> <el-table-column>
@ -76,14 +76,12 @@
submit(formName) { submit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.loading = true;
let saveType = 'add'; let saveType = 'add';
if (this.form.id) { if (this.form.id) {
saveType = 'update' saveType = 'update'
} }
this.$post("/workspace/" + saveType, this.form, () => { this.$post("/workspace/" + saveType, this.form, () => {
this.createVisible = false; this.createVisible = false;
this.loading = false;
this.list(); this.list();
Message.success('保存成功'); Message.success('保存成功');
}); });
@ -94,7 +92,6 @@
}, },
edit(row) { edit(row) {
this.createVisible = true; this.createVisible = true;
this.loading = true;
this.form = row; this.form = row;
// let self = this; // let self = this;