From a2c5fdc5ec81be6082f129c040e19cf0b4da4ba7 Mon Sep 17 00:00:00 2001 From: lys <971387674@qq.com> Date: Tue, 19 Nov 2024 18:58:39 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.15.2.2411.01=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E7=BA=BF-=E6=95=B0=E6=8D=AE=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/datapush.js | 13 ++ .../datapush/components/DPDialog/index.js | 128 ++++++++++++++++++ .../datapush/components/datapushList/index.js | 65 +++++++-- .../hrmSalary/pages/datapush/conditions.js | 76 +++++++++++ pc4mobx/hrmSalary/pages/datapush/index.js | 53 ++++++-- pc4mobx/hrmSalary/pages/datapush/index.less | 62 +++++++++ 6 files changed, 379 insertions(+), 18 deletions(-) create mode 100644 pc4mobx/hrmSalary/pages/datapush/components/DPDialog/index.js create mode 100644 pc4mobx/hrmSalary/pages/datapush/conditions.js diff --git a/pc4mobx/hrmSalary/apis/datapush.js b/pc4mobx/hrmSalary/apis/datapush.js index 8287005c..5260d269 100644 --- a/pc4mobx/hrmSalary/apis/datapush.js +++ b/pc4mobx/hrmSalary/apis/datapush.js @@ -1,5 +1,18 @@ +import { WeaTools } from "ecCom"; import { postFetch } from "../util/request"; // 推送配置列表 export const getPushSettingList = (params) => { return postFetch("/api/bs/hrmsalary/push/setting/list", params); }; +// 保存推送配置 +export const savePushSetting = (params) => { + return postFetch("/api/bs/hrmsalary/push/setting/save", params); +}; +// 删除推送配置 +export const deletePushSetting = (params) => { + return WeaTools.callApi("/api/bs/hrmsalary/push/setting/delete", "GET", params); +}; +// 推送配置明细列表 +export const getPushItemList = (params) => { + return postFetch("/api/bs/hrmsalary/push/item/list", params); +}; diff --git a/pc4mobx/hrmSalary/pages/datapush/components/DPDialog/index.js b/pc4mobx/hrmSalary/pages/datapush/components/DPDialog/index.js new file mode 100644 index 00000000..4c76dd1e --- /dev/null +++ b/pc4mobx/hrmSalary/pages/datapush/components/DPDialog/index.js @@ -0,0 +1,128 @@ +/* + * 数据推送 + * 新增编辑 + * @Author: 黎永顺 + * @Date: 2024/11/19 + * @Wechat: + * @Email: 971387674@qq.com + * @description: +*/ +import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; +import { WeaButtonIcon, WeaLocaleProvider, WeaSearchGroup, WeaSlideModal, WeaTable, WeaTools } from "ecCom"; +import { postFetch } from "../../../../util/request"; +import * as API from "../../../../apis/datapush"; +import { conditions } from "../../conditions"; +import { getSearchs } from "../../../../util"; +import { Button, message } from "antd"; + +const getLabel = WeaLocaleProvider.getLabel; +const getKey = WeaTools.getKey; + +@inject("baseFormStore") +@observer +class Index extends Component { + constructor(props) { + super(props); + this.state = { + conditions: [], loading: false, columns: [], dataSource: [] + }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) { + document.querySelector(".datapush_wrapper").classList.add("zIndex0-weaslide-title"); + this.initForm(nextProps); + } + if (nextProps.visible !== this.props.visible && !nextProps.visible) { + document.querySelector(".datapush_wrapper").classList.remove("zIndex0-weaslide-title"); + this.props.baseFormStore.initForm(); + } + } + + initForm = async (props) => { + const { detail } = props; + const { data: salarySobList } = await postFetch("/api/bs/hrmsalary/salarysob/listAuth", { filterType: "ADMIN_DATA" }); + this.setState({ + conditions: _.map(conditions, item => ({ + ...item, title: getLabel(item.lanId, item.title), items: _.map(item.items, o => { + o = { ...o, label: getLabel(o.lanId, o.label), value: detail[getKey(o)] ? String(detail[getKey(o)]) : "" }; + if (getKey(o) === "salarySobIds") { + return { + ...o, value: detail[getKey(o)] ? detail[getKey(o)] : "", + options: _.map(salarySobList, o => ({ key: String(o.id), showname: o.name })) + }; + } + return { ...o }; + }) + })) + }, () => { + props.baseFormStore.form.initFormFields(this.state.conditions); + !_.isEmpty(detail) && this.getPushItemList(props); + }); + }; + getPushItemList = ({ detail }) => { + const { id: settingId } = detail; + API.getPushItemList({ settingId }).then(({ status, data }) => { + if (status) { + const { columns, list: dataSource } = data; + this.setState({ dataSource, columns }); + } + }); + }; + save = () => { + const { baseFormStore: { form }, detail } = this.props; + form.validateForm().then(f => { + if (f.isValid) { + const { salarySobIds, ...payload } = form.getFormParams(); + this.setState({ loading: true }); + API.savePushSetting({ ...payload, salarySobIds: salarySobIds.split(","), id: detail.id }) + .then(({ status, errormsg }) => { + this.setState({ loading: false }); + if (status) { + message.success(getLabel(30700, "操作成功")); + this.props.onClose(this.props.onSearch()); + } else { + message.error(errormsg); + } + }).catch(() => this.setState({ loading: false })); + } else { + f.showErrors(); + } + }); + }; + renderTitle = () => { + const { loading } = this.state, { title } = this.props; + return
+
+
+
{title}
+
+
+ +
+
; + }; + + render() { + const { baseFormStore: { form }, detail } = this.props, { conditions, columns, dataSource } = this.state; + return ( + {getSearchs(form, conditions, 2, false)} + { + !_.isEmpty(detail) && + +
+ +
+ +
+ } + } + />); + } +} + +export default Index; diff --git a/pc4mobx/hrmSalary/pages/datapush/components/datapushList/index.js b/pc4mobx/hrmSalary/pages/datapush/components/datapushList/index.js index bcb3eb68..83b83ac1 100644 --- a/pc4mobx/hrmSalary/pages/datapush/components/datapushList/index.js +++ b/pc4mobx/hrmSalary/pages/datapush/components/datapushList/index.js @@ -8,31 +8,78 @@ * @description: */ import React, { Component } from "react"; -import { WeaLocaleProvider } from "ecCom"; +import { WeaCheckbox, WeaLocaleProvider, WeaTable } from "ecCom"; import * as API from "../../../../apis/datapush"; const getLabel = WeaLocaleProvider.getLabel; class Index extends Component { + constructor(props) { + super(props); + this.state = { + columns: [], dataSource: [], loading: false, pageInfo: { current: 1, pageSize: 10, total: 0 } + }; + } + componentDidMount() { this.getPushSettingList(); } - getPushSettingList = () => { - const payload = {}; + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.isQuery !== this.props.isQuery) this.setState({ + pageInfo: { ...this.state.pageInfo, current: 1 } + }, () => this.getPushSettingList(nextProps)); + } + + getPushSettingList = (props) => { + const { pageInfo } = this.state, { query } = props || this.props; + const payload = { ...pageInfo, ...query }; + this.setState({ loading: true }); API.getPushSettingList(payload).then(({ status, data }) => { + this.setState({ loading: false }); if (status) { - console.log(data); + const { columns, list: dataSource, pageNum: current, pageSize, total } = data; + this.setState({ + pageInfo: { ...pageInfo, current, pageSize, total }, + dataSource: _.map(dataSource, o => ({ + ...o, salarySobs: _.map(o.salarySobs, k => k.name).join(","), + salarySobIds: _.map(o.salarySobs, k => k.id).join(",") + })), + columns: [..._.map(columns, o => { + if (o.dataIndex === "able") return { + ...o, render: v => () + }; + return { ...o }; + }), { + title: getLabel(111, "操作"), dataIndex: "opts", width: 120, render: (__, record) => ( + this.props.onChange("edit", record)}>{getLabel(111, "编辑")} + this.props.onChange("del", record.id)}>{getLabel(111, "删除")} + ) + }] + }); } }); }; render() { - return ( -
- -
- ); + const { columns, dataSource, loading, 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.getPushSettingList()); + }, + onChange: current => { + this.setState({ pageInfo: { ...pageInfo, current } }, () => this.getPushSettingList()); + } + }; + return (); } } diff --git a/pc4mobx/hrmSalary/pages/datapush/conditions.js b/pc4mobx/hrmSalary/pages/datapush/conditions.js new file mode 100644 index 00000000..5ab37972 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/datapush/conditions.js @@ -0,0 +1,76 @@ +// 推送配置表单 +export const conditions = [ + { + items: [ + { + conditionType: "INPUT", + domkey: ["name"], + fieldcol: 14, + label: "任务名称", + lanId: 111, + labelcol: 6, + value: "", + rules: "required|string", + viewAttr: 3 + }, + { + conditionType: "SWITCH", + domkey: ["able"], + fieldcol: 14, + label: "是否启用", + lanId: 111, + labelcol: 6, + value: "0", + rules: "required|string", + viewAttr: 3 + }, + { + conditionType: "SELECT", + domkey: ["salarySobIds"], + fieldcol: 14, + label: "薪资账套", + lanId: 111, + labelcol: 6, + value: "", + multiple: true, + options: [], + rules: "required|string", + viewAttr: 3 + }, + { + conditionType: "INPUT", + domkey: ["tableName"], + fieldcol: 14, + label: "数据表名", + lanId: 111, + labelcol: 6, + value: "", + rules: "required|string", + viewAttr: 3 + }, + { + conditionType: "INPUT", + domkey: ["modeName"], + fieldcol: 14, + label: "建模名称", + lanId: 111, + labelcol: 6, + value: "", + viewAttr: 2 + }, + { + conditionType: "INPUT", + domkey: ["modeId"], + fieldcol: 14, + label: "建模ID", + lanId: 111, + labelcol: 6, + value: "", + viewAttr: 2 + } + ], + title: "基础信息", + lanId: 111, + defaultshow: true + } +]; diff --git a/pc4mobx/hrmSalary/pages/datapush/index.js b/pc4mobx/hrmSalary/pages/datapush/index.js index e94935d4..1bbf5add 100644 --- a/pc4mobx/hrmSalary/pages/datapush/index.js +++ b/pc4mobx/hrmSalary/pages/datapush/index.js @@ -9,9 +9,11 @@ */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; -import { WeaLocaleProvider, WeaReqTop } from "ecCom"; +import { WeaInputSearch, WeaLocaleProvider, WeaReqTop } from "ecCom"; +import * as API from "../../apis/datapush"; import DatapushList from "./components/datapushList"; -import { Button } from "antd"; +import DatapushDialog from "./components/DPDialog"; +import { Button, message, Modal } from "antd"; import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; @@ -22,24 +24,54 @@ class Index extends Component { constructor(props) { super(props); this.state = { - selectedKey: "datapush", isQuery: false + selectedKey: "datapush", isQuery: false, query: { name: "" }, + DPDialog: { visible: false, title: "", detail: {} } //数据推送弹框 }; } - handleOperate = () => { + handleAdvanceSearch = () => this.setState({ isQuery: !this.state.isQuery }); + handleOperate = (type, detail = {}) => { + switch (type) { + case "create": + case "edit": + const title = type === "create" ? getLabel(111, "新建") : getLabel(111, "编辑"); + this.setState({ DPDialog: { visible: true, title, detail } }); + break; + case "del": + Modal.confirm({ + title: getLabel(111, "信息确认"), + content: getLabel(111, "确认要删除吗?"), + onOk: () => { + API.deletePushSetting({ id: detail }).then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(111, "删除成功")); + this.handleAdvanceSearch(); + } else { + message.error(errormsg); + } + }); + } + }); + break; + default: + break; + } }; render() { - const { selectedKey } = this.state; - const { taxAgentStore: { PageAndOptAuth }, baseFormStore: { form } } = this.props; + const { selectedKey, DPDialog, isQuery, query } = this.state; + const { taxAgentStore: { PageAndOptAuth } } = this.props; const showOperateBtn = PageAndOptAuth.opts.includes("admin"); const tabs = [ { title: getLabel(111, "数据推送"), key: "datapush", showDropIcon: false, dropMenuDatas: [], buttons: showOperateBtn ? [ - - ] : [], - children: + , + this.setState({ query: { ...query, name: v } })}/> + ] : [ this.setState({ query: { ...query, name: v } })}/>], + children: } ]; return ( @@ -52,6 +84,9 @@ class Index extends Component { dropMenuDatas={_.find(tabs, o => selectedKey === o.key).dropMenuDatas} > {_.find(tabs, o => selectedKey === o.key).children} + {/*数据推送框*/} + this.setState({ DPDialog: { ...DPDialog, visible: false } })} + onSearch={this.handleAdvanceSearch}/> ); } diff --git a/pc4mobx/hrmSalary/pages/datapush/index.less b/pc4mobx/hrmSalary/pages/datapush/index.less index a6b2b1f0..d96d8b5e 100644 --- a/pc4mobx/hrmSalary/pages/datapush/index.less +++ b/pc4mobx/hrmSalary/pages/datapush/index.less @@ -14,5 +14,67 @@ height: 100% !important; } + .pushdata_create_dialog { + .scroller { + background: #f6f6f6; + } + + .pushdata_detail { + .opts { + width: 100%; + display: flex; + justify-content: flex-end; + align-items: center; + padding: 8px; + } + } + + .wea-slide-modal-title { + border-bottom: 1px solid #ebebeb; + } + + .titleDialog { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 46px 0 16px; + + .titleCol { + flex: 1; + display: flex; + align-items: center; + } + + .titleLeftBox { + .titleIcon { + color: #fff; + margin: 0; + width: 40px; + height: 40px; + line-height: 40px; + font-size: 22px; + display: flex; + align-items: center; + justify-content: center; + background: #F14A2D; + border-radius: 50%; + } + + .title { + font-size: 14px; + color: #333; + padding-left: 6px; + } + } + + .titleRightBox { + justify-content: flex-end; + + button:last-child { + margin-left: 10px; + } + } + } + } } }