feature/2.15.1.2407.01-权限

This commit is contained in:
黎永顺 2024-09-27 18:30:31 +08:00
parent 8996fa8d79
commit d4763dc2d2
9 changed files with 90 additions and 78 deletions

View File

@ -38,8 +38,9 @@ class Index extends Component {
}
}
initForm = (props) => {
const { baseTableStore: { VSSalaryFileForm }, detail, taxAgentOption } = props;
initForm = async (props) => {
const { baseTableStore: { VSSalaryFileForm }, detail } = props;
const { data: taxAgentOption } = await API.getAdminTaxAgentList();
API.getCreateForm().then(({ data }) => {
this.setState({
conditions: [
@ -48,7 +49,8 @@ class Index extends Component {
if (getKey(o) === "taxAgentIds") {
return {
...o, viewAttr: !_.isEmpty(detail) ? 1 : 3, label: getLabel(o.lanId, o.label),
options: taxAgentOption, value: detail[getKey(o)] || ""
options: _.map(taxAgentOption, o => ({ key: String(o.id), showname: o.name })),
value: detail[getKey(o)] ? String(detail[getKey(o)]) : ""
};
}
return {

View File

@ -30,12 +30,13 @@ class Index extends Component {
componentWillReceiveProps(nextProps, nextContext) {
const { importDialog } = this.state;
if (nextProps.visible !== this.props.visible && nextProps.visible) {
const { baseTableStore: { VSalryForm }, salaryMonth, taxAgentIds } = nextProps;
const payload = {
salaryMonth, taxAgentIds, ...VSalryForm.getFormParams(), hasData: importDialog.hasData
};
const { baseTableStore: { VSalryForm } } = nextProps;
const payload = { ...VSalryForm.getFormParams(), hasData: importDialog.hasData };
this.setState({
importDialog: { ...importDialog, salaryMonth, link: `${importDialog.link}?${convertToUrlString(payload)}` }
importDialog: {
...importDialog, salaryMonth: VSalryForm.getFormParams().salaryMonth,
link: `${importDialog.link}?${convertToUrlString(payload)}`
}
});
} else {
this.setState({
@ -48,9 +49,10 @@ class Index extends Component {
}
handleImport = (payload) => {
const { taxAgentIds } = this.props;
const { baseTableStore: { VSalryForm } } = this.props;
const { importDialog } = this.state;
const { salaryMonth } = importDialog;
const { taxAgentIds } = VSalryForm.getFormParams();
this.setState({ importDialog: { ...importDialog, nextloading: true } });
API.importVariableSalary({
...payload, salaryMonth, taxAgentIds: _.isEmpty(taxAgentIds) ? [] : taxAgentIds.split(",")
@ -64,14 +66,14 @@ class Index extends Component {
}).catch(() => this.setState({ importDialog: { ...importDialog, nextloading: false } }));
};
renderFormComponent = () => {
const { baseTableStore: { VSalryForm }, taxAgentIds } = this.props;
const { baseTableStore: { VSalryForm } } = this.props;
const { importDialog } = this.state;
const { salaryMonth: month, hasData } = importDialog;
return <div style={{ padding: "8px 16px", border: "1px solid #e5e5e5", margin: "4px 0" }}>
<WeaFormItem label={getLabel(111, "薪资所属月")} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
<WeaDatePicker format="YYYY-MM" value={month}
onChange={val => {
const payload = { salaryMonth: val, hasData, taxAgentIds, ...VSalryForm.getFormParams() };
const payload = { ...VSalryForm.getFormParams(), salaryMonth: val, hasData };
this.setState({
importDialog: {
...importDialog, salaryMonth: val,
@ -98,9 +100,9 @@ class Index extends Component {
content={getLabel(543208, "导出现有数据")}
helpfulTip={getLabel(111, "提示:建议先导出现有最新数据,修改后再导入")}
onChange={val => {
const { baseTableStore: { VSalryForm }, taxAgentIds } = this.props;
const { baseTableStore: { VSalryForm } } = this.props;
const { salaryMonth } = importDialog;
const payload = { salaryMonth, taxAgentIds, ...VSalryForm.getFormParams(), hasData: val === "1" };
const payload = { salaryMonth, ...VSalryForm.getFormParams(), hasData: val === "1" };
this.setState({
importDialog: {
...importDialog, hasData: val === "1",

View File

@ -31,6 +31,7 @@ class Index extends Component {
componentDidMount() {
window.addEventListener("message", this.handleReceive, false);
window.addEventListener("resize", this.handleResize, false);
this.getVariableSalaryList();
}
componentWillUnmount() {
@ -39,9 +40,6 @@ class Index extends Component {
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.taxAgentIds !== this.props.taxAgentIds && nextProps.taxAgentIds) {
this.getVariableSalaryList(nextProps);
}
if (nextProps.isQuery !== this.props.isQuery) this.setState({
pageInfo: { ...this.state.pageInfo, current: 1 }
}, () => this.getVariableSalaryList(nextProps));
@ -69,14 +67,15 @@ class Index extends Component {
}
}
};
getVariableSalaryList = (props) => {
const { baseTableStore: { VSalryForm, getVariableSalaryList }, salaryMonth, taxAgentIds } = props || this.props;
getVariableSalaryList = () => {
const { baseTableStore: { VSalryForm, getVariableSalaryList } } = this.props;
const { pageInfo } = this.state;
const { departmentIds } = VSalryForm.getFormParams();
const { departmentIds, taxAgentIds } = VSalryForm.getFormParams();
this.setState({ loading: true });
getVariableSalaryList({
...pageInfo, salaryMonth, taxAgentIds: _.isEmpty(taxAgentIds) ? [] : taxAgentIds.split(","),
...VSalryForm.getFormParams(), departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : []
...pageInfo, ...VSalryForm.getFormParams(),
departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [],
taxAgentIds: _.isEmpty(taxAgentIds) ? [] : taxAgentIds.split(",")
}).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {

View File

@ -9,7 +9,7 @@
*/
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTable } from "ecCom";
import { message, Modal } from "antd";
import { message, Modal, Spin } from "antd";
import * as API from "../../../../apis/variableSalary";
const getLabel = WeaLocaleProvider.getLabel;
@ -103,9 +103,10 @@ class Index extends Component {
}, () => this.getVariableSalaryItemList());
}
};
return (
<WeaTable columns={columns} dataSource={dataSource} loading={loading} bordered
pagination={pagination} scroll={{ y: `calc(100vh - 202px)` }}/>
return (<Spin spinning={loading && pageInfo.total === 0}>
<WeaTable columns={columns} dataSource={dataSource} loading={loading} bordered
pagination={pagination} scroll={{ y: `calc(100vh - 202px)` }}/>
</Spin>
);
}
}

View File

@ -7,9 +7,11 @@
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTools } from "ecCom";
import { Button } from "antd";
import * as API from "../../../../apis/variableSalary";
import { inject, observer } from "mobx-react";
import { getSearchs } from "../../../../util";
import { conditions } from "../../conditions";
import moment from "moment";
const getLabel = WeaLocaleProvider.getLabel;
const getKey = WeaTools.getKey;
@ -24,12 +26,19 @@ class VariableSalarySearchPannel extends Component {
};
}
componentDidMount() {
async componentDidMount() {
const { data } = await API.getAdminTaxAgentList();
this.setState({
searchConditions: _.map(conditions, item => {
return {
...item,
items: _.map(item.items, child => {
if (getKey(child) === "taxAgentIds") {
return {
...child, label: getLabel(child.lanId, child.label),
options: _.map(data, o => ({ key: String(o.id), showname: o.name, selected: true }))
};
}
return { ...child, label: getLabel(child.lanId, child.label) };
})
};
@ -54,7 +63,10 @@ class VariableSalarySearchPannel extends Component {
<Button type="primary" onClick={this.props.onAdSearch}>{getLabel(388113, "搜索")}</Button>
</span>
<span style={{ marginLeft: 15 }}>
<Button type="ghost" onClick={() => VSalryForm.resetForm()}>{getLabel(2022, "重置")}</Button>
<Button type="ghost" onClick={() => {
VSalryForm.resetForm();
VSalryForm.updateFields({ salaryMonth: moment(new Date()).format("YYYY-MM") });
}}>{getLabel(2022, "重置")}</Button>
</span>
<span style={{ marginLeft: 15 }}>
<Button type="ghost" onClick={this.props.onCancel}>{getLabel(31129, "取消")}</Button>

View File

@ -1,3 +1,5 @@
import moment from "moment";
export const conditions = [
{
items: [
@ -22,6 +24,28 @@ export const conditions = [
value: "",
viewAttr: 2
},
{
conditionType: "MONTHPICKER",
domkey: ["salaryMonth"],
fieldcol: 14,
label: "薪资所属月",
lanId: 111,
labelcol: 6,
value: moment(new Date()).format("YYYY-MM"),
viewAttr: 2
},
{
conditionType: "SELECT",
domkey: ["taxAgentIds"],
fieldcol: 14,
label: "个税扣缴义务人",
lanId: 111,
labelcol: 6,
value: "",
options: [],
multiple: true,
viewAttr: 2
},
{
browserConditionParam: {
completeParams: {},

View File

@ -10,7 +10,7 @@
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { toJS } from "mobx";
import { WeaDatePicker, WeaLoadingGlobal, WeaLocaleProvider, WeaReqTop, WeaSelect } from "ecCom";
import { WeaLoadingGlobal, WeaLocaleProvider, WeaReqTop } from "ecCom";
import * as API from "../../apis/variableSalary";
import AdvanceInputBtn from "./components/advanceInputBtn";
import SearchPannel from "./components/searchPannel";
@ -19,7 +19,6 @@ import SalaryFileDialog from "./components/salaryFileDialog";
import SalaryItemList from "./components/salaryItemList";
import SalaryFileList from "./components/salaryFileList";
import SalaryFileImportDialog from "./components/salaryFileImportDialog";
import moment from "moment";
import { Button } from "antd";
import cs from "classnames";
import "./index.less";
@ -32,27 +31,13 @@ class Index extends Component {
constructor(props) {
super(props);
this.state = {
selectedKey: "salaryFile", isQuery: false, showSearchAd: false, taxAgentIds: "",
salaryMonth: moment(new Date()).format("YYYY-MM"), taxAgentOption: [],
SIDialog: { visible: false, title: "", id: "", taxAgentOption: [] }, //薪资项目薪资编辑弹框
SFDialog: { visible: false, title: "", detail: {}, taxAgentOption: [] }, //薪资档案编辑弹框
selectedKey: "salaryFile", isQuery: false, showSearchAd: false,
SIDialog: { visible: false, title: "", id: "" }, //薪资项目薪资编辑弹框
SFDialog: { visible: false, title: "", detail: {} }, //薪资档案编辑弹框
SFImpDialog: { visible: false, title: getLabel(24023, "数据导入") }//薪资档案导入
};
}
componentDidMount() {
API.getAdminTaxAgentList().then(({ status, data }) => {
if (status) {
const taxAgentOption = _.map(data, (o, i) => ({ key: String(o.id), showname: o.name }));
this.setState({
taxAgentOption, taxAgentIds: _.map(taxAgentOption, o => o.key).join(","),
SIDialog: { ...this.state.SIDialog, taxAgentOption },
SFDialog: { ...this.state.SFDialog, taxAgentOption }
});
}
});
}
handleAdvanceSearch = () => this.setState({ isQuery: !this.state.isQuery });
openAdvanceSearch = () => this.setState({ showSearchAd: !this.state.showSearchAd });
handleOperate = (type, detail = {}) => {
@ -71,12 +56,12 @@ class Index extends Component {
break;
case "export":
const columns = _.map(_.filter(toJS(SFTableStore.columns), (item) => item.display === "true"), it => it.dataIndex);
const { salaryMonth, taxAgentIds } = this.state;
const { taxAgentIds, departmentIds } = VSalryForm.getFormParams();
const payload = {
...VSalryForm.getFormParams(),
taxAgentIds: !_.isEmpty(taxAgentIds) ? taxAgentIds.split(",") : [],
departmentIds: !_.isEmpty(VSalryForm.getFormParams().taxAgentIds) ? VSalryForm.getFormParams().taxAgentIds.split(",") : [],
salaryMonth, columns
departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [],
columns
};
WeaLoadingGlobal.start();
const promise = API.exportVariableSalary(payload);
@ -91,10 +76,8 @@ class Index extends Component {
};
render() {
const {
selectedKey, SIDialog, SFDialog, SFImpDialog, showSearchAd, isQuery, salaryMonth, taxAgentOption, taxAgentIds
} = this.state;
const { taxAgentStore: { showOperateBtn }, baseTableStore: { VSSalaryItemForm } } = this.props;
const { selectedKey, SIDialog, SFDialog, SFImpDialog, showSearchAd, isQuery } = this.state;
const { taxAgentStore: { showOperateBtn }, baseTableStore: { VSSalaryItemForm, VSalryForm } } = this.props;
const tabs = [
{
title: getLabel(111, "薪资档案"), key: "salaryFile", showDropIcon: true,
@ -107,22 +90,14 @@ class Index extends Component {
buttons: showOperateBtn ? [
<Button type="primary" onClick={() => this.handleOperate("create")}>{getLabel(111, "新建")}</Button>,
<Button type="ghost" onClick={() => this.handleOperate("import")}>{getLabel(111, "导入")}</Button>,
<WeaDatePicker format="YYYY-MM" value={salaryMonth}
onChange={val => this.setState({ salaryMonth: val }, () => this.handleAdvanceSearch())}/>,
<WeaSelect options={taxAgentOption} style={{ width: 150, display: "flex" }} multiple value={taxAgentIds}
onChange={val => this.setState({ taxAgentIds: val })}/>,
<AdvanceInputBtn searchType="advance" onOpenAdvanceSearch={() => this.openAdvanceSearch()}
onAdvanceSearch={this.handleAdvanceSearch}/>
] : [
<WeaDatePicker format="YYYY-MM" value={salaryMonth}
onChange={val => this.setState({ salaryMonth: val }, () => this.handleAdvanceSearch())}/>,
<WeaSelect options={taxAgentOption} style={{ width: 150, display: "flex" }} multiple value={taxAgentIds}
onChange={val => this.setState({ taxAgentIds: val })}/>,
<AdvanceInputBtn searchType="advance" onOpenAdvanceSearch={() => this.openAdvanceSearch()}
onAdvanceSearch={this.handleAdvanceSearch}/>
],
children: <SalaryFileList {...this.props} salaryMonth={salaryMonth} taxAgentIds={taxAgentIds} isQuery={isQuery}
onViewSalaryFile={(data) => this.handleOperate("create", data)}/>
children: !_.isEmpty(VSalryForm.getFormParams()) ? <SalaryFileList {...this.props} isQuery={isQuery}
onViewSalaryFile={(data) => this.handleOperate("create", data)}/> : null
},
{
title: getLabel(111, "薪资项目"), key: "salaryItem", showDropIcon: false, dropMenuDatas: [],
@ -161,11 +136,10 @@ class Index extends Component {
SFDialog: { ...SFDialog, visible: false }
}, () => callback && callback())}/>
{/* 薪资档案导入*/}
<SalaryFileImportDialog {...this.props} {...SFImpDialog} salaryMonth={salaryMonth} taxAgentIds={taxAgentIds}
onCancel={callback => {
this.setState({ SFImpDialog: { ...SFImpDialog, visible: false } },
() => callback && this.handleAdvanceSearch());
}}/>
<SalaryFileImportDialog {...this.props} {...SFImpDialog} onCancel={callback => {
this.setState({ SFImpDialog: { ...SFImpDialog, visible: false } },
() => callback && this.handleAdvanceSearch());
}}/>
</WeaReqTop>
);
}

View File

@ -1,15 +1,6 @@
.variable_salary_wrapper {
.wea-new-top-req-title > div:last-child {
right: 16px !important;
.ant-calendar-range-picker {
min-width: 100px !important;
width: 100px;
}
.wea-input-focus {
width: 140px;
}
}
.wea-new-top-req-content {
@ -40,7 +31,7 @@
}
.wea-advanced-searchsAd {
height: 108px;
height: 155px;
overflow: hidden auto;
.formItem-delete {
@ -66,6 +57,9 @@
}
}
.wea-form-item-wrapper {
display: block !important;
}
}
}

View File

@ -39,6 +39,10 @@
.form-dialog-layout {
background: #f6f6f6;
.wea-form-item .wea-form-item-wrapper .wea-field-readonly {
line-height: 28px;
}
.wea-search-group {
padding: 16px;
}