产品-工资单模板列表页面接口修改
This commit is contained in:
parent
0b6571c04d
commit
4dca3e3d7d
|
|
@ -254,7 +254,15 @@ export default class Payroll extends React.Component {
|
|||
|
||||
render() {
|
||||
const { payrollStore, taxAgentStore: { showOperateBtn } } = this.props;
|
||||
const { loading, hasRight, templateStore, deletePayroll, templateBaseData } = payrollStore;
|
||||
const {
|
||||
loading,
|
||||
hasRight,
|
||||
templateTableSelectedRowKeys,
|
||||
setTemplateTableSelectedRowKeys,
|
||||
deletePayroll,
|
||||
templateBaseData,
|
||||
setTemplateTablePageInfo
|
||||
} = payrollStore;
|
||||
const { currentStep, selectedTab, templateSearchValue, templateSelect, startDate, endDate } = this.state;
|
||||
if (!hasRight && !loading) { // 无权限处理
|
||||
return renderLoading();
|
||||
|
|
@ -317,7 +325,7 @@ export default class Payroll extends React.Component {
|
|||
style={{ marginLeft: 10 }}
|
||||
type="ghost"
|
||||
onClick={() => {
|
||||
const selectedRowKeys = toJS(templateStore.selectedRowKeys);
|
||||
const selectedRowKeys = toJS(templateTableSelectedRowKeys);
|
||||
if (!selectedRowKeys.length) {
|
||||
message.info("未选中任何数据!");
|
||||
return;
|
||||
|
|
@ -391,7 +399,14 @@ export default class Payroll extends React.Component {
|
|||
topTab={topTab}
|
||||
searchOperationItem={renderRightOperation()}
|
||||
onChange={(v) => {
|
||||
this.setState({ selectedKey: v, stepSlideVisible: false, editSlideVisible: false });
|
||||
this.setState({
|
||||
selectedKey: v,
|
||||
stepSlideVisible: false,
|
||||
editSlideVisible: false
|
||||
}, () => {
|
||||
setTemplateTablePageInfo({ current: 1 });
|
||||
setTemplateTableSelectedRowKeys([]);
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<div className="tableWrapper">
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import React from "react";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { WeaLocaleProvider, WeaTable } from "ecCom";
|
||||
import { toJS } from "mobx";
|
||||
import { Radio, Spin } from "antd";
|
||||
import { WeaTableNew } from "comsMobx";
|
||||
|
||||
const WeaTable = WeaTableNew.WeaTable;
|
||||
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
@inject("payrollStore")
|
||||
@observer
|
||||
export default class TemplateSettingList extends React.Component {
|
||||
|
|
@ -15,23 +15,23 @@ export default class TemplateSettingList extends React.Component {
|
|||
}
|
||||
|
||||
// 编辑操作按钮
|
||||
onEdit(record) {
|
||||
onEdit = (record) => {
|
||||
this.props.onEdit && this.props.onEdit(record);
|
||||
}
|
||||
};
|
||||
|
||||
// 复制操作按钮
|
||||
onCopy(record) {
|
||||
onCopy = (record) => {
|
||||
this.props.onCopy && this.props.onCopy(record);
|
||||
}
|
||||
};
|
||||
|
||||
// 删除操作按钮
|
||||
onDelete(record) {
|
||||
onDelete = (record) => {
|
||||
this.props.onDelete && this.props.onDelete(record);
|
||||
}
|
||||
};
|
||||
|
||||
// 操作按钮
|
||||
onOperatesClick = (record, index, operate, flag) => {
|
||||
switch (operate.index.toString()) {
|
||||
onOperatesClick = (record, operate) => {
|
||||
switch (operate) {
|
||||
case "0": // 编辑
|
||||
this.onEdit(record);
|
||||
break;
|
||||
|
|
@ -45,21 +45,22 @@ export default class TemplateSettingList extends React.Component {
|
|||
};
|
||||
|
||||
// 默认使用配置
|
||||
recordItemChange(record) {
|
||||
recordItemChange = (record) => {
|
||||
const { payrollStore } = this.props;
|
||||
const { changePayrollDefaultUse, getPayrollTemplateList } = payrollStore;
|
||||
changePayrollDefaultUse(record.id).then(() => {
|
||||
getPayrollTemplateList();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 增加编辑功能,重写columns绑定事件
|
||||
getColumns = columns => {
|
||||
const { showOperateBtn } = this.props;
|
||||
let newColumns = "";
|
||||
newColumns = columns.map(column => {
|
||||
getColumns = () => {
|
||||
const { showOperateBtn, payrollStore } = this.props;
|
||||
const { templateTableColumns: columns } = payrollStore;
|
||||
let newColumns = [];
|
||||
newColumns = _.filter(toJS(columns), item => item.dataIndex !== "id").map(column => {
|
||||
let newColumn = column;
|
||||
newColumn.render = (text, record, index) => {
|
||||
newColumn.render = (text, record) => {
|
||||
//前端元素转义
|
||||
let valueSpan =
|
||||
record[newColumn.dataIndex + "span"] !== undefined
|
||||
|
|
@ -70,10 +71,8 @@ export default class TemplateSettingList extends React.Component {
|
|||
return (
|
||||
<Radio
|
||||
disabled={!showOperateBtn}
|
||||
checked={record.useType == "1"}
|
||||
onChange={value => {
|
||||
this.recordItemChange(record);
|
||||
}}
|
||||
checked={record.useType === "1"}
|
||||
onChange={() => this.recordItemChange(record)}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
|
|
@ -82,25 +81,73 @@ export default class TemplateSettingList extends React.Component {
|
|||
};
|
||||
return newColumn;
|
||||
});
|
||||
return newColumns;
|
||||
return [
|
||||
...newColumns,
|
||||
{
|
||||
dataIndex: "operate",
|
||||
title: getLabel(30585, "操作"),
|
||||
width: 150,
|
||||
render: (_, record) => {
|
||||
return <React.Fragment>
|
||||
<a href="javascript:void(0);" style={{ marginRight: 10 }}
|
||||
onClick={() => this.onOperatesClick(record, "0")}>{getLabel(501169, "编辑")}</a>
|
||||
<a href="javascript:void(0);" style={{ marginRight: 10 }}
|
||||
onClick={() => this.onOperatesClick(record, "1")}>{getLabel(77, "复制")}</a>
|
||||
<a href="javascript:void(0);"
|
||||
onClick={() => this.onOperatesClick(record, "2")}>{getLabel(535052, "删除")}</a>
|
||||
</React.Fragment>;
|
||||
}
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
render() {
|
||||
const { payrollStore } = this.props;
|
||||
const { templateStore, loading } = payrollStore;
|
||||
const {
|
||||
templateTableDataSource,
|
||||
loading,
|
||||
templateTablePageInfo,
|
||||
setTemplateTablePageInfo,
|
||||
getPayrollTemplateList,
|
||||
templateTableSelectedRowKeys,
|
||||
setTemplateTableSelectedRowKeys
|
||||
} = payrollStore;
|
||||
const pagination = {
|
||||
...templateTablePageInfo,
|
||||
showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`,
|
||||
showQuickJumper: true,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: ["10", "20", "50", "100"],
|
||||
onShowSizeChange: (current, pageSize) => {
|
||||
setTemplateTablePageInfo({ ...templateTablePageInfo, current, pageSize }, () => {
|
||||
getPayrollTemplateList();
|
||||
});
|
||||
},
|
||||
onChange: current => {
|
||||
setTemplateTablePageInfo({ ...templateTablePageInfo, current }, () => {
|
||||
getPayrollTemplateList();
|
||||
});
|
||||
}
|
||||
};
|
||||
const rowSelection = {
|
||||
selectedRowKeys: toJS(templateTableSelectedRowKeys),
|
||||
onChange: selectedRowKeys => setTemplateTableSelectedRowKeys(selectedRowKeys)
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
{loading
|
||||
? <div style={{ width: "100%", textAlign: "center" }}>
|
||||
<Spin/>
|
||||
</div>
|
||||
: <WeaTable // table内部做了loading加载处理,页面就不需要再加了
|
||||
comsWeaTableStore={templateStore} // table store
|
||||
hasOrder={true} // 是否启用排序
|
||||
needScroll={true} // 是否启用table内部列表滚动,将自适应到父级高度
|
||||
getColumns={this.getColumns}
|
||||
onOperatesClick={this.onOperatesClick.bind(this)}
|
||||
/>}
|
||||
{
|
||||
loading
|
||||
? <div style={{ width: "100%", textAlign: "center" }}>
|
||||
<Spin/>
|
||||
</div>
|
||||
: <WeaTable
|
||||
rowKey="id"
|
||||
rowSelection={rowSelection}
|
||||
columns={this.getColumns()}
|
||||
dataSource={toJS(templateTableDataSource)}
|
||||
pagination={pagination}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@ export class payrollStore {
|
|||
@observable canWidthdrawColumns = []; // 可以撤回的列表列名
|
||||
@observable canWithdrawPageInfo = {}; // 可以撤回列表分页对象
|
||||
|
||||
// **** 工资单模板 ****
|
||||
@observable templateTableColumns = []; // 工资单模板columns
|
||||
@observable templateTableDataSource = []; // 工资单模板dataSource
|
||||
@observable templateTablePageInfo = {
|
||||
current: 1, pageSize: 10, total: 0
|
||||
}; // 工资单模板pageInfo
|
||||
@observable templateTableSelectedRowKeys = []; // 工资单模板复选框
|
||||
|
||||
@action
|
||||
setReplenishSalaryTemplateSalaryItemSet = replenishSalaryTemplateSalaryItemSet =>
|
||||
(this.replenishSalaryTemplateSalaryItemSet = replenishSalaryTemplateSalaryItemSet);
|
||||
|
|
@ -80,6 +88,14 @@ export class payrollStore {
|
|||
@action
|
||||
setSalaryItemSet = salaryItemSet => (this.salaryItemSet = salaryItemSet);
|
||||
|
||||
@action("工资单模板分页信息修改")
|
||||
setTemplateTablePageInfo = (pageInfo, callback) => {
|
||||
this.templateTablePageInfo = { ...this.templateTablePageInfo, ...pageInfo };
|
||||
callback && callback();
|
||||
};
|
||||
@action("工资单模板复选框选择")
|
||||
setTemplateTableSelectedRowKeys = (selectedRowKeys) => this.templateTableSelectedRowKeys = selectedRowKeys;
|
||||
|
||||
// 初始化操作
|
||||
@action
|
||||
doInit = () => {
|
||||
|
|
@ -136,9 +152,15 @@ export class payrollStore {
|
|||
@action
|
||||
getPayrollTemplateList = (params = {}) => {
|
||||
this.loading = true;
|
||||
API.getPayrollTemplateList(params).then(res => {
|
||||
API.getPayrollTemplateList({ ...params, ...this.templateTablePageInfo }).then(res => {
|
||||
if (res.status) {
|
||||
this.templateStore.getDatas(res.data.datas);
|
||||
this.templateTableColumns = res.data.columns;
|
||||
this.templateTableDataSource = res.data.list;
|
||||
this.setTemplateTablePageInfo({
|
||||
current: res.data.pageNum,
|
||||
pageSize: res.data.pageSize,
|
||||
total: res.data.total
|
||||
});
|
||||
} else {
|
||||
message.error(res.errormsg || "获取失败");
|
||||
}
|
||||
|
|
@ -149,9 +171,7 @@ export class payrollStore {
|
|||
// 工资单模板-获取工资单模板基础设置表单
|
||||
@action
|
||||
getPayrollBaseForm = (id = "") => {
|
||||
let params = {
|
||||
id
|
||||
};
|
||||
let params = { id };
|
||||
return new Promise((resolve, reject) => {
|
||||
API.getPayrollBaseForm(params).then(res => {
|
||||
if (res.status) {
|
||||
|
|
@ -354,6 +374,7 @@ export class payrollStore {
|
|||
API.deletePayroll(ids).then(res => {
|
||||
if (res.status) {
|
||||
message.success("删除成功");
|
||||
this.setTemplateTableSelectedRowKeys([]);
|
||||
this.getPayrollTemplateList();
|
||||
} else {
|
||||
message.error(res.errormsg || "删除失败");
|
||||
|
|
@ -525,7 +546,7 @@ export class payrollStore {
|
|||
reject();
|
||||
}
|
||||
}).catch(() => {
|
||||
this.btnLoading = false
|
||||
this.btnLoading = false;
|
||||
// WeaLoadingGlobal.end();
|
||||
// WeaLoadingGlobal.destroy();
|
||||
});
|
||||
|
|
@ -553,7 +574,7 @@ export class payrollStore {
|
|||
reject();
|
||||
}
|
||||
}).catch(() => {
|
||||
this.btnLoading = false
|
||||
this.btnLoading = false;
|
||||
WeaLoadingGlobal.end();
|
||||
WeaLoadingGlobal.destroy();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue