feature/2.15.2.2411.01业务线-数据推送

This commit is contained in:
lys 2024-11-19 18:58:39 +08:00
parent da79b1b7ff
commit a2c5fdc5ec
6 changed files with 379 additions and 18 deletions

View File

@ -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);
};

View File

@ -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 <div className="titleDialog">
<div className="titleCol titleLeftBox">
<div className="titleIcon"><i className="icon-coms-fa"/></div>
<div className="title">{title}</div>
</div>
<div className="titleCol titleRightBox">
<Button type="primary" loading={loading} onClick={this.save}>{getLabel(537558, "保存")}</Button>
</div>
</div>;
};
render() {
const { baseFormStore: { form }, detail } = this.props, { conditions, columns, dataSource } = this.state;
return (<WeaSlideModal
className="pushdata_create_dialog" {...this.props} direction="right"
top={0} width={800} height={100} measureT="%" measureX="px" measureY="%" title={this.renderTitle()}
content={<div className="form-dialog-layout">
{getSearchs(form, conditions, 2, false)}
{
!_.isEmpty(detail) &&
<WeaSearchGroup title={getLabel(111, "推送明细")} showGroup needTigger className="pushdata_detail">
<div className="opts">
<WeaButtonIcon buttonType="add" type="primary" title={getLabel(111, "添加")}/>
</div>
<WeaTable pagination={false} columns={columns} datas={dataSource} bordered/>
</WeaSearchGroup>
}
</div>}
/>);
}
}
export default Index;

View File

@ -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 => (<WeaCheckbox value={String(v)} disabled display="switch"/>)
};
return { ...o };
}), {
title: getLabel(111, "操作"), dataIndex: "opts", width: 120, render: (__, record) => (<React.Fragment>
<a href="javascript: void(0);" style={{ marginRight: 10 }}
onClick={() => this.props.onChange("edit", record)}>{getLabel(111, "编辑")}</a>
<a href="javascript: void(0);" style={{ marginRight: 10 }}
onClick={() => this.props.onChange("del", record.id)}>{getLabel(111, "删除")}</a>
</React.Fragment>)
}]
});
}
});
};
render() {
return (
<div>
</div>
);
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 (<WeaTable loading={loading} dataSource={dataSource} columns={columns} pagination={pagination}
scroll={{ y: `calc(100vh - 182px)` }}/>);
}
}

View File

@ -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
}
];

View File

@ -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 ? [
<Button type="primary" onClick={() => this.handleOperate("create")}>{getLabel(111, "新建")}</Button>
] : [],
children: <DatapushList/>
<Button type="primary" onClick={() => this.handleOperate("create")}>{getLabel(111, "新建")}</Button>,
<WeaInputSearch style={{ top: -3 }} value={query.name} onSearch={this.handleAdvanceSearch}
onChange={v => this.setState({ query: { ...query, name: v } })}/>
] : [<WeaInputSearch style={{ top: -3 }} value={query.name} onSearch={this.handleAdvanceSearch}
onChange={v => this.setState({ query: { ...query, name: v } })}/>],
children: <DatapushList isQuery={isQuery} query={query} onChange={this.handleOperate}/>
}
];
return (
@ -52,6 +84,9 @@ class Index extends Component {
dropMenuDatas={_.find(tabs, o => selectedKey === o.key).dropMenuDatas}
>
{_.find(tabs, o => selectedKey === o.key).children}
{/*数据推送框*/}
<DatapushDialog {...DPDialog} onClose={() => this.setState({ DPDialog: { ...DPDialog, visible: false } })}
onSearch={this.handleAdvanceSearch}/>
</WeaReqTop>
);
}

View File

@ -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;
}
}
}
}
}
}