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

207 lines
5.9 KiB
JavaScript
Raw Normal View History

2022-06-02 14:48:55 +08:00
import { observable, action, toJS } from "mobx";
import { message } from "antd";
import { WeaForm, WeaTableNew } from "comsMobx";
import { removePropertyCondition } from "../util/response";
2022-03-11 10:44:42 +08:00
2022-06-02 14:48:55 +08:00
import * as API from "../apis/otherDeduct"; // 引入API接口文件
2022-03-11 10:44:42 +08:00
const { TableStore } = WeaTableNew;
export class OtherDeductStore {
@observable tableStore = new TableStore(); // new table
@observable slideTableStore = new TableStore();
2022-10-24 18:42:15 +08:00
@observable form = new WeaForm(); // new 一个form
@observable addForm = new WeaForm(); // 新增form
2022-03-11 10:44:42 +08:00
@observable condition = []; // 存储后台得到的form数据
@observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
@observable showSearchAd = false; // 高级搜索面板显示
@observable loading = true; // 数据加载状态
2022-06-02 14:48:55 +08:00
@observable slideLoading = true; // 详情数据加载状态
2022-03-11 10:44:42 +08:00
@observable step = 0; // 当前所在第几步
@observable slideVisiable = false; // slide 是否隐藏
@observable slideDataSource = [];
2022-06-02 14:48:55 +08:00
@observable importResult = {};
2022-03-11 10:44:42 +08:00
@observable modalVisiable = false; // 模态框显示
@observable currentRecord = {}; // 当前record
2022-06-02 14:48:55 +08:00
@observable columns = [];
@observable pageObj = {}; //列表数据
@observable dataSource = []; //列表数据
@observable slideColumns = []; //详情列数据
@observable slidePageObj = {}; //详情分页列表数据
@observable slideTableDataSource = []; //详情列表数据
// ** 设置导入参数 start **
2022-05-12 17:04:33 +08:00
@action
setSlideDataSource = (slideDataSource) => {
2022-06-02 14:48:55 +08:00
this.slideDataSource = slideDataSource;
};
2022-05-12 17:04:33 +08:00
@action
setImportResult = (importResult) => {
2022-06-02 14:48:55 +08:00
this.importResult = importResult;
};
@action
setColumns = (columns) => (this.columns = columns);
@action
setPageObj = (pageObj) => (this.pageObj = pageObj);
2022-05-12 17:04:33 +08:00
2022-03-11 10:44:42 +08:00
@action
2022-06-02 14:48:55 +08:00
setDataSource = (dataSource) => (this.dataSource = dataSource);
2022-03-11 10:44:42 +08:00
2022-06-02 14:48:55 +08:00
// 详情列表数据
2022-03-11 10:44:42 +08:00
@action
2022-06-02 14:48:55 +08:00
setSlideColumns = (columns) => (this.slideColumns = columns);
2022-03-11 10:44:42 +08:00
@action
2022-06-02 14:48:55 +08:00
setSlidePageObj = (pageObj) => (this.slidePageObj = pageObj);
2022-03-11 10:44:42 +08:00
@action
2022-06-02 14:48:55 +08:00
setSlideTableDataSource = (dataSource) =>
(this.slideTableDataSource = dataSource);
2022-03-11 10:44:42 +08:00
2022-06-02 14:48:55 +08:00
// ** 设置导入参数 end **
@action
setCurrentRecord = (currentRecord) => (this.currentRecord = currentRecord);
@action
setModalVisiable = (visiable) => (this.modalVisiable = visiable);
@action
setStep = (step) => (this.step = step);
@action
setSlideVisiable = (slideVisiable) => (this.slideVisiable = slideVisiable);
2022-03-11 10:44:42 +08:00
// 初始化操作
@action
2022-06-16 21:59:29 +08:00
doInit = (params = {}) => {
2022-03-11 10:44:42 +08:00
this.getCondition();
2022-06-16 21:59:29 +08:00
this.getTableDatas(params);
2022-06-02 14:48:55 +08:00
};
2022-03-11 10:44:42 +08:00
// 获得高级搜索表单数据
@action
getCondition = () => {
2022-06-02 14:48:55 +08:00
API.getOtherDeductSaCondition().then(
action((res) => {
if (res.status) {
// 接口请求成功/失败处理
let condition = removePropertyCondition(res.data.condition);
this.condition = condition;
this.form.initFormFields(condition); // 渲染高级搜索form表单
} else {
message.error(res.errormsg || "接口调用失败!");
}
})
);
};
2022-03-11 10:44:42 +08:00
// 渲染table数据
@action
getTableDatas = (params) => {
params = params || {};
this.loading = true;
let requestParams = this.form.getFormParams() || {};
2022-06-02 14:48:55 +08:00
requestParams = { ...requestParams, ...params };
API.getOtherDeductList(requestParams).then(
action(({ status, data, errormsg }) => {
if (status) {
const { columns, list, total, pageNum: current, pageSize } = data;
this.setColumns(columns);
this.setDataSource(list);
this.setPageObj({
total,
current,
pageSize,
});
} else {
this.setDataSource([]);
this.setPageObj({
...this.pageObj,
total: 0,
});
message.error(errormsg || "接口调用失败!");
}
this.loading = false;
})
);
};
2022-03-11 10:44:42 +08:00
@action
2022-06-02 14:48:55 +08:00
setShowSearchAd = (bool) => (this.showSearchAd = bool);
2022-03-11 10:44:42 +08:00
// 高级搜索 - 搜索
@action doSearch = (params) => {
this.getTableDatas(params);
2022-03-11 10:44:42 +08:00
this.showSearchAd = false;
2022-06-02 14:48:55 +08:00
};
2022-03-11 10:44:42 +08:00
// 导入
@action importFile = (params) => {
2022-06-02 14:48:55 +08:00
API.importOtherDeductionParam(params).then(
action((res) => {
if (res.status) {
this.importResult = res.data;
} else {
message.error(res.errormsg || "接口调用失败!");
}
})
);
};
2022-03-11 10:44:42 +08:00
// 导入预览
@action previewImport = (params) => {
2022-06-02 14:48:55 +08:00
API.importOtherDeductionPreview(params).then(
action((res) => {
if (res.status) {
this.slideDataSource = res.data.preview;
} else {
message.error(res.errormsg || "接口调用失败!");
}
})
);
};
2022-03-11 10:44:42 +08:00
// 导出
2022-03-11 17:19:25 +08:00
@action exportOtherDeductList = (ids = "") => {
2022-06-02 14:48:55 +08:00
API.exportOtherDeductList(ids);
};
2022-03-11 10:44:42 +08:00
// 查询明细
2022-03-11 17:19:25 +08:00
@action getOtherDeductDetailList = (id, param = {}) => {
2022-06-02 14:48:55 +08:00
let requestParams = { otherTaxExemptDeductionId: id };
requestParams = { ...requestParams, ...param };
this.slideLoading = true;
API.getOtherDeductDetailList(requestParams).then(
({ status, data, errormsg }) => {
if (status) {
const { columns, list, total, pageNum: current, pageSize } = data;
this.setSlideColumns(columns);
this.setSlideTableDataSource(list);
this.setSlidePageObj({
total,
current,
pageSize,
});
2022-03-11 10:44:42 +08:00
} else {
2022-06-02 14:48:55 +08:00
this.setSlideTableDataSource([]);
this.setSlidePageObj({
...this.slidePageObj,
total: 0,
});
message.error(errormsg || "接口调用失败!");
2022-03-11 10:44:42 +08:00
}
2022-06-10 17:29:46 +08:00
this.slideLoading = false
2022-03-11 10:44:42 +08:00
}
2022-06-02 14:48:55 +08:00
);
};
2022-03-11 10:44:42 +08:00
// 导出明细
@action exportOtherDeductDetailList = (id, ids = "", taxAgentId="") => {
API.exportOtherDeductDetailList(id, ids, taxAgentId);
2022-06-02 14:48:55 +08:00
};
}