| | |
| | | import md5 from 'md5' |
| | | import { connect } from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Table, Typography, Icon, Col, Switch } from 'antd' |
| | | import { Table, Typography, Icon, Col, Switch, message } from 'antd' |
| | | |
| | | import { modifyTabview } from '@/store/action' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | |
| | | const { Paragraph } = Typography |
| | | const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) |
| | | |
| | | const PicRadio = { |
| | | '4:3': '75%', '3:2': '66.67%', '16:9': '56.25%', '2:1': '50%', '3:1': '33.33%', '4:1': '25%', |
| | | '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%', |
| | | '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%' |
| | | } |
| | | class BodyRow extends React.Component { |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props.data), fromJS(nextProps.data)) || !is(fromJS(this.props.className), fromJS(nextProps.className)) |
| | |
| | | try { |
| | | originVal = parseFloat(originVal) |
| | | contrastVal = parseFloat(contrastVal) |
| | | } catch { |
| | | } catch (e) { |
| | | originVal = NaN |
| | | } |
| | | |
| | |
| | | try { |
| | | originVal = parseFloat(originVal) |
| | | contrastVal = parseFloat(contrastVal) |
| | | } catch { |
| | | } catch (e) { |
| | | originVal = NaN |
| | | } |
| | | |
| | |
| | | try { |
| | | originVal = parseFloat(originVal) |
| | | contrastVal = parseFloat(contrastVal) |
| | | } catch { |
| | | } catch (e) { |
| | | originVal = NaN |
| | | } |
| | | |
| | |
| | | try { |
| | | originVal = parseFloat(originVal) |
| | | contrastVal = parseFloat(contrastVal) |
| | | } catch { |
| | | } catch (e) { |
| | | originVal = NaN |
| | | } |
| | | |
| | |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}` |
| | | } |
| | | |
| | | content = col.prefix + content + col.postfix |
| | | content = (col.prefix || '') + content + (col.postfix || '') |
| | | } |
| | | |
| | | if (col.marks) { |
| | |
| | | if (col.rowspan === 'true') { |
| | | resProps.rowSpan = record['$$' + col.field] |
| | | } |
| | | |
| | | |
| | | if (col.linkThdMenu || col.linkurl) { |
| | | content = ( |
| | | <div> |
| | | <div className="link-menu" onDoubleClick={(e) => this.triggerLink(e, col, record)}></div> |
| | | <div className="link-menu" onDoubleClick={(e) => triggerLink(e, col, record)}></div> |
| | | {content} |
| | | </div> |
| | | ) |
| | |
| | | if (isNaN(content)) { |
| | | content = '' |
| | | } |
| | | } catch { |
| | | } catch (e) { |
| | | content = '' |
| | | } |
| | | |
| | |
| | | content = md5(content) |
| | | } |
| | | |
| | | if (col.rowspan === 'true') { |
| | | resProps.rowSpan = record['$$' + col.field] |
| | | } |
| | | |
| | | if (col.linkThdMenu || col.linkurl) { |
| | | content = ( |
| | | <div> |
| | | <div className="link-menu" onDoubleClick={(e) => this.triggerLink(e, col, record)}></div> |
| | | <div className="link-menu" onDoubleClick={(e) => triggerLink(e, col, record)}></div> |
| | | {content} |
| | | </div> |
| | | ) |
| | |
| | | |
| | | let cols = 24 / (col.picSort || 1) |
| | | let paddingTop = '100%' |
| | | let scale = col.scale === 'true' |
| | | |
| | | if (col.lenWidRadio === '16:9') { |
| | | paddingTop = '56.25%' |
| | | } else if (col.lenWidRadio === '3:2') { |
| | | paddingTop = '66.67%' |
| | | } else if (col.lenWidRadio === '4:3') { |
| | | paddingTop = '75%' |
| | | if (PicRadio[col.lenWidRadio]) { |
| | | paddingTop = PicRadio[col.lenWidRadio] |
| | | } |
| | | |
| | | resProps.children = ( |
| | | <div> |
| | | {photos.map((url, i) => ( |
| | | {photos && photos.map((url, i) => ( |
| | | <Col key={i} span={cols}> |
| | | <div className="ant-mk-picture" style={{paddingTop, backgroundImage: `url('${url}')`}}></div> |
| | | <div className={'ant-mk-picture' + (scale ? ' scale' : '')} onClick={() => { |
| | | if (!scale) return |
| | | MKEmitter.emit('mkImageScale', url, photos) |
| | | }} style={{paddingTop, backgroundImage: `url('${url}')`}}></div> |
| | | </Col> |
| | | ))} |
| | | </div> |
| | |
| | | |
| | | try { |
| | | _param = window.btoa(_quary) |
| | | } catch { |
| | | } catch (e) { |
| | | _param = window.btoa(window.encodeURIComponent(_quary)) |
| | | } |
| | | |
| | |
| | | ) |
| | | } else if (col.type === 'custom') { |
| | | style.padding = '0px' |
| | | if (col.style) { |
| | | style = {...style, ...col.style} |
| | | } |
| | | |
| | | resProps.children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | |
| | | if (item.rowspan === 'true') { |
| | | rowspans.push(item.field) |
| | | } |
| | | if (_format && !Math.floor(Math.random() * radio)) { |
| | | if (item.type === 'index') { |
| | | item.field = '$Index' |
| | | item.type = 'text' |
| | | } else if (_format && !Math.floor(Math.random() * radio)) { |
| | | item.blur = true |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('mkCheckAll', this.mkCheckAll) |
| | | MKEmitter.addListener('resetTable', this.resetTable) |
| | | } |
| | | |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('mkCheckAll', this.mkCheckAll) |
| | | MKEmitter.removeListener('resetTable', this.resetTable) |
| | | } |
| | | |
| | | mkCheckAll = (menuId, checked) => { |
| | | const { MenuID, data } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | if (checked) { |
| | | this.setState({ |
| | | activeIndex: '', |
| | | selectedRowKeys: data.map((item, index) => index) |
| | | }) |
| | | |
| | | this.props.chgSelectData(data) |
| | | |
| | | MKEmitter.emit('resetSelectLine', MenuID, '', '') |
| | | MKEmitter.emit('syncBalconyData', MenuID, data, data.length > 0) |
| | | if (data.length === 0) { |
| | | message.warning('未获取到数据!') |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | activeIndex: '', |
| | | selectedRowKeys: [], |
| | | }) |
| | | |
| | | this.props.chgSelectData([]) |
| | | |
| | | MKEmitter.emit('resetSelectLine', MenuID, '', '') |
| | | MKEmitter.emit('syncBalconyData', MenuID, [], false) |
| | | } |
| | | } |
| | | |
| | | // 字段透视 |
| | | triggerLink = (e, item, record) => { |
| | | const { tabviews, MenuID } = this.props |
| | | const { tabviews } = this.props |
| | | e.stopPropagation() |
| | | |
| | | let __param = { |
| | | $searchkey: item.field, |
| | | $searchval: record[item.field] || '', |
| | | $BID: record.$$uuid |
| | | } |
| | | |
| | | if (item.linkfields && item.linkfields.length > 0) { |
| | | item.linkfields.forEach(field => { |
| | | __param[field] = record[field] || '' |
| | | }) |
| | | } |
| | | |
| | | if (item.linkThdMenu) { |
| | | let tabmenu = item.linkThdMenu |
| | | |
| | | tabmenu.param = { |
| | | searchkey: item.field, |
| | | searchval: record[item.field] || '', |
| | | BID: record.$$uuid |
| | | } |
| | | |
| | | tabmenu.param = __param |
| | | tabmenu.selected = true |
| | | |
| | | let index = 0 |
| | | let isexit = false |
| | | let tabs = tabviews.map((tab, i) => { |
| | | let tabs = tabviews.filter((tab, i) => { |
| | | tab.selected = false |
| | | |
| | | if (tab.MenuID === MenuID) { |
| | | index = i |
| | | } else if (tab.MenuID === tabmenu.MenuID) { |
| | | tab.param = tabmenu.param |
| | | tab.selected = true |
| | | isexit = true |
| | | } |
| | | |
| | | return tab |
| | | return tab.MenuID !== tabmenu.MenuID |
| | | }) |
| | | |
| | | if (!isexit) { |
| | | tabs.splice(index + 1, 0, tabmenu) |
| | | if (tabviews.length > tabs.length) { |
| | | this.props.modifyTabview(fromJS(tabs).toJS()) |
| | | } |
| | | |
| | | this.props.modifyTabview(tabs) |
| | | } else { |
| | | this.setState({}, () => { |
| | | tabs.push(tabmenu) |
| | | this.props.modifyTabview(tabs) |
| | | }) |
| | | } else if (item.linkurl) { |
| | | let src = item.linkurl |
| | | |
| | | if (item.linkurl.indexOf('paramsmain/') > -1) { |
| | | if (src.indexOf('paramsmain/') > -1) { |
| | | try { |
| | | let _url = item.linkurl.split('paramsmain/')[0] + 'paramsmain/' |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(item.linkurl.split('paramsmain/')[1]))) |
| | | let dataparam = { |
| | | searchkey: item.field, |
| | | searchval: record[item.field] || '', |
| | | BID: record.$$uuid |
| | | } |
| | | _param.UserID = sessionStorage.getItem('UserID') |
| | | _param.LoginUID = sessionStorage.getItem('LoginUID') |
| | | _param.User_Name = sessionStorage.getItem('User_Name') |
| | | _param.param = dataparam |
| | | _param.param = __param |
| | | src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param))) |
| | | } catch { |
| | | } catch (e) { |
| | | console.warn('菜单参数解析错误!') |
| | | } |
| | | } else { |
| | | let con = '?' |
| | | |
| | | if (/\?/ig.test(src)) { |
| | | con = '&' |
| | | } |
| | | |
| | | if (item.linkfields && item.linkfields.length > 0) { |
| | | item.linkfields.forEach(field => { |
| | | if (field.toLowerCase() === 'id') return |
| | | con += `${field}=${record[field] || ''}&` |
| | | }) |
| | | } |
| | | |
| | | src = src + `${con}id=${record.$$uuid}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` |
| | | } |
| | | |
| | | window.open(src) |
| | |
| | | * |
| | | */ |
| | | onSelectChange = selectedRowKeys => { |
| | | const { setting } = this.props |
| | | const { setting, MenuID, data } = this.props |
| | | |
| | | let index = '' |
| | | let _activeIndex = null |
| | |
| | | index = selectedRowKeys.slice(-1)[0] |
| | | } |
| | | |
| | | if (setting.tableType === 'checkbox') { |
| | | if (setting.tableType === 'checkbox' || setting.tableType === 'radio') { |
| | | _activeIndex = index === '' ? null : index |
| | | } |
| | | |
| | |
| | | let selects = this.props.data.filter((item, _index) => selectedRowKeys.includes(_index)) |
| | | |
| | | this.props.chgSelectData(selects) |
| | | if (setting.$hasSyncModule) { |
| | | MKEmitter.emit('syncBalconyData', MenuID, selects, data.length === selects.length) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 点击整行,触发切换, 判断是否可选,单选或多选,进行对应操作 |
| | | */ |
| | | changeRow = (record, index) => { |
| | | const { setting } = this.props |
| | | const { setting, MenuID, data } = this.props |
| | | |
| | | if (!setting.tableType || this.state.pickup) return |
| | | |
| | |
| | | if (setting.tableType === 'radio') { |
| | | newkeys = [index] |
| | | this.changedata(index) |
| | | this.setState({ selectedRowKeys: newkeys }) |
| | | this.setState({ selectedRowKeys: newkeys, activeIndex: index }) |
| | | } else { |
| | | let _index = '' |
| | | if (newkeys.includes(index)) { |
| | |
| | | let selects = this.props.data.filter((item, _index) => newkeys.includes(_index)) |
| | | |
| | | this.props.chgSelectData(selects) |
| | | |
| | | if (setting.$hasSyncModule) { |
| | | MKEmitter.emit('syncBalconyData', MenuID, selects, data.length === selects.length) |
| | | } |
| | | } |
| | | |
| | | changeTable = (pagination, filters, sorter) => { |
| | |
| | | let preItem = data[index - 1] |
| | | rowspans.forEach((cell, i) => { |
| | | if (i === 0) { |
| | | if ((item[cell] || item[cell] === 0) && preItem[cell] === item[cell]) { |
| | | if (preItem[cell] === item[cell]) { |
| | | item['$' + cell] = preItem['$' + cell] + 1 |
| | | } else { |
| | | item['$' + cell] = 1 |
| | | } |
| | | } else { |
| | | if ((item[cell] || item[cell] === 0) && preItem[cell] === item[cell]) { |
| | | if (preItem[cell] === item[cell]) { |
| | | item['$' + cell] = preItem['$' + cell] + 1 |
| | | } else { |
| | | item['$' + cell] = 1 |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div className={'normal-custom-table ' + setting.tableHeader} id={tableId}> |
| | | <div className={`normal-custom-table ${setting.tableHeader || ''} ${setting.mode || ''}`} id={tableId}> |
| | | {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && data && data.length > 0 ? |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <Table |
| | | components={components} |
| | | style={setting.style} |
| | | size={setting.size || 'middle'} |
| | | bordered={setting.bordered !== 'false'} |
| | | rowSelection={rowSelection} |