import axios from '@/utils/http';
const base = process.env.VUE_APP_SERVER + '/proof';
const proof = {
    count() {
        return axios.get(`${base}/count`);
    },
    list(page: number, params: any) {
        return axios.post(`${base}/list`, {
            is_valid: 0,
            status: [],
            key_words: '',
            page,
            page_size: 20,
            ...params,
        });
    },
    get(id: number, params: any) {
        return axios.get(`${base}/get?id=${id}`, {
            ...params,
        });
    },
    add(name: string, detailInformation: any, note: string, params: any) {
        return axios.post(`${base}/add`, {
            name,
            detail: JSON.stringify(detailInformation),
            note,
            ...params,
         });
    },
    update(id: number, name: string, detailInformation: any, note: string, params: any = {}) {
        return axios.put(`${base}/update`, {
            id,
            name,
            detail: JSON.stringify(detailInformation),
            note,
            ...params,
        });
    },
    delete(id: number, params: any = {}) {
        return axios.delete(`${base}/delete`, {
            data: {
                id,
            },
            ...params,
        });
    },
    abandon(id: number, abandonRemark: string, params: any = {}) {
        return axios.post(`${base}/abandon`, {
            id,
            abandon_remark: abandonRemark,
            ...params,
        });
    },
    sendBlockChian(id: number, params: any = {}) {
        return axios.post(`${base}/sendBlockChain`, {
            id,
            ...params,
        });
    },
    abolishBlockChain(id: number, note: string, params: any = {}) {
        return axios.post(`${base}/abolishBlockChain`, {
            id,
            note,
            ...params,
        });
    },
    incrementList(baseHash: string) {
        return axios.post(`${base}/increment/list`, {
            base_hash: baseHash,
            page: 1,
            page_size: 20,
        });
    },
    incrementAdd(baseProofId: number, baseProofHash: string, preProofHash: string, name: string, detailInformation: any,
                 note: string, params: any) {
        return axios.post(`${base}/increment/add`, {
            base_id: baseProofId,
            base_hash: baseProofHash,
            pre_hash: preProofHash,
            name,
            detail: JSON.stringify(detailInformation),
            note,
            ...params,
        });
    },
    incrementGet(id: number) {
        return axios.get(`${base}/increment/${id}`);
    },
    incrementDelete(id: number) {
        return axios.delete(`${base}/increment/${id}`);
    },
    incrementEdit(id: number, name: string,
                  detailInformation: string, note: string, params: any) {
        return axios.put(`${base}/increment/${id}`, {
            id,
            name,
            detail: JSON.stringify(detailInformation),
            note,
            ...params,
        });
    },
    incrementSendBlockChain(id: number) {
        return axios.post(`${base}/increment/sendBlockChain`, {
            id,
        });
    },
};
export default proof;
