import React from 'react'; import DragSort from '../../libs/DragSort'; import './index.scss'; const tabs = [{ name: '题目控件', }, { name: '问题大纲', }, ]; const subjects = [{ name: '单选题', type: 'radio', icon: 'icon-danxuanicon', }, // { // name: '下拉题', // type: 'dropdown', // icon: 'icon-xialaicon', // }, { name: '多选题', type: 'checkbox', icon: 'icon-duoxuan-icon', }, // { // name: '单行文本题', // type: 'text', // icon: 'icon-danhangicon', // }, { // name: '多行文本题', // type: 'textarea', // icon: 'icon-duohangicon', // }, { // name: '填空题', // type: 'input', // icon: 'icon-tiankongtiicon', // }, ]; class QuestionnairSiderbar extends React.PureComponent { state = { tabIndex: 0, curMoveItem: null, editors: [], }; componentWillReceiveProps(nextProps) { this.setState({ editors: nextProps.editors, }) } toggleTab = (index) => { this.setState({ tabIndex: index, }) } switchIcon = (type) => { switch (type) { case 'radio': return 'icon-danxuanicon'; case 'dropdown': return 'icon-xialaicon'; case 'checkbox': return 'icon-duoxuan-icon'; case 'textarea': return 'icon-duohangicon'; case 'text': return 'icon-danhangicon'; case 'input': return 'icon-tiankongtiicon'; } } handleDragMove = (editors, from, to) => { const { onDragOutline, } = this.props; if (onDragOutline) { onDragOutline(editors) } this.setState({ curMoveItem: to, editors, }) } handleDragEnd = () => { this.setState({ curMoveItem: null, }) } clickOutline = (index) => { const { onClickOutline, } = this.props; if (onClickOutline) { onClickOutline(index) } } render() { this.tabs = []; const { onSelectEditor, } = this.props; const { tabIndex, editors, curMoveItem, } = this.state; return (