diff --git a/pc4mobx/hrmSalary/index.js b/pc4mobx/hrmSalary/index.js index cbaf1ff0..ca8f7464 100644 --- a/pc4mobx/hrmSalary/index.js +++ b/pc4mobx/hrmSalary/index.js @@ -15,7 +15,8 @@ import CumSituation from "./pages/dataAcquisition/cumSituation"; import Attendance from "./pages/dataAcquisition/attendance"; import SpecialAddDeduction from "./pages/dataAcquisition/specialAddDeduction"; import Ledger from "./pages/ledgerPage"; -import Calculate from "./pages/calculate"; +// import Calculate from "./pages/calculate"; +import Calculate from "./pages/calculate/calculate"; //重构的薪资核算页面 import Payroll from "./pages/payroll"; import PayrollGrant from "./pages/payroll/payrollGrant"; import PayrollDetail from "./pages/payroll/payrollDetail"; diff --git a/pc4mobx/hrmSalary/pages/calculate/calculate.js b/pc4mobx/hrmSalary/pages/calculate/calculate.js new file mode 100644 index 00000000..ae98e007 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculate/calculate.js @@ -0,0 +1,209 @@ +/* + * Author: 黎永顺 + * name: 薪资核算-重构页面 + * Description: + * Date: 2023/10/9 + */ +import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; +import { WeaLocaleProvider, WeaTop } from "ecCom"; +import { Button, message, Modal } from "antd"; +import moment from "moment"; +import CalculateQuery from "./components/calculateQuery"; +import CalculateTablelist from "./components/calculateTablelist"; +import CalculateDialog from "./components/calculateDialog"; +import { backCalculate, deleteSalaryacct, fileSalaryAcct, reAccounting } from "../../apis/calculate"; +import "./index.less"; +import ProgressModal from "../../components/progressModal"; + +const getLabel = WeaLocaleProvider.getLabel; + +@inject("calculateStore", "taxAgentStore") +@observer +class Calculate extends Component { + constructor(props) { + super(props); + this.state = { + queryParams: { + name: "", + dateRange: [ + moment(new Date()).startOf("year").format("YYYY-MM"), + moment(new Date()).startOf("month").format("YYYY-MM") + ] + }, isRefresh: false, + progressModule: { visible: false, progress: 0, title: getLabel(111, "正在归档中请稍后") }, + calcDaialog: { visible: false, title: "" } + }; + this.timer = null; + this.handleDebounce = null; + } + + renderCalculateOpts = () => { + const { taxAgentStore: { showOperateBtn } } = this.props; + const { queryParams, isRefresh } = this.state; + let calculateOpts = [ + , + this.setState({ + isRefresh: _.keys(v)[0] === "name" ? isRefresh : !isRefresh, + queryParams: { ...queryParams, ...v } + })} onSearch={() => this.setState({ isRefresh: !isRefresh })}/> + ]; + return !showOperateBtn ? calculateOpts.slice(1) : calculateOpts; + }; + handleCalcOpts = ({ key }, record) => { + const { isRefresh, progressModule } = this.state, { id } = record; + switch (key) { + case "0": + //核算 + window.open(`/spa/hrmSalary/static/index.html#/main/hrmSalary/calculate/${id}`); + break; + case "1": + //删除 + Modal.confirm({ + title: getLabel(131329, "信息确认"), + content: getLabel(543231, "确认删除本条数据吗?"), + onOk: () => { + deleteSalaryacct([id]).then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(502230, "删除成功!")); + this.setState({ isRefresh: !isRefresh }); + } else { + message.error(errormsg); + } + }); + } + }); + break; + case "2": + //归档 + if (!this.handleDebounce) { + this.handleDebounce = _.debounce(() => { + if (this.timer) clearInterval(this.timer); + this.setState({ progressModule: { ...progressModule, visible: true } }); + this.timer = setInterval(() => { + if (progressModule.progress === 100 && this.timer) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressModule: { ...progressModule, visible: false, progress: 0 }, + isRefresh: !isRefresh + }); + } + this.setState({ + progressModule: { ...progressModule, progress: progressModule.progress + 1 } + }); + }, 800); + fileSalaryAcct({ id }).then(({ status, errormsg }) => { + if (status) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressModule: { ...progressModule, visible: false, progress: 0 }, + isRefresh: !isRefresh + }); + message.success(getLabel(503690, "归档成功")); + } else { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressModule: { ...progressModule, visible: false, progress: 0 } + }); + message.error(errormsg); + } + }); + this.handleDebounce = null; + }, 500); + } + this.handleDebounce(); + break; + case "3": + //查看详情 + window.open(`/spa/hrmSalary/static/index.html#/main/hrmSalary/placeOnFileDetail?id=${id}`); + break; + case "4": + //重新核算 + if (!this.handleDebounce) { + this.handleDebounce = _.debounce(() => { + reAccounting({ salaryAcctRecordId: id }).then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(30700, "操作成功!")); + this.setState({ isRefresh: !isRefresh }); + } else { + message.error(errormsg); + } + }); + this.handleDebounce = null; + }, 500); + } + this.handleDebounce(); + break; + case "5": + //回算 + Modal.confirm({ + title: getLabel(131329, "信息确认"), + content: getLabel(543538, "确定回算吗?回算后,正常核算的数据会被覆盖,正常核算的工资单不能继续发放或撤回!"), + onOk: () => { + if (!this.handleDebounce) { + this.handleDebounce = _.debounce(() => { + backCalculate({ salaryAcctRecordId: id }).then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(544367, "回算成功!")); + this.setState({ isRefresh: !isRefresh }); + } else { + message.error(errormsg); + } + }); + this.handleDebounce = null; + }, 500); + } + this.handleDebounce(); + } + }); + break; + default: + break; + } + }; + + render() { + const { queryParams, isRefresh, calcDaialog, progressModule } = this.state; + return ( + } iconBgcolor="#F14A2D" + buttons={this.renderCalculateOpts()} className="calculate-main-layout" + > +
+ + this.setState({ + calcDaialog: { ...calcDaialog, visible: false }, + isRefresh: bool === "refresh" ? !isRefresh : isRefresh + }, () => bool === "refresh" && window.open(`/spa/hrmSalary/static/index.html#/main/hrmSalary/calculate/${id}`))} + /> + {/* 归档进度条*/} + { + progressModule.visible && + { + this.setState({ + progressModule: { + ...progressModule, + visible: false, + progress: 0 + } + }, () => clearInterval(this.timer)); + }} + /> + } +
+
+ ); + } +} + +export default Calculate; diff --git a/pc4mobx/hrmSalary/pages/calculate/columns.js b/pc4mobx/hrmSalary/pages/calculate/columns.js deleted file mode 100644 index 17c4adc3..00000000 --- a/pc4mobx/hrmSalary/pages/calculate/columns.js +++ /dev/null @@ -1,56 +0,0 @@ -export const columns = [ - { - title: "薪资所属月", - dataIndex: 'title', - key: 'title', - }, - { - title: "薪资账套", - dataIndex: 'title', - key: 'title', - }, - { - title: "状态", - dataIndex: 'title', - key: 'title', - }, - { - title: "税款所属期", - dataIndex: 'title', - key: 'title', - }, - { - title: "核算人数", - dataIndex: 'title', - key: 'title', - }, - { - title: "核算人", - dataIndex: 'title', - key: 'title', - }, - { - title: "最后操作时间", - dataIndex: 'title', - key: 'title', - }, - { - title: "备注", - dataIndex: 'title', - key: 'title', - }, - { - title: "操作", - dataIndex: 'cz', - key: 'cz', - } -] - -export const dataSource = [{ - title: "测试" -}]; - - - - - diff --git a/pc4mobx/hrmSalary/pages/calculate/components/calculateDialog/condition.js b/pc4mobx/hrmSalary/pages/calculate/components/calculateDialog/condition.js new file mode 100644 index 00000000..3274d070 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculate/components/calculateDialog/condition.js @@ -0,0 +1,43 @@ +export const calculateConditions = [ + { + items: [ + { + colSpan: 1, + conditionType: "MONTHPICKER", + domkey: ["salaryMonthStr"], + fieldcol: 14, + label: "薪资所属月", + lanId: 542604, + labelcol: 6, + value: "", + rules: "required|string", + viewAttr: 3 + }, + { + colSpan: 1, + conditionType: "SELECT", + domkey: ["salarySobId"], + fieldcol: 14, + label: "核算账套", + lanId: 519146, + labelcol: 6, + options: [], + rules: "required|string", + viewAttr: 3 + }, + { + colSpan: 1, + conditionType: "INPUT", + domkey: ["description"], + fieldcol: 14, + label: "备注", + lanId: 536726, + labelcol: 6, + value: "", + viewAttr: 2 + } + ], + defaultshow: true, + title: "" + } +]; diff --git a/pc4mobx/hrmSalary/pages/calculate/components/calculateDialog/index.js b/pc4mobx/hrmSalary/pages/calculate/components/calculateDialog/index.js new file mode 100644 index 00000000..db89f81b --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculate/components/calculateDialog/index.js @@ -0,0 +1,92 @@ +/* + * Author: 黎永顺 + * name: 薪资核算重构-核算弹框 + * Description: + * Date: 2023/10/9 + */ +import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; +import { WeaDialog, WeaLocaleProvider, WeaTools } from "ecCom"; +import { Button, message } from "antd"; +import { getSearchs } from "../../../../util"; +import { salaryacctGetForm, saveBasic } from "../../../../apis/calculate"; +import { calculateConditions } from "./condition"; + +const getKey = WeaTools.getKey; +const getLabel = WeaLocaleProvider.getLabel; + +@inject("calculateStore") +@observer +class Index extends Component { + constructor(props) { + super(props); + this.state = { + conditions: [], loading: false + }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) this.salaryacctGetForm(nextProps); + if (nextProps.visible !== this.props.visible && !nextProps.visible) this.props.calculateStore.initCalcForm(); + } + + salaryacctGetForm = (props) => { + const { calculateStore: { calculateForm } } = props; + salaryacctGetForm().then(({ status, data }) => { + if (status) { + const { salarySobs } = data; + this.setState({ + conditions: _.map(calculateConditions, item => ({ + ...item, + items: _.map(item.items, o => { + if (getKey(o) === "salarySobId") { + return { + ...o, + options: _.map(salarySobs, g => ({ key: g.id.toString(), showname: g.name })) + }; + } + return { ...o }; + }) + })) + }, () => calculateForm.initFormFields(this.state.conditions)); + } + }); + }; + save = () => { + const { calculateStore: { calculateForm } } = this.props; + calculateForm.validateForm().then(f => { + if (f.isValid) { + const payload = calculateForm.getFormParams(); + this.setState({ loading: true }); + saveBasic({ ...payload }).then(({ status, data, errormsg }) => { + this.setState({ loading: false }); + if (status) { + message.success(getLabel(30700, "操作成功")); + this.props.onCancel("refresh", data); + } else { + message.error(errormsg); + } + }).catch(() => this.setState({ loading: false })); + } else { + f.showErrors(); + } + }); + }; + + render() { + const { conditions, loading } = this.state; + const { calculateStore: { calculateForm } } = this.props; + return ( + {getLabel(543233, "保存并进入核算")} + ]} + > +
{getSearchs(calculateForm, conditions, 1, false)}
+
+ ); + } +} + +export default Index; diff --git a/pc4mobx/hrmSalary/pages/calculate/components/calculateQuery/index.js b/pc4mobx/hrmSalary/pages/calculate/components/calculateQuery/index.js new file mode 100644 index 00000000..00cd202d --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculate/components/calculateQuery/index.js @@ -0,0 +1,34 @@ +/* + * Author: 黎永顺 + * name: 薪资核算-查询 + * Description: + * Date: 2023/10/9 + */ +import React, { Component } from "react"; +import { WeaInputSearch, WeaLocaleProvider } from "ecCom"; +import { MonthRangePicker } from "../../../reportView/components/statisticalMicroSettingsSlide"; + +const getLabel = WeaLocaleProvider.getLabel; + +class Index extends Component { + render() { + const { queryParams } = this.props; + const { dateRange, name } = queryParams; + return ( +
+
+ {getLabel(543549, "薪资所属月:")} + this.props.onChange({ dateRange: v })}/> +
+ this.props.onChange({ name: v })} + onSearch={this.props.onSearch} + /> +
+ ); + } +} + +export default Index; diff --git a/pc4mobx/hrmSalary/pages/calculate/components/calculateTablelist/index.js b/pc4mobx/hrmSalary/pages/calculate/components/calculateTablelist/index.js new file mode 100644 index 00000000..7fc9df9a --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculate/components/calculateTablelist/index.js @@ -0,0 +1,153 @@ +/* + * Author: 黎永顺 + * name: 薪资核算-列表 + * Description: + * Date: 2023/10/9 + */ +import React, { Component } from "react"; +import { WeaHelpfulTip, WeaLocaleProvider, WeaTable } from "ecCom"; +import { Dropdown, Menu, Tag } from "antd"; +import { getSalaryAcctList } from "../../../../apis/calculate"; + +const getLabel = WeaLocaleProvider.getLabel; + +class Index extends Component { + constructor(props) { + super(props); + this.state = { + loading: false, columns: [], dataSource: [], + pageInfo: { current: 1, pageSize: 10, total: 0 } + }; + } + + componentDidMount() { + this.getSalaryAcctList(this.props); + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.isRefresh !== this.props.isRefresh) this.getSalaryAcctList(nextProps); + } + + getSalaryAcctList = (props) => { + const { pageInfo } = this.state; + const { queryParams } = props; + const { dateRange, ...extra } = queryParams; + const [startMonthStr, endMonthStr] = dateRange || []; + const params = { startMonthStr, endMonthStr, ...extra }; + const payload = { ...pageInfo, ...params }; + this.setState({ loading: true }); + getSalaryAcctList(payload).then(({ status, data }) => { + this.setState({ loading: false }); + if (status) { + const { columns, list: dataSource, pageNum, pageSize, total } = data; + this.setState({ + dataSource, pageInfo: { ...pageInfo, pageNum, pageSize, total }, + columns: _.map(_.filter(columns, it => (it.dataIndex !== "backCalcStatus" && it.dataIndex !== "acctTimes")), + o => { + const { dataIndex } = o; + let width = ""; + switch (dataIndex) { + case "status": + case "employeeSize": + width = "5%"; + break; + case "salarySobName": + width = "20%"; + break; + case "description": + width = "15%"; + break; + default: + width = "10%"; + break; + } + if (dataIndex === "operate") { + return { + ...o, width: 170, + title: + {getLabel(30585, "操作")} + + , + render: (__, record) => { + const { operate = [] } = record; + return + { + _.map(operate.slice(0, 2), f => ( + this.props.onCalcOpts({ key: f.index }, record)}>{f.text} + )) + } + { + !_.isEmpty(operate.slice(2)) && + this.props.onCalcOpts(e, record)}> + { + _.map(operate.slice(2), g => ({g.text})) + } + + } + > + + + } + ; + } + }; + } else if (dataIndex === "salarySobName") { + return { + ...o, width, + render: (text, record) => { + const { acctTimes, backCalcStatus } = record; + return
+ {text} +
+ { + backCalcStatus === 1 && + + } + {`${getLabel(15323, "第")}${acctTimes}${getLabel(18929, "次")}`} +
+
; + } + }; + } + return { ...o, width }; + }) + }); + } + }).catch(() => this.setState({ loading: false })); + }; + + render() { + const { loading, dataSource, columns, pageInfo } = this.state; + const pagination = { + ...pageInfo, + showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`, + showQuickJumper: true, + showSizeChanger: true, + pageSizeOptions: ["10", "20", "50", "100"], + onShowSizeChange: (current, pageSize) => { + this.setState({ + pageInfo: { ...pageInfo, current, pageSize } + }, () => this.getSalaryAcctList(this.props)); + }, + onChange: current => { + this.setState({ + pageInfo: { ...pageInfo, current } + }, () => this.getSalaryAcctList(this.props)); + } + }; + return ( + + ); + } +} + +export default Index; diff --git a/pc4mobx/hrmSalary/pages/calculate/index.less b/pc4mobx/hrmSalary/pages/calculate/index.less index 2a274b60..013d6d00 100644 --- a/pc4mobx/hrmSalary/pages/calculate/index.less +++ b/pc4mobx/hrmSalary/pages/calculate/index.less @@ -30,6 +30,9 @@ & > span { flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .salarySobNameTagWrapper { @@ -43,3 +46,86 @@ } } } + +//重构薪资核算页 +.salary-btn-flex { + display: flex; + align-items: center; + + .mounth-range { + display: flex; + align-items: center; + margin-right: 10px; + + .label { + color: #999; + } + } + + .wea-input-focus { + margin-top: -4px; + } +} + +.calculate-main-layout { + .wea-new-top-content { + overflow-y: hidden; + } + + .calculate-body { + height: 100%; + width: 100%; + padding: 16px; + overflow-y: auto; + + .wea-new-table { + background: #fff; + } + + .ant-table-tbody { + td { + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + } + + } +} + +.calculate-dialog-layout { + background: #f6f6f6; + + .wea-search-group { + padding: 16px; + } + + .wea-select, .ant-select-selection, .ant-select { + width: 100%; + } + + .wea-select { + display: inline-block; + position: relative; + } + + .ant-select-selection { + height: 30px; + border-radius: 0; + } + + .wea-content { + padding: 0; + + .wea-form-cell-wrapper { + background: #FFF; + border: 1px solid #e5e5e5; + border-bottom: none; + + .wea-form-cell { + border-bottom: 1px solid #e5e5e5; + } + } + } +} diff --git a/pc4mobx/hrmSalary/single.js b/pc4mobx/hrmSalary/single.js index 329e1bea..863c0a8a 100644 --- a/pc4mobx/hrmSalary/single.js +++ b/pc4mobx/hrmSalary/single.js @@ -29,6 +29,13 @@ const Home = props => props.children; class Root extends React.Component { componentWillMount() { + const src = "/spa/hrmSalary/hrmSalaryCalculateDetail/css/iconfont/iconfont.css" + const link = document.createElement("link") + link.setAttribute('rel','stylesheet'); + link.setAttribute('type','text/css'); + link.setAttribute('href',src); + let header = document.getElementById("container") + header.appendChild(link) top.$(".ant-message").remove(); window.location.hash.indexOf("mobilepayroll") === -1 && allStore.taxAgentStore.getPermission(); if (window.location.hash.indexOf("payroll") !== -1) { diff --git a/pc4mobx/hrmSalary/stores/calculate.js b/pc4mobx/hrmSalary/stores/calculate.js index 2bb4e253..71f64ab6 100644 --- a/pc4mobx/hrmSalary/stores/calculate.js +++ b/pc4mobx/hrmSalary/stores/calculate.js @@ -11,6 +11,7 @@ export class calculateStore { @observable PCSearchForm = new WeaForm(); //人员确认-form @observable ECSearchForm = new WeaForm(); //薪资核算-form @observable otherConditions = []; //薪资核算-其他查询条件 + @observable calculateForm = new WeaForm(); //薪资核算重构-核算form @observable tableStore = new TableStore(); // new table @@ -71,6 +72,9 @@ export class calculateStore { // ** 薪资核算-其他条件查询 ** @action setOtherConditions = (otherConditions) => this.otherConditions = otherConditions; + // ** 薪资核算重构-初始化核算form ** + @action + initCalcForm = () => this.calculateForm = new WeaForm(); // ** 设置导入参数 ** @action