138 lines
3.8 KiB
JavaScript
138 lines
3.8 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';
|
|
|
|
const { TableStore } = WeaTableNew;
|
|
|
|
export class TaxAgentStore {
|
|
@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 modalVisiable = false; // EditModal 模态框
|
|
|
|
@observable columns = [];
|
|
@observable dataSource = [];
|
|
@observable taxAgentOption = []; // 个税扣缴义务人
|
|
|
|
|
|
@action
|
|
setModalVisiable = visiable => this.modalVisiable = visiable;
|
|
|
|
@action
|
|
setColumns = columns => this.columns = columns;
|
|
|
|
@action
|
|
setDataSource = dataSource => this.dataSource = dataSource;
|
|
|
|
// 初始化操作
|
|
@action
|
|
doInit = () => {
|
|
this.getTableDatas();
|
|
}
|
|
|
|
// 获得高级搜索表单数据
|
|
@action
|
|
getCondition = () => {
|
|
API.getCondition().then(action(res => {
|
|
if (res.api_status) { // 接口请求成功/失败处理
|
|
this.condition = res.condition;
|
|
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
|
|
} else {
|
|
message.error(res.msg || '接口调用失败!')
|
|
}
|
|
}));
|
|
}
|
|
|
|
// 渲染table数据
|
|
@action
|
|
getTableDatas = (params) => {
|
|
this.loading = true;
|
|
params = params || {};
|
|
API.getTaxAgentList(params).then(action(res => {
|
|
if (res.status) { // 接口请求成功/失败处理
|
|
let current = this.tableStore.current || 1;
|
|
let sortParams = this.tableStore.sortParams.toJS() || [];
|
|
this.tableStore.getDatas(res.data.datas)
|
|
} else {
|
|
message.error(res.msg || '接口调用失败!')
|
|
}
|
|
this.loading = false;
|
|
}));
|
|
}
|
|
|
|
@action
|
|
setShowSearchAd = bool => this.showSearchAd = bool;
|
|
|
|
// 高级搜索 - 搜索
|
|
@action doSearch = (name) => {
|
|
this.getTableDatas({name});
|
|
this.showSearchAd = false;
|
|
}
|
|
|
|
// 新增
|
|
@action doInsert = (params) => {
|
|
API.saveTaxAgent(params).then(res => {
|
|
if(res.status) {
|
|
message.success("新增成功");
|
|
this.setModalVisiable(false)
|
|
this.getTableDatas();
|
|
this.showSearchAd = false;
|
|
} else {
|
|
message.error( res.errormsg || "新增失败");
|
|
}
|
|
})
|
|
}
|
|
|
|
// 更新
|
|
@action doUpdate = (params) => {
|
|
API.updateTaxAgent(params).then(res => {
|
|
if(res.status) {
|
|
message.success("更新成功");
|
|
this.setModalVisiable(false)
|
|
this.getTableDatas();
|
|
this.showSearchAd = false;
|
|
} else {
|
|
message.error(res.errormsg || "新增失败");
|
|
}
|
|
})
|
|
}
|
|
|
|
@action doDelete = (params) => {
|
|
API.deleteTaxAgent(params).then(res => {
|
|
if(res.status) {
|
|
message.success("删除成功");
|
|
this.setModalVisiable(false)
|
|
this.getTableDatas();
|
|
this.showSearchAd = false;
|
|
} else {
|
|
message.error( res.errormsg || "删除失败");
|
|
}
|
|
})
|
|
}
|
|
|
|
@action fetchTaxAgentOption = () => {
|
|
return new Promise((resolve, reject) => {
|
|
API.getTaxAgentSelectList().then(action(res => {
|
|
if(res.status) {
|
|
let options = res.data.list.map(item => {return {key: item.id, showname: item.content}})
|
|
this.taxAgentOption = options
|
|
resolve()
|
|
} else {
|
|
message.error(res.errormsg || "获取失败")
|
|
reject()
|
|
}
|
|
}))
|
|
})
|
|
|
|
}
|
|
|
|
} |