import React from 'react' import * as mobx from 'mobx' import { inject, observer } from 'mobx-react' import { WeaTop, WeaFormItem, WeaTable, WeaRightMenu, WeaNewScroll, WeaSearchGroup, WeaLocaleProvider, WeaTab } from 'ecCom' import { Row, Col, Button, Modal, message, Input, Dropdown, Icon, Menu } from 'antd' import { WeaSwitch } from 'comsMobx' import { i18n } from '../../public/i18n'; import QuickSearchTableEdit from './QuickSearchTableEdit'; import QuickSearchDetail from './QuickSearchDetail'; const getLabel = WeaLocaleProvider.getLabel; const toJS = mobx.toJS; const confirm = Modal.confirm; @inject('quickSearch') @observer export default class QuickSearch extends React.Component { constructor(props) { super(props); } componentWillMount() { } componentDidMount() { const { quickSearch } = this.props; quickSearch.initList(); } componentWillUnmount() { } componentWillReceiveProps(nextProps) { const { quickSearch } = this.props; if (this.props.location.key !== nextProps.location.key) { quickSearch.initList(); } } getDropMenuDatas() { const { quickSearch } = this.props,{ rightMenu } = quickSearch let menus = []; toJS(rightMenu).map((item, index) => { let obj = { key: item.menuFun, icon: , content: item.menuName, } menus.push(obj); }) return menus; } getTopMenuBtns() { const { quickSearch } = this.props,{ topMenu } = quickSearch let btns = []; topMenu.map((item, i) => { btns.push(); }); return btns; } save = () => { const { quickSearch } = this.props; quickSearch.saveQuickSearchInfo(); } getFormItems = () => { const { quickSearch } = this.props; const { quickSearchFields, quickSearchForm } = quickSearch; const arr = []; const formParams = quickSearchForm.getFormParams(); const { isFormInit } = quickSearchForm; isFormInit && quickSearchFields.map((field, index) => { arr.push(
{}
) }) return {arr} } getSearchButton = () => { return [ (), ] } addRow = () => { // const { CubeListStore } = this.props; // let { quickSearchData } = CubeListStore; // let datas = quickSearchData.datas; // if(datas.length>=6){ // message.error(getLabel('387795',"最多只能添加6项")); // return; // } // let time = new Date().getTime(); // let type = quickSearchData.options.length > 0 ? quickSearchData.options[0].type : '2'; // let fieldid = quickSearchData.options.length > 0 ? quickSearchData.options[0].key : ''; // let customname = quickSearchData.options.length > 0 ? quickSearchData.options[0].showname : ''; // let isdetailtable = quickSearchData.options.length > 0 ? quickSearchData.options[0].isdetailtable : '0'; // let obj = { // key: "new_" + time, // fieldid: fieldid, // customname: customname, // range: type == '1' ? getLabel('387636', "内容自定义") : getLabel('387637', "字段本身值"), // condition: type == '1' ? getLabel('68', "设置") : '', // orderid: 0, // type: type, // isdetailtable: isdetailtable // } // datas = toJS(datas); // datas.push(obj); // CubeListStore.setQuickSearchData(datas); } delRow = () => { // const { CubeListStore } = this.props; // let { qcSelectedRowKeys } = CubeListStore; // if (qcSelectedRowKeys.length <= 0) { // message.error(getLabel(22346, '请选择要删除的信息', 'label')); // return; // } // const that = this; // Modal.confirm({ // title: getLabel(83601, '您确认要删除选中的记录吗?'), // onOk() { // let { datas } = CubeListStore.quickSearchData; // datas = toJS(datas); // datas = that.delFromArray(datas, qcSelectedRowKeys); // CubeListStore.qcSelectedRowKeys = []; // CubeListStore.setQuickSearchData(datas); // }, // onCancel() {}, // }); } onSelectChange = (keys, rows) => { let keyarr = []; rows.map(row => { keyarr.push(row.key); }); const { quickSearch } = this.props; quickSearch.qcSelectedRowKeys = keyarr; } onChange = (data) => { const { quickSearch } = this.props; quickSearch.setQuickSearchData(data); } render() { const { quickSearch: store } = this.props; const { qcSelectedRowKeys } = store; const rowSelection = { selectedRowKeys: qcSelectedRowKeys, onChange: this.onSelectChange, } return (
{this[key] && this[key]()}} > } iconBgcolor='#217346' loading={true} buttons={this.getTopMenuBtns()} showDropIcon={true} dropMenuDatas={this.getDropMenuDatas()} onDropMenuClick={(key) => {this[key] && this[key]()}} > {this.getFormItems()}
) } }