import { observable, action } from 'mobx'; import * as mobx from 'mobx'; import * as Api from '../apis/company'; // 引入API接口文件 import { WeaForm } from 'comsMobx'; import { WeaTableNew } from 'comsMobx'; import { Modal, message, } from 'antd' import { i18n } from '../public/i18n'; const toJS = mobx.toJS; const { TableStore } = WeaTableNew; export class CompanyStore { @observable topMenu = [] @observable rightMenu = []; @observable dataSource = []; @observable columns = []; @observable tableStore = new TableStore(); @observable loading = true; @observable searchCondition = []; @observable isPanelShow = false; //高级搜索面板 @observable form = new WeaForm(); @observable companyName = ''; @observable conditionNum = 8; @observable ids = ''; //选择行id @observable id = ''; //页面跳转参数id @observable searchConditionLoading = true; @observable visible = false; @observable companyId = ''; @observable selectedRowKeys = ''; @observable date = ''; @action getTableInfo() { let params; if (this.isEmptyObject(this.form.getFormParams())) { params = { ...this.form.getFormParams(), //companyName: this.companyName, }; } else { params = { ...this.form.getFormParams(), }; } Api.getSearchList(params).then(response => { return response.json() }).then(res => { if (res.code === 200) { res.data.pageInfo.list && this.setDataSource(res.data.pageInfo.list); res.data.pageInfo.columns && this.setColumns(res.data.pageInfo.columns); this.setLoading(false); } else { message.warning(res.msg); } }).catch(error => { message.warning(error.msg); }) } //删除 delete() { let params = { ids: this.ids }; // Api.deleteTableData(params).then(response => { // return response.json() // }).then(data => { // if (data.code === 200) { // message.success(i18n.message.deleteSuccess()); // this.getTableInfo(); // } else { // message.warning(data.msg); // } // }).catch(error => { // message.warning(error.msg); // }) } updateForbiddenTag(checked, id) { let params = { forbiddenTag: checked, id: id } Api.updateForbiddenTag(params).then(response => { return response.json() }).then(data => { if (data.code === 200) { message.success(data.msg); } else { message.warning(data.msg); } }).catch(error => { message.warning(error.msg); }) } getSearchCondition() { this.setScLoadingStatus(true); Api.getAdvanceSearchCondition().then(res => { if (res.code === 200) { this.setScLoadingStatus(false); res.data.conditions && this.setSearchCondition(res.data.conditions); res.data.conditions && this.form.initFormFields(res.data.conditions); } else { message.warning(res.msg); } }, error => { message.warning(error.msg); }) } @action getHasRight() { Api.getHasRight().then(res => { if (res.code === 200) { res.data.rightMenu && this.setRightMenu(res.data.rightMenu); res.data.topMenu && this.setTopMenu(res.data.topMenu); } else { message.warning(res.msg); } }, error => { message.warning(error.msg); }) } updateFields(val) { this.form.updateFields({ companyName: { value: val } }); } setSearchCondition(condition) { this.searchCondition = condition; } setScLoadingStatus(bool) { this.searchConditionLoading = bool; } setPanelStatus(bool) { this.isPanelShow = bool; bool && this.getSearchCondition(); if (!bool) { this.scLoadingReset(); } } setCompanyName(val) { this.companyName = val; } isEmptyObject(obj) { for (let key in obj) { return false; } return true; } setIds(ids) { this.ids = ids; } setId(id) { this.id =id; } scLoadingReset() { this.searchConditionLoading = true; } formReset() { this.form = new WeaForm(); } setVisible(bool) { this.visible = bool; this.formReset(); !bool && this.dialogLoadingReset(); } setSearchCondition(searchCondition) { this.searchCondition = searchCondition; } setCompanyId(companyId) { this.companyId = companyId; } setDate(date) { this.date = date; } setTopMenu(topMenu) { this.topMenu = topMenu; } setRightMenu(rightMenu) { this.rightMenu = rightMenu; } setDataSource(dataSource) { this.dataSource = dataSource; } setColumns(columns) { this.columns = columns } setSelectedRowKeys(selectedRowKeys) { this.selectedRowKeys = selectedRowKeys; } setLoading(bool) { this.loading = bool; } }