import {
	observable,
	action,
	computed,
	toJS
} from 'mobx';
import {
	WeaDropdown,
	WeaLocaleProvider,
} from 'ecCom';
import {
	WeaForm,
	WeaTableNew
} from 'comsMobx';
import {
	message,
	Button,
	Modal,
} from 'antd';
import * as api from '../apis/post';
const {
	TableStore
} = WeaTableNew;
const getLabel = WeaLocaleProvider.getLabel;
const confirm = Modal.confirm;
const {
	ButtonSelect
} = WeaDropdown;

export class HrmNewPost {
	@computed get POSTSYSTEM () {
		return getLabel(82664, '岗位体系');
	}

	@observable dataUrl = '/api/hrm/job/getJobTree';

	@computed get tree () {
		return {
			dataUrl: `${this.dataUrl}?showCanceled=${this.isShowCanceled ? "1" : "0"}`,
			rootKey: 'rootManager',
			inputLeftDom: `<span title='${this.POSTSYSTEM}'>${this.POSTSYSTEM}</span>`,
			treeNodeClick: (event, ids, nodeids, nodes) => this.handleOrgTreeNodeClick(ids[0], nodes[0])
		}
	}

	@observable orgTree = {
		id: 0,
		type: 'all',
	}

	@observable date = new Date();

	@action handleOrgTreeNodeClick = (id, node) => {
		const {
			type,
		} = node;

		Object.assign(this.orgTree, {
			id,
			type,
		});

		this.handleTabClick('0');
		this.getSearchForm();
		this.setShowSearchAd(false);
		this.getRightMenu();
		if (type !== 'all') {
			this.getBriefInfo()
		}
	}

	@action forceRefresh = () => {
		this.date = new Date();
	}

	top = {
		showDropIcon: true,
		iconBgcolor: '#217346',
		icon: <i className='icon-coms-hrm' />,
	}

	@observable tConf = [];
	@observable rConf = [];

	@action getRightMenu = () => {
		const {
			type,
			id
		} = this.orgTree;

		api.getHasRight({
			id,
			type,
			tab: this.selectedKey,
		}).then(data => {
			const {
				btnMenu
			} = data;

			const {
				tConf,
				rConf
			} = this.filter(btnMenu);

			this.tConf = tConf;
			this.rConf = rConf;
		}, error => {
			message.warning();
		})
	}

	filter = (datas) => {
		let tConf, rConf;
		tConf = datas.filter(item => {
			var bool = false;
			['isTop', 'isBatch'].forEach(prop => {
				const b = parseInt(item[prop]);
				if (b) {
					bool = true
				}
			});

			return bool
		})

		rConf = datas;

		return {
			tConf,
			rConf
		}
	}

	@observable bs_selectedKey = "batchCancel";

	@observable isShowCanceled = false;

	@computed get topButtons () {
		const {
			loading,
			selectedRowKeys
		} = this.tableStore;

		const bs = ["batchDelete", "batchCancel", "batchDoIsCanceled"];

		//批量删除、批量封存、批量解封按钮同时存在
		const isBoth = bs.every(v => this.tConf.find(data => data.menuFun == v));

		let arr = this.tConf,
			bs_arr = [];

		if (isBoth) {
			arr = this.tConf.filter(o => !bs.includes(o.menuFun));
			bs_arr = this.tConf.filter(o => bs.includes(o.menuFun));
		}

		const btns = arr.map((item, index) => {
			const {
				menuFun,
				menuName,
				type
			} = item;

			let disabled;
			if (type === 'BTN_BatchDelete') {
				disabled = (selectedRowKeys.length === 0)
			} else {
				disabled = loading
			}

			return (
				<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vajzul@${index}`}
					type="primary"
					disabled={disabled}
					onClick={() => this[menuFun]()}
				>
					{menuName}
				</Button>
			)
		});

		const datas = this.transToBsDatas(bs_arr);

		if (datas.length) {
			btns.push(<ButtonSelect ecId={`${this && this.props && this.props.ecId || ''}_ButtonSelect@uyod1n`}
				selectedKey={this.bs_selectedKey}
				datas={datas}
				btnProps={{ disabled: selectedRowKeys.length == 0 }}
				btnOnClick={key => this.handleBtnSelectClick(key)}
				menuOnClick={key => this.handleMenuOnClick(key)}
			/>);
		}

		const { type } = this.orgTree;

		if ((type == "JobActivity" && this.selectedKey == "1") || type == "JobTitle") {
			btns.push((
				this.isShowCanceled ?
					<i className="icon-coms-Department-number showCanceled" title={getLabel(522000, "隐藏封存岗位")} onClick={this.toggleIcon} /> :
					<i className="icon-coms-Department-number-hide hideCanceled" title={getLabel(522001, "显示所有岗位")} onClick={this.toggleIcon} />
			));
		}

		return btns;
	}

	handleBtnSelectClick = (key) => {
		this.batchType = key;

		this[key] && this[key]();
	}

	//封存
	doCancel = () => {
		this.showConfirm().then(() => {
			this.batchType = "batchCancel";
			this.doUndo(this.orgTree.id);
		})
	}

	//解封
	doISCanceled = () => {
		this.batchType = "batchDoIsCanceled";
		this.doUndo(this.orgTree.id);
	}

	handleMenuOnClick = (key) => {
		this.bs_selectedKey = key;
		this.getTable();
	}

	batchCancel = () => {
		const msg = getLabel(522002, "确定要封存选中的记录吗？");
		this.showConfirm(msg).then(() => {
			this.batchType = "batchCancel";
			this.doUndo();
		})

	}

	batchDoIsCanceled = () => {
		this.batchType = "batchDoIsCanceled";
		this.doUndo();
	}

	batchExport = () => {
		this.tableStore.exportAll("", "全部岗位")
	}

	//转换成ButtonSelect所需的数据
	transToBsDatas = (arr) => {
		return arr.map(data => {
			const { menuFun, menuName } = data;
			return {
				key: menuFun,
				show: menuName
			}
		});
	}

	//切换显示封存和不显示封存图标
	toggleIcon = () => {
		this.isShowCanceled = !this.isShowCanceled;
		setTimeout(this.forceRefresh, 2000)
		this.getTable();
	}

	//封存、解封、批量封存和批量解封的接口
	doUndo = (id, index) => {
		const {
			selectedRowKeys
		} = this.tableStore;

		if (index != void 0) {
			this.batchType = (index == "3") ? "batchCancel" : "batchDoIsCanceled";
		}

		api.doCanceled({
			ids: id ? id : selectedRowKeys.toString(),
			canceled: (this.batchType == "batchCancel") ? "canceled" : "docanceled"
		}).then(res => {
			const { sign } = res;

			if (sign == "1") {
				message.success(res.message);
				if (this.orgTree.type != "JobTitle") {
					this.getTable();
				} else {
					this.getBriefInfo();
					this.getRightMenu();
				}
				this.forceRefresh();
			} else {
				message.error(res.message);
			}
		})
	}

	showConfirm = (msg = getLabel(522003, "确定要封存吗？")) => {
		return new Promise((resolve, reject) => {
			confirm({
				title: getLabel('131329', '信息确认'),
				content: msg,
				okText: getLabel('33703', '确定'),
				cancelText: getLabel('32694', '取消'),
				onOk () {
					resolve();
				},
				onCancel () {
					return false;
				},
			});
		})
	}

	@computed get dropMenuDatas () {
		const {
			loading,
			selectedRowKeys
		} = this.tableStore;

		return this.rConf.map((item, index) => {
			const {
				menuFun,
				menuName,
				menuIcon,
				type,
			} = item;

			let disabled;
			if (["batchDelete", "batchCancel", "batchDoIsCanceled"].includes(menuFun)) {
				if (menuFun == this.bs_selectedKey) {
					disabled = selectedRowKeys.length === 0;
				} else {
					disabled = true;
				}
			} else {
				disabled = loading
			}

			return {
				key: index.toString(),
				disabled: disabled,
				icon: <i className={`${menuIcon}`} />,
				content: menuName,
				onClick: () => this[menuFun]()
			}
		});
	}

	newJobGroup = () => {
		this.dialog.visible = true;
		this.dialog.title = getLabel(386212, '新建职务类别');
		this.getDialogForm('getJobGroupForm');
		this.dialogType = '1';
	}

	newJob = () => {
		this.dialog.visible = true;
		this.dialog.title = getLabel(386213, '新建职务');
		const type = this.orgTree.type;
		const params = (type === "JobActivity") ? {
			type: type,
			id: this.orgTree.id
		} : {
				jobgroupid: this.orgTree.id,
			}
		this.getDialogForm('getJobForm', params);
		this.dialogType = '2';
	}

	newPost = () => {
		this.isEdit = false;
		this.dialog.visible = true;
		this.dialog.title = getLabel(125302, '新建岗位');
		const type = this.orgTree.type;
		const params = (type === "JobActivity") ? {
			jobactivityid: this.orgTree.id
		} : {
				type: type,
				id: this.orgTree.id
			}
		this.getDialogForm('getPostForm', params);
		this.dialogType = '3';
	}

	batchDelete = () => {
		const {
			type
		} = this.orgTree;

		let apiName;
		if (type === 'all') {
			apiName = 'deleteJobGroup';
		}
		if (type === 'JobGroup') {
			apiName = 'deleteJob';
		}
		if (type === 'JobActivity') {
			apiName = 'deletePost';
		}

		let _this = this;
		confirm({
			title: getLabel('131329', '信息确认'),
			content: getLabel('385625', '确定要删除选择的记录吗？'),
			okText: getLabel('33703', '确定'),
			cancelText: getLabel('32694', '取消'),
			onOk () {
				api[apiName]({
					ids: _this.tableStore.selectedRowKeys.toString()
				}).then(data => {
					const {
						sign
					} = data;

					message[(sign === '1') ? 'success' : 'warning'](data.message);

					if (sign === '1') {
						_this.getTable();
					}
				});
			},
			onCancel () {
				return false;
			},
		});
	}

	jobSystemImport = () => {
		const {
			setTempletName,
			setImportDialogTitle,
			setImportType,
			setImportDialogVisible,
			setSourceStore,
		} = this.importStore;

		setTempletName(getLabel(129833, '导入模板'));
		setImportDialogTitle(getLabel(125443, '岗位体系导入'));
		setImportType('jobtitle');
		setImportDialogVisible(true);
		setSourceStore(this.postStore);
	}

	@observable isTreeShow = true;

	moveToWholePost = () => {
		this.isTreeShow = false;
		this.orgTree.type = 'JobActivity';
		this.orgTree.id = '';
		this.selectedKey = '1';
		this.getTable();
		this.getRightMenu();
	}

	log = () => {
		const {
			type,
			id,
		} = this.orgTree;

		window.setLogViewProps({
			logSmallType: (type == 'all') ? '3012' : (type == 'JobGroup') ? '3013' : '3014',
			targetId: (type == "JobTitle") ? id : ""
		});
	}

	custom = () => {
		this.tableStore.setColSetVisible(true);
		this.tableStore.tableColSet(true);
	}

	@computed get topLoading () {
		return this.tableStore.loading;
	}

	@computed get breadcrumb () {
		const {
			type,
			id,
			pid,
		} = this.orgTree;

		if (!this.isTreeShow) {
			return [{
				name: getLabel(382806, '职务岗位设置'),
				onClick: () => {
					this.handleOrgTreeNodeClick(0, {
						type: 'all',
					});
					this.isTreeShow = true;
				}
			}, {
				name: getLabel(522004, '全部岗位'),
			}]
		}

		let breadcrumb;
		if (type === 'all') {
			breadcrumb = [{
				name: getLabel(382806, '职务岗位设置')
			}];
		} else if (type === 'JobGroup') {
			breadcrumb = [{
				name: getLabel(382806, '职务岗位设置'),
				onClick: () => {
					this.handleOrgTreeNodeClick(0, {
						type: 'all',
					});
					this.forceRefresh()
				}
			}, {
				name: this.postAbbr,
			}];
		} else {
			breadcrumb = [{
				name: this.upperLevelType,
				onClick: () => {
					this.handleOrgTreeNodeClick(this.parentNodeId, {
						type: (this.orgTree.type === 'JobActivity') ? 'JobGroup' : 'JobActivity',
					});
					this.forceRefresh()
				}
			}, {
				name: <span dangerouslySetInnerHTML={{ __html: this.postAbbr }}></span>,
			}];
		}
		return breadcrumb;
	}

	@observable tableStore = new TableStore();
	@observable editId = '';

	@action getTable = () => {
		let func, params = this.search.form.getFormParams();

		const {
			type,
			id,
		} = this.orgTree;

		if (type === 'all') {
			func = 'getJobGroupList';
		} else if (type === 'JobGroup') {
			func = 'getJobActivityList';
			Object.assign(params, {
				jobgroupid: id
			});
		} else {
			func = 'getJobTitleList';
			const sk = this.bs_selectedKey;

			Object.assign(params, {
				jobactivityid: id,
				batchOperateType: (sk == "batchCancel") ? "doCanceled" : (sk == "batchDoIsCanceled") ? "doISCanceled" : "doDel",
				showCanceled: this.isShowCanceled ? "1" : "0"
			});

		}

		api[func](params).then(data => {
			const {
				sessionkey
			} = data;
			this.tableStore = new TableStore();
			this.tableStore.getDatas(sessionkey, 1);
		}, error => {
			message.warning();
		})
	}

	onTableTdClick = (randomFieldId) => {
		const index = this.types.findIndex(type => type === this.orgTree.type);
		this.handleOrgTreeNodeClick(randomFieldId, {
			type: this.types[index + 1]
		});
		this.isTreeShow = true;
	}

	edit = (randomFieldId) => {
		const {
			type
		} = this.orgTree;

		this.isEdit = true;

		const id = randomFieldId ? randomFieldId : this.orgTree.id;

		this.editId = id;

		this.dialog.visible = true;

		let apiName, params, title, dialogType;
		if (type === 'all' || (type === 'JobGroup' && this.selectedKey === '0')) {
			apiName = 'getJobGroupForm';
			params = {
				jobgroupid: id
			};
			title = getLabel(386214, '编辑职务类别');
			dialogType = '4';
		}
		if ((type === 'JobGroup' && this.selectedKey === '1') || (type === 'JobActivity' && this.selectedKey === '0')) {
			apiName = 'getJobForm';
			params = {
				jobactivityid: id
			};
			title = getLabel(386215, '编辑职务');
			dialogType = '5';
		}
		if ((type === 'JobActivity' && this.selectedKey === '1') || type === 'JobTitle') {
			apiName = 'getPostForm';
			params = {
				jobtitleid: id
			};
			title = getLabel(386216, '编辑岗位');
			dialogType = '6';
		}
		this.dialog.title = title;
		this.dialogType = dialogType;
		this.getDialogForm(apiName, params);
	}

	delete = () => {
		const {
			type
		} = this.orgTree;

		let apiName;
		if (type === 'JobGroup') {
			apiName = 'deleteJobGroup';
		}
		if (type === 'JobActivity') {
			apiName = 'deleteJob';
		}
		if (type === 'JobTitle') {
			apiName = 'deletePost';
		}

		let _this = this;
		confirm({
			title: getLabel('131329', '信息确认'),
			content: getLabel('83877', '确定要删除吗？'),
			okText: getLabel('33703', '确定'),
			cancelText: getLabel('32694', '取消'),
			onOk () {
				api[apiName]({
					ids: _this.orgTree.id,
				}).then(data => {
					const {
						sign
					} = data;

					message[(sign === '1') ? 'success' : 'warning'](data.message);

					let type;
					if (_this.orgTree.type === 'JobTitle') {
						type = 'JobActivity';
					}
					if (_this.orgTree.type === 'JobActivity') {
						type = 'JobGroup'
					}
					if (_this.orgTree.type === 'JobGroup') {
						type = 'all'
					}
					if (sign === '1') {
						_this.handleOrgTreeNodeClick(_this.parentNodeId, {
							type
						});
						_this.forceRefresh();
					}
				});
			},
			onCancel () {
				return false;
			},
		});
	}

	del = (id) => {
		const {
			type
		} = this.orgTree;

		let apiName;
		if (type === 'all') {
			apiName = 'deleteJobGroup';
		}
		if (type === 'JobGroup') {
			apiName = 'deleteJob';
		}
		if (type === 'JobActivity') {
			apiName = 'deletePost';
		}

		let _this = this;
		confirm({
			title: getLabel('131329', '信息确认'),
			content: getLabel('83877', '确定要删除吗？'),
			okText: getLabel('33703', '确定'),
			cancelText: getLabel('32694', '取消'),
			onOk () {
				api[apiName]({
					ids: id
				}).then(data => {
					const {
						sign
					} = data;

					message[(sign === '1') ? 'success' : 'warning'](data.message);

					if (sign === '1') {
						_this.getTable();
					}
				});
			},
			onCancel () {
				return false;
			},
		});
	}

	buttonsAds = [getLabel(82529, '搜索'), getLabel(27088, '重置'), getLabel(32694, '取消')];

	tab = {
		keyParam: 'key',
		advanceHeight: 120,
		hasMask: false,
		onChange: key => this.handleTabClick(key),
		setShowSearchAd: bool => this.setShowSearchAd(bool),
		onSearch: () => this.onSearch(),
		onSearchChange: val => this.onSearchChange(val),
		buttonsAd: this.buttonsAds.map((name, index) => {
			const type = (index === 0) && "primary";
			let callback;
			if (index === 0) {
				callback = this.onSearch;
			} else if (index === 1) {
				callback = () => this.search.form.resetForm();
			} else {
				callback = this.setShowSearchAd
			}
			return <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@wngcs0@${index}`} type={type} onClick={() => callback(index === 2 && false)}>{name}</Button>
		})
	}

	@computed get searchType () {
		const {
			type
		} = this.orgTree;

		if (type === 'all' || this.selectedKey === '1') {
			return ['base', 'advanced'];
		} else {
			return [];
		}
	}

	@observable selectedKey = '0';

	@computed get tabDatas () {
		const {
			type
		} = this.orgTree;

		if (!this.isTreeShow) {
			return [];
		}

		let datas;
		if (type === 'JobGroup') {
			datas = [{
				key: '0',
				title: getLabel(32655, '类别信息')
			}, {
				key: '1',
				title: getLabel(386217, '下级职务')
			}];
		} else if (type === 'JobActivity') {
			datas = [{
				key: '0',
				title: getLabel(383211, '职务信息')
			}, {
				key: '1',
				title: getLabel(386218, '下级岗位')
			}];
		}

		return datas;
	}

	@action handleTabClick = (key) => {
		this.selectedKey = key;
		this.getTable();
		this.getRightMenu();
	}

	@observable search = {
		condition: [],
		form: new WeaForm(),
	}

	@observable showSearchAd = false;

	types = ['all', 'JobGroup', 'JobActivity', 'JobTitle'];

	@action getSearchForm = () => {
		const index = this.types.findIndex(type => type === this.orgTree.type);
		api.getSearchCondition({
			type: this.types[index + 1]
		}).then(data => {
			const {
				condition
			} = data;
			this.search.form = new WeaForm();
			this.search.form.setCondition(condition);
		});
	}

	@computed get searchsBaseValue () {
		const {
			type
		} = this.orgTree, {
			form
		} = this.search;

		const {
			jobgroupmark,
			jobactivitymark,
			jobtitlemark
		} = form.getFormParams();

		let val;
		if (type === 'all') {
			val = jobgroupmark
		} else if (type == 'JobGroup') {
			val = jobactivitymark
		} else {
			val = jobtitlemark;
		}

		return val;
	}

	@action setShowSearchAd = (bool) => {
		this.showSearchAd = bool;
	}

	@action onSearch = () => {
		this.getTable();
		this.setShowSearchAd(false);
	}

	@action onSearchChange = (value) => {
		const {
			type
		} = this.orgTree, {
			form
		} = this.search;

		if (type === 'all') {
			form.updateFields({
				jobgroupmark: {
					value
				}
			});
		} else if (type == 'JobGroup') {
			form.updateFields({
				jobactivitymark: {
					value
				}
			});
		} else {
			form.updateFields({
				jobtitlemark: {
					value
				}
			});
		}
	}

	parentNodeId = 0;
	@observable briefInfo = [];
	@observable postAbbr = '';
	@observable upperLevelType = '';

	@action getBriefInfo = () => {
		let params;
		const {
			type,
			id
		} = this.orgTree;
		if (type === 'JobGroup') {
			params = {
				jobGroupid: id
			}
		}
		if (type === 'JobActivity') {
			params = {
				jobActivityid: id
			}
		}
		if (type === 'JobTitle') {
			params = {
				jobTitleid: id
			}
		}
		api.getJobDetail(params).then(data => {
			const {
				datas,
				superNodeId,
			} = data;

			this.parentNodeId = superNodeId;

			this.briefInfo = datas;
			this.postAbbr = datas[0].value;
			if (datas.length > 2) {
				if (type == 'JobTitle') {
					this.upperLevelType = datas[3].value;
				} else {
					this.upperLevelType = datas[2].value;
				}
			}
		});
	}

	dialogCommon = {
		hasScroll: true,
		icon: 'icon-coms-hrm',
		iconBgcolor: '#217346',
		onCancel: () => {
			this.dialog.visible = false
		},
		moreBtn: {
			datas: []
		},
		buttons: [<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@s108a7`} type='primary' onClick={() => this.save()}>{getLabel(30986, '保存')}</Button>]
	}

	@computed get dialogStyle () {
		let style;
		if (['1', '4'].includes(this.dialogType)) {
			style = {
				width: 600,
				height: 135
			}
		}
		if (['2', '5'].includes(this.dialogType)) {
			style = {
				width: 600,
				height: 160
			}
		}
		if (['3', '6'].includes(this.dialogType)) {
			style = {
				width: 600,
				height: 400
			}
		}
		return style;
	}

	@observable dialog = {
		visible: false,
		title: '',
		loading: false,
		form: new WeaForm(),
		date: new Date(),
	}

	@observable dialogType = '';

	@action getDialogForm = (apiName, params = {}) => {
		this.dialog.loading = true;
		api[apiName](params).then(data => {
			const {
				condition
			} = data;

			condition.map(c => {
				c.items.map(item => {
					const {
						conditionType,
						domkey
					} = item;

					if (conditionType === 'BROWSER') {
						if (['jobgroupid', 'jobactivityid'].includes(domkey[0])) {
							item.browserConditionParam.hasAddBtn = false;
						}
					}
				});
			});


			this.dialog.form = new WeaForm();
			this.dialog.form.setCondition(condition);
			this.dialog.loading = false;
		});
	}

	@action save = () => {
		const {
			form
		} = this.dialog;
		form.validateForm().then(f => {
			if (f.isValid) {
				let apiName, params = form.getFormParams();
				switch (this.dialogType) {
					case '1':
						apiName = 'addJobGroup';
						break;
					case '2':
						apiName = 'addJob';
						break;
					case '3':
						apiName = 'addPost';
						break;
					case '4':
						apiName = 'editJobGroup';
						break;
					case '5':
						apiName = 'editJob';
						break;
					case '6':
						apiName = 'editPost';
						break;
				}
				if (['4', '5', '6'].includes(this.dialogType)) {
					Object.assign(params, {
						id: this.editId
					});
				}
				api[apiName](params).then(data => {
					const {
						sign
					} = data;

					message[sign === '1' ? 'success' : 'warning'](data.message);

					if (sign === '1') {
						this.dialog.visible = false;
						if (this.selectedKey === '0' && this.orgTree.type !== 'all') {
							['getBriefInfo', 'forceRefresh'].forEach(f => this[f]())
						} else {
							this.getTable()
						}
					}
				});
			} else {
				f.showErrors();
				this.dialog.date = new Date();
			}
		});

	}

	importStore = null;

	postStore = null;

	exportStore = (importStore, postStore) => {
		this.importStore = importStore;
		this.postStore = postStore;
	}

	@action refresh = () => {
		this.search.form.resetForm();
		this.searchData = []
		this.asyncTreeSpin = true;
		this.isTreeShow = true;
		this.forceRefresh();
		this.handleOrgTreeNodeClick(0, {
			type: 'all',
		});
		this.bs_selectedKey = "batchCancel";
		this.isShowCanceled = false;
	}
	@observable asyncTreeData = {};
	@observable asyncTreeSpin = true;
	@action asyncTreeInit = (params) => {
		this.asyncTreeData = []
		api.getJobTree(params).then(action(data => {
			this.asyncTreeData = toJS(data.datas.rootManager);
			this.asyncTreeSpin = false;
		}))
	}
	@observable asyncTreeSubData = {};
	@observable searchvalue = ''
	@action getSubData = (params) => {
		api.getJobTree(params).then(action(data => {
			this.asyncTreeSubData = data.datas
		}))
	}
	@observable searchData = [];
	@observable searchFlag = 0;
	@action onSearchHandleMobx = (value) => {
		if (value == "") {
			this.searchFlag = 0;
			this.searchvalue = ''
			this.asyncTreeSpin = false;
		} else {
			this.searchFlag = 1;
			const params = { keyword: value }
			api.getJobTree(params).then(data => {
				this.searchData = [data.datas.rootManager]
				this.asyncTreeSpin = false;
			})
			this.searchvalue = value;
		}

	}

}