From 7baf97e20fb3c994b2d021ad09aa38c007a53103 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, 8 Dec 2022 15:48:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E8=B4=A6=E5=A5=97=E9=87=8D?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ledgerPage/components/copyLedgerModal.js | 93 +++++++++++++ .../pages/ledgerPage/components/index.less | 23 +++ .../ledgerPage/components/ledgerTable.js | 131 +++++++++++++++--- pc4mobx/hrmSalary/pages/ledgerPage/config.js | 29 ++++ pc4mobx/hrmSalary/pages/ledgerPage/index.js | 7 +- pc4mobx/hrmSalary/stores/ledger.js | 6 +- 6 files changed, 264 insertions(+), 25 deletions(-) create mode 100644 pc4mobx/hrmSalary/pages/ledgerPage/components/copyLedgerModal.js create mode 100644 pc4mobx/hrmSalary/pages/ledgerPage/components/index.less create mode 100644 pc4mobx/hrmSalary/pages/ledgerPage/config.js diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/copyLedgerModal.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/copyLedgerModal.js new file mode 100644 index 00000000..1d79687f --- /dev/null +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/copyLedgerModal.js @@ -0,0 +1,93 @@ +/* + * Author: 黎永顺 + * name: 复制账套 + * Description: + * Date: 2022/12/8 + */ +import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; +import { copyConditions } from "../config"; +import { WeaDialog } from "ecCom"; +import { Button } from "antd"; +import { getSearchs } from "../../../util"; +import "./index.less"; + +@inject("ledgerStore", "taxAgentStore") +@observer +class CopyLedgerModal extends Component { + + componentDidMount() { + this.getTaxAgentSelectListAsAdmin(); + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) { + const { ledgerStore, name, taxAgentId } = nextProps; + const { copyForm: form } = ledgerStore; + form.updateFields({ + name: { value: name }, + // taxAgentId: { value: taxAgentId } + }); + } + } + + getTaxAgentSelectListAsAdmin = () => { + const { taxAgentStore, ledgerStore } = this.props; + const { copyForm: form } = ledgerStore; + const { getTaxAgentSelectListAsAdmin } = taxAgentStore; + getTaxAgentSelectListAsAdmin().then(({ status, data }) => { + if (status) { + const conditions = _.map(copyConditions, it => { + it.items = _.map(it.items, child => { + if (child.domkey[0] === "taxAgentId") { + return { + ...child, + options: _.map(data, it => ({ key: it.id, showname: it.content })) + }; + } else { + return { ...child }; + } + }); + return { ...it }; + }); + form.initFormFields(conditions); + } + }); + }; + handleSubmit = () => { + const { ledgerStore } = this.props; + const { copyForm: form } = ledgerStore; + form.validateForm().then(f => { + if (f.isValid) { + const params = form.getFormParams(); + console.log(params); + } else { + f.showErrors(); + } + }); + }; + + + render() { + const { onCancel, ledgerStore, ...extra } = this.props; + const { copyForm: form } = ledgerStore; + const buttons = [ + , + + ]; + return ( + + {getSearchs(form, copyConditions, 1)} + + ); + } +} + +export default CopyLedgerModal; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/index.less b/pc4mobx/hrmSalary/pages/ledgerPage/components/index.less new file mode 100644 index 00000000..b797e736 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/index.less @@ -0,0 +1,23 @@ +.ledgerWrapper { + .optWrapper { + display: flex; + align-items: center; + + i { + cursor: pointer; + } + } +} + +.copyWrapper { + .wea-select { + .ant-select { + width: 100% !important; + + .ant-select-selection { + border-radius: 0 !important; + height: 30px !important; + } + } + } +} diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerTable.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerTable.js index cb49bd49..cc2a0bb0 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerTable.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerTable.js @@ -6,8 +6,14 @@ */ import React, { Component } from "react"; import { WeaCheckbox, WeaTable } from "ecCom"; -import { getLedgerList } from "../../../apis/ledger"; +import { inject, observer } from "mobx-react"; +import { Menu, message, Modal, Popover } from "antd"; +import { deleteLedger, getLedgerList } from "../../../apis/ledger"; +import CopyLedgerModal from "./copyLedgerModal"; +import "./index.less"; +@inject("taxAgentStore") +@observer class LedgerTable extends Component { constructor(props) { super(props); @@ -19,6 +25,10 @@ class LedgerTable extends Component { current: 1, pageSize: 10, total: 0 + }, + copyLedgerModal: { + visible: false, + title: "复制账套", id: "", name: "", taxAgenyId: "" } }; } @@ -28,7 +38,7 @@ class LedgerTable extends Component { } getLedgerList = () => { - const { name } = this.props; + const { name, taxAgentStore } = this.props; const { pageInfo } = this.state; const payload = { name, ...pageInfo }; this.setState({ loading: true }); @@ -39,26 +49,95 @@ class LedgerTable extends Component { this.setState({ pageInfo: { ...pageInfo, current, pageSize, total }, dataSource, - columns: _.map(columns, item => { - const { dataIndex } = item; - if (dataIndex === "disable") { - item.render = (text) => { - return ; - }; - } else { - item.render = (text) => { - return {text}; - }; - } - return { ...item }; - }) + columns }); } }); }; + getColumns = () => { + const { columns } = this.state; + const { taxAgentStore } = this.props; + const { showOperateBtn } = taxAgentStore; + return _.map(columns, item => { + const { dataIndex } = item; + if (dataIndex === "disable") { + item.render = (text) => { + return ; + }; + } else if (dataIndex === "operate") { + item.width = 120; + item.render = (text, record) => { + return
+ {showOperateBtn ? "编辑" : "查看"} + { + showOperateBtn && + this.handleMenuClick(e, record.id)}> + 复制 + 删除 + } title=""> + + + } +
; + }; + } else { + item.render = (text) => { + return {text}; + }; + } + return { ...item }; + }); + }; + /* + * Author: 黎永顺 + * Description: 刪除薪资账套 + * Params: + * Date: 2022/12/8 + */ + deleteLedger = (payload) => { + deleteLedger(payload).then(({ status, errormsg }) => { + if (status) { + message.success("删除成功"); + this.getLedgerList(); + } else { + message.error(errormsg || "删除失败"); + } + }); + }; + handleResetCopy = () => { + const { copyLedgerModal } = this.state; + this.setState({ + copyLedgerModal: { ...copyLedgerModal, visible: false, id: "", name: "", taxAgenyId: "" } + }); + }; + handleMenuClick = ({ key }, record) => { + const { copyLedgerModal } = this.state; + const { id, name, taxAgenyId } = this.state; + switch (key) { + case "copy": + this.setState({ + copyLedgerModal: { ...copyLedgerModal, visible: true, id, name, taxAgenyId } + }); + break; + case "delete": + Modal.confirm({ + title: "信息确认", + content: "确认要删除吗?", + onOk: () => { + this.deleteLedger([id]); + } + }); + break; + default: + break; + } + }; render() { - const { dataSource, columns, pageInfo, loading } = this.state; + const { dataSource, columns, pageInfo, loading, copyLedgerModal } = this.state; const pagination = { ...pageInfo, showTotal: total => `共 ${total} 条`, @@ -79,13 +158,19 @@ class LedgerTable extends Component { } }; return ( - + + + + ); } } diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/config.js b/pc4mobx/hrmSalary/pages/ledgerPage/config.js new file mode 100644 index 00000000..0ad53156 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/ledgerPage/config.js @@ -0,0 +1,29 @@ +export const copyConditions = [ + { + items: [ + { + colSpan: 1, + conditionType: "INPUT", + domkey: ["name"], + fieldcol: 14, + rules: "required|string", + label: "账套名称", + labelcol: 6, + value: "", + viewAttr: 3, + }, + { + colSpan: 1, + conditionType: "SELECT", + domkey: ["taxAgentId"], + fieldcol: 14, + rules: "required|string", + label: "个税扣缴义务人", + labelcol: 6, + value: "", + viewAttr: 3, + }, + ], + defaultshow: true, + }, +]; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/index.js b/pc4mobx/hrmSalary/pages/ledgerPage/index.js index c9d66bde..3b062fa2 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/index.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/index.js @@ -5,10 +5,13 @@ * Date: 2022/12/6 */ import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; import { WeaInputSearch, WeaTop } from "ecCom"; import { Button } from "antd"; import LedgerTable from "./components/ledgerTable"; +@inject("taxAgentStore") +@observer class Index extends Component { constructor(props) { super(props); @@ -20,6 +23,8 @@ class Index extends Component { render() { const { searchVal } = this.state; + const { taxAgentStore } = this.props; + const { showOperateBtn } = taxAgentStore; const btns = [ , } iconBgcolor="#F14A2D" showDropIcon={false} - buttons={btns} + buttons={showOperateBtn ? btns : btns.slice(-1)} >
this.ledgerTableRef = dom}/> diff --git a/pc4mobx/hrmSalary/stores/ledger.js b/pc4mobx/hrmSalary/stores/ledger.js index d0fa1604..618cae74 100644 --- a/pc4mobx/hrmSalary/stores/ledger.js +++ b/pc4mobx/hrmSalary/stores/ledger.js @@ -3,12 +3,16 @@ import { message } from "antd"; import { WeaForm, WeaTableNew } from "comsMobx"; import * as API from "../apis/ledger"; // 引入API接口文件 -import { tempateColumns } from "../pages/payroll/columns"; import { notNull } from "../util/validate"; const { TableStore } = WeaTableNew; export class LedgerStore { + //重构薪资账套 + @observable copyForm = new WeaForm(); // nrew 一个form + + + /*******************************************************/ @observable tableStore = new TableStore(); // new table @observable form = new WeaForm(); // nrew 一个form @observable condition = []; // 存储后台得到的form数据