Commit 1d5275b2 authored by yyh's avatar yyh

隐私设置

parent a046ab61
import {ChainStatus} from './enum';
export const ActionList = { blockChain: {key: 'blockChain', icon: 'shanglian1', text: '上链'},
edit: {key: 'edit', icon: 'bianji1', text: '编辑'},
del: {key: 'del', icon: 'shanchu3', text: '删除'},
copy: {key: 'copy', icon: 'fuzhi1', text: '复制'},
blockquery: {key: 'blockquery', icon: 'qukuailianchaxun', text: '区块链查询'},
copyhash: {key: 'copyhash', icon: 'fuzhiHashdizhi', text: '复制hash地址'},
del2: {key: 'del2', icon: 'shanchu3', text: '删除'},
zengliang: {key: 'zengliang', icon: 'zenglianggengxin2', text: '增量'},
};
export const ChainStatusStr: any = {
[ChainStatus.NONE]: '未上链',
[ChainStatus.CHAINING]: '上链中',
[ChainStatus.SUCCESS]: '已上链',
[ChainStatus.FAILURE]: '上链失败',
};
[ChainStatus.HIDING]: '隐藏中',
[ChainStatus.HIDED]: '已隐藏',
[ChainStatus.HIDEFAILURE]: '隐藏失败',
};
export const menu = [
{
text: '首页',
......
import { Component, Vue, Inject } from 'vue-property-decorator';
import { ChainStatus } from '@/const/enum';
@Component
export default class Proof extends Vue {
@Inject('goToBrowser') protected goToBrowser!: (proof: any) => void;
protected baseProof: any = '';
protected preProof: any = '';
protected isZengliang: boolean = false;
protected showAddProof: boolean = false;
protected ActionList: any = {
blockChain: {
key: 'blockChain',
icon: 'shanglian1',
text: '上链',
callback: this.blockChainProof,
},
edit: {
key: 'edit',
icon: 'bianji1',
text: '编辑',
callback: this.goProofDetail,
},
del: {
key: 'del',
icon: 'shanchu3',
text: '删除',
callback: this.delProof,
},
copy: {
key: 'copy',
icon: 'fuzhi1',
text: '复制',
callback: this.copyProof,
},
blockquery: {
key: 'blockquery',
icon: 'qukuailianchaxun',
text: '区块链查询',
callback: this.goToBrowser,
},
copyhash: {
key: 'copyhash',
icon: 'fuzhiHashdizhi',
text: '复制hash地址',
callback: this.copyHash,
},
del2: {
key: 'del2',
icon: 'shanchu3',
text: '删除',
callback: this.abandonProof,
},
zengliang: {
key: 'zengliang',
icon: 'zenglianggengxin2',
text: '增量',
callback: this.increment,
},
hide: {
key: 'hide',
icon: 'zenglianggengxin2',
text: '隐私设置',
callback: this.hide,
},
};
protected resetList() {
throw Error('resetList 在列表实现');
}
private abandonProof(proof: any) {
const { id: proofId } = proof;
this.$confirmdel().then((res: any) => {
this.$api.proof.abandon(proofId, '暂无原因').then(() => {
this.$toast.success('已放入回收站');
this.resetList();
});
});
}
private blockChainProof(proof: any) {
this.$confirmchain().then((res: any) => {
this.$api.proof.sendBlockChian(proof.id).then(() => {
this.$toast.success('提交上链成功');
this.resetList();
}).catch((err: any) => {
if (err.code === 10811) {
this.$dialog.confirm({
title: '提示',
message: '您还未认证,请先认证后在进行上链',
confirmButtonText: '去认证',
cancelButtonText: '取消',
}).then(() => {
this.$router.push({name: 'Auth'});
});
}
});
});
}
private goProofDetail(proof: any) {
const toBlockStatuss: ChainStatus[] = [
ChainStatus.SUCCESS,
ChainStatus.HIDED,
ChainStatus.HIDING,
ChainStatus.HIDEFAILURE,
];
if (toBlockStatuss.includes(proof.status) ) {
this.goToBrowser(proof);
} else {
this.$router.push({ name: 'ProofDetail', query: { proofId: proof.id }});
}
}
private async copyProof(proof: any) {
await this.$api.proof.add(proof.name, JSON.parse(proof.detail), proof.note);
this.$toast.success('复制成功');
this.resetList();
}
private async reName(proof: any) {
this.$toast('重命名成功');
}
private delProof(proof: any) {
const { id: proofId} = proof;
this.$dialog.confirm({
title: '提示',
message: '删除后,信息无法找回,确定要删除吗?',
beforeClose: (action, done) => {
if ( action === 'confirm' ) {
this.$api.proof.delete(proofId).then((res: any) => {
this.$toast.success('删除成功');
this.resetList();
done();
}).catch((err: any) => {
done();
});
} else {
done();
}
},
});
}
private copyHash(proof: any) {
this.$copyText(proof.hash);
this.$toast('hash地址复制成功');
}
private async increment(proof: any) {
const { increment_num, hash } = proof;
if ( increment_num > 0 ) {
const { results } = await this.$api.proof.incrementList(hash);
const preProof = results[0];
if (!preProof.hash) {
this.$toast('请先上链上一条存证');
return Promise.reject('请先上链上一条存证');
}
this.preProof = preProof;
} else {
this.preProof = proof;
}
this.baseProof = proof;
this.showAddProof = true;
this.isZengliang = true;
}
private hide(proofId: number) {
this.$api.proof.deleteBlockChainProof(proofId).then(() => {
this.$toast('隐藏成功');
this.resetList();
});
}
}
......@@ -41,7 +41,9 @@
:key="index"
icon="photo-o"
:text="currentProof.status === ChainStatus.FAILURE && item.text === '上链' ? `重新${item.text}`:`${item.text}`"
@click="select(item.key)">
@click="callbackAction(item.callback)"
>
<!-- @click="select(item.key)" -->
<template #icon>
<common-svg :name="item.icon" width="44px" height="44px"></common-svg>
</template>
......@@ -69,10 +71,11 @@
</template>
<script lang="ts">
import { Component, Prop, Vue, Inject } from 'vue-property-decorator';
import { Component, Prop, Vue, Inject, Mixins } from 'vue-property-decorator';
import { List, Popup, Button, Image, Picker, Grid, GridItem, Empty, Dialog } from 'vant';
import { ChainStatus } from '@/const/enum';
import { ActionList, ChainStatusStr } from '@/const/constants';
import { ChainStatusStr } from '@/const/constants';
import MixinProof from '@/mixins/proof.ts';
import SelectTemplate from '@/views/template/components/SelectTemplate.vue';
import PreviewTemplate from '@/views/template/components/PreviewTemplate.vue';
import AddFolder from '@/views/template/components/AddFolder.vue';
......@@ -94,10 +97,9 @@ import AddBaseinfo from './components/AddBaseinfo.vue';
AddBaseinfo,
},
})
export default class Index extends Vue {
export default class Index extends Mixins(MixinProof) {
@Inject('isSy') private isSy!: boolean;
@Inject('goToBrowser') private goToBrowser!: (proof: any) => void;
private show: boolean = false;
private showFilterPicker: boolean = false;
private columns: any[] = [{text: '全部', status: []}];
......@@ -118,17 +120,24 @@ export default class Index extends Vue {
private detail: any = {};
private showAddFolder: boolean = false;
private showAddProof: boolean = false;
private proofName: string = '';
private templateInfo: any = {
id: '',
name: '',
};
private baseProof: any = '';
private preProof: any = '';
private isZengliang: boolean = false;
protected resetList() {
this.total = 0;
this.list = [];
this.finished = false;
this.page = 1;
this.loading = true;
this.getList();
}
private callbackAction(cb: any) {
cb.call(this, this.currentProof);
this.show = false;
}
private async addProofHandler() {
const { name } = this.templateInfo;
if (!name) {
......@@ -170,29 +179,18 @@ export default class Index extends Vue {
return ChainStatus;
}
get actionList() {
const {blockChain, edit, del, del2, copy, blockquery , copyhash, zengliang } = ActionList;
const {blockChain, edit, del, del2, copy, blockquery , copyhash, zengliang, hide } = this.ActionList;
const obj: any = {
[ChainStatus.NONE]: [blockChain, edit, copy, del],
[ChainStatus.CHAINING]: [ copy],
[ChainStatus.SUCCESS]: [ blockquery, copyhash, del2, zengliang],
[ChainStatus.FAILURE]: [blockChain, edit, copy, del],
[ChainStatus.SUCCESS]: [ blockquery, copyhash, del2, zengliang, hide],
[ChainStatus.FAILURE]: [ blockChain, edit, copy, del],
[ChainStatus.HIDING]: [ blockquery, copyhash, copy ],
[ChainStatus.HIDED]: [ copy ],
[ChainStatus.HIDEFAILURE]: [ blockquery, copyhash, copy, hide],
};
return obj[this.currentProof.status];
}
private select(type: string) {
const obj: any = {
blockChain: () => { this.blockChainProof(this.currentProof); },
edit: () => { this.goProofDetail(this.currentProof); },
del: () => { this.delProof(this.currentProof.id); },
copy: () => { this.copyProof(this.currentProof); },
blockquery: () => { this.goToBrowser(this.currentProof); },
copyhash: () => { this.copyHash(this.currentProof); },
del2: () => { this.abandonProof(this.currentProof.id); },
zengliang: () => { this.increment(this.currentProof); },
};
this.show = false;
obj[type]();
}
private async getList() {
const { chainStatus } = this;
const params = {
......@@ -225,13 +223,6 @@ export default class Index extends Vue {
preProof: JSON.stringify(preProof),
baseProof: JSON.stringify(baseProof) }});
}
private goProofDetail(proof: any) {
if ([ChainStatus.SUCCESS].includes(proof.status) ) {
this.goToBrowser(proof);
} else {
this.$router.push({ name: 'ProofDetail', query: { proofId: proof.id }});
}
}
private showMoreAction(data: any) {
this.show = true;
this.currentProof = data;
......@@ -241,89 +232,7 @@ export default class Index extends Vue {
this.resetList();
this.showFilterPicker = false;
}
private resetList() {
this.total = 0;
this.list = [];
this.finished = false;
this.page = 1;
this.loading = true;
this.getList();
}
private delProof(proofId: number) {
this.$dialog.confirm({
title: '提示',
message: '删除后,信息无法找回,确定要删除吗?',
beforeClose: (action, done) => {
if ( action === 'confirm' ) {
this.$api.proof.delete(proofId).then((res: any) => {
this.$toast.success('删除成功');
this.resetList();
done();
}).catch((err: any) => {
done();
});
} else {
done();
}
},
});
}
private abandonProof(proofId: number) {
this.$confirmdel().then((res: any) => {
this.$api.proof.abandon(proofId, '暂无原因').then(() => {
this.$toast.success('已放入回收站');
this.resetList();
});
});
}
private blockChainProof(proof: any) {
this.$confirmchain().then((res: any) => {
this.$api.proof.sendBlockChian(proof.id).then(() => {
this.$toast.success('提交上链成功');
this.resetList();
}).catch((err: any) => {
if (err.code === 10811) {
this.$dialog.confirm({
title: '提示',
message: '您还未认证,请先认证后在进行上链',
confirmButtonText: '去认证',
cancelButtonText: '取消',
}).then(() => {
this.$router.push({name: 'Auth'});
});
}
});
});
}
private async copyProof(proof: any) {
await this.$api.proof.add(proof.name, JSON.parse(proof.detail), proof.note);
this.$toast.success('复制成功');
this.resetList();
}
private async reName(proof: any) {
this.$toast('重命名成功');
}
private copyHash(proof: any) {
this.$copyText(proof.hash);
this.$toast('hash地址复制成功');
}
private async increment(proof: any) {
const { increment_num } = proof;
if ( increment_num > 0 ) {
const { results } = await this.$api.proof.incrementList(this.currentProof.hash);
const preProof = results[0];
if (!preProof.hash) {
this.$toast('请先上链上一条存证');
return Promise.reject('请先上链上一条存证');
}
this.preProof = preProof;
} else {
this.preProof = proof;
}
this.baseProof = proof;
this.showAddProof = true;
this.isZengliang = true;
}
}
</script>
<style scoped lang="scss">
......
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