diff --git a/pc4mobx/hrmSalary/apis/statistics.js b/pc4mobx/hrmSalary/apis/statistics.js index 3ac89281..6fcc827b 100644 --- a/pc4mobx/hrmSalary/apis/statistics.js +++ b/pc4mobx/hrmSalary/apis/statistics.js @@ -9,3 +9,11 @@ export const dimensionGetForm = (params) => { export const dimensionSave = (params) => { return postFetch("/api/bs/hrmsalary/report/statistics/dimension/save", params); }; +// 薪酬统计维度列表 +export const dimensionList = (params) => { + return postFetch("/api/bs/hrmsalary/report/statistics/dimension/list", params); +}; +// 删除薪酬统计维度 +export const dimensionDelete = (params) => { + return postFetch("/api/bs/hrmsalary/report/statistics/dimension/delete", params); +}; diff --git a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/conditions.js b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/conditions.js index e8066d81..42ef8654 100644 --- a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/conditions.js +++ b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/conditions.js @@ -18,7 +18,7 @@ export const condition = [ { colSpan: 1, conditionType: "SELECT", - domkey: ["dimCode"], + domkey: ["setting4Qualitative"], fieldcol: 14, label: "统计维度", labelcol: 6, @@ -35,7 +35,19 @@ export const condition = [ labelcol: 6, value: "", rules: "required|string", - viewAttr: 3, + viewAttr: 3 + }, + { + colSpan: 1, + conditionType: "SELECT", + domkey: ["dimCode"], + fieldcol: 14, + label: "分组所属字段", + labelcol: 6, + options: [], + viewAttr: 2, + helpfulTip: "", + hide: true }, { colSpan: 1, @@ -45,10 +57,10 @@ export const condition = [ label: "描述", labelcol: 6, value: "", - viewAttr: 2, - }, + viewAttr: 2 + } ], title: "基础设置", - defaultshow: true, - }, + defaultshow: true + } ]; diff --git a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionSlide.js b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionSlide.js index 046c14c1..c3ba1159 100644 --- a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionSlide.js +++ b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionSlide.js @@ -6,10 +6,8 @@ */ import React, { Component } from "react"; import { WeaDialog } from "ecCom"; -import { Button } from "antd"; -import { condition } from "./conditions"; -import { commonEnumList } from "../../../apis/ruleconfig"; -import { dimensionGetForm } from "../../../apis/statistics"; +import { Button, message } from "antd"; +import { dimensionGetForm, dimensionSave } from "../../../apis/statistics"; import { getSearchs } from "../../../util"; import "../index.less"; @@ -17,46 +15,90 @@ class DimensionSlide extends Component { constructor(props) { super(props); this.state = { + loading: false, date: "" }; } + componentDidMount() { + this.props.initCondition(); + } + componentWillReceiveProps(nextProps, nextContext) { - if (nextProps.visible !== this.props.visible && nextProps.visible) { - const promise = this.initCondition(); - nextProps.form.initFormFields(condition); + if (nextProps.visible !== this.props.visible && nextProps.formId) this.dimensionGetForm({ id: nextProps.formId }); + if (nextProps.visible !== this.props.visible && !nextProps.formId) { + nextProps.form.updateFields({ + dimType: "QUALITATIVE" + }); + nextProps.onChangeCondition("QUALITATIVE"); } } - - initCondition = async () => { - const [dimTypeEnum, dimCodeList] = await Promise.all([this.commonEnumList(), this.dimensionGetForm()]); - const { data: dimTypeData } = dimTypeEnum, { data: dimCodeData } = dimCodeList; - - - console.log(dimTypeEnum, dimCodeList, condition); - }; - commonEnumList = () => { - const payload = { - enumClass: "com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum" - }; - return commonEnumList(payload); - }; - dimensionGetForm = () => { - return dimensionGetForm(); + dimensionGetForm = (payload) => { + dimensionGetForm(payload).then(({ status, data }) => { + if (status) { + const { baseForm: { data: formData } } = data; + const fields = _.map(this.props.condition[0].items, it => { + return it.domkey[0]; + }); + fields.map(item => { + if (item !== "setting4Qualitative") { + this.props.form.updateFields({ + [item]: formData[item] || "" + }); + } else { + this.props.form.updateFields({ + setting4Qualitative: formData.statsDim + }); + } + }); + this.props.onChangeCondition(formData["dimType"], 1); + } + }); }; + handleSave = () => { + const { condition, onCancel, formId } = this.props; this.props.form.validateForm().then(f => { + console.log(f); + console.log(this.props.form.getFormParams()); if (f.isValid) { + console.log(this.props.form.getFormParams()); + return; + const { setting4Qualitative, ...extraParams } = this.props.form.getFormParams(); + const options = _.find(condition[0].items, item => item.domkey[0] === "setting4Qualitative").options; + const obj = _.find(options, item => item.key === setting4Qualitative); + const payload = { + id: formId, + ...extraParams, + setting4Qualitative: { id: obj.key, name: obj.showname } + }; + this.setState({ loading: true }); + dimensionSave(payload).then(({ status, errormsg }) => { + this.setState({ loading: false }); + if (status) { + message.success("保存成功"); + onCancel(true); + this.props.form.resetForm(); + } else { + message.error(errormsg || "保存失败"); + } + }).catch(() => this.setState({ loading: false })); } else { f.showErrors(); this.setState({ date: new Date() }); } }); }; + formItemChange = (formObj) => { + const { onChangeCondition } = this.props; + const filedKey = _.keys(formObj)[0]; + if (filedKey === "dimType") onChangeCondition(formObj[filedKey].value); + }; render() { - const { form } = this.props; + const { loading } = this.state; + const { form, condition } = this.props; return ( 新建统计维度 - + } > - {getSearchs(form, condition, 1)} + {getSearchs(form, condition, 1, false, this.formItemChange)} ); } diff --git a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionTable.js b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionTable.js index 8cdb57c9..c94e4910 100644 --- a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionTable.js +++ b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/dimensionTable.js @@ -5,13 +5,107 @@ * Date: 2023/4/11 */ import React, { Component } from "react"; +import { WeaTable } from "ecCom"; +import { message, Modal } from "antd"; +import { dimensionDelete, dimensionList } from "../../../apis/statistics"; +import "../index.less"; + class DimensionTable extends Component { - render() { - return ( -
+ constructor(props) { + super(props); + this.state = { + loading: false, + dataSource: [], + pageInfo: { + current: 0, pageSize: 10, total: 0 + } + }; + } -
+ componentDidMount() { + this.dimensionList(); + } + + dimensionList = (extra = {}) => { + const { pageInfo } = this.state; + this.setState({ loading: true }); + dimensionList({ ...pageInfo, ...extra }).then(({ status, data }) => { + this.setState({ loading: false }); + if (status) { + const { pageNum: curren, pageSize, total, list: dataSource } = data; + this.setState({ + dataSource, + pageInfo: { + ...pageInfo, + curren, pageSize, total + } + }); + } + }).catch(() => this.setState({ loading: false })); + }; + dimensionDelete = (payload) => { + Modal.confirm({ + title: "信息确认", + content: "确认要删除吗?", + onOk: () => { + dimensionDelete(payload).then(({ status, errormsg }) => { + if (status) { + message.success("删除成功"); + this.dimensionList(); + } else { + message.error(errormsg || "删除失败"); + } + }); + } + }); + }; + + render() { + const { dataSource, loading, pageInfo } = this.state; + const { onEdit } = this.props; + const pagination = { + ...pageInfo, + showTotal: total => `共 ${total} 条`, + showQuickJumper: true, + showSizeChanger: true, + pageSizeOptions: ["10", "20", "50", "100"], + onShowSizeChange: (current, pageSize) => { + this.setState({ + pageInfo: { ...pageInfo, current, pageSize } + }, () => this.dimensionList()); + }, + onChange: current => { + this.setState({ + pageInfo: { ...pageInfo, current } + }, () => this.dimensionList()); + } + }; + const columns = [ + { dataIndex: "dimName", title: "统计维度" }, + { dataIndex: "remark", title: "描述" }, + { dataIndex: "dimType", title: "维度类型" }, + { + dataIndex: "operate", title: "操作", + render: (_, record) => { + return ( + + onEdit(record.id)}>编辑 + this.dimensionDelete([record.id])}>删除 + + ); + } + } + ]; + return ( + ); } } diff --git a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/statisticsModal.js b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/statisticsModal.js index de45c1c3..8354993a 100644 --- a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/statisticsModal.js +++ b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/statisticsModal.js @@ -17,8 +17,8 @@ class StatisticsModal extends Component { ] : []; return ( { + const { attendanceStore: { statisticsForm } } = this.props; + const [dimTypeEnum, dimCodeList] = await Promise.all([this.commonEnumList(), this.dimensionGetForm()]); + const { data: dimTypeData } = dimTypeEnum, { data: dimCodeData } = dimCodeList; + const { baseForm: { statsDimOptions, groupDimOptions, data: dimTypeValue } } = dimCodeData; + this.setState({ + conditions: _.map(condition, item => { + return { + ...item, + items: _.map(item.items, child => { + if (child.domkey[0] === "dimType") { + return { + ...child, + value: dimTypeValue.dimType, + options: _.map(dimTypeData, dimTypeItem => ({ + key: dimTypeItem.value, + showname: dimTypeItem.defaultLabel + })) + }; + } + if (child.domkey[0] === "setting4Qualitative") { + return { + ...child, + options: _.map(statsDimOptions, dimCodeItem => ({ + key: dimCodeItem.id, + showname: dimCodeItem.content + })) + }; + } + if (child.domkey[0] === "dimCode") { + return { + ...child, + options: _.map(groupDimOptions, dimCodeItem => ({ + key: dimCodeItem.id, + showname: dimCodeItem.content + })) + }; + } + return { ...child }; + }) + }; + }) + }, () => { + this.setState({ convertConditions: this.state.conditions }); + statisticsForm.initFormFields(this.state.conditions); + }); + }; + commonEnumList = () => { + const payload = { + enumClass: "com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum" + }; + return commonEnumList(payload); + }; + dimensionGetForm = () => { + return dimensionGetForm(); + }; + handleChangeCondition = (val, viewAttr) => { + const { attendanceStore: { statisticsForm, initStatisticsForm } } = this.props; + console.log(val); + const helpfulTitle = val === "RATION_GROUP_SPACING" ? + "例:\n" + + " 若:所属字段为【工龄】,分组设置为【0-5】,【5-10】;统计项为【税前薪资】,对应的统计规则为【求和】; 则统计结果为:【工龄】为【0-5】的所有人的【税前薪资】求和,【工龄】为【5-10】的所有人的【税前薪资】求和;\n" + + "若:未选择所属字段,分组设置为【0-10,000.00】,【10,000.00-20,000.00】;若统计项为【税前薪资】,对应的统计规则为【计数】; 则统计结果为:【税前薪资】为【0-10,000.00】有多少人,【税前薪资】为【10,000.00-20,000.00】有多少人;" : + val === "RATION_GROUP_INDIVIDUAL" ? + "例:\n" + + " 若:所属字段为【职级】,分组设置为【1】,【2】,【3】;统计项为【税前薪资】,对应的统计规则为【平均值】; 则统计结果为:【职级】为【1】的所有人的【税前薪资】的平均值,【职级】为【2】的所有人的【税前薪资】的平均值;【职级】为【3】的所有人的【税前薪资】的平均值;\n" + + "若:未选择所属字段,分组设置为【1】,【2】,【3】;若统计项为【绩效】,对应的统计规则为【计数】; 则统计结果为:【绩效】为【1】有多少人,绩效为【2】有多少人,绩效为【3】有多少人;" : ""; + + if (val === "QUALITATIVE") { + this.setState({ + conditions: _.map(this.state.convertConditions, item => { + return { + ...item, + items: _.map(_.filter(item.items, child => child.domkey[0] !== "dimCode"), it => { + if (it.domkey[0] === "dimType") { + return { ...it, value: val, viewAttr: viewAttr ? viewAttr : it.viewAttr }; + } + return { ...it }; + }) + }; + }) + }, () => { + initStatisticsForm(this.state.conditions); + }); + } else { + this.setState({ + conditions: _.map(this.state.convertConditions, item => { + return { + ...item, + items: _.map(_.filter(item.items, child => child.domkey[0] !== "setting4Qualitative"), it => { + if (it.domkey[0] === "dimType") { + return { ...it, value: val, viewAttr: viewAttr ? viewAttr : it.viewAttr }; + } else if (it.domkey[0] === "dimCode") { + return { ...it, helpfulTitle }; + } + return { ...it }; + }) + }; + }) + }, () => { + initStatisticsForm(this.state.conditions); + // statisticsForm.initFormFields(this.state.conditions); + }); + } + }; handleReqBtnsClick = (key) => { if (key === "search") { @@ -37,7 +148,7 @@ class Index extends Component { const title = key === "dimension" ?
统计维度管理 - +
: "新建报表"; this.setState({ @@ -56,26 +167,31 @@ class Index extends Component { } }); }; - handleAddDimension = () => { + handleAddDimension = (formId = "") => { const { slideReq } = this.state; this.setState({ slideReq: { - ...slideReq, visible: true + ...slideReq, visible: true, + formId } }); }; - handleClose = () => { + handleClose = (initTable = false) => { + const { attendanceStore: { statisticsForm } } = this.props; const { slideReq } = this.state; this.setState({ slideReq: { - ...slideReq, visible: false + ...slideReq, visible: false, formId: "" } + }, () => { + statisticsForm.resetForm(); + initTable && this.dimensionTableRef.dimensionList(); }); }; render() { const { taxAgentStore: { showOperateBtn }, attendanceStore: { statisticsForm } } = this.props; - const { selectedKey, modalReq, slideReq } = this.state; + const { selectedKey, modalReq, slideReq, conditions } = this.state; const buttons = [ , , @@ -95,9 +211,18 @@ class Index extends Component { >
-
123
+ { + modalReq.typeKey === "dimension" && + this.dimensionTableRef = dom} + onEdit={id => this.handleAddDimension(id)} + /> + }
- +
); diff --git a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/index.less b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/index.less index 9840ad74..d53b539c 100644 --- a/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/index.less +++ b/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/index.less @@ -15,6 +15,17 @@ justify-content: space-between; } + .dimensionTableWrapper { + .space10 { + a:first-child { + margin-right: 10px; + } + } + } + +} + +.dimensionSlideWrapper { .wea-select, .ant-select, .ant-select-selection { width: 100%; } diff --git a/pc4mobx/hrmSalary/stores/attendanceStore.js b/pc4mobx/hrmSalary/stores/attendanceStore.js index ed18f076..48730bb5 100644 --- a/pc4mobx/hrmSalary/stores/attendanceStore.js +++ b/pc4mobx/hrmSalary/stores/attendanceStore.js @@ -1,4 +1,4 @@ -import { observable } from "mobx"; +import { action, observable } from "mobx"; import { WeaForm } from "comsMobx"; @@ -7,4 +7,11 @@ export class AttendanceStore { @observable refenceform = new WeaForm(); //薪酬统计 新增form @observable statisticsForm = new WeaForm(); + + @action + initStatisticsForm = (condition) => { + this.statisticsForm && this.statisticsForm.updateIsFormInit(false); + this.statisticsForm = new WeaForm(); + this.statisticsForm.setCondition(condition, true); + }; } diff --git a/pc4mobx/hrmSalary/util/index.js b/pc4mobx/hrmSalary/util/index.js index ffaa1956..7c1344f7 100644 --- a/pc4mobx/hrmSalary/util/index.js +++ b/pc4mobx/hrmSalary/util/index.js @@ -1,65 +1,35 @@ -import { Spin } from 'antd'; -import { WeaSwitch } from 'comsMobx'; -import { WeaLocaleProvider, WeaAlertPage, WeaSearchGroup, WeaFormItem } from 'ecCom'; +import { Spin } from "antd"; +import { WeaSwitch } from "comsMobx"; +import { WeaAlertPage, WeaFormItem, WeaHelpfulTip, WeaLocaleProvider, WeaSearchGroup } from "ecCom"; + const getLabel = WeaLocaleProvider.getLabel; -// 渲染form表单: 一般对form的渲染都统一使用该方法 -export const getCustomSearchs = (form, condition, col, isCenter) => { - const { isFormInit } = form; - const formParams = form.getFormParams(); - let items = []; - let group = []; - isFormInit && condition && - condition.map(c =>{ - c.items.map(fields => { - items.push({ - com:( - - - ), - colSpan:1, - }) - }); +// 获取condition的domKey值 +export const getConditionDomkeys = (condition) => { + let domkeyList = []; + _.forEach(condition, item => { + const tmpV = _.reduce(item.items, (pre, cur) => { + return [...pre, cur["domkey"][0]]; + }, []); + domkeyList = domkeyList.concat(tmpV); }); - - if(items.length > 0) { - group.push( - ) - return group; - } -} + return domkeyList; +}; // 渲染form表单: 一般对form的渲染都统一使用该方法 -export const getSearchs = (form, condition, col, isCenter) => { +export const getSearchs = (form, condition, col, isCenter, onChange = () => void (0)) => { const { isFormInit } = form; const formParams = form.getFormParams(); let group = []; - isFormInit && condition && condition.map(c =>{ + isFormInit && condition && condition.map(c => { let items = []; c.items.map(fields => { items.push({ - com:( + com: ( @@ -67,39 +37,44 @@ export const getSearchs = (form, condition, col, isCenter) => { fieldConfig={fields} form={form} formParams={formParams} + onChange={onChange} /> + { + fields.helpfulTitle && + + } ), - colSpan:1, - }) + colSpan: 1 + }); }); group.push( ) + />); }); return group; -} +}; // 页面加载中效果处理 export const renderLoading = (loading) => (
- +
-) +); // 无权限处理 export const renderNoright = () => (
- {getLabel(2012,'对不起,您暂时没有权限!')} + {getLabel(2012, "对不起,您暂时没有权限!")}
-) +); // 暂无数据处理 export const renderNoData = () => ( @@ -108,13 +83,13 @@ export const renderNoData = () => ( 暂无数据 -) +); //分页计算 -export function calcPageNo (total, pageNo = 1, pageSize = 10, selectDelDataLen = 1) { - const totalPage = Math.ceil((total - selectDelDataLen) / pageSize) // 总页数 - pageNo = pageNo > totalPage ? totalPage : pageNo - pageNo = pageNo < 1 ? 1 : pageNo - return pageNo +export function calcPageNo(total, pageNo = 1, pageSize = 10, selectDelDataLen = 1) { + const totalPage = Math.ceil((total - selectDelDataLen) / pageSize); // 总页数 + pageNo = pageNo > totalPage ? totalPage : pageNo; + pageNo = pageNo < 1 ? 1 : pageNo; + return pageNo; }