/* * 数据推送 * * @Author: 黎永顺 * @Date: 2024/11/19 * @Wechat: * @Email: 971387674@qq.com * @description: */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; import { WeaInputSearch, WeaLocaleProvider, WeaReqTop } from "ecCom"; import * as API from "../../apis/datapush"; import DatapushList from "./components/datapushList"; import PushRecord from "./components/pushRecord"; import DatapushDialog from "./components/DPDialog"; import PushDetailDialog from "./components/pushRecord/pushDetailDialog"; import { Button, message, Modal } from "antd"; import cs from "classnames"; import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; @inject("taxAgentStore", "baseFormStore") @observer class Index extends Component { constructor(props) { super(props); this.state = { selectedKey: "datapush", isQuery: false, query: { name: "" }, DPDialog: { visible: false, title: "", detail: {} }, //数据推送弹框 pushDetailDialog: { visible: false, recordId: "" } //数据推送记录查看推送详情弹框 }; } 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; case "view": this.setState({ pushDetailDialog: { visible: true, recordId: detail.id } }); break; default: break; } }; render() { const { selectedKey, DPDialog, isQuery, query, pushDetailDialog } = 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 ? [ , this.setState({ query: { ...query, name: v } })}/> ] : [ this.setState({ query: { ...query, name: v } })}/>], children: }, { title: getLabel(111, "推送记录"), key: "pushRecord", showDropIcon: false, dropMenuDatas: [], buttons: showOperateBtn ? [ , this.setState({ query: { ...query, name: v } })}/> ] : [ this.setState({ query: { ...query, name: v } })}/>], children: } ]; return ( } selectedKey={selectedKey} iconBgcolor="#F14A2D" tabDatas={tabs} className={cs("datapush_wrapper", { "reqZindex0": pushDetailDialog.visible })} buttonSpace={10} buttons={_.find(tabs, o => selectedKey === o.key).buttons} onChange={selectedKey => this.setState({ selectedKey, pushDetailDialog: { ...pushDetailDialog, visible: false }, DPDialog: { ...DPDialog, visible: false } })} showDropIcon={_.find(tabs, o => selectedKey === o.key).showDropIcon} onDropMenuClick={this.handleOperate} dropMenuDatas={_.find(tabs, o => selectedKey === o.key).dropMenuDatas} > {_.find(tabs, o => selectedKey === o.key).children} {/*数据推送框*/} this.setState({ DPDialog: { ...DPDialog, visible: false } })} onSearch={this.handleAdvanceSearch}/> {/*推送记录查看详情*/} this.setState({ pushDetailDialog: { ...pushDetailDialog, visible: false } })}/> ); } } export default Index;