// 警员管理

import axios from "@/utils/req";
import request from "@/utils/request";

export const base = "/usersvr/v2/police";

export const table = `${base}s`;

// 新增数据
export function saveForm(data) {
    return axios.post(base, data);
}

// 更新数据
export function updateForm(data) {
    return axios.put(`${base}/${data.id}`, data);
}

// 获取编号
export function getNumber() {
    return axios.get(`${base}/number`);
}

// 获取详情
export function detail(id) {
    return axios.get(`${base}/${id}`);
}

// 删除数据
export function del(id) {
    return axios.delete(`${base}/${id}`);
}

// 数据排序
export function sort(data) {
    return axios.post(`${base}/sort`, data);
}

// 导出数据
export function exports(params = {}, option) {
    return axios.arraybuffer(`${base}/exports`, params, option);
}

// 批量导出数据
export function batchExport(orgIds) {
    return axios.arraybuffer(`${base}/batchExports`, { orgIds }, { method: "post" });
}

export function saveBusiness(data) {
    return axios.post(`${base}/business`, data, { loading: true });
}

export function checkBusiness(data) {
    return axios.post(`${base}/businessInclude`, data, { loading: true });
}

export function dataBusiness(data) {
    return axios.post(`${base}/businessUser`, data);
}

// 业务域
export function businessDetail(params) {
    return new Promise((resolve, reject) => {
        request
            .get(`duacm/codeSon/v2/searchColumn`, {
                params: params
            })
            .then((data = {}) => {
                resolve(data.data);
            })
            .catch(error => {
                reject(error);
            });
    });
}
