diff --git a/pc4mobx/hrmSalary/components/CustomSelect/index.js b/pc4mobx/hrmSalary/components/CustomSelect/index.js index d65fe2ba..43068096 100644 --- a/pc4mobx/hrmSalary/components/CustomSelect/index.js +++ b/pc4mobx/hrmSalary/components/CustomSelect/index.js @@ -8,72 +8,119 @@ * @description: */ import React, { Component } from "react"; -import { WeaLocaleProvider } from "ecCom"; +import { WeaCheckbox, WeaInput, WeaLocaleProvider, WeaNewScroll } from "ecCom"; import classNames from "classnames"; -import { Select } from "antd"; +import { Dropdown } from "antd"; import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; -const Option = Select.Option; class Index extends Component { constructor(props) { super(props); this.state = { - visible: false, dropdownWidth: 200, value: props.value ? props.value.split(",") : [] + visible: false, value: props.value ? props.value.split(",") : [], + keywords: "" }; - this.selectedData = {}; } - componentDidMount() { - const { dropdownWidth } = this.state; - const w = $(this.refs.customSelectMui).outerWidth(); - console.log($(this.refs.customSelectMui), w) - if (dropdownWidth < w) { - this.setState({ dropdownWidth: w }); + isAllChecked = () => { + const { options } = this.props, { value, keywords } = this.state; + let v = "0"; + if (_.uniq(value).length === options.filter(k => k.showname.indexOf(keywords) >= 0).length) v = "1"; + return v; + }; + + isChecked = (v) => { + const { value } = this.state; + return value.indexOf(v) > -1 ? "1" : "0"; + }; + onAllChange = (v) => { + const { options, onChange } = this.props, { keywords } = this.state; + let values = [], shownames = []; + if (v == 1) { + options.filter(k => k.showname.indexOf(keywords) >= 0).forEach(o => { + values.push(o.key); + shownames.push(o.showname); + }); } - } + this.setState({ value: values }); + onChange && onChange(values.join(","), shownames.join(",")); + }; - handleChange = (value) => { - this.setState({ value }); - typeof this.props.onChange == "function" && - this.props.onChange(`${value}`); + onItemChange = (v, id) => { + const { onChange, options } = this.props, { value } = this.state; + let values = !_.isEmpty(value) ? value : [], shownames = []; + if (v == "1") { + values.push(id); + } else { + values = values.filter(val => val !== id); + } + values.forEach(val => { + let target = options.filter((data) => data.key == val)[0]; + if (target) shownames.push(target.showname); + }); + this.setState({ value: values }); + onChange && onChange(values.join(","), shownames.join(",")); + }; + + getList = () => { + const { options } = this.props, { keywords } = this.state; + let style = {}; + if (options.length > 5) style = { height: 200 }; + return