import { observable, action, toJS } from "mobx"; import { message } from "antd"; import { WeaForm, WeaTableNew } from "comsMobx"; import { removePropertyCondition } from "../util/response"; import * as API from "../apis/otherDeduct"; // 引入API接口文件 const { TableStore } = WeaTableNew; export class OtherDeductStore { @observable tableStore = new TableStore(); // new table @observable slideTableStore = new TableStore(); @observable form = new WeaForm(); // new 一个form @observable addForm = new WeaForm(); // 新增form @observable condition = []; // 存储后台得到的form数据 @observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据 @observable showSearchAd = false; // 高级搜索面板显示 @observable loading = true; // 数据加载状态 @observable slideLoading = true; // 详情数据加载状态 @observable step = 0; // 当前所在第几步 @observable slideVisiable = false; // slide 是否隐藏 @observable slideDataSource = []; @observable importResult = {}; @observable modalVisiable = false; // 模态框显示 @observable currentRecord = {}; // 当前record @observable columns = []; @observable pageObj = {}; //列表数据 @observable dataSource = []; //列表数据 @observable slideColumns = []; //详情列数据 @observable slidePageObj = {}; //详情分页列表数据 @observable slideTableDataSource = []; //详情列表数据 // ** 设置导入参数 start ** @action setSlideDataSource = (slideDataSource) => { this.slideDataSource = slideDataSource; }; @action setImportResult = (importResult) => { this.importResult = importResult; }; @action setColumns = (columns) => (this.columns = columns); @action setPageObj = (pageObj) => (this.pageObj = pageObj); @action setDataSource = (dataSource) => (this.dataSource = dataSource); // 详情列表数据 @action setSlideColumns = (columns) => (this.slideColumns = columns); @action setSlidePageObj = (pageObj) => (this.slidePageObj = pageObj); @action setSlideTableDataSource = (dataSource) => (this.slideTableDataSource = dataSource); // ** 设置导入参数 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); // 初始化操作 @action doInit = (params = {}) => { this.getCondition(); this.getTableDatas(params); }; // 获得高级搜索表单数据 @action getCondition = () => { 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 || "接口调用失败!"); } }) ); }; // 渲染table数据 @action getTableDatas = (params) => { params = params || {}; this.loading = true; let requestParams = this.form.getFormParams() || {}; 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; }) ); }; @action setShowSearchAd = (bool) => (this.showSearchAd = bool); // 高级搜索 - 搜索 @action doSearch = (params) => { this.getTableDatas(params); this.showSearchAd = false; }; // 导入 @action importFile = (params) => { API.importOtherDeductionParam(params).then( action((res) => { if (res.status) { this.importResult = res.data; } else { message.error(res.errormsg || "接口调用失败!"); } }) ); }; // 导入预览 @action previewImport = (params) => { API.importOtherDeductionPreview(params).then( action((res) => { if (res.status) { this.slideDataSource = res.data.preview; } else { message.error(res.errormsg || "接口调用失败!"); } }) ); }; // 导出 @action exportOtherDeductList = (ids = "") => { API.exportOtherDeductList(ids); }; // 查询明细 @action getOtherDeductDetailList = (id, param = {}) => { 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, }); } else { this.setSlideTableDataSource([]); this.setSlidePageObj({ ...this.slidePageObj, total: 0, }); message.error(errormsg || "接口调用失败!"); } this.slideLoading = false } ); }; // 导出明细 @action exportOtherDeductDetailList = (id, ids = "", taxAgentId="") => { API.exportOtherDeductDetailList(id, ids, taxAgentId); }; }