125 lines
3.8 KiB
JavaScript
125 lines
3.8 KiB
JavaScript
import { observable, action, toJS } from 'mobx';
|
|
import { message } from 'antd';
|
|
import { WeaForm, WeaTableNew } from 'comsMobx';
|
|
|
|
import * as API from '../apis/welfareScheme'; // 引入API接口文件
|
|
|
|
const { TableStore } = WeaTableNew;
|
|
|
|
export class ProgrammeStore {
|
|
@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 selectedKey = "SOCIAL_SECURITY";
|
|
@observable customSelectkey = ""
|
|
@observable defaultPersonDataSource = []; // 默认新增列表DataSource
|
|
@observable defaultCompanyDataSource = [];
|
|
@observable requestParams = {
|
|
schemeName: "",
|
|
remarks: "",
|
|
paymentArea: "1"
|
|
}
|
|
|
|
@action
|
|
setRequestParams = requestParams => this.requestParams;
|
|
|
|
@action
|
|
setDefaultPersonDataSource = defaultPersonDataSource => this.defaultPersonDataSource = defaultPersonDataSource;
|
|
|
|
@action
|
|
setDefaultCompanyDataSource = defaultCompanyDataSource => this.defaultCompanyDataSource = defaultCompanyDataSource;
|
|
|
|
@action
|
|
setCustomSelectkey = customSelectkey => this.customSelectkey = customSelectkey;
|
|
|
|
@action
|
|
setSelectedKey = selectedKey => this.selectedKey = selectedKey;
|
|
|
|
// 初始化操作
|
|
@action
|
|
doInit = () => {
|
|
this.getTableDatas();
|
|
// this.getCustomCategoryList();
|
|
}
|
|
|
|
// 获得高级搜索表单数据
|
|
@action
|
|
getCondition = () => {
|
|
API.getForm().then(action(res => {
|
|
if (res.status) { // 接口请求成功/失败处理
|
|
this.condition = res.condition;
|
|
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
|
|
} else {
|
|
message.error(res.msg || '接口调用失败!')
|
|
}
|
|
}));
|
|
}
|
|
|
|
// 渲染table数据
|
|
@action
|
|
getTableDatas = (selectKey = "SOCIAL_SECURITY", params) => {
|
|
this.loading = true;
|
|
const formParams = this.form.getFormParams() || {};
|
|
params = params || formParams;
|
|
params.welfareTypeEnum = selectKey
|
|
API.getTable(params).then(action(res => {
|
|
if (res.status) { // 接口请求成功/失败处理
|
|
this.tableStore.getDatas(res.data.datas); // table 请求数据
|
|
} else {
|
|
message.error(res.msg || '接口调用失败!')
|
|
}
|
|
this.loading = false;
|
|
}));
|
|
}
|
|
|
|
|
|
// 渲染自定义福利
|
|
@action
|
|
getCustomCategoryList = (selectKey = "SOCIAL_SECURITY", params) => {
|
|
this.loading = true;
|
|
const formParams = this.form.getFormParams() || {};
|
|
params = params || formParams;
|
|
params.welfareTypeEnum = selectKey
|
|
API.getCustomCategoryList(params).then(action(res => {
|
|
if (res.status) { // 接口请求成功/失败处理
|
|
this.tableStore.getDatas(res.data.datas); // table 请求数据
|
|
} else {
|
|
message.error(res.msg || '接口调用失败!')
|
|
}
|
|
this.loading = false;
|
|
}));
|
|
}
|
|
|
|
@action
|
|
setShowSearchAd = bool => this.showSearchAd = bool;
|
|
|
|
// 高级搜索 - 搜索
|
|
@action doSearch = () => {
|
|
this.getTableDatas();
|
|
this.showSearchAd = false;
|
|
}
|
|
|
|
// 获取form, 获取获取详情
|
|
@action getForm = (params) => {
|
|
API.getForm(params).then(res => {
|
|
if(res.status) {
|
|
let resultList = res.data.form.schemeDetailList;
|
|
this.defaultPersonDataSource = resultList.filter(item => item.paymentScope == "个人")
|
|
this.defaultCompanyDataSource = resultList.filter(item => item.paymentScope == "公司")
|
|
}
|
|
})
|
|
}
|
|
|
|
@action createScheme = (params) => {
|
|
API.createScheme(params).then(res => {
|
|
if(res.status) {
|
|
message.success("新建成功");
|
|
this.getTableDatas();
|
|
}
|
|
})
|
|
}
|
|
|
|
} |