commit
9fa6b9da32
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
import {
|
||||
WeaTools
|
||||
} from 'ecCom'
|
||||
|
||||
export const getSearchList = (params) => {
|
||||
return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/listPage', 'GET', params);
|
||||
}
|
||||
|
||||
export const deleteTableData = (params) => {
|
||||
return fetch('/api/bs/hrmorganization/scheme/deleteByIds', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
})
|
||||
}
|
||||
|
||||
export const getAdvanceSearchCondition = (params) => {
|
||||
return WeaTools.callApi('/api/bs/hrmorganization/scheme/getSearchCondition', 'GET', params);
|
||||
}
|
||||
|
||||
export const add = (params) => {
|
||||
return fetch('/api/bs/hrmorganization/hrmresource/saveBaseForm', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
})
|
||||
}
|
||||
|
||||
export const edit = (params) => {
|
||||
return fetch('/api/bs/hrmorganization/scheme/updateScheme', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
})
|
||||
}
|
||||
|
||||
export const updateForbiddenTag = (params) => {
|
||||
return fetch('/api/bs/hrmorganization/scheme/updateForbiddenTagById', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
})
|
||||
}
|
||||
|
||||
export const getSchemeForm = (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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<WeaTableEdit ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEdit@b813my@${i}`}
|
||||
ref={(ref)=>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: (<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@vh6j67@${j}`}
|
||||
underline={!isEditor}
|
||||
label={`${field.label}`}
|
||||
error={form.getError(field)}
|
||||
tipPosition={tipPosition}
|
||||
labelCol={{ span: `${field.labelcol}` }}
|
||||
wrapperCol={{ span: `${field.fieldcol}` }}>
|
||||
<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@d4vaqk@${j}`} fieldConfig={field} form={form} />
|
||||
</WeaFormItem>),
|
||||
colSpan: 1
|
||||
});
|
||||
}
|
||||
});
|
||||
group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@x9hby9@${i}`} className={`${isEditor ? 'hrm-center' : ''}`}
|
||||
needTigger={true} hide={c.hide} title={c.title} showGroup={c.defaultshow} items={items} col={2} />)
|
||||
});
|
||||
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: <i className='icon-coms-common' />,
|
||||
content: i18n.button.save(),
|
||||
key: 'save',
|
||||
onClick: key => {
|
||||
this.saveEditCard();
|
||||
}
|
||||
}, {
|
||||
icon: <i className='icon-coms-go-back' />,
|
||||
content: i18n.button.back(),
|
||||
key: 'back',
|
||||
onClick: key => {
|
||||
this.backCard();
|
||||
}
|
||||
}]
|
||||
} else {
|
||||
arr = [{
|
||||
icon: <i className='icon-coms-edit' />,
|
||||
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 = <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@pkes6y`} type="primary" onClick={this.saveEditCard} >{i18n.button.save()}</Button>;
|
||||
const back = <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@pl1fw8`} type="primary" onClick={this.backCard} >{i18n.button.back()}</Button>;
|
||||
const edit = <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vkeda5`} type="primary" onClick={this.editCard} >{i18n.button.modify()}</Button>;
|
||||
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 (
|
||||
<div className='hrm-my-cardInfo' style={{ height: '100%', position: 'relative' }}>
|
||||
<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@k6oc4u`}
|
||||
datas={this.getRightMenu()}
|
||||
>
|
||||
<WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@bj98s7`}
|
||||
loading={true}
|
||||
buttons={this.getTopButtons()}
|
||||
showDropIcon={true}
|
||||
dropMenuDatas={this.getRightMenu()}
|
||||
>
|
||||
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@9c3zts`}
|
||||
datas={topTab}
|
||||
keyParam="viewCondition" //主键
|
||||
selectedKey={selectedKey}
|
||||
onChange={this.changeData.bind(this)}
|
||||
/>
|
||||
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@4fj4z2`} spinning={loading}>
|
||||
{this.getSearchs()}
|
||||
{
|
||||
!isEmpty(tabInfo) && <div className='hrm-my-cardInfo_detial_tabs'>
|
||||
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@vjrq63`}
|
||||
type='card'
|
||||
keyParam='key'
|
||||
datas={toJS(tabInfo)}
|
||||
selectedKey={detailSelectedKey}
|
||||
onChange={v => {
|
||||
resourceExtend.updateDetailSelectedKey(v);
|
||||
}}
|
||||
/>
|
||||
{this.getTabChildren()}
|
||||
</div>
|
||||
}
|
||||
</Spin>
|
||||
</WeaTop>
|
||||
</WeaRightMenu>
|
||||
|
||||
</div>
|
||||
)
|
||||
} catch (e) {
|
||||
return <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@h1wgnu`}>
|
||||
<div style={{ color: '#000' }}>{i18n.message.authFailed()}</div>
|
||||
</WeaAlertPage>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,455 @@
|
|||
import React from 'react'
|
||||
import * as mobx from 'mobx'
|
||||
import {
|
||||
inject,
|
||||
observer,
|
||||
} from 'mobx-react'
|
||||
import {
|
||||
WeaTop,
|
||||
WeaTab,
|
||||
WeaFormItem,
|
||||
WeaRightMenu,
|
||||
WeaLeftRightLayout,
|
||||
WeaOrgTree,
|
||||
} from 'ecCom'
|
||||
import {
|
||||
Row,
|
||||
Col,
|
||||
Spin,
|
||||
Modal,
|
||||
Button,
|
||||
message,
|
||||
Switch,
|
||||
Menu, Dropdown, Icon
|
||||
} from 'antd'
|
||||
import {
|
||||
WeaSwitch,
|
||||
WeaTableNew
|
||||
} from 'comsMobx'
|
||||
import {
|
||||
i18n
|
||||
} from '../../public/i18n';
|
||||
|
||||
import '../../style/common.less';
|
||||
|
||||
import NewAndEditDialog from '../NewAndEditDialog';
|
||||
import { renderNoright } from '../../util';
|
||||
|
||||
|
||||
|
||||
const toJS = mobx.toJS;
|
||||
const confirm = Modal.confirm;
|
||||
const WeaTable = WeaTableNew.WeaTable;
|
||||
|
||||
|
||||
@inject('resource')
|
||||
@observer
|
||||
export default class Resource extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
|
||||
if (this.props.location.key !== nextProps.location.key) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
resource.getTableInfo();
|
||||
resource.getHasRight();
|
||||
}
|
||||
|
||||
//左侧树
|
||||
getTree = () => {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
companysId,
|
||||
} = resource
|
||||
|
||||
let tree = (
|
||||
<WeaOrgTree ecId={`${this && this.props && this.props.ecId || ''}_WeaOrgTree@dhi1ro`}
|
||||
ref='WeaOrgTree'
|
||||
dataUrl={"/api/bs/hrmorganization/hrmresource/getSearchTree"}
|
||||
loading
|
||||
needSearch
|
||||
noCache={true}
|
||||
needDropMenu={false}
|
||||
//onSelect={this.selectVirtual} //组织维度回调函数
|
||||
isLoadSubDepartment={true}
|
||||
topPrefix={'hrmSearch'}
|
||||
companysId={companysId}
|
||||
inputLeftDom={`<b>${i18n.label.organization()}</b>`}
|
||||
treeNodeClick={this.treeNodeClick}
|
||||
expandAllChildrenOnSearch={true}
|
||||
/>
|
||||
)
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
getTopMenuBtns() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
topMenu,
|
||||
tableStore
|
||||
} = resource;
|
||||
|
||||
let btns = [];
|
||||
topMenu.map((item, i) => {
|
||||
if (item.menuFun !== 'batchDelete') {
|
||||
btns.push(<Button type='primary' onClick={() => this.handleClick(item)}>{item.menuName}</Button>);
|
||||
} else {
|
||||
btns.push(<Button type='primary' onClick={() => this.handleClick(item)} disabled={tableStore.selectedRowKeys.length > 0 ? false : true} >{item.menuName}</Button>);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return btns;
|
||||
}
|
||||
|
||||
handleClick(item) {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
isPanelShow
|
||||
} = resource;
|
||||
|
||||
isPanelShow && resource.setPanelStatus(false);
|
||||
this[item.menuFun] && this[item.menuFun]();
|
||||
}
|
||||
|
||||
new() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
|
||||
resource.setNeDialogTitle(i18n.label.newRankScheme());
|
||||
resource.setIsNew(true);
|
||||
resource.setVisible(true);
|
||||
resource.getForm();
|
||||
}
|
||||
|
||||
batchDelete() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
tableStore
|
||||
} = resource;
|
||||
|
||||
let keys = toJS(tableStore.selectedRowKeys).toString();
|
||||
resource.setIds(keys);
|
||||
this.showConfirm('batchDel');
|
||||
}
|
||||
showConfirm(v) {
|
||||
let _this = this;
|
||||
confirm({
|
||||
title: i18n.confirm.defaultTitle(),
|
||||
content: (v == 'del') ? i18n.confirm.delete() : i18n.confirm.batchDeleteConfirm(),
|
||||
okText: i18n.button.ok(),
|
||||
cancelText: i18n.button.cancel(),
|
||||
onOk() {
|
||||
_this.onOk();
|
||||
},
|
||||
onCancel() {
|
||||
return false;
|
||||
},
|
||||
});
|
||||
}
|
||||
onOk() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
resource.delete();
|
||||
}
|
||||
|
||||
|
||||
getDropMenuDatas() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
rightMenu
|
||||
} = resource;
|
||||
|
||||
let menus = [];
|
||||
toJS(rightMenu).map((item, index) => {
|
||||
let obj = {
|
||||
key: item.menuFun,
|
||||
icon: <i className={`${item.menuIcon}`} />,
|
||||
content: item.menuName,
|
||||
}
|
||||
if (item.menuFun == 'collection' || item.menuFun == 'help' || item.menuFun == 'pageAddress') {
|
||||
obj.disabled = true;
|
||||
}
|
||||
menus.push(obj);
|
||||
})
|
||||
return menus;
|
||||
}
|
||||
|
||||
handleMenuClick(key) {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
isPanelShow
|
||||
} = resource;
|
||||
|
||||
isPanelShow && resource.setPanelStatus(false);
|
||||
this[key] && this[key]();
|
||||
}
|
||||
|
||||
getTabBtn() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
form2
|
||||
} = resource;
|
||||
|
||||
const btn = [
|
||||
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@bx87i8`} type="primary" onClick={() => { resource.getTableInfo(); resource.setPanelStatus(false) }}>{i18n.button.search()}</Button>),
|
||||
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju6`} onClick={() => form2.reset()}>{i18n.button.reset()}</Button>),
|
||||
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@5u9mfz`} onClick={() => resource.setPanelStatus(false)}>{i18n.button.cancel()}</Button>),
|
||||
];
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
custom = () => {
|
||||
const {
|
||||
resource
|
||||
} = this.props, {
|
||||
tableStore,
|
||||
} = resource;
|
||||
|
||||
tableStore.setColSetVisible(true);
|
||||
tableStore.tableColSet(true);
|
||||
}
|
||||
|
||||
onSearchChange(val) {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
form2
|
||||
} = resource;
|
||||
|
||||
resource.setSchemeName(val);
|
||||
!this.isEmptyObject(form2.getFormParams()) && resource.updateFields(val);
|
||||
}
|
||||
|
||||
reRenderColumns(columns) {
|
||||
let _this = this;
|
||||
columns.forEach((c, index) => {
|
||||
if (c.dataIndex == 'last_name') {
|
||||
c.render = function (text, record) {
|
||||
return <a href='javascript:void(0);' onClick={() => {
|
||||
window.open(`/spa/organization/static/index.html#/main/organization/ResourceExtend/${record.id}`, "_blank")
|
||||
}}>{text}</a>
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
updateForbiddenTag(checked, id) {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
resource.updateForbiddenTag(checked, id);
|
||||
}
|
||||
|
||||
onOperatesClick(record, rowIndex, operate) {
|
||||
const {
|
||||
index
|
||||
} = operate;
|
||||
(index == '0') && this.doEdit(record.randomFieldId);
|
||||
(index == '1') && this.doDel(record.randomFieldId);
|
||||
|
||||
}
|
||||
|
||||
doEdit(id) {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
|
||||
resource.setNeDialogTitle(i18n.label.editRankScheme());
|
||||
resource.setSchemeId(id);
|
||||
resource.setIsNew(false);
|
||||
resource.setVisible(true);
|
||||
resource.getForm();
|
||||
}
|
||||
|
||||
doDel(id) {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
resource.setIds(id);
|
||||
this.showConfirm('del');
|
||||
}
|
||||
|
||||
|
||||
handleSave() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
isNew
|
||||
} = resource;
|
||||
|
||||
isNew && resource.save();
|
||||
!isNew && resource.edit();
|
||||
}
|
||||
|
||||
getPanelComponents() {
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
searchCondition,
|
||||
form2,
|
||||
searchConditionLoading
|
||||
} = resource;
|
||||
|
||||
let arr = [];
|
||||
let formParams = form2.getFormParams();
|
||||
const {
|
||||
isFormInit
|
||||
} = form2;
|
||||
|
||||
isFormInit && searchCondition.map(c => {
|
||||
c.items.map((field, index) => {
|
||||
arr.push(<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@4cc308@${index}`} span={(index % 2 == 0) ? 10 : 11} offset={1}>
|
||||
<div style={{ marginTop: 20 }}>
|
||||
<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@u6ex85@${index}`}
|
||||
label={`${field.label}`}
|
||||
labelCol={{ span: `${field.labelcol}` }}
|
||||
wrapperCol={{ span: `${field.fieldcol}` }}>
|
||||
{<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@p7d3td@${index}`} fieldConfig={field} form={form2} formParams={formParams} />}
|
||||
</WeaFormItem>
|
||||
</div>
|
||||
</Col>)
|
||||
})
|
||||
})
|
||||
|
||||
if (searchConditionLoading) {
|
||||
return (
|
||||
<div className='hrm-loading-center-small' style={{ top: '25%' }}>
|
||||
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@lbktzb`} spinning={searchConditionLoading}></Spin>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@ppeb6z`} onKeyDown={(e) => {
|
||||
if (e.keyCode == 13 && e.target.tagName === "INPUT") {
|
||||
resource.getTableInfo();
|
||||
resource.setPanelStatus(false)
|
||||
}
|
||||
}}>{arr}</Row>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 非空判断
|
||||
isEmptyObject(obj) {
|
||||
for (let key in obj) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
const {
|
||||
resource
|
||||
} = this.props;
|
||||
const {
|
||||
isPanelShow, form2, schemeName, conditionNum, tableStore, nEdialogTitle, visible, condition,
|
||||
form, dialogLoading, isEdit, date, hasRight,defaultShowLeft
|
||||
} = resource;
|
||||
|
||||
if (hasRight === false) {
|
||||
return renderNoright();
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
hasRight && <div ref='page' style={{ height: '100%' }}>
|
||||
<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@k6oc4u`}
|
||||
datas={this.getDropMenuDatas()}
|
||||
onClick={key => this.handleMenuClick(key)}
|
||||
>
|
||||
<WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@bj98s7`}
|
||||
title={i18n.label.schemeName()}
|
||||
icon={<i className='icon-coms-hrm' />}
|
||||
iconBgcolor='#217346'
|
||||
loading={true}
|
||||
buttons={this.getTopMenuBtns()}
|
||||
showDropIcon={true}
|
||||
dropMenuDatas={this.getDropMenuDatas()}
|
||||
onDropMenuClick={(e) => this.handleMenuClick(e)}
|
||||
>
|
||||
<WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@7muhhb`} isNew={true} showLeft={defaultShowLeft} leftCom={this.getTree()}>
|
||||
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@9c3zts`}
|
||||
searchType={['base', 'advanced']}
|
||||
showSearchAd={isPanelShow}
|
||||
searchsBaseValue={this.isEmptyObject(form2.getFormParams()) ? schemeName : form2.getFormParams().schemeName}
|
||||
setShowSearchAd={bool => resource.setPanelStatus(bool)}
|
||||
hideSearchAd={() => resource.setPanelStatus(false)}
|
||||
searchsAd={isPanelShow ? this.getPanelComponents() : <div></div>}
|
||||
advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20}
|
||||
hasMask={false}
|
||||
buttonsAd={this.getTabBtn()}
|
||||
onSearch={() => resource.getTableInfo()}
|
||||
onSearchChange={val => this.onSearchChange(val)}
|
||||
/>
|
||||
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@pgmg3x`}
|
||||
comsWeaTableStore={tableStore}
|
||||
hasOrder={true}
|
||||
needScroll={true}
|
||||
getColumns={c => this.reRenderColumns(c)}
|
||||
onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)}
|
||||
/>
|
||||
</WeaLeftRightLayout>
|
||||
</WeaTop>
|
||||
</WeaRightMenu>
|
||||
<NewAndEditDialog ecId={`${this && this.props && this.props.ecId || ''}_NewAndEditDialog@q4rrwm`}
|
||||
title={nEdialogTitle}
|
||||
visible={visible}
|
||||
condition={toJS(condition)}
|
||||
form={form}
|
||||
isFormInit={form.isFormInit}
|
||||
loading={dialogLoading}
|
||||
isEdit={isEdit}
|
||||
height={350}
|
||||
conditionLen={3}
|
||||
save={() => this.handleSave()}
|
||||
onCancel={() => resource.setVisible(false)}
|
||||
enable={false} //是否开启字段联动
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@ import JobExtend from "./components/job/JobExtend";
|
|||
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";
|
||||
|
|
@ -79,6 +81,8 @@ const Routes = (
|
|||
<Route key="job" path="job" component={Job} />
|
||||
<Route key="jobExtend" path="jobExtend/:id" component={JobExtend} />
|
||||
<Route name="fieldDef" path="fieldDef/:type" component={FieldDefined} />
|
||||
<Route key="resource" path="resource" component={Resource} />
|
||||
<Route key="resourceExtend" path="resourceExtend/:id" component={ResourceExtend} />
|
||||
|
||||
</Route>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -148,6 +148,8 @@ export const i18n = {
|
|||
mergeDept:()=> getLabel(386246, '合并部门'),
|
||||
transferDept:()=> getLabel(386246, '转移部门'),
|
||||
typeName: () => getLabel(129927, '类型名称'),
|
||||
ResourceName: () => getLabel(385936, '人员'),
|
||||
newPeople: () => getLabel(386246, '新建人员'),
|
||||
|
||||
|
||||
authorizationGroup: () => getLabel(492, '权限组'),
|
||||
|
|
@ -938,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, '已存在同名分组,请确认'),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import { JobStore } from "./job";
|
|||
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(),
|
||||
|
|
@ -35,5 +37,7 @@ module.exports = {
|
|||
job: new JobStore(),
|
||||
jobExtend: new JobExtendStore(),
|
||||
numberSet: new NumberSetStore(),
|
||||
fieldDefined: new FieldDefinedStore()
|
||||
fieldDefined: new FieldDefinedStore(),
|
||||
resource: new ResourceStore(),
|
||||
resourceExtend: new ResourceExtendStore()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,316 @@
|
|||
import {
|
||||
observable,
|
||||
action
|
||||
} from 'mobx';
|
||||
import * as mobx from 'mobx';
|
||||
import * as Api from '../apis/resource'; // 引入API接口文件
|
||||
import {
|
||||
WeaForm
|
||||
} from 'comsMobx';
|
||||
import {
|
||||
WeaTableNew
|
||||
} from 'comsMobx';
|
||||
import {
|
||||
Modal,
|
||||
message,
|
||||
} from 'antd'
|
||||
import {
|
||||
i18n
|
||||
} from '../public/i18n';
|
||||
|
||||
const toJS = mobx.toJS;
|
||||
const {
|
||||
TableStore
|
||||
} = WeaTableNew;
|
||||
|
||||
|
||||
export class ResourceStore {
|
||||
@observable tableStore = new TableStore();
|
||||
@observable topMenu = []
|
||||
@observable rightMenu = [];
|
||||
@observable condition = [];
|
||||
@observable searchCondition = [];
|
||||
@observable isEdit = true;
|
||||
@observable isNew = true;
|
||||
@observable isPanelShow = false; //高级搜索面板
|
||||
@observable form2 = new WeaForm();
|
||||
@observable form = new WeaForm();
|
||||
@observable form1 = new WeaForm();
|
||||
@observable schemeName = '';
|
||||
@observable conditionNum = 2;
|
||||
@observable ids = ''; //选择行id
|
||||
@observable searchConditionLoading = true;
|
||||
@observable nEdialogTitle = '';
|
||||
@observable visible = false;
|
||||
@observable dialogLoading = true;
|
||||
@observable schemeId = '';
|
||||
@observable date = '';
|
||||
|
||||
@observable defaultShowLeft = true;
|
||||
@observable companysId = 1
|
||||
@observable hasRight = true;
|
||||
|
||||
|
||||
@action
|
||||
getTableInfo() {
|
||||
let params;
|
||||
this.tableStore = new TableStore();
|
||||
if (this.isEmptyObject(this.form2.getFormParams())) {
|
||||
params = {
|
||||
...this.form2.getFormParams(),
|
||||
schemeName: this.schemeName
|
||||
};
|
||||
} else {
|
||||
params = {
|
||||
...this.form2.getFormParams()
|
||||
};
|
||||
}
|
||||
Api.getSearchList(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
//this.setHasRight(res.data.hasRight);
|
||||
res.data.datas && this.tableStore.getDatas(res.data.datas, 1);
|
||||
} else {
|
||||
message.warning(res.msg);
|
||||
}
|
||||
}, error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//删除
|
||||
delete() {
|
||||
let params = {
|
||||
ids: this.ids
|
||||
};
|
||||
Api.deleteTableData(params).then(response => {
|
||||
return response.json()
|
||||
}).then(data => {
|
||||
if (data.code === 200) {
|
||||
message.success(i18n.message.deleteSuccess());
|
||||
this.getTableInfo();
|
||||
} else {
|
||||
message.warning(data.msg);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
}
|
||||
|
||||
save() {
|
||||
let params = {
|
||||
...this.form.getFormParams()
|
||||
};
|
||||
this.form.validateForm().then(f => {
|
||||
if (f.isValid) {
|
||||
Api.add(params).then(response => {
|
||||
return response.json()
|
||||
}).then(data => {
|
||||
if (data.code === 200) {
|
||||
message.success(data.msg);
|
||||
this.getTableInfo();
|
||||
this.setVisible(false);
|
||||
} else {
|
||||
message.warning(data.msg);
|
||||
}
|
||||
}).catch(error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
} else {
|
||||
f.showErrors();
|
||||
this.setDate(new Date());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
edit() {
|
||||
let params = { ...this.form.getFormParams(), id: this.schemeId };
|
||||
this.form.validateForm().then(f => {
|
||||
if (f.isValid) {
|
||||
Api.edit(params).then(response => {
|
||||
return response.json()
|
||||
}).then(data => {
|
||||
if (data.code === 200) {
|
||||
message.success(data.msg);
|
||||
this.getTableInfo();
|
||||
this.setVisible(false);
|
||||
} else {
|
||||
message.warning(data.msg);
|
||||
}
|
||||
}).catch(error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
} else {
|
||||
f.showErrors();
|
||||
this.setDate(new Date());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateForbiddenTag(checked, id) {
|
||||
let params = {
|
||||
forbiddenTag: checked,
|
||||
id: id
|
||||
}
|
||||
Api.updateForbiddenTag(params).then(response => {
|
||||
return response.json()
|
||||
}).then(data => {
|
||||
if (data.code === 200) {
|
||||
message.success(data.msg);
|
||||
} else {
|
||||
message.warning(data.msg);
|
||||
}
|
||||
}).catch(error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
getForm() {
|
||||
let params = this.isNew ? {} : {
|
||||
id: this.schemeId
|
||||
}
|
||||
this.setDialogLoadingStatus(true);
|
||||
|
||||
Api.getSchemeForm(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.setDialogLoadingStatus(false);
|
||||
res.data.condition && this.setCondition(res.data.condition);
|
||||
res.data.condition && this.form.initFormFields(res.data.condition);
|
||||
} else {
|
||||
message.warning(res.msg);
|
||||
}
|
||||
}, error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
getSearchCondition() {
|
||||
this.setScLoadingStatus(false);
|
||||
Api.getAdvanceSearchCondition().then(res => {
|
||||
if (res.code === 200) {
|
||||
this.setScLoadingStatus(false);
|
||||
res.data.conditions && this.setSearchCondition(res.data.conditions);
|
||||
res.data.conditions && this.form2.initFormFields(res.data.conditions);
|
||||
} else {
|
||||
message.warning(res.msg);
|
||||
}
|
||||
}, error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
getHasRight() {
|
||||
Api.getHasRight().then(res => {
|
||||
if (res.code === 200) {
|
||||
res.data.rightMenu && this.setRightMenu(res.data.rightMenu);
|
||||
res.data.topMenu && this.setTopMenu(res.data.topMenu);
|
||||
} else {
|
||||
message.warning(res.msg);
|
||||
}
|
||||
}, error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
}
|
||||
|
||||
updateFields(val) {
|
||||
this.form2.updateFields({
|
||||
schemeName: {
|
||||
value: val
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setSearchCondition(condition) {
|
||||
this.searchCondition = condition;
|
||||
}
|
||||
|
||||
setScLoadingStatus(bool) {
|
||||
this.searchConditionLoading = bool;
|
||||
}
|
||||
|
||||
setPanelStatus(bool) {
|
||||
this.isPanelShow = bool;
|
||||
bool && this.getSearchCondition();
|
||||
if (!bool) {
|
||||
this.scLoadingReset();
|
||||
}
|
||||
}
|
||||
|
||||
setSchemeName(val) {
|
||||
this.schemeName = val;
|
||||
}
|
||||
|
||||
isEmptyObject(obj) {
|
||||
for (let key in obj) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
setIds(ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
scLoadingReset() {
|
||||
this.searchConditionLoading = true;
|
||||
}
|
||||
|
||||
|
||||
formReset() {
|
||||
this.form = new WeaForm();
|
||||
}
|
||||
|
||||
dialogLoadingReset() {
|
||||
this.dialogLoading = true;
|
||||
}
|
||||
|
||||
setVisible(bool) {
|
||||
this.visible = bool;
|
||||
this.formReset();
|
||||
!bool && this.dialogLoadingReset();
|
||||
}
|
||||
|
||||
setDialogLoadingStatus(bool) {
|
||||
this.dialogLoading = bool;
|
||||
}
|
||||
|
||||
setNeDialogTitle(title) {
|
||||
this.nEdialogTitle = title;
|
||||
}
|
||||
|
||||
setIsNew(bool) {
|
||||
this.isNew = bool;
|
||||
}
|
||||
|
||||
setCondition(condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
setSchemeId(schemeId) {
|
||||
this.schemeId = schemeId;
|
||||
}
|
||||
|
||||
@action
|
||||
setDate(date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
setTopMenu(topMenu) {
|
||||
this.topMenu = topMenu;
|
||||
}
|
||||
|
||||
setRightMenu(rightMenu) {
|
||||
this.rightMenu = rightMenu;
|
||||
}
|
||||
|
||||
setHasRight(bool) {
|
||||
this.hasRight = bool;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue