From 9759a529f5eb42d31abb2be6f1aaa1767dd6c311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Tue, 10 Sep 2024 12:23:18 +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/customBrowserDialog.js | 90 ++++++++++++------- .../components/customBrowserMutiRight.js | 23 ++++- .../components/customBrowserOperation.js | 4 +- .../components/CustomBrowser/index.js | 12 ++- .../components/addRoleDialog/index.js | 21 ++--- .../roleManagement/components/conditions.js | 12 ++- .../roleManagement/components/index.less | 10 ++- .../roleDetailSetDialog/editRoleDialog.js | 30 +++++-- .../components/roleDetailSetDialog/index.js | 82 +++++++++++++---- .../hrmSalary/pages/roleManagement/index.js | 18 ++-- pc4mobx/hrmSalary/style/index.less | 5 -- pc4mobx/hrmSalary/util/index.js | 8 +- 12 files changed, 230 insertions(+), 85 deletions(-) diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js index 936113f7..eed764dd 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserDialog.js @@ -34,9 +34,15 @@ class CustomBrowserDialog extends Component { componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) { this.getData(); - this.setState({ selectedRowKeys: nextProps.selectedValues }); + this.setState({ + selectedRowKeys: nextProps.selectedValues, + leftListSelectedData: _.values(nextProps.datas), rightDatas: _.values(nextProps.datas) + }); } else { - this.setState({ pageInfo: { current: 1, pageSize: 10, total: 0 } }); + this.setState({ + pageInfo: { current: 1, pageSize: 10, total: 0 }, query: { [this.props.searchParamsKey]: "" }, + rightDatas: [], rightCheckedKeys: [], leftListSelectedData: [], leftListSelectedKeys: [] + }); this.selectedData = {}; } } @@ -44,7 +50,7 @@ class CustomBrowserDialog extends Component { getData = () => { const { pageInfo, query } = this.state; const { dialogType, completeURL, convertDatasource, dataParams = {} } = this.props; - let payload = { ...dataParams }; + let payload = { ...dataParams, ...query }; dialogType === "table" && (payload = { ...pageInfo, ...payload, ...query }); this.setState({ loading: true }); postFetch(completeURL, payload).then(({ status, data }) => { @@ -56,7 +62,7 @@ class CustomBrowserDialog extends Component { pageInfo: { ...pageInfo, current, pageSize, total } }); } else { - this.setState({ listDatas: data }); + this.setState({ listDatas: _.map(data, o => ({ ...o, id: String(o.id) })) }); } }); }; @@ -72,12 +78,13 @@ class CustomBrowserDialog extends Component { this.props.onChange && this.props.onChange([], {}); }; handleOk = () => { - const { selectedRowKeys } = this.state; - selectedRowKeys.forEach((v) => { + const { selectedRowKeys, rightDatas } = this.state, { dialogType } = this.props; + const convertSelectedRowKeys = dialogType !== "table" ? rightDatas.map((v) => v.id) : selectedRowKeys; + convertSelectedRowKeys.forEach((v) => { let item = this.getItemById(v); if (item) this.selectedData[v] = item; }); - this.props.onChange && this.props.onChange(selectedRowKeys, this.selectedData); + this.props.onChange && this.props.onChange(convertSelectedRowKeys, this.selectedData); this.props.onCancel && this.props.onCancel(); }; getItemById = (id) => { @@ -85,7 +92,7 @@ class CustomBrowserDialog extends Component { if (this.selectedData[id]) return this.selectedData[id]; if (!_.isEmpty(listDatas)) { for (let i = 0; i < listDatas.length; i++) { - if (id === listDatas[i].id) return listDatas[i]; + if (String(id) === String(listDatas[i].id)) return listDatas[i]; } } }; @@ -106,6 +113,11 @@ class CustomBrowserDialog extends Component { leftListSelectedKeys: [] }); }; + onRightDoubleClick = (key) => { + const { rightDatas } = this.state; + const newRightDatas = rightDatas.filter(item => String(item.id) !== key); + this.setState({ rightDatas: newRightDatas, rightCheckedKeys: [] }); + }; moveTo = (direction) => { const { rightDatas, rightCheckedKeys, listDatas, leftListSelectedData } = this.state; if (direction === "right") { @@ -114,49 +126,58 @@ class CustomBrowserDialog extends Component { 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") { + } else if (direction === "left") { + this.setState({ + rightDatas: rightDatas.filter(item => !rightCheckedKeys.some(checkedKey => String(item.id) === checkedKey)), + rightCheckedKeys: [] + }); + } else if (direction === "allToLeft") { this.setState({ rightDatas: [], rightCheckedKeys: [] }); - this.onCountChange(rds); - } - - if (direction === "allToRight") { + } else if (direction === "allToRight") { if (this.leftListAllActive()) { - rds = rightDatas.concat(listDatas); this.setState({ - rightDatas: rds, + rightDatas: rightDatas.concat(listDatas), rightCheckedKeys: [], leftListSelectedData: [], - leftTreeCheckedData: [], - leftTreeCheckedKeys: [], leftListSelectedKeys: [] }); } - this.onCountChange(rds); } }; + leftListAllActive = () => { + const { rightDatas, listDatas } = this.state; + let bool = true; + if (_.isEmpty(listDatas)) bool = false; + if (!_.isEmpty(listDatas) && !_.isEmpty(rightDatas)) { + bool = listDatas.filter((l) => !rightDatas.some(r => l.id === r.id)).length !== 0; + } + return bool; + }; render() { - const { loading, listDatas, pageInfo, selectedRowKeys, query, leftListSelectedKeys, rightDatas } = this.state; + const { + loading, listDatas, pageInfo, selectedRowKeys, query, leftListSelectedKeys, rightDatas, rightCheckedKeys + } = 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; + let rightActive = false, leftActive = false, rightAllActive = false; if (leftListSelectedKeys && leftListSelectedKeys.length > 0) rightActive = true; + if (rightCheckedKeys && rightCheckedKeys.length > 0) leftActive = true; + if (rightDatas && rightDatas.length > 0) rightAllActive = true; let dom =
- + + this.setState({ query: { ...query, [searchParamsKey]: value } })} + /> +
@@ -173,13 +194,20 @@ class CustomBrowserDialog extends Component {
this.moveTo("right")} + moveToLeft={() => this.moveTo("left")} + moveAllToRight={() => this.moveTo("allToRight")} + moveAllToLeft={() => this.moveTo("allToLeft")} />
this.setState({ rightCheckedKeys })} + onDoubleClick={this.onRightDoubleClick} />
diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js index c51d1c42..ed56dd09 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserMutiRight.js @@ -14,6 +14,8 @@ import { Tree } from "antd"; const getLabel = WeaLocaleProvider.getLabel; const TreeNode = Tree.TreeNode; +let timeout = null; + class CustomBrowserMutiRight extends Component { constructor(props) { super(props); @@ -53,15 +55,30 @@ class CustomBrowserMutiRight extends Component { }); return treeNodes; }; + handleSearchChange = (v) => this.setState({ key: v }); + checkHandler = (v) => { + clearTimeout(timeout); + timeout = setTimeout(() => { + this.props.checkedCb && this.props.checkedCb(v); + }, 200); + }; + onDoubleClick = (key) => { + clearTimeout(timeout); + this.props.onDoubleClick && this.props.onDoubleClick(key); + }; render() { - const { height } = this.props; + const { height, checkedKeys } = this.props; return (
- +
- + {this.generateTreeNodes()} diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserOperation.js b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserOperation.js index c6688f32..ab56ef02 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserOperation.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/components/customBrowserOperation.js @@ -42,12 +42,12 @@ class CustomBrowserOperation extends Component { const moveAllToLeftButton = ( ); const moveAllToRightButton = ( ); return ( diff --git a/pc4mobx/hrmSalary/components/CustomBrowser/index.js b/pc4mobx/hrmSalary/components/CustomBrowser/index.js index 92d2944f..b0a9ead4 100644 --- a/pc4mobx/hrmSalary/components/CustomBrowser/index.js +++ b/pc4mobx/hrmSalary/components/CustomBrowser/index.js @@ -30,15 +30,21 @@ class Index extends Component { componentDidMount() { const { value, fieldConfig } = this.props; - const { browserConditionParam: { replaceDatas = [] } } = fieldConfig; - if (value && replaceDatas.length > 0) { + const { value: defaultValue, browserConditionParam: { replaceDatas = [] } } = fieldConfig; + if ((value || defaultValue) && replaceDatas.length > 0) { this.setState({ - searchKeys: value.split(","), + searchKeys: (value || defaultValue).split(","), selectedData: _.reduce(replaceDatas, (pre, cur) => ({ ...pre, [cur["id"]]: cur }), {}) }); } } + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.value !== this.props.value && _.isEmpty(nextProps.value)) { + this.setState({ searchKeys: [], selectedData: [] }); + } + } + renderSingle = () => { const { fieldConfig } = this.props; const { selectedData, searchKeys } = this.state; diff --git a/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js b/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js index 51e4f4a3..543cf535 100644 --- a/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js +++ b/pc4mobx/hrmSalary/pages/roleManagement/components/addRoleDialog/index.js @@ -24,7 +24,7 @@ class Index extends Component { constructor(props) { super(props); this.state = { - conditions: [], loading: false + conditions: [], loading: false, formData: { taxAgentIds: [], sobIds: [] } }; } @@ -40,15 +40,13 @@ class Index extends Component { } save = (isSetting) => { - const { taxAgentStore: { roleForm }, taxAgentId } = this.props; + const { taxAgentStore: { roleForm } } = this.props; + const { formData } = this.state; 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 }) => { + API.saveAuthRole({ ...payload, ...formData }).then(({ status, data, errormsg }) => { this.setState({ loading: false }); if (status) { message.success(getLabel(111, "操作成功!")); @@ -63,16 +61,19 @@ class Index extends Component { } }); }; - handleFormChange=(val)=>{ - console.log(val) - } + handleFormChange = (val) => { + const key = _.keys(val)[0]; + if (key === "taxAgentIds" || key === "sobIds") { + this.setState({ formData: { ...this.state.formData, ...val } }); + } + }; render() { const { conditions, loading, roleSetDialog } = this.state; const { taxAgentStore: { roleForm } } = this.props; return ( this.save()}>{getLabel(111, "保存")}, ]} > -
{getSearchs(roleOperatorForm, conditions, 1, false)}
+
+ {getSearchs(roleOperatorForm, conditions, 1, false, this.handleFormChange)} +
); } diff --git a/pc4mobx/hrmSalary/pages/roleManagement/components/roleDetailSetDialog/index.js b/pc4mobx/hrmSalary/pages/roleManagement/components/roleDetailSetDialog/index.js index 0ec684c4..957b88df 100644 --- a/pc4mobx/hrmSalary/pages/roleManagement/components/roleDetailSetDialog/index.js +++ b/pc4mobx/hrmSalary/pages/roleManagement/components/roleDetailSetDialog/index.js @@ -13,6 +13,7 @@ import { WeaDialog, WeaFormItem, WeaInput, + WeaInputNumber, WeaLocaleProvider, WeaScope, WeaSelect, @@ -26,6 +27,7 @@ import AuthTree from "./authTree"; import * as API from "../../../../apis/taxAgent"; import { Button, Col, message, Modal, Row } from "antd"; import "../index.less"; +import CustomBrowser from "../../../../components/CustomBrowser"; const getLabel = WeaLocaleProvider.getLabel; const APIFOX = { @@ -46,7 +48,8 @@ class Index extends Component { selectedKey: "auth.MemberTargetTypeEnum", name: "", options: [], enumType: "", selectedRowKeys: [], replaceDatas: [], loading: { set: false, query: false, async: false, delete: false }, columns: [], dataSource: [], pageInfo: { current: 1, pageSize: 10, total: 0 }, - editOperatorDialog: { visible: false, linkOptions: [], record: {} } + editOperatorDialog: { visible: false, linkOptions: [], record: {} }, + dataTargetSettings: { link: "OR", sortedIndex: null } }; } @@ -57,7 +60,10 @@ class Index extends Component { this.getSettingRoler(nextProps.roleId); }); } else { - this.setState({ selectedRowKeys: [], replaceDatas: [], pageInfo: { current: 1, pageSize: 10, total: 0 } }); + this.setState({ + selectedRowKeys: [], replaceDatas: [], pageInfo: { current: 1, pageSize: 10, total: 0 }, + dataTargetSettings: { link: "OR", sortedIndex: "" } + }); } } @@ -91,18 +97,18 @@ class Index extends Component { } }); }; - handleEditOperator = async (record) => { - let { selectedKey } = this.state, linkOptions = []; - if (selectedKey === "auth.DataTargetTypeEnum") { - const payload = { enumClass: `com.engine.salary.enums.auth.DataLinkEnum` }; - const { data } = await commonEnumList(payload); - linkOptions = _.map(data, o => ({ key: o.enum, showname: o.defaultLabel })); - } - this.setState({ editOperatorDialog: { visible: true, record, linkOptions } }); + handleEditOperator = (record) => { + this.setState({ editOperatorDialog: { ...this.state.editOperatorDialog, visible: true, record } }); + }; + getConnectSymbol = async () => { + const payload = { enumClass: `com.engine.salary.enums.auth.DataLinkEnum` }; + const { data } = await commonEnumList(payload); + const linkOptions = _.map(data, o => ({ key: o.enum, showname: o.defaultLabel })); + this.setState({ editOperatorDialog: { ...this.state.editOperatorDialog, linkOptions } }); }; addOperatorSettings = () => { const { roleId } = this.props; - const { selectedKey, enumType: targetType, replaceDatas } = this.state; + const { selectedKey, enumType: targetType, replaceDatas, dataTargetSettings } = this.state; if (_.isEmpty(replaceDatas)) { Modal.warning({ title: getLabel(111, "系统提示"), @@ -111,8 +117,11 @@ class Index extends Component { return; } const payload = _.map(replaceDatas, o => ({ - roleId, targetType: o.targetType || targetType, target: o.id || "", targetName: o.name || "", - link: o.link || "OR", sortedIndex: o.sortedIndex || 0, id: o.editId || "" + roleId, target: o.id || "", id: o.editId || "", + targetType: o.targetType || targetType, + targetName: o.name || "", + link: o.link || dataTargetSettings.link, + sortedIndex: o.sortedIndex || dataTargetSettings.sortedIndex })); this.setState({ loading: { ...this.state.loading, set: true } }); APIFOX[`save.${selectedKey}`](payload).then(({ status, errormsg }) => { @@ -213,6 +222,23 @@ class Index extends Component { cur.id.split("-"), [])} onChange={v => this.setState({ replaceDatas: [{ id: v.join("-"), name: v.join("-") }] })}/> ); + case "SOB": + return ( + (o.id))} + onCustomChange={replaceDatas => this.setState({ + replaceDatas: _.map(_.values(replaceDatas), o => ({ id: o.id, name: o.name })) + })} + /> + ); default: return (); } @@ -228,8 +254,10 @@ class Index extends Component { render() { const { roleId } = this.props; const { - selectedKey, name, options, enumType, pageInfo, columns, dataSource, loading, selectedRowKeys, editOperatorDialog + selectedKey, name, options, enumType, pageInfo, columns, dataSource, loading, selectedRowKeys, editOperatorDialog, + dataTargetSettings } = this.state; + const { linkOptions } = editOperatorDialog; const tabs = [ { title: getLabel(111, "成员"), viewcondition: "auth.MemberTargetTypeEnum" }, { title: getLabel(111, "权限"), viewcondition: "auth.AuthTargetTypeEnum" }, @@ -287,6 +315,7 @@ class Index extends Component { }, () => { this.state.selectedKey !== "auth.AuthTargetTypeEnum" && this.getEnumList(); this.state.selectedKey !== "auth.AuthTargetTypeEnum" && this.getSettingRoler(roleId); + this.state.selectedKey === "auth.DataTargetTypeEnum" && this.getConnectSymbol(); })}/> { this.state.selectedKey !== "auth.AuthTargetTypeEnum" && @@ -297,7 +326,30 @@ class Index extends Component { { this.state.selectedKey !== "auth.AuthTargetTypeEnum" && - + { + this.state.selectedKey === "auth.DataTargetTypeEnum" && + + + + + this.setState({ + dataTargetSettings: { ...dataTargetSettings, link } + })}/> + + + + + this.setState({ + dataTargetSettings: { ...dataTargetSettings, sortedIndex } + })}/> + + + + + } + diff --git a/pc4mobx/hrmSalary/pages/roleManagement/index.js b/pc4mobx/hrmSalary/pages/roleManagement/index.js index 66c7c9e3..425e1a9f 100644 --- a/pc4mobx/hrmSalary/pages/roleManagement/index.js +++ b/pc4mobx/hrmSalary/pages/roleManagement/index.js @@ -22,7 +22,8 @@ class Index extends Component { super(props); this.state = { query: { name: "" }, dataSource: [], columns: [], pageInfo: { current: 1, pageSize: 10, total: 0 }, - loading: false, selectedRowKeys: [], addRoleDialog: { taxAgentId: "", visible: false } + loading: false, selectedRowKeys: [], addRoleDialog: { taxAgentId: "", visible: false }, + roleSetDialog: { visible: false, roleId: "", name: "" } }; } @@ -41,14 +42,21 @@ class Index extends Component { this.setState({ dataSource, pageInfo: { ...pageInfo, current, pageSize, total }, columns: [...columns, { - title: getLabel(111, "操作"), width: 120, dataIndex: "action", + title: getLabel(111, "操作"), width: 150, dataIndex: "action", render: (__, record) => ( - this.deleteAuthRole([record.id])}>{getLabel(111, "删除")}) + + this.showRoleSetDialog(record)}>{getLabel(111, "编辑")} + this.deleteAuthRole([record.id])}>{getLabel(111, "删除")} + + ) }] }); } }); }; + showRoleSetDialog = (role) => this.setState({ roleSetDialog: { visible: true, roleId: role.id, name: role.name } }); deleteAuthRole = (payload) => { Modal.confirm({ title: getLabel(111, "信息确认"), @@ -98,12 +106,12 @@ class Index extends Component { }; return ( } + title={getLabel(111, "业务线管理")} icon={} iconBgcolor="#F14A2D" buttons={buttons} className="rolemanagement-index" >
+ rowSelection={rowSelection} scroll={{ y: `calc(100vh - 173px)` }} rowKey="id"/> {/*添加角色*/} { @@ -46,7 +47,10 @@ export const getSearchs = (form, condition, col, isCenter, onChange = () => void > { fields.conditionType === "CUSTOMBROWSER" ? - : + onChange({ + [getKey(fields)]: _.map(_.values(val), o => ({ id: o.id, name: o.name })) + })}/> : } {