花名册开发

This commit is contained in:
Chengliang 2023-01-10 18:23:25 +08:00
parent d98f86be17
commit b15b08433f
4 changed files with 379 additions and 192 deletions

View File

@ -54,3 +54,35 @@ 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 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 = (id) => {
return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getSearchTemplate?templateId=${id}`, 'GET');
}
export const getTemplateSelectKeys = (id) => {
return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getTemplateSelectKeys?templateId=${id}`, 'GET');
}

View File

@ -5,6 +5,10 @@ import {
WeaDialog, WeaDialog,
} from 'ecCom'; } from 'ecCom';
import Customization from './Customization'; import Customization from './Customization';
import {
Spin,
Button,
} from 'antd'
@observer @observer
export default class SearchCustomDialog extends React.Component { export default class SearchCustomDialog extends React.Component {
@ -17,14 +21,23 @@ export default class SearchCustomDialog extends React.Component {
store store
} = this.props, { } = this.props, {
SEARCHDIALOG, SEARCHDIALOG,
searchDialog searchDialog,
search
} = store; } = store;
const buttons = [
<Button type='primary' onClick={()=>store.saveHrmSearchUserDefine()}>保存</Button>,
<Button type='primary' onClick={()=>store.saveHrmSearchUserDefine()}>存为模板</Button>,
<Button type='primary' onClick={()=>store.saveHrmSearchUserDefine()}>模板管理</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,
@ -280,6 +281,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 +328,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>),
]; ];
@ -391,7 +429,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 +446,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) => {

View File

@ -6,7 +6,7 @@ import {
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,
@ -22,24 +22,22 @@ import {
i18n i18n
} from '../public/i18n'; } from '../public/i18n';
import trim from 'lodash/trim'; import trim from 'lodash/trim';
import {getSecondPath} from '../util/index' import { getSecondPath } from '../util/index'
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
const toJS = mobx.toJS; const toJS = mobx.toJS;
const { const {
TableStore TableStore
} = 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;
@ -141,7 +139,8 @@ const {
@action("高级搜索表单") getSearchCondition() { @action("高级搜索表单") getSearchCondition() {
this.setScLoadingStatus(true); this.setScLoadingStatus(true);
const params = { const params = {
selectKeys:this.transfer.transferKeys selectKeys: this.transfer.transferKeys,
templateId:this.searchTemplateId
} }
Api.getAdvanceSearchCondition(params).then(res => { Api.getAdvanceSearchCondition(params).then(res => {
if (res.code === 200) { if (res.code === 200) {
@ -149,7 +148,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 +171,7 @@ const {
}) })
} }
@action("导出") export(){ @action("导出") export() {
const params = { const params = {
...this.form.getFormParams() ...this.form.getFormParams()
} }
@ -182,7 +180,7 @@ 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 {
@ -194,12 +192,17 @@ const {
} }
/** ====================================================================================== */ /** ============================================================================================= */
@observable searchDialog = { @observable searchDialog = {
visible: false, visible: false,
title: '常用条件定制',
} }
@observable templates = [];
@observable searchTemplateName = '';
@observable searchTemplateId = '-1';
@observable search = false;
SEARCHDIALOG = { SEARCHDIALOG = {
hasScroll: false, hasScroll: false,
icon: 'icon-coms-hrm', icon: 'icon-coms-hrm',
@ -212,7 +215,7 @@ const {
moreBtn: { moreBtn: {
datas: [] datas: []
}, },
buttons: [<Button type='primary' onClick={()=>this.saveHrmSearchUserDefine()}>保存</Button>],
} }
@ -238,6 +241,11 @@ const {
this.getSearchCondition(); this.getSearchCondition();
} }
@action("高级搜索模板切换") changeSearchTemplate(v){
this.searchTemplateId = v;
this.getSearchCondition();
}
@action("常用条件定制") formatTransfer = () => { @action("常用条件定制") formatTransfer = () => {
const transferDatas = [] const transferDatas = []
const transferKeys = [] const transferKeys = []
@ -272,16 +280,84 @@ const {
this.transfer.transferOptions = transferOptions; this.transfer.transferOptions = transferOptions;
} }
inputSearchStyle = { @action("列定制") customization = (v) => {
width:"105px", this.openSearchDialog(false);
float:"right",
marginTop:"5px",
marginLeft:"10px"
} }
selectStyle={
marginTop:"-1px", @action("常用条件定制模板切换") getTemplateSelectKeys = v => {
width:"85px", Api.getTemplateSelectKeys(v).then(res => {
float:"right" 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("搜索模板删除") 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 = {
width: "105px",
float: "right",
marginTop: "5px",
marginLeft: "10px"
}
selectStyle = {
marginTop: "-1px",
width: "85px",
float: "right"
} }
@computed get leftHeader() { @computed get leftHeader() {
const { const {
@ -309,7 +385,7 @@ const {
@computed get rightHeader() { @computed get rightHeader() {
const { const {
transferRightIptVal transferRightIptVal,
} = this.transfer; } = this.transfer;
return ( return (
<div className="trasfer-header"> <div className="trasfer-header">
@ -317,7 +393,12 @@ const {
<WeaInputSearch <WeaInputSearch
style={this.inputSearchStyle} style={this.inputSearchStyle}
value={transferRightIptVal} value={transferRightIptVal}
onSearchChange={ this.updateTransferRightptVal} onSearchChange={this.updateTransferRightptVal}
/>
<WeaSelect
style={this.selectStyle}
options={this.templates}
onChange={v => this.getTemplateSelectKeys(v)}
/> />
</div> </div>
) )
@ -327,9 +408,9 @@ 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>)
}; };
@ -363,6 +444,20 @@ const {
this.transfer.transferKeys = v; this.transfer.transferKeys = v;
} }
@action("高级搜索模板") getSearchTemplate = () => {
Api.getSearchTemplate(this.searchTemplateId).then(res => {
if (res.code === 200) {
res.data && this.setTemplates(res.data);
} else {
message.warning(res.msg);
}
}, error => {
message.warning(error.msg);
})
}
@action updateTransferleftIptVal = (v) => { @action updateTransferleftIptVal = (v) => {
this.transfer.transferleftIptVal = v; this.transfer.transferleftIptVal = v;
} }
@ -371,13 +466,19 @@ const {
this.transfer.transferSelectedKey = v; this.transfer.transferSelectedKey = v;
} }
@action updateTransferKeys = (v) => {
this.transfer.transferKeys = v;
}
@action updateTransferRightptVal = (v) => { @action updateTransferRightptVal = (v) => {
this.transfer.transferRightIptVal = v; this.transfer.transferRightIptVal = v;
} }
@action openSearchDialog = () => { @action openSearchDialog = (bool) => {
this.search = bool;
this.searchDialog.visible = true; this.searchDialog.visible = true;
this.formatTransfer(); this.formatTransfer();
@ -416,6 +517,7 @@ const {
setPanelStatus(bool) { setPanelStatus(bool) {
this.isPanelShow = bool; this.isPanelShow = bool;
this.getSearchTemplate();
bool && this.getSearchCondition(); bool && this.getSearchCondition();
if (!bool) { if (!bool) {
this.scLoadingReset(); this.scLoadingReset();
@ -492,4 +594,4 @@ const {
this.hasRight = bool; this.hasRight = bool;
} }
} }