import React from 'react'; import { inject, observer } from 'mobx-react'; import { toJS } from 'mobx'; import { Button, Table, DatePicker, message, Modal } from 'antd'; import moment from 'moment' import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable,WeaDatePicker, WeaHelpfulTip, WeaSelect, WeaInputSearch, WeaSlideModal } from 'ecCom'; import { renderNoright, getSearchs } from '../../util'; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 import CustomTab from '../../components/customTab'; import ContentWrapper from '../../components/contentWrapper'; import { columns, dataSource, tempateColumns } from './columns'; import StepSlide from '../../components/stepSlide' import ItemMangeFormModal from '../dataAcquisition/attendance/itemMangeFormModal'; import BaseInformForm from './stepForm/baseInformForm' import ShowSettingForm from './stepForm/showSettingForm' import SlideModalTitle from "../../components/slideModalTitle" import TemplateSettingList from './templateSettingList' import { notNull } from '../../util/validate'; import CopyModal from './copyModal'; import SalarySendList from './SalarySendList' const { RangePicker } = DatePicker; @inject('payrollStore') @observer export default class Payroll extends React.Component { constructor(props) { super(props); this.state = { value: "", selectedKey: "0", currentStep: 0, stepSlideVisible: false, selectedTab: 0, editSlideVisible: false, initSelected: false, ledgerOptions: [], templateSearchValue: "", // 工资单模板列表-搜索条件-名称 templateSelect: "", // 工资单模板列表-搜索条件-账套下拉选中值 templateCurrentId: "", copyModalVisible: false } this.recordId = "" this.salaryYearMonth = [] this.listPageInfo = {current: 1, pageSize: 10} columns.map(item => { if(item.dataIndex == "cz") { item.render = (text, record) => { return (
) } } }) tempateColumns.map(item => { if(item.dataIndex == "username") { item.render = (text) => { return ( {this.setState({editSlideVisible: true})}}>{text} ) } } else if(item.dataIndex == "cz") { item.render = () => { return ( ) } } }) } // 更新模板 handleUpdateTemplate(record) { this.setState({ selectedKey: "1", editSlideVisible: true, templateCurrentId: record.templateId }) } // 工资单模板-新建表单变化监听 handleBaseInfoChange(request) { const { payrollStore: {setTemplateBaseData}} = this.props; setTemplateBaseData(request); } // 新建保存 handleSave() { const { payrollStore } = this.props; const { fetchSavePayroll } = payrollStore fetchSavePayroll().then(() => { this.setState({currentStep: 0, stepSlideVisible: false}) }) } componentWillMount() { const { payrollStore } = this.props; const { getPayrollTemplateLedgerList } = payrollStore; // 获取薪资账套下拉列表 getPayrollTemplateLedgerList().then((options) => { this.setState({ initSelected: true, ledgerOptions: options }) }) } // 模板搜索 handleTemplateSearch() { const { templateSearchValue, templateSelect } = this.state; let params = {name: templateSearchValue, salarySobId: templateSelect} const { payrollStore: {getPayrollTemplateList}} = this.props; getPayrollTemplateList(params) } // 模板选择框下拉改变事件 handleTemplateSelectChange(value) { this.setState({templateSelect: value}) this.handleTemplateSearch() } // 模板列表编辑 handleTemplateListEdit(record) { const { payrollStore } = this.props; const { getPayrollShowForm } = payrollStore this.recordId = record.id getPayrollShowForm(record.id) this.setState({templateCurrentId: record.id, selectedTab: 0},() => { this.setState({editSlideVisible: true}) }) } // 模板列表复制 handleTemplateListCopy(record) { this.setState({ templateCurrentId: record.id }, () => { this.setState({ copyModalVisible: true }) }) } // 复制模板保存事件监听 handleCopyModalSave(value) { const { payrollStore } = this.props; const { duplicatePayroll } = payrollStore duplicatePayroll(this.state.templateCurrentId, value).then(() => { this.setState({ copyModalVisible: false }) }) } // 模板列表删除 handleTemplateListDelete(record) { const { payrollStore: { deletePayroll }} = this.props; Modal.confirm({ title: '信息确认', content: '确认删除', onOk:() => { deletePayroll([record.id]) }, onCancel: () => { }, }); } handleRangePickerChange(value) { let range = value.map(item => moment(item).format("YYYY-MM")) const { payrollStore: { getPayrollList } } = this.props; this.salaryYearMonth = range getPayrollList({salaryYearMonth: range, ...this.listPageInfo}) } // 预览 handlePreview() { const { payrollStore : {templateBaseData, salaryTemplateShowSet, salaryItemSet}} = this.props; window.localStorage.setItem("templateBaseData", JSON.stringify(templateBaseData)) window.localStorage.setItem("salaryTemplateShowSet", JSON.stringify(salaryTemplateShowSet)) window.localStorage.setItem("salaryItemSet", JSON.stringify(salaryItemSet)) window.open("/spa/hrmSalary/static/index.html#/main/hrmSalary/templatePreview") } // 更新保存 handleUpdateSave() { const { payrollStore} = this.props; const { fetchUpdatePayroll } = payrollStore; fetchUpdatePayroll(this.recordId).then(() => { this.setState({ editSlideVisible: false, selectedTab: 0 }) }) } // 发放页面页码跳转 handleListDataPageChange(value, pageInfo) { const { payrollStore: {getPayrollList} } = this.props; this.listPageInfo = pageInfo getPayrollList({salaryYearMonth: this.salaryYearMonth, ...pageInfo}) } // 发放页面每页条数 handleListShowSizeChange(pageInfo) { const { payrollStore: {getPayrollList} } = this.props; this.listPageInfo = pageInfo getPayrollList({salaryYearMonth: this.salaryYearMonth, ...pageInfo}) } render() { const { payrollStore } = this.props; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = payrollStore; const { currentStep, selectedTab, templateSearchValue, templateSelect } = this.state if (!hasRight && !loading) { // 无权限处理 return renderNoright(); } const rightMenu = [// 右键菜单 // { // key: 'BTN_COLUMN', // icon: , // content: '显示列定制', // onClick: this.showColumn // }, ]; const collectParams = { // 收藏功能配置 favname: '工资单发放', favouritetype: 1, objid: 0, link: 'wui/index.html#/ns_demo03/index', importantlevel: 1, }; const adBtn = [ // 高级搜索内部按钮 , , , ]; const topTab = [{ title: "工资单发放", viewcondition: "0" }, { title: "工资单模板设置", viewcondition: "1" }]; const renderRightOperation = () => { if(this.state.selectedKey == "0") { return