From c517a80b87451d02315db2a8ab7ecd70ac63f303 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Thu, 31 Mar 2022 15:32:11 +0800 Subject: [PATCH] archives --- pc4mobx/hrmSalary/apis/archive.js | 11 ++- .../socialSecurityBenefits/archives/index.js | 51 ++++++++++---- pc4mobx/hrmSalary/stores/archives.js | 70 +++++++++++++++++++ pc4mobx/hrmSalary/stores/index.js | 4 +- 4 files changed, 119 insertions(+), 17 deletions(-) create mode 100644 pc4mobx/hrmSalary/stores/archives.js diff --git a/pc4mobx/hrmSalary/apis/archive.js b/pc4mobx/hrmSalary/apis/archive.js index a76a523d..7f47832b 100644 --- a/pc4mobx/hrmSalary/apis/archive.js +++ b/pc4mobx/hrmSalary/apis/archive.js @@ -7,13 +7,20 @@ import { WeaTools } from 'ecCom'; //薪资档案-薪资档案列表 export const getArchiveList = params => { - return WeaTools.callApi('/api/bs/hrmsalary/salaryArchive/list', 'POST', params); + return fetch('/api/bs/hrmsalary/archives/getTable', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) } //薪资档案的高级搜索 export const getSaCondition = params => { - return WeaTools.callApi('/api/bs/hrmsalary/salaryArchive/getSearchCondition', 'GET', params); + return WeaTools.callApi('/api/bs/hrmsalary/archives/getSearchCondition', 'get', params); } diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js index 08b5ea60..231fbe95 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js @@ -5,16 +5,17 @@ import { toJS } from 'mobx'; import { Button, Table, DatePicker } from 'antd'; import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable } from 'ecCom'; +// import { WeaTableNew } from "comsMobx" +// const WeaTable = WeaTableNew.WeaTable; import { renderNoright, getSearchs } from '../../../util'; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 import CustomTab from '../../../components/customTab'; import ContentWrapper from '../../../components/contentWrapper'; -import { columns, dataSource } from './columns'; const { MonthPicker } = DatePicker; -@inject('baseTableStore') +@inject('archivesStore') @observer export default class Archives extends React.Component { constructor(props) { @@ -24,10 +25,16 @@ export default class Archives extends React.Component { selectedKey: "0" } } - render() { - const { baseTableStore } = this.props; - const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = baseTableStore; + componentWillMount() { + const { archivesStore: {doInit}} = this.props; + doInit() + } + + render() { + const { archivesStore } = this.props; + const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = archivesStore; + const { dataSource } = archivesStore if (!hasRight && !loading) { // 无权限处理 return renderNoright(); } @@ -75,16 +82,32 @@ export default class Archives extends React.Component { dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同) dropMenuProps={{ collectParams }} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能 > - { - this.setState({selectedKey: v}) - }} - /> - + setShowSearchAd(bool)} //高级搜索面板受控 + searchsAd={getSearchs(form, toJS(condition), 2)} // 高级搜索内部数据 + buttonsAd={adBtn} // 高级搜索内部按钮 + onSearch={getTableDatas} // 点搜索按钮时的回调 + onSearchChange={v => form.updateFields({ username: v })} // 在搜索框中输入的文字改变时的回调: 这里需要同步高级搜索和外部搜索框的值 + searchsBaseValue={form.getFormParams().username} // 外部input搜索值受控: 这里和高级搜索的requestname同步 + /> + {/* */} + + item.hide == "false")} + dataSource={dataSource} + + /> + diff --git a/pc4mobx/hrmSalary/stores/archives.js b/pc4mobx/hrmSalary/stores/archives.js new file mode 100644 index 00000000..c89f5c3d --- /dev/null +++ b/pc4mobx/hrmSalary/stores/archives.js @@ -0,0 +1,70 @@ +import { observable, action, toJS } from 'mobx'; +import { message } from 'antd'; +import { WeaForm, WeaTableNew } from 'comsMobx'; + +import * as API from '../apis/archive'; // 引入API接口文件 + +const { TableStore } = WeaTableNew; + +export class ArchivesStore { + @observable tableStore = new TableStore( + // {dataHandle: (datas) => { + // return dataSource; + // }} + ); + @observable form = new WeaForm(); // nrew 一个form + @observable condition = []; // 存储后台得到的form数据 + @observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据 + @observable showSearchAd = false; // 高级搜索面板显示 + @observable loading = true; // 数据加载状态 + + @observable dataSource = []; + + // 初始化操作 + @action + doInit = () => { + this.getCondition(); + this.getTableDatas(); + } + + // 获得高级搜索表单数据 + @action + getCondition = () => { + API.getSaCondition().then(action(res => { + if (res.status) { // 接口请求成功/失败处理 + this.condition = res.data.condition; + this.form.initFormFields(res.data.condition); // 渲染高级搜索form表单 + } else { + message.error(res.msg || '接口调用失败!') + } + })); + } + + // 渲染table数据 + @action + getTableDatas = (params) => { + this.loading = true; + const formParams = this.form.getFormParams() || {}; + params = params || formParams; + API.getArchiveList(params).then(action(res => { + if (res.status) { // 接口请求成功/失败处理 + this.dataSource = res.data.datas; + // this.columns = res.data.columns; + this.tableStore.getDatas(res.data.dataKey.datas) + } else { + message.error(res.msg || '接口调用失败!') + } + this.loading = false; + })); + } + + @action + setShowSearchAd = bool => this.showSearchAd = bool; + + // 高级搜索 - 搜索 + @action doSearch = () => { + this.getTableDatas(); + this.showSearchAd = false; + } + +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/stores/index.js b/pc4mobx/hrmSalary/stores/index.js index 41fcb730..dc02382b 100644 --- a/pc4mobx/hrmSalary/stores/index.js +++ b/pc4mobx/hrmSalary/stores/index.js @@ -11,6 +11,7 @@ import { ProgrammeStore } from './programme' import { AttendanceStore } from './attendanceStore'; import { SalaryItemStore } from './salaryItem' import { LedgerStore } from './ledger' +import { ArchivesStore } from './archives' module.exports = { baseFormStore: new BaseFormStore(), @@ -24,6 +25,7 @@ module.exports = { programmeStore: new ProgrammeStore(), attendanceStore: new AttendanceStore(), salaryItemStore: new SalaryItemStore(), - ledgerStore: new LedgerStore() + ledgerStore: new LedgerStore(), + archivesStore: new ArchivesStore() };