import {stringify} from 'qs';
import request from './../utils/request';

export async function queryReportCustomerData(params) {
    return request(
        `/customer/report_customer/?${stringify(params)}`,
    );
}

export async function queryReportDict() {
    return request(`/customer/dict/`);
}

export async function getUser() {
    return request(`/customer/get_user/`);
}

export async function dispatchUser(params) {
    let formdata = new FormData();
    formdata.append('user', params.user[0]);
    return request('/customer/report_customer/' + params.id + '/dispatch_customer/', {
        method: 'POST',
        body: formdata,
    });
}

export async function signRepeat(params) {
    return request('/customer/report_customer/' + params.id + '/sign_hit/', {
        method: 'POST',
    });
}

export async function saveReportCustomer(params) {
    let formdata = new FormData();
    formdata.append('name', params.name);
    formdata.append('gender', params.gender);
    formdata.append('tel', params.tel);
    formdata.append('village', params.village);
    formdata.append('address', params.address);
    formdata.append('source', params.source[0]);
    formdata.append('project', JSON.stringify(params.project));
    formdata.append('notes', params.notes);
    return request('/customer/report_customer/', {
        method: 'POST',
        body: formdata,
    });
}
