Commit 47325f8f authored by yyh's avatar yyh

代码调整

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