diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js
index 774b64c7..25dc8d1e 100644
--- a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js
+++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js
@@ -8,7 +8,7 @@
* @description:
*/
import React, { Component } from "react";
-import { WeaDialog, WeaInputSearch, WeaLocaleProvider, WeaNewScroll } from "ecCom";
+import { WeaDialog, WeaInputSearch, WeaLocaleProvider, WeaNewScroll, WeaTable } from "ecCom";
import { Button, Col, Row, Spin } from "antd";
import CustomBrowserMutiLeft from "./customBrowserMutiLeft";
import CustomBrowserMutiRight from "./customBrowserMutiRight";
@@ -21,60 +21,129 @@ class CustomBrowserDialog extends Component {
constructor(props) {
super(props);
this.state = {
- loading: false, listDatas: []
+ loading: false, listDatas: [], pageInfo: { current: 1, pageSize: 10, total: 0 }, selectedRowKeys: []
};
+ this.selectedData = {};
}
componentWillReceiveProps(nextProps, nextContext) {
- if (nextProps.visible !== this.props.visible) this.getData();
+ if (nextProps.visible !== this.props.visible && nextProps.visible) this.getData();
+ if (nextProps.visible !== this.props.visible && nextProps.visible) this.setState({ selectedRowKeys: nextProps.selectedValues });
}
getData = (query = {}) => {
- const { completeURL = "/api/bs/hrmsalary/salarysob/listByTaxAgent" } = this.props;
+ const { pageInfo } = this.state;
+ const { dialogType, completeURL, convertDatasource } = this.props;
+ let payload = {};
+ dialogType === "table" && (payload = { ...pageInfo, ...payload, ...query });
this.setState({ loading: true });
- postFetch(completeURL, { taxAgentId: "19", ...query }).then(({ status, data }) => {
+ postFetch(completeURL, payload).then(({ status, data }) => {
this.setState({ loading: false });
- if (status) {
- this.setState({ listDatas: _.map(data, o => ({ ...o, id: String(o.id) })) });
+ if (status && data.list) {
+ const { pageNum: current, pageSize, total } = data;
+ this.setState({
+ listDatas: convertDatasource ? convertDatasource(data.list) : data.list,
+ pageInfo: { ...pageInfo, current, pageSize, total }
+ });
+ } else {
+ this.setState({ listDatas: data });
}
});
};
+ handleRowClick = record => {
+ if (!this.props.isSingle) return;
+ const values = [record.id];
+ const selectedData = { [record["id"]]: record };
+ this.props.onCancel();
+ this.props.onChange && this.props.onChange(values, selectedData);
+ };
+ handleClear = () => {
+ this.props.onCancel();
+ this.props.onChange && this.props.onChange([], {});
+ };
+ handleOk = () => {
+ const { selectedRowKeys } = this.state;
+ this.selectedData = {};
+ selectedRowKeys.forEach((v) => {
+ let item = this.getItemById(v);
+ if (item) this.selectedData[v] = item;
+ });
+ this.props.onChange && this.props.onChange(selectedRowKeys, this.selectedData);
+ this.props.onCancel && this.props.onCancel();
+ };
+ getItemById = (id) => {
+ const { listDatas } = this.state, { datas } = this.props;
+ if (datas[id]) return datas[id];
+ if (!_.isEmpty(listDatas)) {
+ for (let i = 0; i < listDatas.length; i++) {
+ if (id === listDatas[i].id) return listDatas[i];
+ }
+ }
+ };
render() {
- const { loading, listDatas } = this.state;
+ const { loading, listDatas, pageInfo, selectedRowKeys } = this.state;
+ const { dialogType, tableProps: { rowKey, columns }, isSingle } = this.props;
const sheight = this.dialog ? this.dialog.state.height - 55 : 260;
+ const buttons = [
+
,
+
,
+
];
+ let dom =
+
+ ;
+ if (dialogType === "table") {
+ 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.getData());
+ },
+ onChange: current => {
+ this.setState({ pageInfo: { ...pageInfo, current } }, () => this.getData());
+ }
+ };
+ const rowSelection = {
+ selectedRowKeys,
+ onChange: selectedRowKeys => this.setState({ selectedRowKeys })
+ };
+ dom =
;
+ }
+ dialogType === "table" && isSingle && buttons.splice(0, 1);
return (
this.dialog = dom} title={getLabel(111, "数据选择")}
className="custom_browser_dialog" style={{
width: 784, height: 460, minHeight: 200, minWidth: 380,
maxHeight: "90%", maxWidth: "90%", overflow: "hidden", transform: "translate(0px, 0px)"
- }} buttons={[
- ,
- ,
- ]}>
-
-
-
+ }} buttons={buttons}>
+ {dom}
);
}
diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/index.js b/pc4mobx/hrmSalary/components/CustomBrowser/index.js
index 42b8fe6f..3b9fb3ed 100644
--- a/pc4mobx/hrmSalary/components/CustomBrowser/index.js
+++ b/pc4mobx/hrmSalary/components/CustomBrowser/index.js
@@ -10,6 +10,7 @@
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTools } from "ecCom";
import AssociativeSearchMult from "./components/associativeSearchMult";
+import AssociativeSearchSingle from "./components/AssociativeSearchSingle";
import CustomBrowserDialog from "./components/customBrowserDialog";
import classNames from "classnames";
import "./index.less";
@@ -27,8 +28,30 @@ class Index extends Component {
};
}
+ componentDidMount() {
+ const { value, fieldConfig } = this.props;
+ const { browserConditionParam: { replaceDatas = [] } } = fieldConfig;
+ if (value && replaceDatas.length > 0) {
+ this.setState({
+ searchKeys: value.split(","),
+ selectedData: _.reduce(replaceDatas, (pre, cur) => ({ ...pre, [cur["id"]]: cur }), {})
+ });
+ }
+ }
+
renderSingle = () => {
- return null;
+ const { fieldConfig } = this.props;
+ const { selectedData, searchKeys } = this.state;
+ return ();
};
renderMult = () => {
const { fieldConfig } = this.props;
@@ -45,12 +68,16 @@ class Index extends Component {
);
};
onBrowerChangeHandler = (values, datas) => {
- const { form, fieldConfig } = this.props;
- this.setState({ searchKeys: values, selectedData: datas }, () => {
+ const { form, fieldConfig, isSingle } = this.props;
+ const { browserConditionParam = {} } = fieldConfig || {};
+ this.setState({
+ searchKeys: (isSingle || browserConditionParam.isSingle) ? values.slice(-1) : values,
+ selectedData: ((isSingle || browserConditionParam.isSingle) && !_.isEmpty(values)) ? { [_.last(values)]: datas[_.last(values)] } : datas
+ }, () => {
this.props.onChange && this.props.onChange(values.join(","));
if (form) {
form.updateFields({
- [getKey(fieldConfig)]: { value: values.join(",") }
+ [getKey(fieldConfig)]: { value: this.state.searchKeys.join(",") }
});
}
});
@@ -63,7 +90,7 @@ class Index extends Component {
};
render() {
- const { browserDialog } = this.state;
+ const { browserDialog, selectedData, searchKeys } = this.state;
const { isSingle, viewAttr, fieldConfig = {} } = this.props;
const { browserConditionParam = {} } = fieldConfig || {};
const className = classNames({
@@ -76,8 +103,9 @@ class Index extends Component {
return (
);
}
diff --git a/pc4mobx/hrmSalary/pages/custom-pages/index.js b/pc4mobx/hrmSalary/pages/custom-pages/index.js
index e4767f84..7fbeb7aa 100644
--- a/pc4mobx/hrmSalary/pages/custom-pages/index.js
+++ b/pc4mobx/hrmSalary/pages/custom-pages/index.js
@@ -3,13 +3,16 @@ import Route from "react-router/lib/Route";
import CustomSalarySummary from "./lingyue/salarySummary";
import CustomSocialFundSummary from "./lingyue/socialFundSummary";
import VouncherSummary from "./lingyue/vouncherSummary";
+import HistoryVouncherSummary from "./lingyue/historyVouncherSummary";
const CustomRoutes = [