weaver_trunk_cli/pc4mobx/hrm/stores/password.js

156 lines
3.0 KiB
JavaScript

import {
observable,
action
} from 'mobx';
import * as mobx from 'mobx'
import * as Api from '../apis/password';
import {
message,
} from 'antd';
import {
WeaLocaleProvider
} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
export class HrmPassword {
@observable tabKey = '0';
@observable isPwdVerifyDialogShow = false;
@observable isPwdSecuritySettingShow = false;
@observable current = 0;
@observable columns = [];
@observable datasource = [];
@observable answerArray = [];
@observable isSetted = false;
@observable secStatus = false;
@observable isModifyBtnClick = false;
@observable pwdCopy = '';
@observable hrmId;
@observable showSecondaryPwd = false;
@observable showSecuritySetting = false;
@observable date = new Date();
@action reDate = () => {
this.date = new Date();
}
@action
doOpen(arg) {
if (arg == '1'){
this.isPwdVerifyDialogShow = true;
this.reDate();
};
if (arg == '2') this.isPwdSecuritySettingShow = true;
}
doClose(arg) {
if (arg == '1') this.isPwdVerifyDialogShow = false;
if (arg == '2') this.isPwdSecuritySettingShow = false;
}
plus() {
this.current = this.current + 1;
}
minus() {
this.current = this.current - 1;
}
reset() {
this.current = 0;
}
setPwdCopy(pwd) {
this.pwdCopy = pwd;
}
setModifyBtnStatus(bool) {
this.isModifyBtnClick = bool;
}
getTableEditInfo() {
let params = {};
Api.getTableEditInfo(params).then((data) => {
if (data) {
this.columns = data.tableinfo.columns;
let ds = data.tableinfo.datas;
if (ds && ds.length == 0) {
this.datasource = [];
this.datasource.push({
question: '',
answer: ''
});
} else {
this.datasource = data.tableinfo.datas;
}
}
});
}
getSecuritySettingStatus() {
Api.isSecutitySetting().then((data) => {
this.secStatus = data.secStatus;
this.isSetted = data.isSetted;
});
}
@action isOpenSecondaryPwd = () => {
Api.isOpenSecondaryPwd().then(datas => {
const {
isOpenSecondaryPwd,
securityQuestion,
} = datas;
this.showSecondaryPwd = (isOpenSecondaryPwd === '1');
this.showSecuritySetting = (securityQuestion === '1');
})
}
pushAnswer(answer) {
this.answerArray.push(answer);
}
save(params) {
Api.securityQaSave(params).then((data) => {
if (data.result == 'true') {
message.success(getLabel('386524', "密保问题保存成功!"));
Api.setSecSettingStatus({
pswd: this.pwdCopy,
checked: true
}).then((data) => {
if (data.result == 'true') {
this.secStatus = true;
this.isSetted = true;
}
})
}
});
}
setSecutityStatus(params,cb) {
if (this.secStatus) {
params.checked = false;
} else {
params.checked = true;
}
Api.setSecSettingStatus(params).then((data) => {
if (data.result == 'true') {
this.secStatus = !this.secStatus;
this.doClose('1');
cb&&cb();
} else {
this.reDate();
if (data.message) {
message.error(data.message);
} else {
message.error(getLabel('386525', "密码校验不通过,请重新输入!"));
}
}
});
}
}