156 lines
4.4 KiB
JavaScript
156 lines
4.4 KiB
JavaScript
import { observable, action, toJS } from "mobx";
|
|
import { message } from "antd";
|
|
import { WeaForm, WeaTableNew } from "comsMobx";
|
|
import moment from "moment";
|
|
|
|
import * as API from "../apis/taxAgent"; // 引入API接口文件
|
|
import { columns } from "../pages/socialSecurityBenefits/archives/columns";
|
|
import { dataSource } from "../pages/mySalary/columns";
|
|
import { editConditions } from "../pages/taxAgent/editConditions";
|
|
|
|
const { TableStore } = WeaTableNew;
|
|
|
|
export class TaxAgentStore {
|
|
@observable tableStore = new TableStore(); // new table
|
|
@observable form = new WeaForm(); //表单实体
|
|
@observable condition = []; // 存储后台得到的form数据
|
|
@observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
|
|
@observable showSearchAd = false; // 高级搜索面板显示
|
|
@observable loading = false; // 数据加载状态
|
|
@observable modalVisiable = false; // EditModal 模态框
|
|
@observable columns = [];
|
|
@observable pageObj = {}; //列表数据
|
|
@observable dataSource = []; //列表数据
|
|
@observable taxAgentOption = []; // 个税扣缴义务人
|
|
|
|
@action
|
|
setModalVisiable = (visiable) => (this.modalVisiable = visiable);
|
|
|
|
@action
|
|
setColumns = (columns) => (this.columns = columns);
|
|
|
|
@action
|
|
setPageObj = (pageObj) => (this.pageObj = pageObj);
|
|
|
|
@action
|
|
setDataSource = (dataSource) => (this.dataSource = dataSource);
|
|
|
|
// 初始化操作
|
|
@action
|
|
doInit = (params) => {
|
|
this.getTaxAgentList(params);
|
|
this.getCondition(editConditions);
|
|
};
|
|
|
|
// 获得高级搜索表单数据
|
|
@action
|
|
getCondition = (condition) => {
|
|
this.form.initFormFields(condition);
|
|
};
|
|
|
|
// 渲染table数据
|
|
@action
|
|
getTaxAgentList = (params) => {
|
|
this.loading = true;
|
|
params = params || {};
|
|
API.getTaxAgentList(params).then(
|
|
action(({ data, status }) => {
|
|
this.loading = false;
|
|
if (status) {
|
|
// 接口请求成功/失败处理
|
|
const { columns, list, total, pageNum: current, pageSize } = data;
|
|
this.setColumns(columns);
|
|
this.setDataSource(list);
|
|
this.setPageObj({
|
|
total,
|
|
current,
|
|
pageSize,
|
|
});
|
|
} else {
|
|
message.error(res.msg || "接口调用失败!");
|
|
}
|
|
})
|
|
);
|
|
};
|
|
|
|
@action
|
|
setShowSearchAd = (bool) => (this.showSearchAd = bool);
|
|
|
|
// 高级搜索 - 搜索
|
|
@action doSearch = (name) => {
|
|
this.getTaxAgentList({ name });
|
|
this.showSearchAd = false;
|
|
};
|
|
|
|
// 新增
|
|
@action saveTaxAgent = (params) => {
|
|
return API.saveTaxAgent(params);
|
|
};
|
|
|
|
// 更新
|
|
@action updateTaxAgent = (params) => {
|
|
return API.updateTaxAgent(params);
|
|
};
|
|
|
|
// 获取个税扣缴义务人基础信息表单
|
|
@action getTaxAgentBaseForm = (params) => {
|
|
return API.getTaxAgentBaseForm(params);
|
|
};
|
|
|
|
// 获取个税扣缴义务人表单
|
|
@action getTaxAgentForm = (params) => {
|
|
return API.getTaxAgentForm(params);
|
|
};
|
|
|
|
// 保存个税扣缴义务人基础信息
|
|
@action taxAgentBaseSave = (params) => {
|
|
return API.taxAgentBaseSave(params);
|
|
};
|
|
|
|
@action deleteTaxAgent = (params) => {
|
|
return API.deleteTaxAgent(params);
|
|
};
|
|
|
|
@action getPermission = (params) => {
|
|
return API.getPermission(params);
|
|
};
|
|
// 人员范围列表
|
|
@action getTaxAgentRangeListInclude = (params) => {
|
|
return API.getTaxAgentRangeListInclude(params);
|
|
};
|
|
// 人员范围排除列表
|
|
@action getTaxAgentRangeListExclude = (params) => {
|
|
return API.getTaxAgentRangeListExclude(params);
|
|
};
|
|
// 获取人员范围表单
|
|
@action getTaxAgentRangeForm = (params) => {
|
|
return API.getTaxAgentRangeForm(params);
|
|
};
|
|
// 人员范围保存
|
|
@action taxAgentRangeSave = (params) => {
|
|
return API.taxAgentRangeSave(params);
|
|
};
|
|
// 人员范围删除
|
|
@action taxAgentRangeDelete = (params) => {
|
|
return API.taxAgentRangeDelete(params);
|
|
};
|
|
|
|
@action fetchTaxAgentOption = () => {
|
|
return new Promise((resolve, reject) => {
|
|
API.getTaxAgentSelectList().then(
|
|
action((res) => {
|
|
if (res.status) {
|
|
this.taxAgentOption = res.data.map((item) => {
|
|
return { key: item.id, showname: item.content };
|
|
});
|
|
resolve();
|
|
} else {
|
|
message.error(res.errormsg || "获取失败");
|
|
reject();
|
|
}
|
|
})
|
|
);
|
|
});
|
|
};
|
|
}
|