import config from "@/config"
import http from "@/utils/request"
import tool from '@/utils/tool'

export default {
    token: {
        url: `${config.API_URL}/zcxt/auth/login`,
        name: "登录获取TOKEN",
        post: async function (data = {}) {
            const query = {
                username: data.user,
                password: tool.crypto.encrypt(data.password),
                code: data.code,
                uuid: data.uuid
            }
            return await http.post(this.url, query);
        }
    },

    codeImg: {
        url: `${config.API_URL}/zcxt/auth/code`,
        name: "获取登录验证码",
        get: async function () {
            return await http.get(this.url);
        }
    },

    updatePassword: {
        url: `${config.API_URL}/zcxt/users/updatePass`,
        name: "修改密码",
        post: async function (data = {}) {
            const query = {
                oldPass: tool.crypto.encrypt(data.userPassword),
                newPass: tool.crypto.encrypt(data.newPassword)
            }
            return await http.post(this.url, query);
        }
    },

    oa: {
        url: `${config.API_URL}/zcxt/oa`,
        name: "oa跳转 单点登录 -> 获取token user",

        getUserToken: async function (data = {}) {
            return await http.post(`${this.url}/getUserToken`, data);
        },

        updateStatus: async function (data = {}) {
            return await http.post(`${this.url}/updateStatus`, data);
        }
    },

    gldMaster: {
        url: `${config.API_URL}/zcxt/gldMaster`,
        name: "审批流参数",

        getToken: async function (data = {}) { // 获取审批流 参数
            return await http.post(`${this.url}/getToken`, data);
        },

        removeToken: async function () {
            return await http.get(`${this.url}/removeToken`);
        },

        getFormId: async function (data = {}) { // 获取审批流 formId
            return await http.post(`${this.url}/getFormId`, data);
        },

        getUserDeptList: async function (data = {}) {
            return await http.post(`${this.url}/getUserDeptList`, data);
        }
    }
}