From 3e944ded89fbfbf13de6c9838bdf2f4ad000b237 Mon Sep 17 00:00:00 2001
From: liyongshun <971387674@qq.com>
Date: Tue, 12 Jul 2022 17:39:57 +0800
Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E8=96=AA=E8=B5=84=E7=A6=8F?=
=?UTF-8?q?=E5=88=A9=E6=B7=BB=E5=8A=A0=E6=9D=83=E9=99=90=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/customTable/index.less | 2 +-
pc4mobx/hrmSalary/pages/mySalary/authority.js | 43 +++
pc4mobx/hrmSalary/pages/mySalary/index.js | 319 +++++++++---------
pc4mobx/hrmSalary/stores/mySalary.js | 132 +++++---
4 files changed, 292 insertions(+), 204 deletions(-)
create mode 100644 pc4mobx/hrmSalary/pages/mySalary/authority.js
diff --git a/pc4mobx/hrmSalary/components/customTable/index.less b/pc4mobx/hrmSalary/components/customTable/index.less
index e6a5c40c..ccf590a7 100644
--- a/pc4mobx/hrmSalary/components/customTable/index.less
+++ b/pc4mobx/hrmSalary/components/customTable/index.less
@@ -2,7 +2,7 @@
.ant-table-tbody {
tr {
td {
- height: 42px !important;
+ height: 41px !important;
border-bottom: 1px solid #e2e2e2 !important;
}
}
diff --git a/pc4mobx/hrmSalary/pages/mySalary/authority.js b/pc4mobx/hrmSalary/pages/mySalary/authority.js
new file mode 100644
index 00000000..00a74712
--- /dev/null
+++ b/pc4mobx/hrmSalary/pages/mySalary/authority.js
@@ -0,0 +1,43 @@
+import { observer } from "mobx-react";
+import { WeaAlertPage, WeaLocaleProvider } from "ecCom";
+import { Spin } from "antd";
+
+const getLabel = WeaLocaleProvider.getLabel;
+
+@observer
+export default class Authority extends React.Component {
+ render() {
+ const { store } = this.props;
+ const { loading, hasRight } = store;
+
+ const style = {
+ position: "absolute",
+ top: "50%",
+ left: "50%",
+ marginLeft: -16,
+ marginTop: -16
+ };
+
+ if (loading) {
+ return (
+
+
+
+ );
+ }
+
+ if (hasRight) {
+ return this.props.children;
+ } else {
+ return (
+
+
+
+ {getLabel(2012, "对不起,您暂时没有权限!")}
+
+
+
+ );
+ }
+ }
+}
diff --git a/pc4mobx/hrmSalary/pages/mySalary/index.js b/pc4mobx/hrmSalary/pages/mySalary/index.js
index 7803f3bd..ae35cf9a 100644
--- a/pc4mobx/hrmSalary/pages/mySalary/index.js
+++ b/pc4mobx/hrmSalary/pages/mySalary/index.js
@@ -1,28 +1,18 @@
-import React from 'react';
-import { inject, observer } from 'mobx-react';
-import { toJS } from 'mobx';
-
-import { Button, Table, DatePicker, Spin } from 'antd';
-
-import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable, WeaDatePicker } from 'ecCom';
-
-import { renderNoright, getSearchs } from '../../util'; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中
-import CustomTab from '../../components/customTab';
-import ContentWrapper from '../../components/contentWrapper';
-import CustomTable from '../../components/customTable'
-import CustomPaginationTable from '../../components/customPaginationTable'
-import moment from 'moment'
-import "./index.less"
-
-import { payrollColumns,
- socialSecurityBenefitsColumns,
- salaryRecordColumns,
- dataSource } from './columns';
-import PayrollModal from './payrollModal';
+import React from "react";
+import { inject, observer } from "mobx-react";
+import { Button, DatePicker } from "antd";
+import { WeaRightMenu, WeaTop } from "ecCom";
+import { renderNoright } from "../../util"; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中
+import CustomTab from "../../components/customTab";
+import CustomPaginationTable from "../../components/customPaginationTable";
+import moment from "moment";
+import "./index.less";
+import PayrollModal from "./payrollModal";
+import Authority from "./authority";
const { RangePicker } = DatePicker;
-@inject('mySalaryStore')
+@inject("mySalaryStore")
@observer
export default class MySalary extends React.Component {
constructor(props) {
@@ -31,16 +21,16 @@ export default class MySalary extends React.Component {
value: "",
selectedKey: "0",
salaryBillVisible: false
- }
- this.salaryInfoId = ""
- this.range = []
- this.pageInfo = {current: 1, pageSize: 10}
- this.historyPageInfo = {current: 1, pageSize: 10}
+ };
+ this.salaryInfoId = "";
+ this.range = [];
+ this.pageInfo = { current: 1, pageSize: 10 };
+ this.historyPageInfo = { current: 1, pageSize: 10 };
}
componentWillMount() {
- const { mySalaryStore : {mySalaryBillList}} = this.props;
- mySalaryBillList()
+ const { mySalaryStore: { init } } = this.props;
+ init();
}
// 查看工资单
@@ -48,70 +38,90 @@ export default class MySalary extends React.Component {
this.salaryInfoId = record.id;
this.setState({
salaryBillVisible: true
- })
+ });
}
getColumns() {
- const { mySalaryStore: {myBillTableStore}} = this.props;
- let columns = myBillTableStore.columns ? myBillTableStore.columns: []
- columns = columns.filter(item => item.hide == "false")
+ const { mySalaryStore: { myBillTableStore } } = this.props;
+ let columns = myBillTableStore.columns ? myBillTableStore.columns : [];
+ columns = columns.filter(item => item.hide == "false");
columns.map(item => {
- if(item.dataIndex == "salaryYearMonth") {
- item.render = (text, record) => {
- return {moment(parseInt(text)).format("YYYY-MM")}
- }
- } else if(item.dataIndex == "sendTime") {
- item.render = (text, record) => {
- return {moment(parseInt(text)).format("YYYY-MM-DD HH:mm:ss")}
- }
+ if (item.dataIndex == "salaryYearMonth") {
+ item.render = (text, record) => {
+ return {moment(parseInt(text)).format("YYYY-MM")};
+ };
+ } else if (item.dataIndex == "sendTime") {
+ item.render = (text, record) => {
+ return {moment(parseInt(text)).format("YYYY-MM-DD HH:mm:ss")};
+ };
}
- })
+ });
columns.push({
title: "操作",
dataIndex: "operate",
- render: (text,record) => {
+ render: (text, record) => {
return (
- {this.handleView(record)}}>查看
- )
+ {
+ this.handleView(record);
+ }}>查看
+ );
}
- })
+ });
return columns;
}
// 区间改变事件
handleSalaryRangePickerChange(range) {
- const { mySalaryStore : {mySalaryBillList}} = this.props;
- const isNull= _.every(range, it=> !!it)
- if(!_.isEmpty(range) && isNull){
- this.range = range.map(item => moment(item).format("YYYY-MM"))
- mySalaryBillList(this.range, this.pageInfo)
- }else{
- mySalaryBillList([], this.pageInfo)
+ const { mySalaryStore: { mySalaryBillList } } = this.props;
+ const isNull = _.every(range, it => !!it);
+ if (!_.isEmpty(range) && isNull) {
+ this.range = range.map(item => moment(item).format("YYYY-MM"));
+ mySalaryBillList(this.range, this.pageInfo);
+ } else {
+ mySalaryBillList([], this.pageInfo);
}
}
handleTabChange(selectedKey) {
- if(selectedKey == "2") {
- const { mySalaryStore: {getRecordList}} = this.props;
- getRecordList()
+ if (selectedKey == "2") {
+ const { mySalaryStore: { getRecordList } } = this.props;
+ getRecordList();
}
}
handlePageChange() {
- const { mySalaryStore : {mySalaryBillList}} = this.props;
- mySalaryBillList(this.range, this.pageInfo)
+ const { mySalaryStore: { mySalaryBillList } } = this.props;
+ mySalaryBillList(this.range, this.pageInfo);
}
handleHistoryPageChange() {
- const { mySalaryStore: {getRecordList}} = this.props;
- getRecordList(this.historyPageInfo)
+ const { mySalaryStore: { getRecordList } } = this.props;
+ getRecordList(this.historyPageInfo);
}
render() {
const { mySalaryStore } = this.props;
- const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = mySalaryStore;
- const { tabIndex, myBillTableStore, myBillDataSource, recordListColumns, recordListDataSource, recordListPageInfo, myBillPageInfo } = mySalaryStore
+ const {
+ loading,
+ hasRight,
+ form,
+ condition,
+ tableStore,
+ showSearchAd,
+ getTableDatas,
+ doSearch,
+ setShowSearchAd
+ } = mySalaryStore;
+ const {
+ tabIndex,
+ myBillTableStore,
+ myBillDataSource,
+ recordListColumns,
+ recordListDataSource,
+ recordListPageInfo,
+ myBillPageInfo
+ } = mySalaryStore;
const { salaryBillVisible } = this.state;
if (!hasRight && !loading) { // 无权限处理
return renderNoright();
@@ -126,16 +136,16 @@ export default class MySalary extends React.Component {
// },
];
const collectParams = { // 收藏功能配置
- favname: '我的薪资福利',
+ favname: "我的薪资福利",
favouritetype: 1,
objid: 0,
- link: 'wui/index.html#/ns_demo03/index',
- importantlevel: 1,
+ link: "wui/index.html#/ns_demo03/index",
+ importantlevel: 1
};
const adBtn = [ // 高级搜索内部按钮
,
,
- ,
+
];
const topTab = [
@@ -154,108 +164,113 @@ export default class MySalary extends React.Component {
];
const renderSearchOperationItem = () => {
- if(this.state.selectedKey == "0") {
+ if (this.state.selectedKey == "0") {
return (薪资所属月:
- this.handleSalaryRangePickerChange(value)}
- />
-
)
- } else if(this.state.selectedKey == "1"){
+ this.handleSalaryRangePickerChange(value)}
+ />
+ );
+ } else if (this.state.selectedKey == "1") {
return (缴纳月份:
-
)
- } else {
- return (
)
+
);
+ } else {
+ return ();
}
-
- }
+
+ };
return (
-
- } // 左侧图标
- iconBgcolor='#F14A2D' // 左侧图标背景色
- showDropIcon={true} // 是否显示下拉按钮
- dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同)
- dropMenuProps={{ collectParams }} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能
+
+
- {
- this.handleTabChange(v)
- this.setState({selectedKey: v})
- }}
- />
+ } // 左侧图标
+ iconBgcolor="#F14A2D" // 左侧图标背景色
+ showDropIcon={true} // 是否显示下拉按钮
+ dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同)
+ dropMenuProps={{ collectParams }} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能
+ >
+ {
+ this.handleTabChange(v);
+ this.setState({ selectedKey: v });
+ }}
+ />
- {
- this.state.selectedKey == '0' &&
-
- {
- this.pageInfo.current = value
- this.handlePageChange()
- }}
- onShowSizeChange={(current, pageSize) => {
- this.pageInfo = {current, pageSize}
- this.handlePageChange()
- }}
- />
- }
- {/* {
- this.state.selectedKey == '1' &&
- } */}
- {
- this.state.selectedKey == '2' &&
- {
- this.historyPageInfo.current = value
- this.handleHistoryPageChange()
- }}
- onShowSizeChange={(current, pageSize) => {
- this.historyPageInfo = {current, pageSize}
- this.handleHistoryPageChange()
- }}
- />
- }
-
-
-
+ {
+ this.state.selectedKey == "0" &&
+
+ {
+ this.pageInfo.current = value;
+ this.handlePageChange();
+ }}
+ onShowSizeChange={(current, pageSize) => {
+ this.pageInfo = { current, pageSize };
+ this.handlePageChange();
+ }}
+ />
+ }
+ {/* {
+ this.state.selectedKey == '1' &&
+ } */}
+ {
+ this.state.selectedKey == "2" &&
+ {
+ this.historyPageInfo.current = value;
+ this.handleHistoryPageChange();
+ }}
+ onShowSizeChange={(current, pageSize) => {
+ this.historyPageInfo = { current, pageSize };
+ this.handleHistoryPageChange();
+ }}
+ />
+ }
+
+
+
+
{
- salaryBillVisible &&
{this.setState({salaryBillVisible: false})}}
+ onCancel={() => {
+ this.setState({ salaryBillVisible: false });
+ }}
/>
}
- )
+ );
}
-}
\ No newline at end of file
+}
diff --git a/pc4mobx/hrmSalary/stores/mySalary.js b/pc4mobx/hrmSalary/stores/mySalary.js
index 0fe8834c..16e445de 100644
--- a/pc4mobx/hrmSalary/stores/mySalary.js
+++ b/pc4mobx/hrmSalary/stores/mySalary.js
@@ -1,12 +1,12 @@
-import { observable, action, toJS } from 'mobx';
-import { message } from 'antd';
-import { WeaForm, WeaLogView, WeaTableNew } from 'comsMobx';
-import { WeaLocaleProvider } from 'ecCom';
-import moment from 'moment'
+import { action, observable } from "mobx";
+import { message } from "antd";
+import { WeaForm, WeaLogView, WeaTableNew } from "comsMobx";
+import { WeaLocaleProvider } from "ecCom";
+import moment from "moment";
-import * as API from '../apis/mySalaryBenefits'; // 引入API接口文件
+import * as API from "../apis/mySalaryBenefits"; // 引入API接口文件
-const {LogStore} = WeaLogView;
+const { LogStore } = WeaLogView;
const getLabel = WeaLocaleProvider.getLabel;
const { TableStore } = WeaTableNew;
@@ -14,7 +14,7 @@ export class MySalaryStore {
@observable tableStore = new TableStore(); // new table
@observable form = new WeaForm(); // nrew 一个form
@observable condition = []; // 存储后台得到的form数据
- @observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
+ @observable hasRight = false; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
@observable showSearchAd = false; // 高级搜索面板显示
@observable loading = true; // 数据加载状态
@observable tabIndex = 0; // tab选中坐标
@@ -31,27 +31,57 @@ export class MySalaryStore {
@observable recordListColumns = [];
@observable recordListDataSource = [];
@observable recordListPageInfo = {};
- @observable myBillPageInfo = {}
+ @observable myBillPageInfo = {};
+
+ @action clear = () => {
+ this.loading = true;
+ this.hasRight = false;
+ };
+
+ @action init = async props => {
+ this.clear();
+ //1.check is need second verify
+ if (window.doCheckSecondaryVerify4ec) {
+ window.doCheckSecondaryVerify4ec({ mouldCode: "HRM", itemCode: "SALARY" }, this.getData);
+ } else {
+ //4.loaddata
+ this.getData({ status: "1", token: "" });
+ }
+ };
+
+ @action
+ getData = async (params = {}) => {
+ if (_.isEmpty(params)) return;
+ const { status, token } = params;
+ if (status == "1") {
+ // Object.assign(this._reqParams, { token });
+ // this.getFormData({ viewAttr: 1 });
+ this.hasRight = true;
+ this.mySalaryBillList()
+ } else {
+ this.hasRight = false;
+ }
+ this.loading = false;
+ };
@action
initParams = () => {
- let month = moment().format("YYYY-MM")
- this.params = {startMonth: month, endMonth: month}
+ let month = moment().format("YYYY-MM");
+ this.params = { startMonth: month, endMonth: month };
return this.params;
- }
+ };
@action
setTabIndex = index => {
- this.tabIndex = index
+ this.tabIndex = index;
this.getTableDatas(index);
- }
+ };
// 初始化操作
@action
doInit = () => {
- this.
this.getTableDatas(0, params);
- }
+ };
// 获得高级搜索表单数据
@action
@@ -61,10 +91,10 @@ export class MySalaryStore {
this.condition = res.condition;
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
} else {
- message.error(res.errormsg || '接口调用失败!')
+ message.error(res.errormsg || "接口调用失败!");
}
}));
- }
+ };
// 渲染table数据
@action
@@ -72,22 +102,22 @@ export class MySalaryStore {
this.loading = true;
const formParams = this.form.getFormParams() || {};
params = params || formParams;
- switch(params) {
- case 0:
- // 工资单
- API.mySalaryBillList(param)
- break;
+ switch (params) {
+ case 0:
+ // 工资单
+ API.mySalaryBillList(param);
+ break;
}
API.getTableDatas(params).then(action(res => {
if (res.api_status) { // 接口请求成功/失败处理
this.tableStore.getDatas(res.datas); // table 请求数据
this.hasRight = res.hasRight;
} else {
- message.error(res.errormsg || '接口调用失败!')
+ message.error(res.errormsg || "接口调用失败!");
}
this.loading = false;
}));
- }
+ };
@action
setShowSearchAd = bool => this.showSearchAd = bool;
@@ -96,46 +126,46 @@ export class MySalaryStore {
@action doSearch = () => {
this.getTableDatas();
this.showSearchAd = false;
- }
+ };
// 我的工资单列表
@action
mySalaryBillList = (salaryYearMonth = [], params = {}) => {
- this.loading = true
- API.mySalaryBillList({salaryYearMonth, ...params}).then(res => {
- if(res.status) {
- this.myBillDataSource = res.data.datas
- this.myBillTableStore.getDatas(res.data.dataKey.datas)
- this.myBillPageInfo = res.data.pageInfo
- this.loading = false
+ this.loading = true;
+ API.mySalaryBillList({ salaryYearMonth, ...params }).then(res => {
+ if (res.status) {
+ this.myBillDataSource = res.data.datas;
+ this.myBillTableStore.getDatas(res.data.dataKey.datas);
+ this.myBillPageInfo = res.data.pageInfo;
+ this.loading = false;
} else {
- message.error(res.errormsg || "获取失败")
- this.loading = false
+ message.error(res.errormsg || "获取失败");
+ this.loading = false;
}
- })
- }
+ });
+ };
// 我的工资单详情
@action
getMySalaryBill = (salaryInfoId) => {
- API.mySalaryBill({salaryInfoId}).then(res => {
- if(res.status) {
- this.mySalaryBill = res.data
+ API.mySalaryBill({ salaryInfoId }).then(res => {
+ if (res.status) {
+ this.mySalaryBill = res.data;
} else {
- message.error(res.errormsg || "获取失败")
+ message.error(res.errormsg || "获取失败");
}
- })
- }
+ });
+ };
@action
getRecordList = (params = {}) => {
API.recordList(params).then(res => {
- if(res.status) {
- this.recordListColumns = res.data.columns
- this.recordListDataSource = res.data.list ? res.data.list : []
- this.recordListPageInfo = res.data
+ if (res.status) {
+ this.recordListColumns = res.data.columns;
+ this.recordListDataSource = res.data.list ? res.data.list : [];
+ this.recordListPageInfo = res.data;
}
- })
- }
-
-}
\ No newline at end of file
+ });
+ };
+
+}