From 34bf2c8c526ee93203fc3c00a5e89ec89d13466a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Mon, 9 Sep 2024 09:35:02 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.15.1.2407.01-=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/associativeSearchMult.js | 37 ++++---- .../components/customBrowserDialog.js | 85 +++++++++++++++++-- .../components/customBrowserMutiLeft.js | 44 +++++++++- .../components/customBrowserMutiRight.js | 49 +++++++++-- .../components/CustomBrowser/index.js | 1 + .../components/CustomBrowser/index.less | 12 +-- .../components/addRoleDialog/index.js | 10 ++- .../roleManagement/components/conditions.js | 26 ++++-- pc4mobx/hrmSalary/style/index.less | 5 ++ pc4mobx/hrmSalary/util/index.js | 2 +- 10 files changed, 220 insertions(+), 51 deletions(-) diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/associativeSearchMult.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/associativeSearchMult.js index db895085..cfa0b04a 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/components/associativeSearchMult.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/associativeSearchMult.js @@ -39,23 +39,28 @@ class AssociativeSearchMult extends Component { }; getData = (name = "") => { const { browserConditionParam } = this.props; - const { completeURL, searchParamsKey, convertDatasource, dataParams = {} } = browserConditionParam; + const { + completeURL, filterByName, searchParamsKey, convertDatasource, dataParams = {} + } = browserConditionParam; if (_.trim(name)) { - postFetch(completeURL, { ...dataParams, [searchParamsKey]: name, current: 1, pageSize: 9999 }) - .then(({ status, data }) => { - this.setState({ loading: false }); - if (status && data.list) { - this.setState({ - data: convertDatasource ? convertDatasource(data.list) : data.list, - activeKey: this.getActiveKey(convertDatasource ? convertDatasource(data.list) : data.list) - }); - } else { - this.setState({ - data: _.map(data, o => ({ ...o, id: String(o.id), name: o.name })), - activeKey: this.getActiveKey(data) - }); - } - }); + let payload = { ...dataParams }; + searchParamsKey && (payload = { ...payload, [searchParamsKey]: name, current: 1, pageSize: 9999 }); + postFetch(completeURL, payload).then(({ status, data }) => { + this.setState({ loading: false }); + if (status && data.list) { + this.setState({ + data: convertDatasource ? convertDatasource(data.list) : data.list, + activeKey: this.getActiveKey(convertDatasource ? convertDatasource(data.list) : data.list) + }); + } else { + this.setState({ + data: filterByName ? _.filter(_.map(data, o => ({ + ...o, id: String(o.id), name: o.name + })), k => k.name.indexOf(name) !== -1) : _.map(data, o => ({ ...o, id: String(o.id), name: o.name })), + activeKey: this.getActiveKey(data) + }); + } + }); } else { this.setState({ data: [], loading: false, activeKey: "" }); } diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js index 4e3ac10c..936113f7 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js @@ -22,15 +22,20 @@ class CustomBrowserDialog extends Component { super(props); this.state = { loading: false, listDatas: [], pageInfo: { current: 1, pageSize: 10, total: 0 }, selectedRowKeys: [], - query: { [props.searchParamsKey]: "" } + query: { [props.searchParamsKey]: "" }, + leftListSelectedKeys: [], // 左侧table选择的keys + leftListSelectedData: [], // 左侧table选择的数据 + rightCheckedKeys: [], //右侧选择的keys + rightDatas: [] // 右侧展示的数据 }; this.selectedData = {}; } componentWillReceiveProps(nextProps, nextContext) { - if (nextProps.visible !== this.props.visible && nextProps.visible) this.getData(); - if (nextProps.visible !== this.props.visible && nextProps.visible) this.setState({ selectedRowKeys: nextProps.selectedValues }); - if (nextProps.visible !== this.props.visible && !nextProps.visible) { + if (nextProps.visible !== this.props.visible && nextProps.visible) { + this.getData(); + this.setState({ selectedRowKeys: nextProps.selectedValues }); + } else { this.setState({ pageInfo: { current: 1, pageSize: 10, total: 0 } }); this.selectedData = {}; } @@ -85,16 +90,70 @@ class CustomBrowserDialog extends Component { } }; + onLeftListCheck = (keys, datas) => { + const { leftListSelectedData } = this.state; + let targets = leftListSelectedData.concat(datas); + targets = _.uniqBy(targets, "id"); + targets = targets.filter((t) => keys.indexOf(t["id"]) > -1); + this.setState({ leftListSelectedKeys: keys, leftListSelectedData: targets }); + }; + onleftDoubleClick = (data) => { + const { rightDatas } = this.state; + this.setState({ + rightDatas: rightDatas.concat(data), + rightCheckedKeys: [], + leftListSelectedData: [], + leftListSelectedKeys: [] + }); + }; + moveTo = (direction) => { + const { rightDatas, rightCheckedKeys, listDatas, leftListSelectedData } = this.state; + if (direction === "right") { + this.setState({ + rightDatas: rightDatas.concat(leftListSelectedData), + leftListSelectedData: [], + leftListSelectedKeys: [] + }); + } + if (direction === "left") { + rds = rightDatas.filter(item => !rightCheckedKeys.some(checkedKey => item[inputId] === checkedKey)); + this.setState({ rightDatas: rds, rightCheckedKeys: [] }); + this.onCountChange(rds); + } + + if (direction === "allToLeft") { + this.setState({ rightDatas: [], rightCheckedKeys: [] }); + this.onCountChange(rds); + } + + if (direction === "allToRight") { + if (this.leftListAllActive()) { + rds = rightDatas.concat(listDatas); + this.setState({ + rightDatas: rds, + rightCheckedKeys: [], + leftListSelectedData: [], + leftTreeCheckedData: [], + leftTreeCheckedKeys: [], + leftListSelectedKeys: [] + }); + } + this.onCountChange(rds); + } + }; + render() { - const { loading, listDatas, pageInfo, selectedRowKeys, query } = this.state; + const { loading, listDatas, pageInfo, selectedRowKeys, query, leftListSelectedKeys, rightDatas } = this.state; const { dialogType, tableProps: { rowKey, columns }, isSingle, searchParamsKey } = this.props; const sheight = this.dialog ? this.dialog.state.height - 55 : 260; const buttons = [ , , ]; + let rightActive = false; + if (leftListSelectedKeys && leftListSelectedKeys.length > 0) rightActive = true; let dom = -
+
@@ -102,16 +161,26 @@ class CustomBrowserDialog extends Component {
- + this.moveTo("right")} + />
- +
; diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiLeft.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiLeft.js index a6b962af..94343950 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiLeft.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiLeft.js @@ -12,11 +12,51 @@ import { WeaLocaleProvider } from "ecCom"; const getLabel = WeaLocaleProvider.getLabel; +let timeout = null; + class CustomBrowserMutiLeft extends Component { + constructor(props) { + super(props); + this.dataObj = {}; + } + + onClick = (data) => { + clearTimeout(timeout); + timeout = setTimeout(() => { + let { selectedKeys } = this.props; + let keys = selectedKeys ? [...selectedKeys] : []; + let datas = []; + if (keys.indexOf(data.id) > -1) { + keys = keys.filter((k) => k !== data.id); + } else { + keys.push(data.id); + } + keys.forEach((k) => this.dataObj[k] && datas.push(this.dataObj[k])); + this.props.onClick && this.props.onClick(keys, datas); + }, 200); + }; + onDoubleClick = (data) => { + clearTimeout(timeout); + this.props.onDoubleClick && this.props.onDoubleClick([data]); + }; + cls = (item) => { + const { selectedKeys, filterData } = this.props; + let cls = []; + if (selectedKeys && selectedKeys.indexOf(item.id) > -1) { + cls.push("selected"); + } + if (filterData && filterData.filter((d) => d.id === item.id).length > 0) { + cls.push("hide"); + } + return cls.join(" "); + }; + render() { - const { datas } = this.props; + const { datas, selectedKeys } = this.props; const list = datas.map(item => { - return
  • + this.dataObj[item.id] = item; + return
  • this.onClick(item)} + onDoubleClick={() => this.onDoubleClick(item)}>
    {item.name}
    diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js index 5b4376d9..c51d1c42 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js @@ -15,24 +15,55 @@ const getLabel = WeaLocaleProvider.getLabel; const TreeNode = Tree.TreeNode; class CustomBrowserMutiRight extends Component { - generateTreeNodes = () => { + constructor(props) { + super(props); + this.state = { + key: "" + }; + this.nodeIds = []; + this.nodeObj = {}; + } + generateTreeNodes = () => { + const { data } = this.props, { key } = this.state; + const treeNodes = []; + let showData = [...data]; + if (_.trim(key)) { + showData = showData.filter((item) => { + return item.name.indexOf(_.trim(key)) > -1; + }); + } + showData = _.uniqBy(showData, "id"); + this.nodeIds = []; + this.nodeObj = {}; + showData.map((item) => { + let title = ( +
    +
    +
    + {item.name} +
    +
    +
    +
    + ); + treeNodes.push(); + this.nodeIds.push(item["id"]); + this.nodeObj[item["id"]] = item; + }); + return treeNodes; }; render() { const { height } = this.props; return (
    - +
    - {/**/} - {/* {this.generateTreeNodes()}*/} - {/**/} + + {this.generateTreeNodes()} +
    diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/index.js b/pc4mobx/hrmSalary/components/CustomBrowser/index.js index 3b9fb3ed..92d2944f 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/index.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/index.js @@ -75,6 +75,7 @@ class Index extends Component { selectedData: ((isSingle || browserConditionParam.isSingle) && !_.isEmpty(values)) ? { [_.last(values)]: datas[_.last(values)] } : datas }, () => { this.props.onChange && this.props.onChange(values.join(",")); + this.props.onCustomChange && this.props.onCustomChange(this.state.selectedData); if (form) { form.updateFields({ [getKey(fieldConfig)]: { value: this.state.searchKeys.join(",") } diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/index.less b/pc4mobx/hrmSalary/components/CustomBrowser/index.less index e2d30e6e..ff1844c7 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/index.less +++ b/pc4mobx/hrmSalary/components/CustomBrowser/index.less @@ -11,12 +11,14 @@ height: 100%; } - .wea-input-focus { - height: 35px !important; - //width: 100% !important; + .wea-hr-muti-dialog { + .wea-input-focus { + height: 35px !important; + width: 100% !important; - input { - height: 100% !important; + input { + height: 100% !important; + } } } } diff --git a/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js b/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js index e196b343..51e4f4a3 100644 --- a/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js +++ b/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js @@ -44,6 +44,9 @@ class Index extends Component { roleForm.validateForm().then(f => { if (f.isValid) { const payload = roleForm.getFormParams(); + + console.log(payload,roleForm.getFormDatas()) + return this.setState({ loading: true }); API.saveAuthRole({ ...payload, taxAgentId }).then(({ status, data, errormsg }) => { this.setState({ loading: false }); @@ -60,20 +63,23 @@ class Index extends Component { } }); }; + handleFormChange=(val)=>{ + console.log(val) + } render() { const { conditions, loading, roleSetDialog } = this.state; const { taxAgentStore: { roleForm } } = this.props; return ( this.save()}>{getLabel(111, "保存")}, ]} > -
    {getSearchs(roleForm, conditions, 1, false)}
    +
    {getSearchs(roleForm, conditions, 1, false, this.handleFormChange)}
    ); } diff --git a/pc4mobx/hrmSalary/pages/roleManagement/components/conditions.js b/pc4mobx/hrmSalary/pages/roleManagement/components/conditions.js index 2e232630..bc9b50a1 100644 --- a/pc4mobx/hrmSalary/pages/roleManagement/components/conditions.js +++ b/pc4mobx/hrmSalary/pages/roleManagement/components/conditions.js @@ -4,7 +4,7 @@ export const roleConditions = [ { conditionType: "INPUT", domkey: ["name"], - fieldcol: 14, + fieldcol: 16, label: "名称", lanId: 111, labelcol: 6, @@ -13,29 +13,39 @@ export const roleConditions = [ viewAttr: 3 }, { - browserConditionParam: {}, + browserConditionParam: { + completeURL: "/api/bs/hrmsalary/salarysob/listAll", + filterByName: true, + tableProps: {}, + isSingle: false + }, conditionType: "CUSTOMBROWSER", domkey: ["taxAgentIds"], - fieldcol: 14, + fieldcol: 16, label: "个税扣缴义务人", lanId: 111, labelcol: 6, - viewAttr: 2 + rules: "required|string", + viewAttr: 3 }, { - browserConditionParam: {}, + browserConditionParam: { + tableProps: {}, + isSingle: false + }, conditionType: "CUSTOMBROWSER", domkey: ["sobIds"], - fieldcol: 14, + fieldcol: 16, label: "薪资账套", lanId: 111, labelcol: 6, - viewAttr: 2 + rules: "required|string", + viewAttr: 3 }, { conditionType: "TEXTAREA", domkey: ["description"], - fieldcol: 14, + fieldcol: 16, label: "描述", lanId: 111, labelcol: 6, diff --git a/pc4mobx/hrmSalary/style/index.less b/pc4mobx/hrmSalary/style/index.less index 4ce6ef7a..a7e56969 100644 --- a/pc4mobx/hrmSalary/style/index.less +++ b/pc4mobx/hrmSalary/style/index.less @@ -43,6 +43,11 @@ padding: 16px; } + .wea-content:not(.wea-associative-search) { + + + } + .wea-select, .ant-select-selection, .ant-select { width: 100%; } diff --git a/pc4mobx/hrmSalary/util/index.js b/pc4mobx/hrmSalary/util/index.js index f9e0150a..2f79dbe7 100644 --- a/pc4mobx/hrmSalary/util/index.js +++ b/pc4mobx/hrmSalary/util/index.js @@ -46,7 +46,7 @@ export const getSearchs = (form, condition, col, isCenter, onChange = () => void > { fields.conditionType === "CUSTOMBROWSER" ? - : + : } {