diff --git a/pc4mobx/organization/apis/resource.js b/pc4mobx/organization/apis/resource.js index c3fff25..bd794ec 100644 --- a/pc4mobx/organization/apis/resource.js +++ b/pc4mobx/organization/apis/resource.js @@ -4,7 +4,7 @@ import { } from 'ecCom' export const getSearchList = (params) => { - return WeaTools.callApi('/api/bs/hrmorganization/scheme/getTable', 'GET', params); + return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/listPage', 'GET', params); } export const deleteTableData = (params) => { @@ -23,7 +23,7 @@ export const getAdvanceSearchCondition = (params) => { } export const add = (params) => { - return fetch('/api/bs/hrmorganization/scheme/save', { + return fetch('/api/bs/hrmorganization/hrmresource/saveBaseForm', { method: 'POST', mode: 'cors', headers: { @@ -56,9 +56,17 @@ export const updateForbiddenTag = (params) => { } export const getSchemeForm = (params) => { - return WeaTools.callApi('/api/bs/hrmorganization/scheme/getSchemeForm', 'GET', params); + return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/getSaveForm', 'GET', params); } export const getHasRight = (params) => { return WeaTools.callApi('/api/bs/hrmorganization/scheme/getTableBtn', 'GET', params); -} \ No newline at end of file +} + +export const editResource = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/updateForm', 'POST', params); +} + +export const getResourceExtendForm = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/getBaseForm', 'GET', params); +} diff --git a/pc4mobx/organization/components/postionrank/RankScheme.js b/pc4mobx/organization/components/postionrank/RankScheme.js index 2289d6f..86e8ab6 100644 --- a/pc4mobx/organization/components/postionrank/RankScheme.js +++ b/pc4mobx/organization/components/postionrank/RankScheme.js @@ -239,10 +239,23 @@ export default class RankScheme extends React.Component { } updateForbiddenTag(checked, id) { + debugger const { rankScheme } = this.props; - rankScheme.updateForbiddenTag(checked, id); + confirm({ + title: i18n.confirm.defaultTitle(), + content: (checked == '0') ? i18n.confirm.enableTag() : i18n.confirm.forbiddenTag(), + okText: i18n.button.ok(), + cancelText: i18n.button.cancel(), + onOk() { + rankScheme.updateForbiddenTag(checked, id); + }, + onCancel() { + return false; + }, + }); + } onOperatesClick(record, rowIndex, operate) { diff --git a/pc4mobx/organization/components/resource/ResourceExtend.js b/pc4mobx/organization/components/resource/ResourceExtend.js index e69de29..a241998 100644 --- a/pc4mobx/organization/components/resource/ResourceExtend.js +++ b/pc4mobx/organization/components/resource/ResourceExtend.js @@ -0,0 +1,282 @@ +/** + * @Author: 程亮 + * @Date: 2022-06-20 14:59:21 + * @LastEditTime: 2022-06-21 18:05:35 + * @Description: + * @FilePath: /trunk/src4js/pc4mobx/organization/components/resource/ResourceExtend.js + */ + + + import { Button, Modal, message, Row, Col, Spin } from 'antd'; + import isEmpty from 'lodash/isEmpty' + import cloneDeep from 'lodash/cloneDeep' + import forEach from 'lodash/forEach' + import { WeaAlertPage, WeaTools, WeaTableEdit, WeaSearchGroup, WeaRightMenu, WeaFormItem, WeaTab,WeaTop } from 'ecCom' + import { WeaSwitch } from 'comsMobx'; + import { inject, observer } from 'mobx-react'; + import * as mobx from 'mobx'; + import { i18n } from '../../public/i18n'; + + const toJS = mobx.toJS; + import '../../style/common.less'; + + + @inject('resourceExtend') + @inject('resource') + @observer + export default class ResourceExtend extends React.Component { + + componentDidMount() { + this.init(); + } + init = () => { + const { resourceExtend,resource } = this.props; + let {hash} = window.location; + hash = hash.split("?")[0]; + let id = hash.match("[^/]+(?=/$|$)")[0]; + resourceExtend.init(); + resourceExtend.setId(id); + resourceExtend.getData(); + } + + getTabChildren = () => { + const { resourceExtend } = this.props; + let { tableInfo, isEditor, tabkey, onRowSelect, selectedRowKeys,detailSelectedKey } = resourceExtend; + let tabChildren = []; + tableInfo = toJS(tableInfo); + tableInfo && tableInfo.map((t, i) => { + if (detailSelectedKey == i) { + tabChildren.push( + resourceExtend.setPersonalEditTables(ref)} + showTitle={isEditor} + // title={'列表信息'} + //addFirstRow={isEditor} + columns={t.tabinfo.columns} + datas={t.tabinfo.datas} + onChange={this.tableEditChange} + selectedRowKeys={toJS(selectedRowKeys)} + onRowSelect={keys => onRowSelect(keys)} + onBtnsSelect={key => this.onBtnsSelect(key, i)} + viewAttr={isEditor ? 2 : 1} + getRowSelection={isEditor ? (rowSelection) => { + Object.assign(rowSelection, { + getCheckboxProps: record => ({ + disabled: record.viewAttr === 1, // 配置无法勾选的列 + }) + }) + return rowSelection; + } : () => null} + /> + ); + } + }) + return tabChildren; + } + + onBtnsSelect = (key, index) => { + const { + resourceExtend + } = this.props, { + tableInfo, + selectedRows, + setSelectedRowKeys, + selectedRowKeys + } = resourceExtend; + + const datas = tableInfo[index].tabinfo.datas; + if (key === 'copy') { + tableInfo[index].tabinfo.datas = datas.map((data, i) => { + if (!selectedRows[index].includes(i)) { + data.viewAttr = 2; + } + return data + }) + } + if (key === 'delete') { + tableInfo[index].tabinfo.datas = datas.map((data, i) => { + if (selectedRows[index].includes(i)) { + data.viewAttr = 1; + } + return data + }); + setSelectedRowKeys(selectedRowKeys.filter(row => !selectedRows[index].includes(row))) + } + } + + getSearchs = () => { + const { resourceExtend } = this.props; + let { form, conditions, isEditor } = resourceExtend; + const { isFormInit } = form; + let group = []; + let tipPosition = 'bottom'; + window.e9HideFormFieldKeys = []; + isFormInit && conditions.forEach((c, i) => { + let items = []; + c.items.forEach((field, j) => { + if (c.hide || (!isEmpty(field.otherParams) && field.otherParams.hide)) { + window.e9HideFormFieldKeys.push(field.domkey[0]); + } else { + items.push({ + com: ( + + ), + colSpan: 1 + }); + } + }); + group.push() + }); + return group; + } + + tableEditChange = (data) => { + const { resourceExtend } = this.props; + let { detailSelectedKey = '0', tableInfo } = resourceExtend; + tableInfo = toJS(tableInfo); + let d = cloneDeep(tableInfo); + d[Number(detailSelectedKey)].tabinfo.datas = data; + resourceExtend.updateTableInfo(d); + } + + getRightMenu = () => { + const { resourceExtend } = this.props; + const { isEditor, buttons } = resourceExtend; + let arr = []; + try { + if (buttons.hasEdit) { + if (isEditor) { + arr = [{ + icon: , + content: i18n.button.save(), + key: 'save', + onClick: key => { + this.saveEditCard(); + } + }, { + icon: , + content: i18n.button.back(), + key: 'back', + onClick: key => { + this.backCard(); + } + }] + } else { + arr = [{ + icon: , + content: i18n.button.modify(), + key: 'editCard', + onClick: key => { + this.editCard(); + } + } + ] + } + } + } catch (e) { } + return arr; + } + + getTopButtons = () => { + const { resourceExtend } = this.props; + const { isEditor, buttons } = resourceExtend; + const save = ; + const back = ; + const edit = ; + const btns = []; + try { + if (isEditor) { + if (buttons.hasSave) { + btns.push(save); + btns.push(back); + } + } else { + if (buttons.hasEdit) { + btns.push(edit); + } + } + } catch (e) { } + return btns; + } + + editCard = () => { + const { resourceExtend } = this.props; + resourceExtend.edit(); + } + + saveEditCard = () => { + const { resourceExtend } = this.props; + resourceExtend.save(); + } + + backCard = () => { + this.init(); + } + + changeData(key) { + const { + resourceExtend + } = this.props; + resourceExtend.changeData(key); + } + + render() { + const { resourceExtend } = this.props; + const { loading, tabkey, tabInfo,topTab,selectedKey,date,detailSelectedKey } = resourceExtend; + + try { + return ( +
+ + + + + {this.getSearchs()} + { + !isEmpty(tabInfo) &&
+ { + resourceExtend.updateDetailSelectedKey(v); + }} + /> + {this.getTabChildren()} +
+ } +
+
+
+ +
+ ) + } catch (e) { + return +
{i18n.message.authFailed()}
+
+ } + } + } + + \ No newline at end of file diff --git a/pc4mobx/organization/components/resource/resource.js b/pc4mobx/organization/components/resource/resource.js index 26ac068..014f296 100644 --- a/pc4mobx/organization/components/resource/resource.js +++ b/pc4mobx/organization/components/resource/resource.js @@ -86,7 +86,7 @@ export default class Resource extends React.Component { let tree = ( { - //todo + if (c.dataIndex == 'last_name') { + c.render = function (text, record) { + return { + window.open(`/spa/organization/static/index.html#/main/organization/ResourceExtend/${record.id}`, "_blank") + }}>{text} + } + } }) } @@ -363,7 +369,7 @@ export default class Resource extends React.Component { } - //非空判断 + // 非空判断 isEmptyObject(obj) { for (let key in obj) { return false; @@ -388,6 +394,7 @@ export default class Resource extends React.Component { return renderNoright(); } + return ( hasRight &&
this.handleSave()} onCancel={() => resource.setVisible(false)} diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js index 0217c86..bbc703d 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -24,6 +24,7 @@ import Department from "./components/department/department"; import DepartmentExtendStore from "./components/department/departmentExtend"; import FieldDefined from "./components/fieldDefinedSet/FieldDefined"; import Resource from "./components/resource/resource"; +import ResourceExtend from "./components/resource/ResourceExtend"; import stores from "./stores"; import "./style/index"; @@ -81,6 +82,7 @@ const Routes = ( + ); diff --git a/pc4mobx/organization/public/i18n.js b/pc4mobx/organization/public/i18n.js index 9f31395..2a44586 100644 --- a/pc4mobx/organization/public/i18n.js +++ b/pc4mobx/organization/public/i18n.js @@ -149,6 +149,7 @@ export const i18n = { transferDept:()=> getLabel(386246, '转移部门'), typeName: () => getLabel(129927, '类型名称'), ResourceName: () => getLabel(385936, '人员'), + newPeople: () => getLabel(386246, '新建人员'), authorizationGroup: () => getLabel(492, '权限组'), @@ -939,6 +940,10 @@ export const i18n = { deleteImg: () => getLabel('16075', "删除图片") }, confirm: { + forbiddenTag: () => getLabel(131329, '确定禁用该记录吗'), + enableTag: () => getLabel(131329, '确定启用该记录吗'), + + defaultTitle: () => getLabel(131329, '信息确认'), removeGroupInfo: () => getLabel(383053, '删除分组,该分组下的字段将显示到“基本信息”分组中,确定要删除吗?'), groupNameExist: () => getLabel(130074, '已存在同名分组,请确认'), diff --git a/pc4mobx/organization/stores/index.js b/pc4mobx/organization/stores/index.js index 7eed1b0..b1c5c1d 100644 --- a/pc4mobx/organization/stores/index.js +++ b/pc4mobx/organization/stores/index.js @@ -17,6 +17,7 @@ import { JobExtendStore } from "./jobextend"; import { NumberSetStore } from "./numberSet"; import {FieldDefinedStore} from "./fieldDefined"; import {ResourceStore} from "./resource"; +import {ResourceExtendStore} from "./resourceExtend"; module.exports = { simpleOrgStore: new SimpleOrgStore(), @@ -37,5 +38,6 @@ module.exports = { jobExtend: new JobExtendStore(), numberSet: new NumberSetStore(), fieldDefined: new FieldDefinedStore(), - resource: new ResourceStore() + resource: new ResourceStore(), + resourceExtend: new ResourceExtendStore() }; diff --git a/pc4mobx/organization/stores/resource.js b/pc4mobx/organization/stores/resource.js index 0a093c0..8dc8d88 100644 --- a/pc4mobx/organization/stores/resource.js +++ b/pc4mobx/organization/stores/resource.js @@ -48,7 +48,7 @@ const { @observable defaultShowLeft = true; @observable companysId = 1 - @observable hasRight = ''; + @observable hasRight = true; @action @@ -67,7 +67,7 @@ const { } Api.getSearchList(params).then(res => { if (res.code === 200) { - this.setHasRight(res.data.hasRight); + //this.setHasRight(res.data.hasRight); res.data.datas && this.tableStore.getDatas(res.data.datas, 1); } else { message.warning(res.msg); diff --git a/pc4mobx/organization/stores/resourceExtend.js b/pc4mobx/organization/stores/resourceExtend.js index e69de29..4faa146 100644 --- a/pc4mobx/organization/stores/resourceExtend.js +++ b/pc4mobx/organization/stores/resourceExtend.js @@ -0,0 +1,237 @@ +import { observable, action, toJS } from "mobx"; +import { WeaForm } from "comsMobx"; +import isEmpty from 'lodash/isEmpty' +import { WeaTableNew } from "comsMobx"; +import { Modal, message } from "antd"; +import { i18n } from "../public/i18n"; +import forEach from 'lodash/forEach' +import * as Api from '../apis/resource'; // 引入API接口文件 + + +export class ResourceExtendStore { + @observable form = new WeaForm(); + @observable tableInfo = [] + @observable conditions = []; + @observable isEditor = false; + @observable isNew = true; + @observable loading = true; + @observable tabInfo = []; + @observable selectedKey = '0'; + @observable detailSelectedKey = '0'; + @observable topTab = []; + @observable buttons = {}; + @observable id = ''; //人员id + @observable date = ''; + @observable personalEditTables; + @observable tabkey = '0' + + + @observable selectedRowKeys = []; + @observable selectedRows = []; + + @action onRowSelect = (keys) => { + this.setSelectedRowKeys(keys); + } + + @action setSelectedRowKeys = (keys) => { + this.selectedRowKeys = keys; + } + + + @action + edit = () => { + this.isEditor = true; + this.getData(); + this.getTabInfo(); + this.detailSelectedKey = '0' + } + + init = () => { + this.detailSelectedKey = '0' + this.isEditor = false; + } + + save = () => { + if (this.loading) + return; + this.loading = true; + this.form.validateForm().then(f => { + if (f.isValid) { + if (this.personalEditTables) { + const targetDatas = this.tableInfo[this.detailSelectedKey].tabinfo.datas, + isPass = (targetDatas.length > 0) ? this.personalEditTables.refs.edit.doRequiredCheck().pass : true + if (isPass) { + this.editResource() + } else { + this.loading = false; + } + } else { + this.editResource(); + } + } else { + f.showErrors(); + this.setDate(new Date()); + this.loading = false; + } + }) + } + + editResource = () => { + let pDatas = this.form.getFormParams(); + Api.editResource({ ...{ + id: this.id + }, + ...pDatas, + ...this.getTableEditParams() + }).then(data => { + if (data.code == 200) { + message.success(i18n.message.saveSuccess()); + this.init(); + this.getData(); + this.selectedRowKeys = []; + } else { + message.warning(data.message); + } + this.loading = false; + }, error => { + message.warning(error.message); + this.loading = false; + }) + } + + getTableEditParams = () => { + const params = {}; + this.tableInfo && this.tableInfo.forEach(t => { + t.tabinfo.datas = t.tabinfo.datas || []; + params[t.tabinfo.rownum] = t.tabinfo.datas.length; + t.tabinfo && t.tabinfo.datas && t.tabinfo.datas.forEach((item, index) => { + !isEmpty(item) && forEach(item, (value, key) => { + Object.assign(params, { + [`${key}_${index}`]: value + }); + }) + }) + }) + return params + } + + + + getData = () => { + this.setLoading(true); + let params = { + viewAttr: this.isEditor ? 2 : 1, + id: this.id, + viewCondition:this.selectedKey + } + Api.getResourceExtendForm(params).then((res) => { + if (res.code === 200) { + res.data.result.conditions && this.form.initFormFields(res.data.result.conditions); + res.data.result.conditions && this.setConditions(res.data.result.conditions); + this.tableInfo = this.handleTable(res.data.result.tables); + this.getTabInfo(); + res.data.result.buttons && this.setButtons(res.data.result.buttons); + res.data.result.tabInfo && this.setTopTab(res.data.result.tabInfo); + this.isEditor && this.getSelectedRows(); + this.setLoading(false); + + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + + + + + } + + handleTable = (datas) => { + return datas && datas.map(data => { + const { tabinfo: { columns } } = data; + const length = columns.length; + columns.map(c => { + c.width = `${95 / length}%` + }) + return data + }) + } + + getTabInfo = () => { + this.tabInfo = []; + this.tableInfo && this.tableInfo.forEach((c, idx) => { + if (!c.hide) { + this.tabInfo.push({ + key: `${idx}`, + title: c.tabname, + }) + } + }) + //if (!isEmpty(this.tabInfo)) this.tabkey = this.tabInfo[0].key; + if (!isEmpty(this.tabInfo)) this.detailSelectedKey = this.tabInfo[0].key; + } + + setLoading(val) { + this.loading = val; + } + + + updateTabKey = (key) => { + this.tabKey = key; + } + + updateDetailSelectedKey =(key) => { + this.detailSelectedKey = key; + } + + updateTableInfo = (data) => { + this.tableInfo = data + } + + setSelectedKey = (key) => { + this.selectedKey = key; + } + + getSelectedRows = () => { + const selectedRows = []; + this.tableInfo.forEach(t => { + const singleTableRows = []; + t.tabinfo.datas.forEach((data, i) => { + if (data.viewAttr === 1) { + singleTableRows.push(i); + } + }); + selectedRows.push(singleTableRows); + }) + this.selectedRows = selectedRows; + } + + + setTopTab(topTab) { + this.topTab = topTab; + } + + changeData(key) { + this.setSelectedKey(key); + this.getData(); + } + + setId(id) { + this.id = id; + } + + setPersonalEditTables = (ref) => { + this.personalEditTables = ref; + } + + setConditions(conditions) { + this.conditions = conditions; + } + + setButtons(buttons) { + this.buttons = buttons; + } + + +}