import {
	observable,
	action,
	computed,
	autorun
} from 'mobx';
import {
	WeaInput,
	WeaInputNumber,
	WeaTextarea,
	WeaBrowser,
	WeaSelect,
	WeaCheckbox,
	WeaDatePicker,
	WeaTimePicker
} from 'ecCom';
import {
	WeaTableNew
} from 'comsMobx';
import {
	message,
	Button,
	Modal,
} from 'antd';
import HrmBaseStore from './baseStore';
import * as api from '../apis/batchEdit';
import { findIndex, has, filter } from 'lodash';
import {
	i18n
} from '../public/i18n';
import { jumpToHrmCard, jumpToHrmDept, jumpToHrmSubCompany } from '../public/pulic-func';
const {
	TableStore
} = WeaTableNew;
import loadjs from 'loadjs';
import data from "../../../pc4mobx/hrm/stores/data";
import { WeaLocaleProvider } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
const confirm = Modal.confirm;

import NeedRender from '../components/batchMaintenance/edit/NeedRender'

export class HrmBatchEdit extends HrmBaseStore {
	rootStore;
	router;

	setRootStore = (rootStore, router) => {
		this.rootStore = rootStore;
		this.router = router;
		rootStore.getFormStatus = this.getFormStatus;
		rootStore.updateForm = this.updateForm;
		rootStore.saveEdit = this.saveEdit;
		rootStore.getForm = this.getForm;
		rootStore.saveForm = this.saveForm;
		rootStore.definedColumnVisible = this.definedColumnVisible;
		rootStore.exportData = this.exportData;
		rootStore.showOpLog = this.showOpLog;
		rootStore.getListDatas = this.generateTableSelectedData;
		rootStore.generateTableReqParams = this.generateTableReqParams;
		this.menus = this.rootStore.topMenuDef().edit[this.rootStore.routeProps.params].menus;
		this.refreshMenu = new Date().getTime();
	}
	/********************* unobservable list *********************/
	orgTreeProps = {
		needSearch: true,
		noCache: true,
		// isLoadSubDepartment: true,
		topPrefix: 'hrmSearch',
		inputLeftDom: `<b>${i18n.label.organization()}</b>`,
		treeNodeClick: this.treeNodeClick,
		params: {
			rightStr: 'PersonnelOrganization:Batchmaintenance'
		}
	}


	tabConfig = {
		tabs: [{
			color: '#000000',
			groupId: 'key',
			title: '',
			viewCondition: '1',
			searchType: ['base', 'advanced'],
			// searchKey: 'roleName',
			doSearch: () => {
				this.generateTableSelectedData(this.generateTableReqParams(), false)
			}
		}],
		keyParam: 'viewCondition',
		activeTabKey: '1'
	}

	tableColDef = {};
	containerType = 'subCompany';
	selectedSubCompany = '';
	formType = '';
	treeRef;
	dirtyData = new Map();
	openRSA = "0";
	/********************* unobservable list *********************/

	/********************* dialog info setting *********************/

	/********************* dialog info setting *********************/

	/********************* observable list *********************/
	@observable menus = [];
	@observable refreshData = new Date().getTime();
	@observable refreshMenu = new Date().getTime();
	@observable verificationCode = '/weaver/weaver.file.MakeValidateCode?isView=1&validatetype=0&validatenum=4&from=_batch&seriesnum_=' + new Date().getTime();
	@observable table = new TableStore();
	@observable spinning = false;

	dialogParams = {
		...this.dialogPropsDef,
		opType: '',
		onCancel: () => {
			this.dialogParams.opType = '';
			this.dialogParams.visible = false;
			this.formType = '';
		}
	}
	/********************* observable list *********************/

	/********************* computed list *********************/
	@computed get multFiOp () {
		return this.table.selectedRowKeys.length == 0;
	}

	monitorMenuStats = () => {
		this.multFiOp;
		this.rootStore && this.rootStore.setMultiOpDisable(this.multFiOp);
	}

	monitorSpinning = () => {
		this.spinning;
		this.rootStore && this.rootStore.setSpinning(this.spinning);
	}

	getFormStatus = () => {
		this.multFiOp;
		if (this.rootStore) {
			if (this.tableStatus == 'passwordlockT') {
				this.rootStore.setUnblockStatus(true)
			} else {
				this.rootStore.setUnblockStatus(false)
			}
		}
	}

	monitor1 = autorun(this.monitorMenuStats)
	monitor2 = autorun(this.monitorSpinning)
	monitor3 = autorun(this.getFormStatus)
	/********************* computed list *********************/

	/********************* action list *********************/


	updateForm = (status) => {
		this.formTarget.conditionForm.updateFields({ 'passwordlock': status })
	}
	setTreeRef = (ref) => {
		this.treeRef = ref;
	}

	cleanMenuStatus = () => {
		this.rootStore.setMultiOpDisable(true);
	}

	cleanProps = () => {
		this.spinning = false;
		this.selectedSubCompany = null;
		this.formType = '';
	}

	init = (type) => {
		this.table.tableUpdate({ datas: [] });
		this.containerType = type.toLowerCase();
		this.cleanProps();

		api.getCondition(null, this.containerType).then(data => {
			if (data.status === '1') {
				this.setFormData('conditionForm', data.conditions);
				if (this.formTarget.conditionForm.isFormInit) {
					this.tabConfig.tabs[0].searchKey = data.conditions[0].items[0].domkey[0];
					this.generateTableSelectedData();
				}
			} else {
				message.error(data.message);
			}
		}, error => { })
	}

	generateTableSelectedData = (params = {}, onTree = true, flag) => {
		this.dirtyData.clear();
		const formParams = this.formTarget.conditionForm.getFormParams();
		if (formParams.passwordlock == 1) {
			this.tableStatus = 'passwordlockT'
		} else {
			this.tableStatus = 'passwordlockF'
		}
		if (flag == true) {
			formParams.passwordlock = 1
		} else if (flag == false) {
			formParams.passwordlock = ''
		};
		onTree && Object.assign(formParams, { ...params });
		this.rootStore.batchOpenStatus==true&& Object.assign(formParams, { ...params });
		api.batch(formParams, this.containerType).then(data => {
			this.table = new TableStore();
			if (data.status === '1') {
				this.table.getDatas(data.sessionkey, 1);
				this.tableColDef = data.columnItems;
				this.defaultPasswordEnable = data.defaultPasswordEnable;
			} else {
				message.error(data.message);
			}
		}, error => { })
	}

	generateTableReqParams = () => {
		if (this.selectedSubCompany == null)
			return {};

		const params = {}
		let type = '';
		switch (this.selectedSubCompany.type) {
			case '0':
				type = 'company';
				break;
			case '1':
				type = 'subcompany';
				break;
			case '2':
				type = 'department';
				break;
		}
		Object.assign(params, { id: this.selectedSubCompany.type === '0' ? this.selectedSubCompany.companyid : this.selectedSubCompany.id, type });
		return params;
	}

	@action treeNodeClick = (event, ids, nodeids, nodes) => {
		const {
			data: nodeData
		} = event.node.props;
		this.selectedSubCompany = nodeData;
		this.rootStore.batchOpenStatus=false;
		this.formTarget.conditionForm.resetConditionValue();
		this.generateTableSelectedData(this.generateTableReqParams(), true);
	}

	@action onComponentChange = async (comType, value, record, dataIndex, names, datas1) => {
		let datas = this.toJS(this.table.datas);
		const idx = findIndex(datas, { id: record.id });
		datas[idx][dataIndex] = value;
		if (comType == 'BROWSER') {
			datas[idx][`${dataIndex}span`] = names;
		}
		if (['supdepid', 'departmentid'].indexOf(dataIndex) >= 0) {
			if (value != '') {
				this.spinning = true;
				const data = await api.getSubCompanyInfo({ departmentid: value });
				if (data.status === '1') {
					datas[idx].subcompanyid1 = data.id.toString();
					datas[idx].subcompanyid1span = data.name;
					this.table.tableUpdate({ datas });
				} else {
					message.error(data.message);
				}
				this.spinning = false;
			} else {
				datas[idx].subcompanyid1 = null;
				datas[idx].subcompanyid1span = null;
				this.table.tableUpdate({ datas });
			}
			const replaceDatas = this.genReplaceDatas(datas[idx], 'subcompanyid1');
			this.browserRefs && this.browserRefs[`${record.id}_subcompanyid1`] && this.browserRefs[`${record.id}_subcompanyid1`].set(replaceDatas);
		} else if (dataIndex === 'subcompanyid1') {
			if (value != '' && ((datas[idx].supdepid != null && datas[idx].supdepid != '') || (datas[idx].departmentid != null && datas[idx].departmentid != ''))) {
				this.spinning = true;
				const departmentid = datas[idx].supdepid != null && datas[idx].supdepid != '' ? datas[idx].supdepid : datas[idx].departmentid;
				const data = await api.checkSubDeptAvailable({ subcompanyid1: value, departmentid });
				if (data.status === '1') {
					if (!data.available) {
						datas[idx].supdepid = null;
						datas[idx].supdepidspan = null;
						datas[idx].departmentid = null;
						datas[idx].departmentidspan = null;
						this.table.tableUpdate({ datas });
					}
				} else {
					message.error(data.message);
				}
				this.spinning = false;
			} else {
				datas[idx].supdepid = null;
				datas[idx].supdepidspan = null;
				datas[idx].departmentid = null;
				datas[idx].departmentidspan = null;
				this.table.tableUpdate({ datas });
			}
			const replaceDatas1 = this.genReplaceDatas(datas[idx], 'supdepid');
			const replaceDatas2 = this.genReplaceDatas(datas[idx], 'departmentid');
			this.browserRefs && this.browserRefs[`${record.id}_supdepid`] && this.browserRefs[`${record.id}_supdepid`].set(replaceDatas1);
			this.browserRefs && this.browserRefs[`${record.id}_departmentid`] && this.browserRefs[`${record.id}_departmentid`].set(replaceDatas2);
		} else {
			this.table.tableUpdate({ datas });
		}
		this.dirtyData.set(datas[idx].id, datas[idx]);
		// this.table.reloadCurrent();
	}

	@action saveEdit = () => {
		if (this.spinning)
			return;
		let dataSource = [];
		let checkValue = true;
		[...this.dirtyData.values()].map(value => {
			let pattern;
			if (has(value, 'email') && value.email != '') {
				pattern = /^(?:[a-z\d]+[_\-\+\.']?)*[a-z\d]+@(?:([a-z\d]+\-?)*[a-z\d]+\.)+([a-z]{2,})+$/i;
				if (!pattern.test(value.email)) {
					message.error(i18n.message['24570']());
					checkValue = false;
				}
			}
			[...Object.keys(this.tableColDef)].map(key => {
				if (this.tableColDef[key].conditionType === 'INPUTNUMBER') {
					value[key] = value[key] == '0' ? '0' : (value[key] || '0');
				}
			})

			dataSource.push(value);
		})
		if (!checkValue) {
			return;
		}

		this.spinning = true;
		api.saveBatch({ datas: JSON.stringify(dataSource) }, this.containerType).then(data => {
			if (data.status === '1') {
				message.success(i18n.message.saveSuccess());
				this.treeRef && this.treeRef.refs.tree.fetchData();
				this.generateTableSelectedData(this.generateTableReqParams());
			} else {
				message.error(data.message);
			}
			this.spinning = false;
		}, error => {
			this.spinning = false;
		});
	}

	@action getForm = (type, title) => {
		if (type === 'Accounttype') {
			const datas = this.toJS(this.table.datas);
			let arr = [];
			this.table.selectedRowKeys.map(key => {
				arr.push(datas[findIndex(datas, { id: key })]);
			})
			let type0Count = filter(arr, { accounttype: '0' }).length;
			let type1Count = filter(arr, { accounttype: '1' }).length;
			if (type0Count > 0 && type1Count > 0) {
				message.error(i18n.message.accountTypeDiff())
				return;
			}
		}
		if (type === "Reset") {//批量重置密码
			this.saveBatchDefaultPwd();
			return;
		}
		if (type === "unblock") {
			Modal.confirm({
				title: i18n.button.ok(),
				content: i18n.label.confirmBatchUnblock(),
				onOk: () => this.saveForm("unblock")
			});
			return;
		}
		this.formType = type;
		api.getForm(null, type).then(data => {
			if (data.status === '1') {
				this.setFormData('form', data.conditions);
				if (this.formTarget.form.isFormInit) {
					this.dialogParams.title = title;
					this.dialogParams.style = {
						width: 400,
						height: (['Accounttype', 'Password'].indexOf(type) ? 130 : 100)
					};
					this.dialogParams.visible = true;
				}
				if (this.formType === 'Password') {
					//是否开启了RSA加密
					this.openRSA = data.openRSA;
					//异步加载ras文件
					loadjs.isDefined('rsa') ? loadjs.ready('rsa', () => {

					}) : loadjs(["/js/rsa/jsencrypt.js", "/js/rsa/rsa.js"], 'rsa', {
						async: false
					});
				}
			} else {
				message.error(data.message);
			}
		}, error => { })
	}

	saveBatchDefaultPwd = () => {
		var _this = this;
		confirm({
			title: i18n.confirm.defaultTitle(),
			content: (this.defaultPasswordEnable === "0") ? getLabel(515424, '未开启初始密码，请前往账户中心的安全设置中开启。') : getLabel(515423, '确定要将选中用户的密码重置为初始密码吗？'),
			onOk () {
				if (_this.defaultPasswordEnable === "1") {//开启
					const params = {
						resourceIds: _this.table.selectedRowKeys
					};
					api.saveBatchDefaultPwd(params).then(datas => {
						const { status } = datas;
						if (status === "1") {
							message.success(datas.message);
							_this.generateTableSelectedData(this.generateTableReqParams());
						} else {
							message.warning(datas.message);
						}
					})
				} else {
					window.open("/spa/hrm/engine.html#/hrmengine/securitySetting");
				}
			},
			onCancel () {
				return false
			},
		});

	}

	passwordVerification = (val, minPassLen, passwordComplexity) => {
		let checkpass = true;
		if (val.length < minPassLen) {
			message.error(i18n.message.pwdLen() + minPassLen);
			return false;
		} else if (passwordComplexity == "1") {
			const complexity11 = /[a-z]+/;
			const complexity12 = /[A-Z]+/;
			const complexity13 = /\d+/;
			if (complexity11.test(val) && complexity12.test(val) && complexity13.test(val)) {
				checkpass = true;
			} else {
				message.error(i18n.message.pwdType());
				checkpass = false;
			}
		} else if (passwordComplexity == "2") {
			const complexity21 = /[a-zA-Z_]+/;
			const complexity22 = /\W+/;
			const complexity23 = /\d+/;
			if (complexity21.test(val) && complexity22.test(val) && complexity23.test(val)) {
				checkpass = true;
			} else {
				message.error(i18n.message.pwdType1());
				checkpass = false;
			}
		} else if (passwordComplexity == "3") {
			const complexity31 = /[a-zA-Z_]+/;
			const complexity32 = /\d+/;
			if (complexity31.test(val) && complexity32.test(val)) {
				checkpass = true;
			} else {
				message.error(i18n.message.pwdType2());
				checkpass = false;
			}
		}
		return checkpass;
	}

	//对密码进行RSA加密
	RSAEcrypt = (password) => {
		//异步加载ras文件
		loadjs.isDefined('rsa') ? loadjs.ready('rsa', () => {
			if (this.openRSA && this.openRSA == '1') {
				password = __RSAEcrypt__.rsa_data_encrypt(password);
			}
		}) : loadjs(["/js/rsa/jsencrypt.js", "/js/rsa/rsa.js"], 'rsa', {
			async: false,
			success: () => {
				if (this.openRSA && this.openRSA == '1') {
					password = __RSAEcrypt__.rsa_data_encrypt(password);
				}
			}
		});
		return password;
	}

	@action saveForm = (opera) => {
		if (this.spinning)
			return;
		if (opera == "unblock") {
			const params = {
				resourceIds: this.table.selectedRowKeys
			}
			this.spinning = true;
			api.saveForm(params, "UnlockStatus").then(data => {
				if (data.status === '1') {
					message.success(i18n.message.saveSuccess());
					this.generateTableSelectedData(this.generateTableReqParams(), false, true);
				} else {
					message.error(data.message);
				}
				this.spinning = false;
			}, error => {
				this.spinning = false;
			})
			return;
		}
		this.formTarget.form.validateForm().then(f => {
			if (f.isValid) {
				const formParams = this.formTarget.form.getFormParams();
				if (this.formType === 'Password') {
					const fields = this.formTarget.formFields;
					const otherParams = fields[0].items[0].otherParams;
					if (!this.passwordVerification(formParams.password, otherParams.minpasslen, otherParams.passwordComplexity)) {
						return;
					}
					formParams.password = this.RSAEcrypt(formParams.password);
				}

				const params = {
					...formParams,
					ids: this.table.selectedRowKeys
				}
				const save = () => {
					this.spinning = true;
					api.saveForm(params, this.formType).then(data => {
						if (data.status === '1') {
							message.success(i18n.message.saveSuccess());
							this.dialogParams.onCancel();
							this.treeRef && this.treeRef.refs.tree.fetchData();
							this.generateTableSelectedData(this.generateTableReqParams());

						} else {
							if (this.formType === 'Password')
								this.refreshVerificationCode();
							message.error(data.message);
						}
						this.spinning = false;
					}, error => {
						this.spinning = false;
					})
				}
				if (formParams.password) {
					this.isWeakPassword(formParams.password).then(() => {
						save();
					})
				} else {
					save();
				}
			} else {
				f.showErrors();
				this.showError = new Date().getTime();
			}
		})
	}

	@action definedColumnVisible = () => {
		this.definedColumn(this.table)
	}

	@action exportData = () => {
		this.table.exportAll('', this.containerType == 'department' ? getLabel('16289', '部门信息') : getLabel('32816', '分部信息'));
	}

	genReplaceDatas = (record, dataIndex) => {
		let arr = [];
		if (record[dataIndex] != '' && record[`${dataIndex}span`] != '' && record[dataIndex] != null && record[`${dataIndex}span`] != null) {
			try {
				const t1 = record[dataIndex].split(','), t2 = record[`${dataIndex}span`].split(',');
				if (t1.length == 0)
					return [];
				t1.map((id, idx) => {
					arr.push({
						id,
						name: t2[idx]
					})
				})
			} catch (e) {
			}
			return arr;
		} else
			return [];
	}

	browserRefs = {};
	setBrowserRef = (dom, record, dataIndex) => this.browserRefs[`${record.id}_${dataIndex}`] = dom;

	generateCom = (props, dataIndex, record) => {
		switch (props.conditionType.toUpperCase()) {
			case 'INPUT':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@jl6htq`} data={record[dataIndex]} children={<WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@uu83no`} {...props} {...props.otherParams} value={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} />} />
			case 'INPUTNUMBER':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@mzpp2z`} data={record[dataIndex]} children={<WeaInputNumber ecId={`${this && this.props && this.props.ecId || ''}_WeaInputNumber@avec5q`} {...props} defaultValue={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} />} />
			case 'TEXTAREA':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@qzqeoa`} data={record[dataIndex]}><WeaTextarea ecId={`${this && this.props && this.props.ecId || ''}_WeaTextarea@t5rt3i`} {...props} value={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} /></NeedRender>
			case 'BROWSER':
				const replaceDatas = this.genReplaceDatas(record, dataIndex);
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@3vza8h`} data={replaceDatas}><WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@iirl3k`} {...props.browserConditionParam} ref={dom => this.setBrowserRef(dom, record, dataIndex)} replaceDatas={replaceDatas} onChange={(value, names, datas) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex, names, datas)} /></NeedRender>
			case 'SELECT':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@qy14cp`} data={record[dataIndex]}><WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@1uplr2`} {...props} value={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} /></NeedRender>
			case 'CHECKBOX':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@tv25xc`} data={record[dataIndex]}><WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@ye9t95`} {...props} value={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} /></NeedRender>
			case 'SWITCH':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@fy5i4a`} data={record[dataIndex]}><WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@93agkb`} {...props} value={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} /></NeedRender>
			case 'UPLOAD':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@qvpju9`} data={record[dataIndex]}><WeaUpload ecId={`${this && this.props && this.props.ecId || ''}_WeaUpload@8wzwd0`} {...props} /></NeedRender>
			case 'DATEPICKER':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@760hvv`} data={record[dataIndex]}><WeaDatePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaDatePicker@23u8uz`} {...props} value={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} /></NeedRender>
			case 'TIMEPICKER':
				return <NeedRender ecId={`${this && this.props && this.props.ecId || ''}_NeedRender@ycy48k`} data={record[dataIndex]}><WeaTimePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaTimePicker@xu4crp`} {...props} value={record[dataIndex]} onChange={(value) => this.onComponentChange(props.conditionType.toUpperCase(), value, record, dataIndex)} /></NeedRender>
		}
	}

	onLinkClickHandle = id => {
		switch (this.containerType) {
			case 'subcompany':
				jumpToHrmSubCompany(id);
				break;
			case 'department':
				jumpToHrmDept(id);
				break;
		}
	}

	renderCol = (cols) => {
		cols.length > 0 && [...Object.keys(this.tableColDef)].map(key => {
			const def = this.tableColDef[key];
			let idx = -1;
			switch (key) {
				case 'id':
					if (['subcompany', 'department'].indexOf(this.containerType) > -1) {
						idx = findIndex(cols, item => item.dataIndex === key);
						if (idx != -1) {
							cols[idx].render = (text, record) => {
								return <a onClick={this.onLinkClickHandle.bind(this, record.id)} >{record[key]}</a>
							}
						}
					}
					break;
				case 'lastname':
					idx = findIndex(cols, item => item.dataIndex === key);
					if (idx != -1) {
						cols[idx].render = (text, record) => {
							return <span className={record.accounttype == 1 ? 'icon-coms-Related-account' : ''} style={{ fontSize: '14px', color: record.accounttype == 1 ? '#2DB7F5' : null }}>&nbsp;<a onClick={() => jumpToHrmCard(record.id)} >{record[key]}</a></span>
						}
					}
					break;
				default:
					idx = findIndex(cols, item => item.dataIndex === key.toLowerCase());
					if (idx != -1) {
						cols[idx].render = (text, record) => {
							return this.generateCom(def, key.toLowerCase(), record)
						}
					}
					break;
			}
		})
	}

	@action
	refreshVerificationCode = () => {
		this.verificationCode = `/weaver/weaver.file.MakeValidateCode?isView=1&validatetype=0&validatenum=4&from=_batch&seriesnum_=${new Date().getTime()}`;
	}

	@observable modalVisible = false;
	@action changeModalState = (bool) => {
		this.modalVisible = bool;
	}
	isWeakPassword = (password) => {
		return new Promise((resolve, reject) => {
			api.isWeakPassword({ password }).then(datas => {
				const { weakPasswordDisable, isWeakPassword } = datas;

				if (weakPasswordDisable === "1") {//开启弱密码开关
					if (isWeakPassword) {//当前密码为弱密码
						this.changeModalState(true);//弹出确认框
						reject();
					} else {
						resolve();//不为弱密码
					}
				} else {
					resolve();//未开启弱密码开关
				}
			}).catch(() => {
				reject();//接口异常
			})
		})
	}
	/********************* action list *********************/
}