/*
 * @Author: Kane
 * @Date: 2023-02-04 15:48:00
 * @LastEditors: Kane
 * @LastEditTime: 2023-02-22 17:08:26
 * @FilePath: /IT工具综合平台/src/utils/api/requirement/requirement.js
 * @Description: 
 * 
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 */
import instance from "@/utils/api/request";
import { API_URL } from "@/utils/api/config";
import router from "@/router/index";

/*****************************************************
 * 从后台获取需求管理页面所需数据，存放到vuex中。
 * @param ui 保存ui标志位的对象
 * @param store 保存在vuex中需求相关的对象
 * @param {string} error_page_name 提示错误页面的路径
 *****************************************************/
function query_requirement_ui(requirement_store, error_page_name)
{
    //发送请求
    instance.request(
        {
            method: "post",
            url: API_URL.URL_QUERY_REQUIREMENT_STATUS,
        })
        .then((response) =>
        {
            const data = response.data;

            if (data.success === true)
            {
                requirement_store.status = data.requirement_status;
            }
        })
        .catch((error) =>
        {
            console.log("获取需求后台数据失败", error);
            router.push(
                {
                    name: error_page_name,
                    query: {
                        error,
                    },
                });
        });
}

export { query_requirement_ui };