salary-management-front/pc4mobx/hrmSalary/stores/declare.js

147 lines
4.1 KiB
JavaScript
Raw Normal View History

2023-02-13 10:41:40 +08:00
import { action, observable } from "mobx";
import { message } from "antd";
import { WeaForm, WeaTableNew } from "comsMobx";
2022-04-20 15:28:40 +08:00
2023-02-13 10:41:40 +08:00
import * as API from "../apis/declare"; // 引入API接口文件
2022-04-20 15:28:40 +08:00
const { TableStore } = WeaTableNew;
export class DeclareStore {
@observable tableStore = new TableStore(); // new table
@observable form = new WeaForm(); // nrew 一个form
@observable condition = []; // 存储后台得到的form数据
@observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
@observable showSearchAd = false; // 高级搜索面板显示
@observable loading = true; // 数据加载状态
// 列表
@observable listDataSource = [];
@observable listColumns = [];
2023-02-13 10:41:40 +08:00
@observable pageInfo = {};
2022-04-20 15:28:40 +08:00
// 详情页
@observable declareInfo = {}; // 详情基本信息
@observable detailTableStore = new TableStore();
@observable detailDataSource = [];
@observable datailColumns = [];
2023-02-13 10:41:40 +08:00
@observable detailPageInfo = {};
2022-04-20 15:28:40 +08:00
2023-02-13 10:41:40 +08:00
@action setPageinfo = pageinfo => this.pageInfo = pageinfo;
2022-04-20 15:28:40 +08:00
// 初始化操作
@action
doInit = () => {
this.getCondition();
this.getTableDatas();
2023-02-13 10:41:40 +08:00
};
2022-04-20 15:28:40 +08:00
// 获得高级搜索表单数据
@action
getCondition = () => {
API.getCondition().then(action(res => {
if (res.api_status) { // 接口请求成功/失败处理
this.condition = res.condition;
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
} else {
2023-02-13 10:41:40 +08:00
message.error(res.msg || "接口调用失败!");
2022-04-20 15:28:40 +08:00
}
}));
2023-02-13 10:41:40 +08:00
};
2022-04-20 15:28:40 +08:00
// 渲染table数据
@action
getTableDatas = (params) => {
this.loading = true;
const formParams = this.form.getFormParams() || {};
params = params || formParams;
API.getTableDatas(params).then(action(res => {
if (res.api_status) { // 接口请求成功/失败处理
this.tableStore.getDatas(res.datas); // table 请求数据
this.hasRight = res.hasRight;
} else {
2023-02-13 10:41:40 +08:00
message.error(res.msg || "接口调用失败!");
2022-04-20 15:28:40 +08:00
}
this.loading = false;
}));
2023-02-13 10:41:40 +08:00
};
2022-04-20 15:28:40 +08:00
@action
setShowSearchAd = bool => this.showSearchAd = bool;
// 高级搜索 - 搜索
@action doSearch = () => {
this.getTableDatas();
this.showSearchAd = false;
2023-02-13 10:41:40 +08:00
};
2022-04-20 15:28:40 +08:00
//个税申报表-个税申报表列表
@action
getDeclareList = (params = {}) => {
2023-02-13 10:41:40 +08:00
this.loading = true;
2022-04-20 15:28:40 +08:00
API.getDeclareList(params).then(res => {
2023-02-13 10:41:40 +08:00
if (res.status) {
this.listDataSource = res.data.list ? res.data.list : [];
this.listColumns = res.data.columns;
// this.setPageinfo({...this.pageInfo, })
this.pageInfo = res.data;
2022-04-20 15:28:40 +08:00
} else {
2023-02-13 10:41:40 +08:00
message.error(res.errormsg || "获取失败");
2022-04-20 15:28:40 +08:00
}
2023-02-13 10:41:40 +08:00
this.loading = false;
});
};
2022-04-20 15:28:40 +08:00
//个税申报表-个税申报表生成
@action
2022-06-07 18:24:05 +08:00
saveDeclare = (params) => {
2022-04-20 15:28:40 +08:00
return new Promise((resolve, reject) => {
2023-02-13 10:41:40 +08:00
this.loading = true;
2022-06-07 18:24:05 +08:00
API.saveDeclare(params).then(res => {
2023-02-13 10:41:40 +08:00
this.loading = false;
if (res.status) {
message.success("生成成功");
2022-04-20 15:28:40 +08:00
resolve();
} else {
2023-02-13 10:41:40 +08:00
message.error(res.errormsg || "生成失败");
reject();
2022-04-20 15:28:40 +08:00
}
2023-02-13 10:41:40 +08:00
});
});
2022-10-26 18:40:25 +08:00
2023-02-13 10:41:40 +08:00
};
2022-04-20 15:28:40 +08:00
//个税申报表-个税申报表相关信息
@action
getDeclareInfo = (taxDeclarationId) => {
2023-02-13 10:41:40 +08:00
API.getDeclareInfo({ taxDeclarationId }).then(res => {
if (res.status) {
this.declareInfo = res.data;
2022-04-20 15:28:40 +08:00
} else {
2023-02-13 10:41:40 +08:00
message.error(res.errormsg || "获取失败");
2022-04-20 15:28:40 +08:00
}
2023-02-13 10:41:40 +08:00
});
};
2022-04-20 15:28:40 +08:00
// 个税申报表详情列表
@action
2022-06-07 09:08:36 +08:00
getDetailList = (taxDeclarationIdStr, params = {}) => {
2023-02-13 10:41:40 +08:00
API.getDetailList({ taxDeclarationIdStr, ...params }).then(res => {
if (res.status) {
2022-06-10 14:21:07 +08:00
this.detailDataSource = res.data.list ? res.data.list : [];
2023-02-13 10:41:40 +08:00
this.datailColumns = res.data.columns;
this.detailPageInfo = res.data;
2022-04-20 15:28:40 +08:00
// this.detailTableStore.getDatas(res.data.dataKey.datas)
} else {
2023-02-13 10:41:40 +08:00
message.error(res.errrmsg || "获取失败");
2022-04-20 15:28:40 +08:00
}
2023-02-13 10:41:40 +08:00
});
};
2022-04-20 15:28:40 +08:00
// 个税申报表导出
@action
exportSalaryArchive = (id) => {
2023-02-13 10:41:40 +08:00
API.exportSalaryArchive(id);
};
2022-04-20 15:28:40 +08:00
2022-10-26 18:40:25 +08:00
}