Commit 4204cc04 authored by yyh's avatar yyh

代码优化

parent dcc07782
...@@ -82,9 +82,10 @@ export default class Detail extends Vue { ...@@ -82,9 +82,10 @@ export default class Detail extends Vue {
private proofName!: string; private proofName!: string;
get addOrTemplate() { get addOrTemplate() {
const { templateId, proofName } = this;
return { return {
templateId: this.templateId, templateId,
proofName: this.proofName, proofName,
}; };
} }
...@@ -94,7 +95,7 @@ export default class Detail extends Vue { ...@@ -94,7 +95,7 @@ export default class Detail extends Vue {
if (templateId) { if (templateId) {
const { detail, name } = await this.$api.template.get(templateId); const { detail, name } = await this.$api.template.get(templateId);
this.detail = JSON.parse(detail); this.detail = JSON.parse(detail);
this.detail2 = Object.freeze(detail);; this.detail2 = Object.freeze(detail);
this.proofType = name; this.proofType = name;
this.name = proofName ? proofName : name; this.name = proofName ? proofName : name;
this.name2 = this.name; this.name2 = this.name;
...@@ -104,14 +105,19 @@ export default class Detail extends Vue { ...@@ -104,14 +105,19 @@ 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 { detail, id, name, note }: any = this.baseProof ? await this.$api.proof.incrementGet(newProofId) : await this.$api.proof.get(newProofId); const { detail,
id,
name,
note }: any = this.baseProof
? await this.$api.proof.incrementGet(newProofId)
: await this.$api.proof.get(newProofId);
const proof: any = JSON.parse(detail); const proof: any = JSON.parse(detail);
const ext: any = proof[proof.length - 1];
this.detail = proof.slice(0, -1); this.detail = proof.slice(0, -1);
this.detail2 = Object.freeze(detail); this.detail2 = Object.freeze(detail);
this.id = id; this.id = id;
this.name = name; this.name = name;
this.name2 = this.name; this.name2 = this.name;
const ext: any = proof[proof.length - 1];
this.proofType = ext.data.find((item: any) => item.key === '存证类型').data.value; this.proofType = ext.data.find((item: any) => item.key === '存证类型').data.value;
this.banners = JSON.parse(note).banners; this.banners = JSON.parse(note).banners;
this.showBtn = true; this.showBtn = true;
...@@ -230,7 +236,13 @@ export default class Detail extends Vue { ...@@ -230,7 +236,13 @@ export default class Detail extends Vue {
} }
private async addIncrementProof() { private async addIncrementProof() {
const { baseProofId, baseProofHash, preProofHash , name , note, proofAndExt } = this; const { baseProofId, baseProofHash, preProofHash , name , note, proofAndExt } = 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,
proofAndExt,
note);
return result.id; return result.id;
} }
private async editProof() { private async editProof() {
......
...@@ -127,7 +127,7 @@ export default class Index extends Vue { ...@@ -127,7 +127,7 @@ export default class Index extends Vue {
let query: any = { let query: any = {
templateId: this.templateInfo.id, templateId: this.templateInfo.id,
proofName: this.proofName, proofName: this.proofName,
} };
if ( this.isZengliang ) { if ( this.isZengliang ) {
let preProof = null; let preProof = null;
if (this.currentProof.increment_num > 0) { if (this.currentProof.increment_num > 0) {
...@@ -136,7 +136,7 @@ export default class Index extends Vue { ...@@ -136,7 +136,7 @@ export default class Index extends Vue {
} else { } else {
preProof = this.currentProof; preProof = this.currentProof;
} }
query = {...query, baseProof: JSON.stringify(this.currentProof), preProof: JSON.stringify(preProof),} query = {...query, baseProof: JSON.stringify(this.currentProof), preProof: JSON.stringify(preProof)};
} }
this.$router.push({ name: 'ProofDetail', query}); this.$router.push({ name: 'ProofDetail', query});
} }
......
...@@ -104,13 +104,11 @@ export default class AddBanner extends Vue { ...@@ -104,13 +104,11 @@ export default class AddBanner extends Vue {
} }
@Emit('save') @Emit('save')
private save() { private save() {
this.$emit('update:banners',this.hashs); this.$emit('update:banners', this.hashs);
return this.hashs;
} }
@Emit('save-and-chain') @Emit('save-and-chain')
private saveAndChain() { private saveAndChain() {
this.$emit('update:banners',this.hashs); this.$emit('update:banners', this.hashs);
return this.hashs;
} }
} }
</script> </script>
......
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