Commit 34c99a07 authored by chenqikuai's avatar chenqikuai

store

parent 2420969e
......@@ -3,92 +3,94 @@ import { ChainStatus } from '@/const/enum';
@Component
export default class Proof extends Vue {
/* 本mixins被 存证页面和 回收站页面 两个页面使用 */
@Inject('goToBrowser') protected goToBrowser!: (proof: any) => void;
@Inject('getProofViewingWebSite') protected getProofViewingWebSite!: (proof: any) => string;
protected baseProof: any = '';
protected preProof: any = '';
/* 是否是增量 */
protected isZengliang: boolean = false;
/* 添加存证框是否显示 */
protected showAddProof: boolean = false;
/* 动作列表 */
protected ActionList: any = {
blockChain: {
key: 'blockChain',
icon: 'shanglian',
text: '上链',
callback: this.blockChainProof,
},
edit: {
key: 'edit',
icon: 'bianji2x',
text: '编辑',
callback: this.goProofDetail,
},
del: {
key: 'del',
icon: 'shanchu2x',
text: '移至回收站',
callback: this.delProof,
},
copy: {
key: 'copy',
icon: 'chuangjianfuben2x',
text: '创建副本',
callback: this.copyProof,
},
blockquery: {
key: 'blockquery',
icon: 'qukuailianchaxun2x',
text: '区块链查询',
callback: this.goToBrowser,
},
viewQrCode: {
key: 'viewQrCode',
icon: 'chakanerweima2x',
text: '查看二维码',
callback: this.goToQrCodePage,
},
copyhash: {
key: 'copyhash',
icon: 'fuzhiHASHdizhi2x',
text: '复制hash地址',
callback: this.copyHash,
},
del2: {
key: 'del2',
icon: 'shanchu2x',
text: '移至回收站',
callback: this.abandonProof,
},
zengliang: {
key: 'zengliang',
icon: 'shanglian',
text: '增量更新',
callback: this.increment,
},
hide: {
key: 'hide',
icon: 'yinsishezhi2x',
text: '隐私设置',
callback: this.hide,
},
};
protected resetList() {
throw Error('resetList 在列表实现');
}
private goToQrCodePage(proof: any) {
const locationUrl = this.getProofViewingWebSite(proof);
this.$router.push({
name: 'ViewCode',
query: {
locationUrl,
},
});
}
private abandonProof(proof: any) {
/* 接受到的proof是存证的所有信息 */
/* 存证包含了
@Inject('goToBrowser') protected goToBrowser!: (proof: any) => void;
@Inject('getProofViewingWebSite') protected getProofViewingWebSite!: (
proof: any,
) => string;
protected baseProof: any = '';
protected preProof: any = '';
/* 是否是增量 */
protected isZengliang: boolean = false;
/* 添加存证框是否显示 */
protected showAddProof: boolean = false;
/* 动作列表 */
protected ActionList: any = {
blockChain: {
key: 'blockChain',
icon: 'shanglian',
text: '上链',
callback: this.blockChainProof,
},
edit: {
key: 'edit',
icon: 'bianji2x',
text: '编辑',
callback: this.goProofDetail,
},
del: {
key: 'del',
icon: 'shanchu2x',
text: '移至回收站',
callback: this.delProof,
},
copy: {
key: 'copy',
icon: 'chuangjianfuben2x',
text: '创建副本',
callback: this.copyProof,
},
blockquery: {
key: 'blockquery',
icon: 'qukuailianchaxun2x',
text: '区块链查询',
callback: this.goToBrowser,
},
viewQrCode: {
key: 'viewQrCode',
icon: 'chakanerweima2x',
text: '查看二维码',
callback: this.goToQrCodePage,
},
copyhash: {
key: 'copyhash',
icon: 'fuzhiHASHdizhi2x',
text: '复制hash地址',
callback: this.copyHash,
},
del2: {
key: 'del2',
icon: 'shanchu2x',
text: '移至回收站',
callback: this.abandonProof,
},
zengliang: {
key: 'zengliang',
icon: 'shanglian',
text: '增量更新',
callback: this.increment,
},
hide: {
key: 'hide',
icon: 'yinsishezhi2x',
text: '隐私设置',
callback: this.hide,
},
};
protected resetList() {
throw Error('resetList 在列表实现');
}
private goToQrCodePage(proof: any) {
const locationUrl = this.getProofViewingWebSite(proof);
this.$router.push({
name: 'ViewCode',
query: {
locationUrl,
},
});
}
private abandonProof(proof: any) {
/* 接受到的proof是存证的所有信息 */
/* 存证包含了
遗弃标志
创建时间
存证详细内容
......@@ -103,118 +105,140 @@ export default class Proof extends Vue {
更新时间
用户id
*/
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'});
});
}
if (err.code === 10702) {
this.$dialog.confirm({
title: '提示',
message: '剩余上链次数不足,请充值',
confirmButtonText: '去充值',
cancelButtonText: '取消',
}).then(() => {
this.$router.push({
name: 'Recharge',
});
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' });
});
}
if (err.code === 10702) {
this.$dialog
.confirm({
title: '提示',
message: '剩余上链次数不足,请充值',
confirmButtonText: '去充值',
cancelButtonText: '取消',
})
.then(() => {
this.$router.push({
name: 'Recharge',
});
}
});
});
}
});
});
}
private goProofDetail(proof: any) {
const { id: proofId } = proof;
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 } });
}
private goProofDetail(proof: any) {
const { id: proofId } = proof;
const toBlockStatuss: ChainStatus[] = [
ChainStatus.SUCCESS,
ChainStatus.HIDED,
ChainStatus.HIDING,
ChainStatus.HIDEFAILURE,
];
if (toBlockStatuss.includes(proof.status) ) {
this.goToBrowser(proof);
}
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 {
this.$router.push({ name: 'ProofDetail', query: { proofId }});
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;
}
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;
this.baseProof = proof;
this.showAddProof = true;
this.isZengliang = true;
this.$router.push({
name: 'ProofList',
query: {
preProof: JSON.stringify(this.preProof),
baseProof: JSON.stringify(this.baseProof),
},
});
}
private async hide(proof: any) {
this.$dialog.confirm({
title: '提示',
message: '隐藏该存证后,区块链列表不做展示,确定要隐藏吗?',
beforeClose: async (action, done) => {
if (action === 'confirm') {
await this.$api.proof.deleteBlockChainProof(proof.id);
this.$toast('隐藏提交成功');
done();
} else {
this.preProof = proof;
done();
}
this.baseProof = proof;
this.showAddProof = true;
this.isZengliang = true;
this.$router.push({
name: 'ProofList',
query: {
preProof: JSON.stringify(this.preProof),
baseProof: JSON.stringify(this.baseProof),
},
});
}
private async hide(proof: any) {
await this.$api.proof.deleteBlockChainProof(proof.id);
this.$toast('隐藏成功');
this.resetList();
}
},
});
}
}
......@@ -139,7 +139,7 @@ export default class Index extends Mixins(TemplateMixin) {
return [edit, rename, move, copy, del];
}
}
private async getUserFolders() {
private async getTemplateListByFolderId() {
const id = +this.id;
const res = await this.$api.template.list({ id: [id] });
this.list = res.results[0].detail || [];
......@@ -147,7 +147,7 @@ export default class Index extends Mixins(TemplateMixin) {
private async callbackAction(cb: any) {
// cb是什么东西?
this.isShowRename = await cb.call(this, this.currentTem);
this.getUserFolders();
this.getTemplateListByFolderId();
}
private getTemplateById(id: number){
......@@ -162,7 +162,7 @@ export default class Index extends Mixins(TemplateMixin) {
private async onConfirm() {
const params = this.currentTem;
await this.$api.template.updateCustomize(params);
this.getUserFolders();
this.getTemplateListByFolderId();
}
private handleClickMoveToCurrent() {
......@@ -177,7 +177,7 @@ export default class Index extends Mixins(TemplateMixin) {
.then(() => {
this.setMovedTemplateId(null);
Toast('移动成功');
this.getUserFolders();
this.getTemplateListByFolderId();
});
}
}
......
......@@ -118,6 +118,10 @@ export default class BaseInfo extends Vue {
this.showSelectFolder = false;
this.folder = value;
}
private onPickerChange(picker: any, value: any, index: number){
console.log(index);
}
private handleFileChange(e: any) {
const [file] = e.target.files;
if (file) {
......
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