import { Button,Row,Col, Modal} from 'antd';
import { WeaTools,WeaSearchGroup,WeaRightMenu,WeaFormItem,WeaTop, WeaCheckbox, WeaSelect, WeaDatePicker,WeaDialog,WeaLocaleProvider, WeaAlertPage} from 'ecCom'
import isEmpty from 'lodash/isEmpty'
import forEach from 'lodash/forEach'
import {WeaSwitch} from 'comsMobx';
import { inject, observer} from 'mobx-react';
import * as mobx from 'mobx';
import moment from 'moment';
import "../../style/systeminfo.less";
import InputBtn from '../../coms/inputBtn'
import NeedAutoBtn from '../../coms/needAutoBtn'
import TopButton from '../../coms/topButton';
import {i18n} from '../../public/i18n';
import {addContentPath} from '../../util/index.js'
const getKey = WeaTools.getKey;
const toJS = mobx.toJS;
const confirm = Modal.confirm;
const getLabel = WeaLocaleProvider.getLabel;
@inject('hrmSystemInfo')
@inject('hrmCard')
@observer
class HrmSystemInfo extends React.Component {
componentDidMount(){
const {hrmSystemInfo,hrmCard} = this.props;
hrmSystemInfo.init();
hrmSystemInfo.hrmId = this.props.params.hrmId || '';
hrmSystemInfo.getFormField();
hrmSystemInfo.getWeekInfo(new moment().format('YYYY-MM-DD'));
const dom = $('');
$(document.body).append(dom);
hrmCard.setTopButtons(this.getTopButtons.bind(this));
hrmCard.setTopRightMenus(this.getRightMenu.bind(this));
hrmCard.setTopShowDropIcon(true);
}
getSearchs = () => {
const {hrmSystemInfo} = this.props;
let {isEditor, checkValue, inputVlaue, pickerValue, selectValue, options, formFields, form} = hrmSystemInfo;
const formParams = hrmSystemInfo.getFormParams();
const userUsbType = formParams.userUsbType || '';
const usbState = formParams.usbstate || '';
const {date} = hrmSystemInfo;
const cancelSecondPwd = () => {
confirm({
title: i18n.confirm.defaultTitle(),
content: (
{i18n.label['388923']()}
{i18n.label['388924']()}
),
okText: i18n.button.ok(),
cancelText: i18n.button.cancel(),
width: 420,
onOk: () => {
form.updateFields({
useSecondaryPwd: {
value: '0'
}
})
}
});
}
const {isFormInit} = form;
let group = [];
let group1 = [];
let colIndex = 1;
let is901 = userUsbType == '901' ;
if (is901 && (['tokenKey','serial'].indexOf(domkey) >= 0)){
hide=true ;
}
isFormInit && formFields.forEach((c, i) =>{
c.items.forEach( (field, j) => {
let domkey = field.domkey[0] || '';
let hide = false;
let hideLabel = false;
if (userUsbType == '' && (domkey == 'tokenKey' || domkey == 'serial' || domkey == 'usbstate')) hide = true;
if ((userUsbType == '4' || userUsbType == "6") && (domkey == 'tokenKey' || domkey == 'serial')) hide = true;
if (userUsbType == '2' && domkey == 'tokenKey') hide = true;
if (userUsbType == '3' && domkey == 'serial') hide = true;
if (!isEditor && (domkey == 'password'||domkey == 'password1')) hide = true;
if (domkey === 'validatecode') {
hide = isEditor ? false : true;
}
if(domkey == 'startUsing'){
hide = true;
if (isEditor && (userUsbType == '2' || userUsbType == '3') && usbState =='1' ){
hide = false;
}
}
if(!hide){
let dom;
if (isEditor && domkey == 'tokenKey') {
hideLabel = true;
const key = getKey(field);
const bindObj = form.$(key);
dom =
{i18n.label.tokenNum()}:
this.updateKey()}/>
} else if (isEditor && domkey == 'serial') {
hideLabel = true;
const key = getKey(field);
const bindObj = form.$(key);
dom =
{i18n.label.userKey()}:
this.updateKey(v)}/>
}else if (isEditor && domkey == 'startUsing') {
hideLabel = true;
dom =
{i18n.label.autoEnable()}:
{
checkValue && checkValue=='1' &&
{i18n.label.enableDate()}:
{i18n.label.enableMode()}:
}
}else if(domkey=='useSecondaryPwd'){
dom = (
{formParams.useSecondaryPwd === '1' ? i18n.label['15809']() : i18n.label['15808']()}
);
}else {
dom =
}
if(!isEditor){
if(colIndex % 2 == 0){
group1.push(
{dom}
);
}else{
group.push(
{dom}
);
}
colIndex++;
}else{
if(domkey=='password' || domkey=='password1' || domkey=='seclevel'){
group1.push(
{dom}
);
}else if(domkey=='useSecondaryPwd'){
group1.push(
{formParams.useSecondaryPwd === '1' ? i18n.label['15809']() : i18n.label['15808']()}
{
formParams.useSecondaryPwd === '1' &&
}
);
}else if(domkey === 'validatecode'){
group1.push(
{dom}
hrmSystemInfo.date = new Date().getTime()}
/>
)
}else if((is901 || userUsbType == "6") && domkey == 'usbstate'){
let statesOptions = Array.from(field.options) ;
statesOptions.pop()
group.push(
{this.changeUsbstate(v)}}
/>
);
} else {
group.push(
{dom}
);
}
}
}
});
});
return
{group}
{group1}
}
render() {
const {hrmSystemInfo} = this.props;
const {viewDate, isEditor, weekInfo, title,weakPasswordDisable,doSave,changeModalState,modalVisible} = hrmSystemInfo;
const formParams = hrmSystemInfo.getFormParams();
const {query} = this.props.location;
if(!query.fromcard && window.location.href.indexOf("/spa/hrm/index_mobx.html")>-1){
document.title=i18n.label.sysInfo();
}
try{
const weakPassBtns = [,
]
return (
}
iconBgcolor='#217346'
buttons={this.getTopButtons()}
buttonSpace={10}
showDropIcon={true}
dropMenuDatas={this.getRightMenu()}
/>
{this.getSearchs()}
{
!isEditor && weekInfo && !isEmpty(weekInfo) &&
{i18n.label.weekSituation()}
{weekInfo.kqinfo.weekworkdayslabel}:{weekInfo.kqinfo.weekworkdays}
{weekInfo.kqinfo.weeksigninnumlabel}:{weekInfo.kqinfo.weeksigninnum}
{weekInfo.kqinfo.weeksignoutnumlabel}:{weekInfo.kqinfo.weeksignoutnum}
{weekInfo.kqinfo.weekblogwritenumlabel}:{weekInfo.kqinfo.weekblogwritenum}
{weekInfo.kqinfo.weekblognotwritenumlabel}:{weekInfo.kqinfo.weekblognotwritenum}
{viewDate && viewDate.slice(0, 7)}
hrmSystemInfo.onPickerHandler(v)}/>
{
weekInfo.weekInfo && !isEmpty(weekInfo.weekInfo) && weekInfo.weekInfo.map((item, i) => {
return
{item.weekday}
{item.date}
})
}
{
hrmSystemInfo.bodyConf && !isEmpty(hrmSystemInfo.bodyConf) && hrmSystemInfo.bodyConf.map((conf, i) => {
return
{conf.title}
{conf.fieldsConf[0].title} :
{
conf.fieldsConf.length>1 && conf.fieldsConf[1] &&
{conf.fieldsConf[1].isIp ?
:
}
{conf.fieldsConf[1].title} :
}
{
weekInfo.weekInfo && !isEmpty(weekInfo.weekInfo) && weekInfo.weekInfo.map((item, i) => {
return
{item[conf.fields[0]]}
{
conf.fields.length>1 && conf.fields[1] &&
{item[conf.fields[1]]}
}
})
}
})
}
}
{
(weakPasswordDisable === "0") ? getLabel('515419','该密码比较容易被猜到,确定保存吗?') : getLabel('515420','该密码比较容易被猜到,为了您的系统安全,请重新修改密码。')
}
)
}catch(e){
return (
{i18n.message.authFailed()}
)
}
}
getTopButtons = () => {
const {hrmSystemInfo} = this.props;
const {isEditor, buttons} = hrmSystemInfo;
const save = ;
const back = ;
const edit = ;
const btns = [];
try{
if (isEditor) {
if(buttons && buttons.hasEdit){
btns.push(save);
btns.push(back);
}
} else {
if(buttons && buttons.hasEdit){
btns.push(edit);
}
}
}catch(e){}
return btns;
}
doSave = () => {
const {hrmSystemInfo} = this.props;
hrmSystemInfo.doSave();
}
edit = () => {
const {hrmSystemInfo} = this.props;
hrmSystemInfo.edit();
}
backCard = () => {
const {hrmSystemInfo} = this.props;
hrmSystemInfo.backCard();
}
updateKey = () => {
const {hrmSystemInfo} = this.props;
hrmSystemInfo.updateKey();
}
onPickerChange = (v) => {
const {hrmSystemInfo} = this.props;
hrmSystemInfo.onPickerChange(v);
}
onCheckChange = (v) => {
const {hrmSystemInfo} = this.props;
hrmSystemInfo.onCheckChange(v);
}
onSelectChange = (v) => {
const {hrmSystemInfo} = this.props;
hrmSystemInfo.onSelectChange(v);
}
getRightMenu = () => {
const {hrmSystemInfo} = this.props;
const {isEditor, buttons, hrmId} = hrmSystemInfo;
let arr = [];
try{
if(buttons && buttons.hasEdit){
if (isEditor){
arr = [{
icon: ,
content: i18n.button.save(),
key: 'save',
onClick: key =>{
this.doSave();
}
}, {
icon: ,
content: i18n.button.back(),
key: 'back',
onClick: key =>{
this.backCard();
}
}]
} else {
arr = [{
icon: ,
content:i18n.button.modify(),
key: 'editCard',
onClick: key =>{
this.edit();
}
}]
arr.push(
{
icon: ,
content:i18n.button.log(),
key: 'showLog',
onClick: key =>{
window.setLogViewProps({logSmallType:i18n.smallType.HRM_RSOURCE_CARD_SYSTEM,targetId:hrmId});
}
}
)
}
}
}catch(e){}
return arr;
}
changeUsbstate = v =>{
const {hrmSystemInfo:{form}} = this.props;
form.updateFields({
usbstate:{
value : v
}
})
}
onChangeHandle = value => {
if(value.userUsbType.value == '6'){
const {hrmSystemInfo:{form}} = this.props;
form.updateFields({
usbstate:{
value : '1'
}
})
}
}
}
export default HrmSystemInfo;