weaver_trunk_cli/pc4mobx/hrm/stores/base.js

227 lines
5.4 KiB
JavaScript
Raw Normal View History

2024-12-11 15:32:14 +08:00
import {
WeaLocaleProvider,
} from 'ecCom';
import {
Button,
Modal,
message
} from 'antd';
import {
IEVersion
} from '../util/pulic-func.js';
const getLabel = WeaLocaleProvider.getLabel;
const confirm = Modal.confirm;
export default class Base {
get TOP_HRM() {
return {
showDropIcon: true,
iconBgcolor: '#217346',
icon: <i className='icon-coms-hrm'/>,
}
}
convertDatasToTopRightConf = (datas) => {
let tConf, rConf;
tConf = datas && datas.filter(data => {
const {
isTop,
isBatch
} = data;
if (isTop === '1') {
return true;
}
if (isBatch === '1') {
return true;
}
})
rConf = datas;
return {
tConf,
rConf
}
}
get SEARCH_BUTTONS() {
return [getLabel(82529, '搜索'), getLabel(27088, '重置'), getLabel(32694, '取消')];
}
get SEARCH() {
return{
advanceHeight: 130,
hasMask: false,
keyParam: 'key',
searchType: ['base', 'advanced'],
onChange: key => this.setSelectedKey && this.setSelectedKey(key),
setShowSearchAd: bool => this.setShowSearchAd && this.setShowSearchAd(bool),
onSearch: () => this.onSearch && this.onSearch(),
onSearchChange: val => this.onSearchChange && this.onSearchChange(val),
buttonsAd: this.SEARCH_BUTTONS.map((name, index) => {
const type = (index === 0) && "primary";
let callback;
if (index === 0) {
callback = () => this.onSearch && this.onSearch();
} else if (index === 1) {
callback = () => this.tab && this.tab.form && this.tab.form.reset();
} else {
callback = () => this.setShowSearchAd && this.setShowSearchAd(false)
}
return <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@xx3qf3@${index}`} type={type} onClick={() => callback()}>{name}</Button>
})
}
}
get TREE_ORG() {
return {
needSearch: true,
noCache: true,
isLoadAllSub: true,
inputLeftDom: `<b>${getLabel(25332, '组织结构')}</b>`,
treeNodeClick: (event, ids, nodeids, nodes) => this.handleOrgTreeNodeClick && this.handleOrgTreeNodeClick(event, ids, nodeids, nodes)
}
}
get TABLE() {
return {
hasOrder: true,
needScroll: true,
getColumns: columns => this.reRenderColumns && this.reRenderColumns(columns),
onOperatesClick: (record, rowIndex, operate) => this.onOperatesClick && this.onOperatesClick(record, rowIndex, operate)
}
}
get DIALOG_HRM() {
return {
hasScroll: true,
icon: 'icon-coms-hrm',
iconBgcolor: '#217346',
onCancel: () => this.closeDialog && this.closeDialog(),
style: {
width: 700,
height: 350
},
moreBtn: {
datas: []
},
}
};
get MONTHYEAR() {
return {
datas: [{
key: '0',
title: getLabel(26577, "年")
}, {
key: '1',
title: getLabel(6076, '月')
}],
onMonthYearClick: key => this.handleMonthYearClick && this.handleMonthYearClick(key),
onDatePickerChange: date => this.handleDatePickerChange && this.handleDatePickerChange(date),
resetMonthYear: () => this.resetMonthYear && this.resetMonthYear(),
}
}
/**
* @DateTime 2019-05-17
* @param {Date} date 日期
* @param {Boolen} onlyYear 是否只需要年份
* @return {String} 20192019-05
*/
formatDate = (date, onlyYear) => {
let pureDate;
if (!date._d) {
pureDate = date;
} else {
pureDate = date._d;
}
const year = pureDate.getFullYear();
const month = pureDate.getMonth() + 1;
if (onlyYear) {
return year
} else {
return `${year}-${ (month < 10) ? `0${month}`: month}`
}
}
/**
* @DateTime 2019-05-17
* 概述获取表单中所有需要校验的domkey
* @param {Array} conditions 表单的配置数据
* @return {Array} 需要校验的domkey
*/
getAllNeedValidateFieldKey = (conditions) => {
const allNeedValidateKeys = [];
conditions && conditions.forEach(c => {
c.items.forEach(item => {
const {
viewAttr,
domkey
} = item;
if (viewAttr === 3) {
allNeedValidateKeys.push(domkey[0])
}
});
});
return allNeedValidateKeys;
}
/**
* @DateTime 2019-05-17
* 概述获取当前不需要校验的表单元素对应的key值集合该函数配合getAllNeedValidateFieldKey一起使用
* @param {Array} allNeedValidateKeys 所有需要校验
* @param {Array} needValidateKeys 当前需要校验
* @return {Array} 当前不需要校验
*/
getNoNeedValidateKeys = (allNeedValidateKeys, needValidateKeys = []) => {
const noNeedValidateKeys = allKeys.filter(key => !needValidateKeys.includes(key));
return noNeedValidateKeys;
}
/**
* @DateTime 2019-05-18
* @param {String} msg 提示信息
* @param {Function} callback 回调函数
*/
showConfirm = (msg, callback) => {
confirm({
title: getLabel('131329', '信息确认'),
content: msg,
okText: getLabel('33703', '确定'),
cancelText: getLabel('32694', '取消'),
onOk() {
callback && callback();
},
onCancel() {
return false;
},
});
}
/**
* @DateTime 2019-05-21
* 概述显示接口返回的错误信息
* @param {StringArray} msgs 错误信息
*/
showErrorInfo = (msgs) => {
if (typeof msgs === 'string') {
message.warning(<div dangerouslySetInnerHTML = {{ __html: msgs }} />);
} else {
message.warning(<ul>{
msgs.map(msg=><li>{msg}</li>)
}</ul>);
}
}
/**
* @DateTime 2019-06-24
* 概述阻止冒泡
*/
stopBubble = (e) => {
e.stopPropagation &&e.stopPropagation();
e.preventDefault && e.preventDefault();
}
}