/*
* 数据推送
* 新增编辑
* @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 PDetailDialog from "../PDDialog";
import { postFetch } from "../../../../util/request";
import * as API from "../../../../apis/datapush";
import { conditions } from "../../conditions";
import { Button, message, Modal } from "antd";
import { formRender } from "../../formRender";
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: [],
PDDialog: { visible: false, title: "", settingId: "", detail: {} } //推送明细弹框
};
}
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)] || "" };
if (getKey(o) === "salarySobIds") {
return {
...o, value: detail[getKey(o)] ? detail[getKey(o)] : "",
options: _.map(salarySobList, o => ({ key: String(o.id), showname: o.name }))
};
} else if (getKey(o) === "able") {
return { ...o, value: !_.isEmpty(detail) ? String(detail[getKey(o)]) : o.value };
}
return { ...o };
})
}))
}, () => {
props.baseFormStore.form.initFormFields(this.state.conditions);
!_.isEmpty(detail) && this.getPushItemList(props);
});
};
getPushItemList = (props) => {
const { detail } = props || this.props;
const { id: settingId } = detail;
API.getPushItemList({ settingId }).then(({ status, data }) => {
if (status) {
const { columns, list: dataSource } = data;
this.setState({
dataSource, columns: [...columns, {
title: getLabel(111, "操作"), width: 120, render: (__, record) => (