From 10721ecba0f21edfba7e42f311bb3ef2c70dc5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 2 Mar 2023 18:44:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E4=BF=9D=E7=A6=8F=E5=88=A9=E6=96=B9?= =?UTF-8?q?=E6=A1=88-=E8=87=AA=E5=AE=9A=E4=B9=89=E6=96=B9=E6=A1=88?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/welfareScheme.js | 10 +- .../programme/customBenefitsTable.js | 131 ++++++++++++++++++ .../programme/customNewModal.js | 4 +- .../socialSecurityBenefits/programme/index.js | 82 +++-------- pc4mobx/hrmSalary/stores/programme.js | 3 - 5 files changed, 161 insertions(+), 69 deletions(-) create mode 100644 pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customBenefitsTable.js diff --git a/pc4mobx/hrmSalary/apis/welfareScheme.js b/pc4mobx/hrmSalary/apis/welfareScheme.js index d0e0b11c..e7d1f3e7 100644 --- a/pc4mobx/hrmSalary/apis/welfareScheme.js +++ b/pc4mobx/hrmSalary/apis/welfareScheme.js @@ -62,7 +62,15 @@ export const getCustomCategoryForm = params => { return WeaTools.callApi('/api/bs/hrmsalary/sicategory/customCategoryForm', 'get', params); }; export const getCustomCategoryList = params => { - return WeaTools.callApi('/api/bs/hrmsalary/sicategory/customCategoryList', 'get', params); + // return WeaTools.callApi('/api/bs/hrmsalary/sicategory/customCategoryList', 'get', params); + return fetch('/api/bs/hrmsalary/sicategory/customCategoryList', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) }; export const createSICategory = params => { return fetch('/api/bs/hrmsalary/sicategory/createSICategory', { diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customBenefitsTable.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customBenefitsTable.js new file mode 100644 index 00000000..79ade76e --- /dev/null +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customBenefitsTable.js @@ -0,0 +1,131 @@ +/* + * Author: 黎永顺 + * name: 社保福利方案-自定义福利表格 + * Description: + * Date: 2023/3/2 + */ +import React, { Component } from "react"; +import { WeaCheckbox, WeaTable } from "ecCom"; +import { message, Modal } from "antd"; +import { getCustomCategoryList, updateCustomCategoryStatus } from "../../../apis/welfareScheme"; + +class CustomBenefitsTable extends Component { + constructor(props) { + super(props); + this.state = { + loading: { + query: false + }, + dataSource: [], + columns: [], + pageInfo: { + current: 1, + pageSize: 10, + total: 0 + } + }; + } + + componentDidMount() { + this.getCustomCategoryList(); + } + + getCustomCategoryList = (extraPayload) => { + const { loading, pageInfo } = this.state; + const { welfareTypeEnum } = this.props; + const module = { welfareTypeEnum, ...pageInfo, ...extraPayload }; + this.setState({ loading: { ...loading, query: true } }); + getCustomCategoryList(module).then(({ status, data }) => { + this.setState({ loading: { ...loading, query: false } }); + if (status) { + const { columns, list: dataSource, pageNum: current, pageSize, total } = data; + this.setState({ + pageInfo: { ...pageInfo, current, pageSize, total }, + dataSource, + columns + }); + } + }).catch(() => this.setState({ loading: { ...loading, query: false } })); + }; + getColumns = () => { + const { columns } = this.state; + const { showOperateBtn, onCustomEdit } = this.props; + return [..._.map(_.filter(columns, item => !!item.display), child => ({ + ...child, + render: (text, record) => { + switch (child.dataIndex) { + case "isUse": + return ( + this.handleCustomBenefitsSwitch(record, value)} + /> + ); + default: + return
; + } + } + })), { + title: "操作", + width: 120, + dataIndex: "operate", + render: (_, record) => { + return ( +
+ {showOperateBtn && + onCustomEdit(record)}>编辑 + } +
+ ); + } + }]; + }; + handleCustomBenefitsSwitch = ({ id }, isUse) => { + Modal.confirm({ + title: "信息确认", + content: `确认要${isUse ? "启用" : "停用"}吗`, + onOk: () => { + const payload = { id, isUse }; + updateCustomCategoryStatus(payload).then(({ status, errormsg }) => { + if (status) { + message.success("操作成功"); + this.getCustomCategoryList(); + } else { + message.error(errormsg || "操作失败"); + } + }); + } + }); + }; + + render() { + const { dataSource, pageInfo, loading } = this.state; + 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.getCustomCategoryList()); + }, + onChange: current => { + this.setState({ + pageInfo: { ...pageInfo, current } + }, () => this.getCustomCategoryList()); + } + }; + return ( + + ); + } +} + +export default CustomBenefitsTable; diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js index 95339fb1..b5a775e4 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js @@ -16,11 +16,11 @@ export default class CustomNewModal extends React.Component { const { programmeStore: { createSICategory, customRequest, updateCustomCategory } } = this.props; if (!this.props.edit) { // 新增 createSICategory(customRequest).then(() => { - this.props.onCancel(); + this.props.onCancel(true); }); } else { updateCustomCategory(customRequest).then(() => { - this.props.onCancel(); + this.props.onCancel(true); }); } } diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js index 1df0a010..07629fd4 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js @@ -15,6 +15,7 @@ import CustomPaginationTable from "../../../components/customPaginationTable"; import TwoColContent from "../../../components/twoColContent"; import CopySchemaModal from "./copySchemaModal"; import "./index.less"; +import CustomBenefitsTable from "./customBenefitsTable"; const WeaMobxTable = WeaTableNew.WeaTable; @@ -151,47 +152,6 @@ export default class Programme extends React.Component { }); } - getCustomColumns = columns => { - const { taxAgentStore: { showOperateBtn } } = this.props; - let newColumns = []; - newColumns = columns.map(column => { - let newColumn = column; - newColumn.render = (text, record, index) => { - //前端元素转义 - let valueSpan = - record[newColumn.dataIndex + "span"] !== undefined - ? record[newColumn.dataIndex + "span"] - : record[newColumn.dataIndex]; - switch (newColumn.dataIndex) { - case "operate": - return ( - { - this.onCustomEdit(record); - }}> - 编辑 - - ); - case "is_use": - return ( - { - this.handleCategoryStatusChange(record, value); - }} - /> - ); - default: - return
; - } - }; - return newColumn; - }); - return newColumns; - }; - onEdit(record) { let id = record.id; const { programmeStore } = this.props; @@ -226,14 +186,6 @@ export default class Programme extends React.Component { }); }; - onCustomOperatesClick(record, index, operate, flag) { - switch (operate.text.toString()) { - case "编辑": // 编辑 - this.onCustomEdit(record); - break; - } - } - onCustomEdit = (record) => { const { programmeStore: { getCustomForm, setCustomNewVisible, setCustomRequest }, @@ -249,9 +201,9 @@ export default class Programme extends React.Component { customEdit: true }); setCustomRequest({ - insuranceName: record["insurance_name"], + insuranceName: record["insuranceName"], id: record.id, - isUse: record.is_use, + isUse: record.isUse, paymentScope: record["payment_scope"].split(",").map(item => paymentScopeEnum[item]).join(","), welfareType: welfareTypeEnum[record.welfare_type] }); @@ -266,12 +218,10 @@ export default class Programme extends React.Component { render() { const { programmeStore, taxAgentStore: { showOperateBtn } } = this.props; - const { loading, hasRight, form, tableStore, getTableDatas } = programmeStore; + const { loading, hasRight, form, getTableDatas } = programmeStore; const { selectedKey, setSelectedKey, - getCustomCategoryList, - customTableStore, customSelectkey, setCustomSelectkey, requestParams, @@ -446,7 +396,7 @@ export default class Programme extends React.Component { style={{ width: "150px" }} onChange={v => { setCustomSelectkey(v); - getCustomCategoryList(v); + this.customBenefitsTableRef.getCustomCategoryList({ curren: 1, welfareTypeEnum: v }); }} />}
@@ -456,7 +406,6 @@ export default class Programme extends React.Component { handleSlideClose(); if (v == "custom") { // 自定义福利 - getCustomCategoryList(); } else { getTableDatas(v); } @@ -467,13 +416,19 @@ export default class Programme extends React.Component { {selectedKey == "custom" ? this.customBenefitsTableRef = dom} + showOperateBtn={showOperateBtn} + welfareTypeEnum={customSelectkey} + onCustomEdit={this.onCustomEdit} /> + // } rightContent={renderCustomRightContent()} /> @@ -562,8 +517,9 @@ export default class Programme extends React.Component { condition={formCondition} form={form} edit={this.state.customEdit} - onCancel={() => { + onCancel={(isRefresh) => { setCustomNewVisible(false); + isRefresh && this.customBenefitsTableRef.getCustomCategoryList(); }} />}
diff --git a/pc4mobx/hrmSalary/stores/programme.js b/pc4mobx/hrmSalary/stores/programme.js index 2f4153a2..b6d994d0 100644 --- a/pc4mobx/hrmSalary/stores/programme.js +++ b/pc4mobx/hrmSalary/stores/programme.js @@ -120,7 +120,6 @@ export class ProgrammeStore { params.welfareTypeEnum = selectKey; API.getCustomCategoryList(params).then(action(res => { if (res.status) { // 接口请求成功/失败处理 - this.tableStore.getDatas(res.data.datas, 1); // table 请求数据 } else { message.error(res.errormsg || "接口调用失败!"); } @@ -294,7 +293,6 @@ export class ProgrammeStore { if (res.status) { message.success("新增成功"); resolve(); - this.getCustomCategoryList(); } else { reject(); message.error(res.errormsg || "新增失败"); @@ -331,7 +329,6 @@ export class ProgrammeStore { if (res.status) { message.success("编辑成功"); resolve(); - this.getCustomCategoryList(); } else { reject(); message.error(res.errormsg || "编辑失败");