2022-06-21 14:27:16 +08:00
|
|
|
|
import React from "react";
|
|
|
|
|
|
import { inject, observer } from "mobx-react";
|
2023-06-19 17:51:51 +08:00
|
|
|
|
import { WeaLocaleProvider, WeaTable } from "ecCom";
|
|
|
|
|
|
import { toJS } from "mobx";
|
2023-07-03 16:03:56 +08:00
|
|
|
|
import { Dropdown, Menu, Radio, Spin } from "antd";
|
2022-04-13 16:56:31 +08:00
|
|
|
|
|
2023-06-19 17:51:51 +08:00
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
2022-06-21 14:27:16 +08:00
|
|
|
|
@inject("payrollStore")
|
2022-04-13 16:56:31 +08:00
|
|
|
|
@observer
|
|
|
|
|
|
export default class TemplateSettingList extends React.Component {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
componentWillMount() {
|
|
|
|
|
|
const { payrollStore } = this.props;
|
|
|
|
|
|
const { getPayrollTemplateList } = payrollStore;
|
|
|
|
|
|
getPayrollTemplateList();
|
|
|
|
|
|
}
|
2022-04-14 19:32:57 +08:00
|
|
|
|
|
2022-06-21 14:27:16 +08:00
|
|
|
|
// 编辑操作按钮
|
2023-06-19 17:51:51 +08:00
|
|
|
|
onEdit = (record) => {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
this.props.onEdit && this.props.onEdit(record);
|
2023-06-19 17:51:51 +08:00
|
|
|
|
};
|
2022-04-14 19:32:57 +08:00
|
|
|
|
|
2022-06-21 14:27:16 +08:00
|
|
|
|
// 复制操作按钮
|
2023-06-19 17:51:51 +08:00
|
|
|
|
onCopy = (record) => {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
this.props.onCopy && this.props.onCopy(record);
|
2023-06-19 17:51:51 +08:00
|
|
|
|
};
|
2022-04-14 19:32:57 +08:00
|
|
|
|
|
2022-06-21 14:27:16 +08:00
|
|
|
|
// 删除操作按钮
|
2023-06-19 17:51:51 +08:00
|
|
|
|
onDelete = (record) => {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
this.props.onDelete && this.props.onDelete(record);
|
2023-06-19 17:51:51 +08:00
|
|
|
|
};
|
2022-04-14 19:32:57 +08:00
|
|
|
|
|
2022-06-21 14:27:16 +08:00
|
|
|
|
// 操作按钮
|
2023-06-19 17:51:51 +08:00
|
|
|
|
onOperatesClick = (record, operate) => {
|
|
|
|
|
|
switch (operate) {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
case "0": // 编辑
|
|
|
|
|
|
this.onEdit(record);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "1": // 复制
|
|
|
|
|
|
this.onCopy(record);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "2": // 删除
|
|
|
|
|
|
this.onDelete(record);
|
|
|
|
|
|
break;
|
2022-04-14 19:32:57 +08:00
|
|
|
|
}
|
2022-06-21 14:27:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 默认使用配置
|
2023-06-19 17:51:51 +08:00
|
|
|
|
recordItemChange = (record) => {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
const { payrollStore } = this.props;
|
|
|
|
|
|
const { changePayrollDefaultUse, getPayrollTemplateList } = payrollStore;
|
|
|
|
|
|
changePayrollDefaultUse(record.id).then(() => {
|
|
|
|
|
|
getPayrollTemplateList();
|
|
|
|
|
|
});
|
2023-06-19 17:51:51 +08:00
|
|
|
|
};
|
2022-04-14 19:32:57 +08:00
|
|
|
|
|
2022-06-21 14:27:16 +08:00
|
|
|
|
// 增加编辑功能,重写columns绑定事件
|
2023-06-19 17:51:51 +08:00
|
|
|
|
getColumns = () => {
|
|
|
|
|
|
const { showOperateBtn, payrollStore } = this.props;
|
|
|
|
|
|
const { templateTableColumns: columns } = payrollStore;
|
|
|
|
|
|
let newColumns = [];
|
|
|
|
|
|
newColumns = _.filter(toJS(columns), item => item.dataIndex !== "id").map(column => {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
let newColumn = column;
|
2023-06-19 17:51:51 +08:00
|
|
|
|
newColumn.render = (text, record) => {
|
2022-06-21 14:27:16 +08:00
|
|
|
|
//前端元素转义
|
|
|
|
|
|
let valueSpan =
|
|
|
|
|
|
record[newColumn.dataIndex + "span"] !== undefined
|
|
|
|
|
|
? record[newColumn.dataIndex + "span"]
|
|
|
|
|
|
: record[newColumn.dataIndex];
|
|
|
|
|
|
switch (newColumn.dataIndex) {
|
|
|
|
|
|
case "useType":
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Radio
|
|
|
|
|
|
disabled={!showOperateBtn}
|
2023-06-19 17:51:51 +08:00
|
|
|
|
checked={record.useType === "1"}
|
|
|
|
|
|
onChange={() => this.recordItemChange(record)}
|
2022-06-21 14:27:16 +08:00
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
default:
|
2022-12-02 14:27:39 +08:00
|
|
|
|
return <div dangerouslySetInnerHTML={{ __html: valueSpan }}/>;
|
2022-04-14 19:32:57 +08:00
|
|
|
|
}
|
2022-06-21 14:27:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
return newColumn;
|
|
|
|
|
|
});
|
2023-06-19 17:51:51 +08:00
|
|
|
|
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>
|
2023-07-03 16:03:56 +08:00
|
|
|
|
<Dropdown
|
|
|
|
|
|
overlay={
|
|
|
|
|
|
<Menu onClick={() => this.onOperatesClick(record, "2")}>
|
|
|
|
|
|
<Menu.Item key="delete">{getLabel(535052, "删除")}</Menu.Item>
|
|
|
|
|
|
</Menu>
|
|
|
|
|
|
}>
|
|
|
|
|
|
<i className="icon-coms-more more"/>
|
|
|
|
|
|
</Dropdown>
|
2023-06-19 17:51:51 +08:00
|
|
|
|
</React.Fragment>;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
2022-06-21 14:27:16 +08:00
|
|
|
|
};
|
2022-04-14 19:32:57 +08:00
|
|
|
|
|
2022-06-21 14:27:16 +08:00
|
|
|
|
render() {
|
|
|
|
|
|
const { payrollStore } = this.props;
|
2023-06-19 17:51:51 +08:00
|
|
|
|
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)
|
|
|
|
|
|
};
|
2022-06-21 14:27:16 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
2023-06-19 17:51:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
loading
|
|
|
|
|
|
? <div style={{ width: "100%", textAlign: "center" }}>
|
|
|
|
|
|
<Spin/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
: <WeaTable
|
|
|
|
|
|
rowKey="id"
|
|
|
|
|
|
rowSelection={rowSelection}
|
|
|
|
|
|
columns={this.getColumns()}
|
|
|
|
|
|
dataSource={toJS(templateTableDataSource)}
|
|
|
|
|
|
pagination={pagination}
|
|
|
|
|
|
/>
|
|
|
|
|
|
}
|
2022-06-21 14:27:16 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|