Merge pull request 'feature/cl' (#31) from feature/cl into dev

Reviewed-on: http://221.226.25.34:3000/liang.cheng/trunk/pulls/31
This commit is contained in:
liang.cheng 2023-01-16 09:54:48 +08:00
commit 95735084d9
6 changed files with 878 additions and 307 deletions

View File

@ -54,3 +54,64 @@ export const exportResource = (ids) => {
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
})) }))
} }
export const saveSearchTemplate = (params) => {
return fetch('/api/bs/hrmorganization/hrmresource/saveSearchTemplate', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
})
}
export const saveCustomTemplate = (params) => {
return fetch('/api/bs/hrmorganization/hrmresource/saveCustomTemplate', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
})
}
export const deleteSearchTemplate = (params) => {
return fetch('/api/bs/hrmorganization/hrmresource/deleteSearchTemplate', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
})
}
export const getSearchTemplate = (params) => {
return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getSearchTemplate`, 'GET',params);
}
export const getTemplateSelectKeys = (params) => {
return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getTemplateSelectKeys`, 'GET',params);
}
export const updateCustomTemplate = (params) => {
return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/updateCustomTemplate`, 'POST',params);
}
export const saveColumnsCustomTemplate = (params) => {
return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/saveColumnsCustomTemplate`, 'POST',params);
}
export const getEditTable = () => {
return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/getCustomTemplate', 'GET');
}
export const getCustomTransferData = (id) => {
return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getCustomTransferData?templateId=${id}`, 'GET');
}

View File

@ -0,0 +1,60 @@
import {
observer
} from 'mobx-react';
import {
WeaDialog,
WeaTableEdit
} from 'ecCom';
import {
Spin,
Button, Modal
} from 'antd'
import * as mobx from "mobx";
const toJS = mobx.toJS;
@observer
export default class NewWeaTableEditDialog extends React.Component {
constructor(props) {
super(props);
}
onRowSelect = (sRowKeys, rows, dataIndex, selectedDatas) => {
const { store } = this.props;
if (dataIndex === undefined || selectedDatas === undefined) {
return;
}
store.setEnableRows(selectedDatas.isused);
};
render() {
const {
store,
} = this.props, {
temlateManageDialog,
relatedData
} = store;
const { datas, columns, loading,selectedData } = relatedData;
return (
<WeaDialog
{...temlateManageDialog}
initLoadCss
>
<WeaTableEdit
ecId={`${this && this.props && this.props.ecId || ""}_WeaTableEdit@7rorir`}
draggable
deleteConfirm
title="模板"
showCopy={false}
columns={toJS(columns)}
datas={toJS(datas)}
copyFilterProps={["id"]}
selectedData={!loading && toJS(selectedData)}
onChange={e => store.setTableEditDatas(e)}
onRowSelect={(sRowKeys, rows, dataIndex, selectedDatas) => this.onRowSelect(sRowKeys, rows, dataIndex, selectedDatas)}
/>
</WeaDialog>
);
}
}

View File

@ -3,11 +3,16 @@ import {
} from 'mobx-react'; } from 'mobx-react';
import { import {
WeaTransfer, WeaTransfer,
WeaInputSearch,
WeaSelect
} from 'ecCom'; } from 'ecCom';
import { import {
toJS toJS
} from 'mobx'; } from 'mobx';
import isEmpty from 'lodash/isEmpty' import isEmpty from 'lodash/isEmpty'
import {
Spin
} from 'antd'
@observer @observer
export default class Customization extends React.Component { export default class Customization extends React.Component {
@ -15,6 +20,41 @@ export default class Customization extends React.Component {
super(props); super(props);
} }
rightHeader = () => {
const {
store
} = this.props, {
transfer,
inputSearchStyle,
search,
customTemplates,
templates,
searchTemplateId,
customTemplateId
} = store, {
transferRightIptVal,
} = transfer;
return (
<div className="trasfer-header">
<span>已选</span>
<WeaInputSearch
style={inputSearchStyle}
value={transferRightIptVal}
onSearchChange={store.updateTransferRightptVal}
/>
<WeaSelect
style={store.selectStyle}
options={search ? templates : customTemplates}
value={search ? searchTemplateId : customTemplateId}
onChange={v => store.getTemplateSelectKeys(v)}
/>
</div>
)
}
render() { render() {
const { const {
store store
@ -23,21 +63,29 @@ export default class Customization extends React.Component {
transfer, transfer,
leftHeader, leftHeader,
rightHeader, rightHeader,
searchDialog,
search
} = store, { } = store, {
transferDatas, transferDatas,
transferKeys transferKeys
} = transfer; } = transfer;
return ( return (
<div className='customization' style={{padding: 20}}> <div className='customization' style={{ padding: 20 }}>
<WeaTransfer {
{...TRANSFER} !searchDialog.loading ? <WeaTransfer
data={toJS(transferDatas)} {...TRANSFER}
selectedKeys={toJS(transferKeys)} data={toJS(transferDatas)}
leftHeader={leftHeader} selectedKeys={toJS(transferKeys)}
rightHeader={rightHeader} leftHeader={leftHeader}
/> rightHeader={rightHeader}
</div> /> : <div className='hrm-loading-center-small' style={{ top: '25%' }}>
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@lbktzb`} spinning={searchDialog.loading}></Spin>
</div>
}
</div>
); );
} }
} }

View File

@ -3,8 +3,18 @@ import {
} from 'mobx-react'; } from 'mobx-react';
import { import {
WeaDialog, WeaDialog,
WeaFormItem,
WeaInput
} from 'ecCom'; } from 'ecCom';
import Customization from './Customization'; import Customization from './Customization';
import {
Spin,
Button,Modal
} from 'antd'
import {
i18n
} from '../../public/i18n';
const confirm = Modal.confirm;
@observer @observer
export default class SearchCustomDialog extends React.Component { export default class SearchCustomDialog extends React.Component {
@ -12,19 +22,57 @@ export default class SearchCustomDialog extends React.Component {
super(props); super(props);
} }
saveCustomTemplate() {
const {
store
} = this.props, {
customTemplateName
} = store;
confirm({
title: "存为模板",
content:
<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@62kt85`}
label="列定制模板名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
<WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@j9bmvw`} viewAttr="3" value={customTemplateName} {...window.inputType} onChange={v => store.customTemplateName = v} />
</WeaFormItem>,
okText: i18n.button.save(),
cancelText: i18n.button.cancel(),
onOk() {
store.saveCustomTemplate();
},
onCancel() {
return false;
},
});
}
render() { render() {
const { const {
store store,
} = this.props, { } = this.props, {
SEARCHDIALOG, SEARCHDIALOG,
searchDialog searchDialog,
search,
searchTemplateName
} = store; } = store;
const buttons = [
<Button type='primary' onClick={()=> search ? store.saveHrmSearchUserDefine() : store.saveCustomDefine()}>保存</Button>,
<Button type='primary' onClick={()=> this.saveCustomTemplate()}>存为模板</Button>,
<Button type='primary' onClick={()=> store.getEditTable()}>模板管理</Button>
]
return ( return (
<WeaDialog <WeaDialog
{...SEARCHDIALOG} {...SEARCHDIALOG}
{...searchDialog} {...searchDialog}
buttons={search ? buttons.slice(0, 1) : buttons}
initLoadCss initLoadCss
title={search ? '常用条件定制':'列定制'}
> >
<Customization store={store}/> <Customization store={store}/>
</WeaDialog> </WeaDialog>

View File

@ -7,6 +7,7 @@ import {
import { import {
WeaTop, WeaTop,
WeaTab, WeaTab,
WeaInput,
WeaFormItem, WeaFormItem,
WeaRightMenu, WeaRightMenu,
WeaLeftRightLayout, WeaLeftRightLayout,
@ -40,6 +41,7 @@ import NewAndEditDialog from '../NewAndEditDialog';
import { renderNoright } from '../../util'; import { renderNoright } from '../../util';
import DatasImport from '../import/datasImport'; import DatasImport from '../import/datasImport';
import SearchCustomDialog from './SearchCustomDialog'; import SearchCustomDialog from './SearchCustomDialog';
import NewWeaTableEditDialog from '../NewWeaTableEditDialog';
@ -280,6 +282,43 @@ export default class Resource extends React.Component {
this[key] && this[key](); this[key] && this[key]();
} }
//列定制
customization() {
const {
resource
} = this.props;
resource.customization();
}
//存为模板
saveTemplate() {
const {
resource
} = this.props, {
searchTemplateName
} = resource;
confirm({
title: "存为模板",
content:
<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@62kt85`}
label="搜索模板名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
<WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@j9bmvw`} viewAttr="3" value={searchTemplateName} {...window.inputType} onChange={v => resource.searchTemplateName = v} />
</WeaFormItem>,
okText: i18n.button.save(),
cancelText: i18n.button.cancel(),
onOk() {
resource.saveTemplate();
},
onCancel() {
return false;
},
});
}
getTabBtn() { getTabBtn() {
const { const {
resource resource
@ -290,8 +329,8 @@ export default class Resource extends React.Component {
const btn = [ 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@bx87i8`} type="primary" onClick={() => { resource.getTableInfo(); resource.setPanelStatus(false) }}>{i18n.button.search()}</Button>),
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju6`} type="primary" onClick={() => resource.openSearchDialog()}>{i18n.button.saveTemplate()}</Button>), (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju6`} type="primary" onClick={() => this.saveTemplate()}>{i18n.button.saveTemplate()}</Button>),
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju7`} type="primary" onClick={() => resource.openSearchDialog()}>{i18n.button.conditionSet()}</Button>), (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju7`} type="primary" onClick={() => resource.openSearchDialog(true)}>{i18n.button.conditionSet()}</Button>),
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju8`} onClick={() => form2.reset()}>{i18n.button.reset()}</Button>), (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju8`} 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>), (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@5u9mfz`} onClick={() => resource.setPanelStatus(false)}>{i18n.button.cancel()}</Button>),
]; ];
@ -325,6 +364,7 @@ export default class Resource extends React.Component {
reRenderColumns(columns) { reRenderColumns(columns) {
let _this = this; let _this = this;
columns.forEach((c, index) => { columns.forEach((c, index) => {
c.className = "wea-table-indent"
if (c.dataIndex == 'lastname') { if (c.dataIndex == 'lastname') {
c.render = function (text, record) { c.render = function (text, record) {
return <a href='javascript:void(0);' onClick={() => { return <a href='javascript:void(0);' onClick={() => {
@ -378,10 +418,6 @@ export default class Resource extends React.Component {
!isNew && resource.edit(); !isNew && resource.edit();
} }
//高级搜索模板修改
handleTemplateChange() {
}
getPanelComponents() { getPanelComponents() {
const { const {
@ -391,7 +427,8 @@ export default class Resource extends React.Component {
defaultCondition, defaultCondition,
form2, form2,
searchConditionLoading, searchConditionLoading,
templates templates,
searchTemplateId
} = resource; } = resource;
let arr = []; let arr = [];
@ -407,12 +444,13 @@ export default class Resource extends React.Component {
<WeaSelect <WeaSelect
style={{ width: "100%" }} style={{ width: "100%" }}
options={templates} options={templates}
value={searchTemplateId}
onChange={v => { onChange={v => {
resource.changeSearchTemplate(v)
}} }}
/> />
</Col> </Col>
<Col offset={1} span={2}><Button onClick={() => console.log(11)}>删除模板</Button></Col> <Col offset={1} span={2}><Button onClick={() => resource.deleteSearchTemplate()}>删除模板</Button></Col>
</Row>) </Row>)
isFormInit && defaultCondition.map((c, i) => { isFormInit && defaultCondition.map((c, i) => {
@ -440,7 +478,7 @@ export default class Resource extends React.Component {
</div> </div>
) )
} else { } else {
return <div onKeyDown={(e) => { return <div onKeyDown={(e) => {
if (e.keyCode == 13 && e.target.tagName === "INPUT") { if (e.keyCode == 13 && e.target.tagName === "INPUT") {
rankScheme.getTableInfo(); rankScheme.getTableInfo();
rankScheme.setPanelStatus(false) rankScheme.setPanelStatus(false)
@ -472,8 +510,7 @@ export default class Resource extends React.Component {
if (hasRight === false) { if (hasRight === false) {
return renderNoright(); return renderNoright();
} }
const width = tableStore.columns.filter(c => c.display === "true").length * 50;
return ( return (
hasRight && <div ref='page' style={{ height: '100%' }}> hasRight && <div ref='page' style={{ height: '100%' }}>
<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@k6oc4u`} <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@k6oc4u`}
@ -495,6 +532,7 @@ export default class Resource extends React.Component {
searchType={['base', 'advanced']} searchType={['base', 'advanced']}
showSearchAd={isPanelShow} showSearchAd={isPanelShow}
searchsBaseValue={this.isEmptyObject(form2.getFormParams()) ? lastName : form2.getFormParams().lastName} searchsBaseValue={this.isEmptyObject(form2.getFormParams()) ? lastName : form2.getFormParams().lastName}
searchsBasePlaceHolder='请输入姓名'
setShowSearchAd={bool => resource.setPanelStatus(bool)} setShowSearchAd={bool => resource.setPanelStatus(bool)}
hideSearchAd={() => resource.setPanelStatus(false)} hideSearchAd={() => resource.setPanelStatus(false)}
searchsAd={isPanelShow ? this.getPanelComponents() : <div></div>} searchsAd={isPanelShow ? this.getPanelComponents() : <div></div>}
@ -510,6 +548,7 @@ export default class Resource extends React.Component {
needScroll={true} needScroll={true}
getColumns={c => this.reRenderColumns(c)} getColumns={c => this.reRenderColumns(c)}
onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)} onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)}
tableWidth={width}
/> />
</WeaLeftRightLayout> </WeaLeftRightLayout>
</WeaTop> </WeaTop>
@ -529,7 +568,9 @@ export default class Resource extends React.Component {
/> />
<DatasImport ecId={`${this && this.props && this.props.ecId || ''}_DatasImport@q4rrwm`} /> <DatasImport ecId={`${this && this.props && this.props.ecId || ''}_DatasImport@q4rrwm`} />
<SearchCustomDialog ecId={`${this && this.props && this.props.ecId || ''}_SearchCustomDialog@q4rrwm`} <SearchCustomDialog ecId={`${this && this.props && this.props.ecId || ''}_SearchCustomDialog@q4rrwm`}
store={store} /> store={store}/>
<NewWeaTableEditDialog ecId={`${this && this.props && this.props.ecId || ''}_NewWeaTableEditDialog@q4rrwm`}
store={store}/>
</div> </div>
) )
} }

View File

@ -1,12 +1,13 @@
import { import {
observable, observable,
action, action,
computed computed,
extendObservable
} from 'mobx'; } from 'mobx';
import * as mobx from 'mobx'; import * as mobx from 'mobx';
import * as Api from '../apis/resource'; // 引入API接口文件 import * as Api from '../apis/resource'; // 引入API接口文件
import { import {
WeaForm,WeaTableNew WeaForm, WeaTableNew
} from 'comsMobx'; } from 'comsMobx';
import { import {
Modal, Modal,
@ -14,17 +15,15 @@ import {
Button Button
} from 'antd' } from 'antd'
import { import {
WeaSelect, WeaSelect,
WeaInputSearch, WeaInputSearch,
WeaLocaleProvider, WeaLocaleProvider,
} from 'ecCom'; } from 'ecCom';
import { import {
i18n i18n
} from '../public/i18n'; } from '../public/i18n';
import trim from 'lodash/trim'; import { getSecondPath } from '../util/index'
import {getSecondPath} from '../util/index' import {cloneDeep,isEmpty,trim} from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
const toJS = mobx.toJS; const toJS = mobx.toJS;
const { const {
@ -32,14 +31,13 @@ const {
} = WeaTableNew; } = WeaTableNew;
export class ResourceStore { export class ResourceStore {
@observable tableStore = new TableStore(); @observable tableStore = new TableStore();
@observable topMenu = [] @observable topMenu = []
@observable rightMenu = []; @observable rightMenu = [];
@observable condition = []; @observable condition = [];
@observable searchCondition = []; @observable searchCondition = [];
@observable defaultCondition = []; @observable defaultCondition = [];
@observable templates=[];
@observable isEdit = true; @observable isEdit = true;
@observable isNew = true; @observable isNew = true;
@observable isPanelShow = false; //高级搜索面板 @observable isPanelShow = false; //高级搜索面板
@ -48,7 +46,7 @@ const {
@observable lastName = ''; @observable lastName = '';
@observable conditionNum = 8; @observable conditionNum = 8;
@observable ids = ''; //选择行id @observable ids = ''; //选择行id
@observable searchConditionLoading = true; @observable searchConditionLoading = false;
@observable nEdialogTitle = ''; @observable nEdialogTitle = '';
@observable visible = false; @observable visible = false;
@observable dialogLoading = true; @observable dialogLoading = true;
@ -88,8 +86,8 @@ const {
} }
@action("nodetree事件") doSearch(params) { @action("nodetree事件") doSearch(params) {
this.selectTreeNodeInfo = params; this.selectTreeNodeInfo = params;
this.getTableInfo(); this.getTableInfo();
} }
@action("保存") save() { @action("保存") save() {
@ -138,10 +136,14 @@ const {
} }
@action("高级搜索表单") getSearchCondition() { @action("高级搜索表单") getSearchCondition(key = true) {
this.setScLoadingStatus(true); this.setScLoadingStatus(true);
const params = { this.form2 = new WeaForm();
selectKeys:this.transfer.transferKeys let params = {};
key ? params = {
templateId: this.searchTemplateId
} : params = {
selectKeys: this.transfer.transferKeys,
} }
Api.getAdvanceSearchCondition(params).then(res => { Api.getAdvanceSearchCondition(params).then(res => {
if (res.code === 200) { if (res.code === 200) {
@ -149,7 +151,6 @@ const {
res.data.conditions && this.setSearchCondition(res.data.conditions); res.data.conditions && this.setSearchCondition(res.data.conditions);
res.data.defaultcondition && this.setDefaultCondition(res.data.defaultcondition); res.data.defaultcondition && this.setDefaultCondition(res.data.defaultcondition);
res.data.defaultcondition && this.form2.initFormFields(res.data.defaultcondition); res.data.defaultcondition && this.form2.initFormFields(res.data.defaultcondition);
res.data.templates && this.setTemplates(res.data.templates);
} else { } else {
message.warning(res.msg); message.warning(res.msg);
} }
@ -173,7 +174,7 @@ const {
}) })
} }
@action("导出") export(){ @action("导出") export() {
const params = { const params = {
...this.form.getFormParams() ...this.form.getFormParams()
} }
@ -182,314 +183,626 @@ const {
} }
@action("另存为版本") version(id) { @action("另存为版本") version(id) {
Api.version({id:id}).then(res => { Api.version({ id: id }).then(res => {
if (res.code === 200) { if (res.code === 200) {
message.success(res.msg); message.success(res.msg);
} else { } else {
message.warning(res.msg); message.warning(res.msg);
} }
}, error => { }, error => {
message.warning(error.msg); message.warning(error.msg);
}) })
} }
/** ====================================================================================== */ /** ============================================================================================= */
@observable searchDialog = { @observable search = true;
visible: false,
title: '常用条件定制',
}
@observable searchDialog = {
visible: false,
loading: true
}
@observable templates = [];
@observable customTemplates = [];
@observable searchTemplateName = '';
@observable searchTemplateId = '-1';
@observable customTemplateName = '';
@observable customTemplateId = '-1';
@observable search = false;
SEARCHDIALOG = { SEARCHDIALOG = {
hasScroll: false, hasScroll: false,
icon: 'icon-coms-hrm', icon: 'icon-coms-hrm',
iconBgcolor: '#217346', iconBgcolor: '#217346',
onCancel: () => this.closeSearchDialog(), onCancel: () => this.closeSearchDialog(),
style: { style: {
width: 700, width: 700,
height: 450 height: 450
}, },
moreBtn: { moreBtn: {
datas: [] datas: []
}, },
buttons: [<Button type='primary' onClick={()=>this.saveHrmSearchUserDefine()}>保存</Button>], }
}
TRANSFER = { TRANSFER = {
height: 350, height: 350,
renderItem: (items) => this.renderItem(items), renderItem: (items) => this.renderItem(items),
filterLeft: (items) => this.filterLeft(items), filterLeft: (items) => this.filterLeft(items),
filterRight: (items) => this.filterRight(items), filterRight: (items) => this.filterRight(items),
onChange: (v) => this.updateTransferKeys(v) onChange: (v) => this.updateTransferKeys(v)
} }
@observable transfer = { @observable transfer = {
transferDatas: [], transferDatas: [],
transferKeys: [], transferKeys: [],
transferOptions: [], transferOptions: [],
transferSelectedKey: '0', transferSelectedKey: '0',
transferleftIptVal: '', transferleftIptVal: '',
transferRightIptVal: '' transferRightIptVal: ''
} }
@action("常用条件定制保存") saveHrmSearchUserDefine = () => { @action("常用条件定制保存") saveHrmSearchUserDefine = () => {
this.closeSearchDialog(); this.closeSearchDialog();
this.getSearchCondition(false);
}
@action("列定制保存") saveCustomDefine = () => {
if(this.customTemplateId == '-1') {
message.error("默认模板不能修改,将返回默认模板列");
}
const params = {
columns:this.transfer.transferKeys,
templateId:this.customTemplateId
}
Api.saveColumnsCustomTemplate(params).then(res => {
if (res.code === 200) {
this.searchDialog.visible = false;
this.getTableInfo();
}
}, error => {
message.warning(error.msg);
})
}
@action("高级搜索模板切换") changeSearchTemplate(v) {
this.searchTemplateId = v;
this.getSearchCondition(); this.getSearchCondition();
} }
@action("常用条件定制") formatTransfer = () => { @action("常用条件定制") formatTransfer = () => {
const transferDatas = [] const transferDatas = []
const transferKeys = [] const transferKeys = []
const transferOptions = [{ const transferOptions = [{
key: "", key: "",
showname: "" showname: ""
}] }]
this.transfer.transferSelectedKey = '0'; this.transfer.transferSelectedKey = '0';
this.transfer.transferleftIptVal = ''; this.transfer.transferleftIptVal = '';
this.transfer.transferRightIptVal = ''; this.transfer.transferRightIptVal = '';
this.searchCondition.forEach((c, idx) => { this.searchCondition.forEach((c, idx) => {
transferOptions.push({ transferOptions.push({
key: `${idx}`, key: `${idx}`,
showname: c.title, showname: c.title,
}) })
c.items.forEach((i) => { c.items.forEach((i) => {
transferDatas.push({ transferDatas.push({
id: i.domkey[0], id: i.domkey[0],
label: i.label, label: i.label,
title: c.title, title: c.title,
idx: `${idx}` idx: `${idx}`
}) })
}) })
}) })
this.defaultCondition.forEach((c, idx) => { this.defaultCondition.forEach((c, idx) => {
c.items.forEach((i) => { c.items.forEach((i) => {
transferKeys.push(i.domkey[0]); transferKeys.push(i.domkey[0]);
}) })
}) })
this.transfer.transferDatas = transferDatas; this.transfer.transferDatas = transferDatas;
this.transfer.transferKeys = transferKeys; this.transfer.transferKeys = transferKeys;
this.transfer.transferOptions = transferOptions; this.transfer.transferOptions = transferOptions;
} this.searchDialog.visible = true;
}
@action("列定制") customization = (v = false) => {
this.openCustomDialog(v);
}
@action("常用条件定制模板切换") getTemplateSelectKeys = v => {
if(!this.search){
this.customTemplateId = v;
}
const params = {
templateId: v,
type: this.search ? 'search' : 'custom'
}
Api.getTemplateSelectKeys(params).then(res => {
if (res.code === 200) {
this.transfer.transferKeys = res.data.split(",");
} else {
message.warning(res.msg);
}
}, error => {
message.warning(error.msg);
})
}
@action("搜索模板保存") saveTemplate = () => {
if (this.searchTemplateName == '') {
message.error("搜索模板名称不能为空");
} else {
const fields = [];
this.defaultCondition.forEach((c, idx) => {
c.items.forEach((i) => {
fields.push(i.domkey[0]);
})
})
const params = {
showname: this.searchTemplateName,
fields: fields.toString()
}
Api.saveSearchTemplate(params).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
this.searchTemplateId = data.data;
this.setPanelStatus(true);
} else {
message.warning(data.msg);
}
}).catch(error => {
message.warning(error.msg);
})
}
}
@action("常用定制列模板保存") saveCustomTemplate = () => {
if (this.customTemplateName == '') {
message.error("列定制模板名称不能为空");
} else {
const params = {
showname: this.customTemplateName,
fields: this.transfer.transferKeys.toString()
}
Api.saveCustomTemplate(params).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
this.customTemplateId = data.data;
this.getSearchTemplate();
message.success(data.msg);
} else {
message.warning(data.msg);
}
}).catch(error => {
message.warning(error.msg);
})
}
}
@action("搜索模板删除") deleteSearchTemplate = () => {
if (this.searchTemplateId == -1) {
return message.error("默认模板不可删除");
}
Api.deleteSearchTemplate({ id: this.searchTemplateId }).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
message.success(data.msg);
this.searchTemplateId = '-1';
this.setPanelStatus(true);
} else {
message.warning(data.msg);
}
}).catch(error => {
message.warning(error.msg);
})
}
inputSearchStyle = { inputSearchStyle = {
width:"105px", width: "105px",
float:"right", float: "right",
marginTop:"5px", marginTop: "5px",
marginLeft:"10px" marginLeft: "10px"
} }
selectStyle={ selectStyle = {
marginTop:"-1px", marginTop: "-1px",
width:"85px", width: "85px",
float:"right" float: "right"
} }
@computed get leftHeader() { @computed get leftHeader() {
const { const {
transferleftIptVal, transferleftIptVal,
transferOptions, transferOptions,
transferSelectedKey transferSelectedKey
} = this.transfer; } = this.transfer;
return ( return (
<div className="trasfer-header"> <div className="trasfer-header">
<span>待选</span> <span>待选</span>
<WeaInputSearch <WeaInputSearch
style={this.inputSearchStyle} style={this.inputSearchStyle}
value={transferleftIptVal} value={transferleftIptVal}
onSearchChange={this.updateTransferleftIptVal} onSearchChange={this.updateTransferleftIptVal}
/> />
<WeaSelect <WeaSelect
style={this.selectStyle} style={this.selectStyle}
options={transferOptions} options={transferOptions}
value={transferSelectedKey} value={transferSelectedKey}
onChange={this.updateTransferSelectedKey} onChange={this.updateTransferSelectedKey}
/> />
</div>
)
}
@computed get rightHeader() {
const {
transferRightIptVal
} = this.transfer;
return (
<div className="trasfer-header">
<span>已选</span>
<WeaInputSearch
style={this.inputSearchStyle}
value={transferRightIptVal}
onSearchChange={ this.updateTransferRightptVal}
/>
</div> </div>
) )
} }
@computed get rightHeader() {
const {
transferRightIptVal,
} = this.transfer;
return (
<div className="trasfer-header">
<span>已选</span>
<WeaInputSearch
style={this.inputSearchStyle}
value={transferRightIptVal}
onSearchChange={this.updateTransferRightptVal}
/>
<WeaSelect
style={this.selectStyle}
options={this.search ? this.templates : this.customTemplates}
value={this.search ? this.searchTemplateId : this.customTemplateId}
onChange={v => this.getTemplateSelectKeys(v)}
/>
</div>
)
}
renderItem = (item) => { renderItem = (item) => {
const { const {
label, label,
title title
} = item; } = item;
return (<div className="trasfer-list-item" style={{"padding":"10px 20px","borderBottom":"1px solid #ddd"}}> return (<div className="trasfer-list-item" style={{ "padding": "10px 20px", "borderBottom": "1px solid #ddd" }}>
<div className="top text-overflow" style={{"marginBottom":"4px"}} title={label}>{label}</div> <div className="top text-overflow" style={{ "marginBottom": "4px" }} title={label}>{label}</div>
<div className="bottom text-overflow" style={{"color":"#999"}} title={title}>{title}</div> <div className="bottom text-overflow" style={{ "color": "#999" }} title={title}>{title}</div>
</div>) </div>)
}; };
filterLeft = (items) => { filterLeft = (items) => {
let leftItems = cloneDeep(items); let leftItems = cloneDeep(items);
const { const {
transferleftIptVal, transferleftIptVal,
transferSelectedKey transferSelectedKey
} = this.transfer; } = this.transfer;
if (transferSelectedKey) { if (transferSelectedKey) {
leftItems = leftItems.filter((item) => item.idx == transferSelectedKey) leftItems = leftItems.filter((item) => item.idx == transferSelectedKey)
} }
if (trim(transferleftIptVal)) { if (trim(transferleftIptVal)) {
leftItems = leftItems.filter((item) => item.label.indexOf(trim(transferleftIptVal)) > -1) leftItems = leftItems.filter((item) => item.label.indexOf(trim(transferleftIptVal)) > -1)
} }
return leftItems return leftItems
} }
filterRight = (items) => { filterRight = (items) => {
let rightItems = cloneDeep(items); let rightItems = cloneDeep(items);
const { const {
transferRightIptVal transferRightIptVal
} = this.transfer; } = this.transfer;
if (trim(transferRightIptVal)) { if (trim(transferRightIptVal)) {
rightItems = rightItems.filter((item) => item.label.indexOf(trim(transferRightIptVal)) > -1) rightItems = rightItems.filter((item) => item.label.indexOf(trim(transferRightIptVal)) > -1)
} }
return rightItems return rightItems
} }
@action("穿梭框变化回调") updateTransferKeys = (v) => { @action("穿梭框变化回调") updateTransferKeys = (v) => {
this.transfer.transferKeys = v; this.transfer.transferKeys = v;
} }
@action updateTransferleftIptVal = (v) => { @action("模板") getSearchTemplate = (bool) => {
this.transfer.transferleftIptVal = v; Api.getSearchTemplate({ type: bool ? 'search' : 'custom' }).then(res => {
} if (res.code === 200) {
bool ? this.setTemplates(res.data) : this.setCustomTemplates(res.data);
@action updateTransferSelectedKey = (v) => { } else {
this.transfer.transferSelectedKey = v; message.warning(res.msg);
}
@action updateTransferRightptVal = (v) => {
this.transfer.transferRightIptVal = v;
}
@action openSearchDialog = () => {
this.searchDialog.visible = true;
this.formatTransfer();
}
@action closeSearchDialog = () => {
this.searchDialog.visible = false;
}
updateFields(val) {
this.form2.updateFields({
lastName: {
value: val
} }
}, error => {
message.warning(error.msg);
})
}
@observable relatedData = {
datas: [],
columns: [],
loading: true,
selectedData: {}
};
@observable temlateManageDialog = {
title: '模板管理',
visible: false,
hasScroll: true,
icon: 'icon-coms-hrm',
iconBgcolor: '#217346',
onCancel: () => this.closeTemlateManageDialog(),
style: {
width: 500,
height: 650
},
buttons: [<Button type='primary' onClick={() => this.updateCustomTemplate()}>保存</Button>]
}
@computed get editTableParams() {
let datas = this.relatedData.datas;
let selectedData = this.relatedData.selectedData.status;
let params = this.arrToJson(toJS(datas), toJS(selectedData), 'status');
params.rownum = datas.length;
return params;
}
@action("列定制模板管理") getEditTable() {
this.temlateManageDialog.visible = true;
this.relatedData.loading = true;
Api.getEditTable().then(result => {
if (result.code === 200) {
const { columns, datas, selectedData } = result.data;
extendObservable(this.relatedData, {
datas: datas,
columns: columns
});
selectedData && extendObservable(this.relatedData, {
selectedData: selectedData
});
extendObservable(this.relatedData, {
loading: false
});
} else {
message.warning(result.msg);
}
}, error => {
message.warning(error.msg);
})
}
@action("保存") updateCustomTemplate() {
let params = this.editTableParams;
Api.updateCustomTemplate(params).then(res => {
let { code, msg } = res;
if (code === 200) {
message.success(msg || "操作成功");
this.getEditTable();
this.customization();
} else {
message.error(msg);
}
}).catch(error => {
message.error(error);
}); });
} }
setSearchCondition(condition) { @action("列定制") getCustomTransferData() {
this.searchCondition = condition; Api.getCustomTransferData(this.customTemplateId).then(result => {
} if (result.code === 200) {
const { transferDatas, transferKeys, transferOptions } = result.data;
setDefaultCondition(defaultcondition) { this.transfer.transferDatas = transferDatas;
this.defaultCondition = defaultcondition; this.transfer.transferKeys = transferKeys;
} this.transfer.transferOptions = transferOptions;
this.searchDialog.visible = true;
setTemplates(templates) { this.searchDialog.loading = false;
this.templates = templates; } else {
} message.warning(result.msg);
setScLoadingStatus(bool) {
this.searchConditionLoading = bool;
}
setPanelStatus(bool) {
this.isPanelShow = bool;
bool && this.getSearchCondition();
if (!bool) {
this.scLoadingReset();
} }
} }, error => {
message.warning(error.msg);
})
}
setLastName(val) {
this.lastName = val;
}
isEmptyObject(obj) {
for (let key in obj) {
return false; @action updateTransferleftIptVal = (v) => {
this.transfer.transferleftIptVal = v;
}
@action updateTransferSelectedKey = (v) => {
this.transfer.transferSelectedKey = v;
}
@action updateTransferKeys = (v) => {
this.transfer.transferKeys = v;
}
@action updateTransferRightptVal = (v) => {
this.transfer.transferRightIptVal = v;
}
@action openSearchDialog = (bool) => {
this.search = bool;
this.searchDialog.loading = false;
this.formatTransfer();
}
@action openCustomDialog = (bool) => {
this.search = bool;
this.searchDialog.loading = true;
this.getSearchTemplate(bool);
this.getCustomTransferData();
}
@action closeSearchDialog = () => {
this.searchDialog.visible = false;
}
@action closeTemlateManageDialog = () => {
this.temlateManageDialog.visible = false;
}
setTableEditDatas(e) {
e.map(item => {
for (let key in item) {
if (key == "undefined") {
delete item[key];
}
if (!item["isused"]) {
item["isused"] = "";
}
} }
return true; });
extendObservable(this.relatedData, {
datas: e
});
}
setEnableRows(e) {
extendObservable(this.relatedData, {
selectedData: {
isused: e
}
});
}
updateFields(val) {
this.form2.updateFields({
lastname: {
value: val
}
});
}
setSearchCondition(condition) {
this.searchCondition = condition;
}
setDefaultCondition(defaultcondition) {
this.defaultCondition = defaultcondition;
}
setTemplates(datas) {
this.templates = datas;
}
setCustomTemplates(datas) {
this.customTemplates = datas;
}
setScLoadingStatus(bool) {
this.searchConditionLoading = bool;
}
setPanelStatus(bool) {
this.isPanelShow = bool;
this.search = true;
this.searchDialog.loading = true;
this.getSearchTemplate(bool);
bool && this.getSearchCondition();
if (!bool) {
this.scLoadingReset();
} }
}
setIds(ids) { arrToJson(arr, rows, rowKey = "isused") {
this.ids = ids; let json = {};
const _rows = isEmpty(arr) ? [] : rows;
_rows && _rows.map(index => {
arr[index][rowKey] = "1";
});
arr.map((item, index) => {
if (!item[rowKey]) item[rowKey] = "0";
for (let key in item) {
json[key + "_" + index] = item[key];
}
});
return json;
}
setLastName(val) {
this.lastName = val;
}
isEmptyObject(obj) {
for (let key in obj) {
return false;
} }
return true;
}
scLoadingReset() { setIds(ids) {
this.searchConditionLoading = true; this.ids = ids;
} }
scLoadingReset() {
this.searchConditionLoading = true;
}
formReset() { formReset() {
this.form = new WeaForm(); this.form = new WeaForm();
} }
dialogLoadingReset() { dialogLoadingReset() {
this.dialogLoading = true; this.dialogLoading = true;
} }
setVisible(bool) { setVisible(bool) {
this.visible = bool; this.visible = bool;
this.formReset(); this.formReset();
!bool && this.dialogLoadingReset(); !bool && this.dialogLoadingReset();
} }
setDialogLoadingStatus(bool) { setDialogLoadingStatus(bool) {
this.dialogLoading = bool; this.dialogLoading = bool;
} }
setNeDialogTitle(title) { setNeDialogTitle(title) {
this.nEdialogTitle = title; this.nEdialogTitle = title;
} }
setIsNew(bool) { setIsNew(bool) {
this.isNew = bool; this.isNew = bool;
} }
setCondition(condition) { setCondition(condition) {
this.condition = condition; this.condition = condition;
} }
setUserId(userId) { setUserId(userId) {
this.userId = userId; this.userId = userId;
} }
setDate(date) { setDate(date) {
this.date = date; this.date = date;
} }
setTopMenu(topMenu) { setTopMenu(topMenu) {
this.topMenu = topMenu; this.topMenu = topMenu;
} }
setRightMenu(rightMenu) { setRightMenu(rightMenu) {
this.rightMenu = rightMenu; this.rightMenu = rightMenu;
} }
setHasRight(bool) { setHasRight(bool) {
this.hasRight = bool; this.hasRight = bool;
} }
} }