Commit 47325f8f authored by yyh's avatar yyh

代码调整

parent fa3a98e3
......@@ -96,11 +96,7 @@ export default class Detail extends Vue {
this.detail = JSON.parse(templateDetail.detail);
this.detail2 = JSON.stringify(this.detail);
this.proofType = templateDetail.name;
if (newTemplateId.proofName) {
this.name = newTemplateId.proofName;
} else {
this.name = templateDetail.name;
}
this.name = newTemplateId.proofName ? newTemplateId.proofName : templateDetail.name;
this.name2 = this.name;
this.showBtn = true;
}
......@@ -108,21 +104,17 @@ export default class Detail extends Vue {
@Watch('proofId', { immediate: true, deep: true })
private async onProofIdChange(newProofId: number, oldProofId: number) {
if (newProofId) {
let proofDetail: any;
if (this.baseProof) {
proofDetail = await this.$api.proof.incrementGet(newProofId);
} else {
proofDetail = await this.$api.proof.get(newProofId);
}
this.detail = (JSON.parse(proofDetail.detail) as any).slice(0, -1);
let proofDetail: any = this.baseProof ? this.$api.proof.incrementGet(newProofId) : await this.$api.proof.get(newProofId);
const proof: any = JSON.parse(proofDetail.detail);
this.detail = proof.slice(0, -1);
this.detail2 = Object.freeze(JSON.stringify(this.detail));
this.id = proofDetail.id;
this.name = proofDetail.name;
this.name2 = this.name;
this.proofType = (JSON.parse(proofDetail.detail) as any)[(JSON.parse(proofDetail.detail) as any).length - 1]
.data.find((item: any) => item.key === '存证类型').data.value;
this.showBtn = true;
const ext: any = proof[proof.length - 1];
this.proofType = ext.data.find((item: any) => item.key === '存证类型').data.value;
this.banners = JSON.parse(proofDetail.note).banners;
this.showBtn = true;
}
}
get baseProofId() {
......@@ -144,7 +136,7 @@ export default class Detail extends Vue {
return 'null';
}
get note() {
const {user , icon } = this.userInfo;
const { user , icon } = this.userInfo;
let obj: any = {};
if (this.baseProof) {
const baseProof = JSON.parse(this.baseProof);
......@@ -228,24 +220,24 @@ export default class Detail extends Vue {
next();
}
}
get proofAndExt() {
const { detail, extData } = this;
return [...detail, extData];
}
private async addProof() {
const detail = [...this.detail, this.extData];
const result = await this.$api.proof.add(this.name, detail, this.note);
const result = await this.$api.proof.add(this.name, this.proofAndExt, this.note);
return result.id;
}
private async addIncrementProof() {
const detail = [...this.detail, this.extData];
const { baseProofId, baseProofHash, preProofHash , name , note } = this;
const result = await this.$api.proof.incrementAdd(baseProofId, baseProofHash, preProofHash, name, detail, note);
const { baseProofId, baseProofHash, preProofHash , name , note, proofAndExt } = this;
const result = await this.$api.proof.incrementAdd(baseProofId, baseProofHash, preProofHash, name, proofAndExt, note);
return result.id;
}
private async editProof() {
const detail = [...this.detail, this.extData];
await this.$api.proof.update(this.id, this.name, detail, this.note);
await this.$api.proof.update(this.id, this.name, this.proofAndExt, this.note);
}
private async editIncrementProof() {
const detail = [...this.detail, this.extData];
return await this.$api.proof.incrementEdit(this.id, this.name, detail, this.note);
return await this.$api.proof.incrementEdit(this.id, this.name, this.proofAndExt, this.note);
}
private async incrementSendBlockChain(id: number) {
return await this.$api.proof.incrementSendBlockChain(id);
......@@ -254,7 +246,6 @@ export default class Detail extends Vue {
await this.$api.proof.sendBlockChian(id);
}
private async submit(flag: boolean) { // flase 仅保存 true: 保存并上链
const detail = [...this.detail, this.extData];
this.checkEdited = false;
let id: number = -1;
if (this.baseProof) {
......@@ -282,17 +273,14 @@ export default class Detail extends Vue {
await this.sendBlockChain(id);
}
}
// this.$router.push({name: 'ProofList'});
}
private save(hashs: string[]) {
private async save(hashs: []) {
this.banners = hashs;
this.showBanner = false;
this.submit(false);
await this.submit(false);
this.$router.push({name: 'ProofList'});
}
private async saveAndChain(hashs: string[]) {
private async saveAndChain(hashs: []) {
this.banners = hashs;
this.showBanner = false;
await this.submit(true);
this.$router.push({name: 'ProofList'});
}
......
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