import {observable, action} from "mobx"; import {API} from "../../constants/api"; import { IResponse, NetworkService } from '../../services/networkService'; import {RespConstant} from "../../constants/resp.constant"; import {CallbackUtils} from '../../services/callbackUtils'; import {dateFormat} from "../../services/utilService"; import {HealthResponse, IHealthStore, HealthTableData} from './HealthInterface';
class HealthStore implements IHealthStore {
/**
* 页首-检查详情 /check/queryTask.json
*/
@observable queryTaskLoading: boolean = false;
@observable queryTaskResult = {};
@action
public changeQueryTaskLoading = (value: boolean): void => {
this.queryTaskLoading = value;
};
@action
public queryTask = async (stage: string, domainAppId: string, appName: string): Promise<void> => {
this.changeQueryTaskLoading(true);
try {
const resp: HealthResponse<any> = await NetworkService.getInstance().send<HealthResponse<any>>(
{
url: API.QUERY_TASK,
data: {
stage,
domainAppId,
appName,
}
}
);
if (resp.respCode===RespConstant.Code.SUCCESS){
this.queryTaskResult = resp.respData
this.changeQueryTaskLoading(false);
}
} catch (err) {
CallbackUtils.dealOnError(err);
}
};
@observable HealthInfoList: HealthTableData[] = [];
@action
public removeHealth = async (currentId: string[], userId: string): Promise<void> => {
try {
const resp: HealthResponse = await NetworkService.getInstance().send<HealthResponse>(
{
url: API.DELETE_Health,
data: {
artifactIds: currentId,
updateUser: userId
}
});
if (resp.respCode===RespConstant.Code.SUCCESS){
await this.queryHealthInfoList(true);
}
} catch (err) {
CallbackUtils.dealOnError(err);
}
}
}
const HealthStoreInstance = new HealthStore(); export {HealthStoreInstance};