|
@@ -22,17 +22,19 @@
|
|
|
<div class="control-right">
|
|
|
<el-button
|
|
|
class="btn-white"
|
|
|
- @click="toPreview"
|
|
|
+ :loading="isSubmit"
|
|
|
:disabled="!pages.length"
|
|
|
+ @click="toPreview"
|
|
|
>预览</el-button
|
|
|
>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
- @click="toSave"
|
|
|
+ :loading="isSubmit"
|
|
|
:disabled="canSave || !pages.length"
|
|
|
+ @click="toSave"
|
|
|
>暂存</el-button
|
|
|
>
|
|
|
- <el-button type="primary" @click="toSubmit" :loading="isSubmit"
|
|
|
+ <el-button type="primary" :loading="isSubmit" @click="toSubmit"
|
|
|
>提交</el-button
|
|
|
>
|
|
|
</div>
|
|
@@ -460,12 +462,10 @@ export default {
|
|
|
},
|
|
|
// 操作
|
|
|
async toPreview() {
|
|
|
- // this.$ls.set("cardData", {
|
|
|
- // cardConfig: this.cardConfig,
|
|
|
- // pages: this.pages,
|
|
|
- // paperParams: this.paperParams
|
|
|
- // });
|
|
|
- const result = await this.save();
|
|
|
+ if (this.isSubmit) return;
|
|
|
+ this.isSubmit = true;
|
|
|
+ const result = await this.save().catch(() => {});
|
|
|
+ this.isSubmit = false;
|
|
|
if (!result) return;
|
|
|
const { href } = this.$router.resolve({
|
|
|
name: "CardPreview",
|
|
@@ -547,19 +547,25 @@ export default {
|
|
|
return true;
|
|
|
},
|
|
|
getModel() {
|
|
|
- return JSON.stringify(
|
|
|
- {
|
|
|
- version: CARD_VERSION,
|
|
|
- cardConfig: this.cardConfig,
|
|
|
- paperParams: this.paperParams,
|
|
|
- pages: this.pages
|
|
|
- },
|
|
|
- (k, v) => (k.startsWith("_") ? undefined : v)
|
|
|
- );
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ const data = JSON.stringify(
|
|
|
+ {
|
|
|
+ version: CARD_VERSION,
|
|
|
+ cardConfig: this.cardConfig,
|
|
|
+ paperParams: this.paperParams,
|
|
|
+ pages: this.pages
|
|
|
+ },
|
|
|
+ (k, v) => (k.startsWith("_") ? undefined : v)
|
|
|
+ );
|
|
|
+ resolve(data);
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
},
|
|
|
async save() {
|
|
|
if (!this.checkCardValid()) return;
|
|
|
- let datas = this.getCardData("", this.getModel());
|
|
|
+ const model = await this.getModel();
|
|
|
+ let datas = this.getCardData("", model);
|
|
|
datas.status = "STAGE";
|
|
|
const result = await saveCard(datas, this.getRequestConfig());
|
|
|
this.cardId = result;
|
|
@@ -567,7 +573,10 @@ export default {
|
|
|
return true;
|
|
|
},
|
|
|
async toSave() {
|
|
|
- const result = await this.save();
|
|
|
+ if (this.isSubmit) return;
|
|
|
+ this.isSubmit = true;
|
|
|
+ const result = await this.save().catch(() => {});
|
|
|
+ this.isSubmit = false;
|
|
|
if (result) this.$message.success("保存成功!");
|
|
|
},
|
|
|
toSubmit() {
|