| | |
| | | usedTemplates: res.UserTemp.map(temp => { |
| | | let _config = '' |
| | | if (temp.LongParam) { |
| | | _config = window.atob(temp.LongParam) |
| | | _config = window.decodeURIComponent(window.atob(temp.LongParam)) |
| | | try { |
| | | _config = JSON.parse(_config) |
| | | } catch (e) { |
| | |
| | | 'header.form.dateweek': '日期(周)', |
| | | 'header.form.datemonth': '日期(月)', |
| | | 'header.form.dateyear': '日期(年)', |
| | | 'header.form.daterange': '日期(区间)', |
| | | 'header.form.initval': 'Initial Value', |
| | | 'header.form.isRequired': '行设置', |
| | | 'header.form.notRequired': '不选择行', |
| | |
| | | 'header.form.dateweek': '日期(周)', |
| | | 'header.form.datemonth': '日期(月)', |
| | | 'header.form.dateyear': '日期(年)', |
| | | 'header.form.daterange': '日期(区间)', |
| | | 'header.form.initval': '初始值', |
| | | 'header.form.isRequired': '行设置', |
| | | 'header.form.notRequired': '不选择行', |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { BackTop } from 'antd' |
| | | import { BackTop, notification} from 'antd' |
| | | import Api from '@/api' |
| | | import MainSearch from './modules/mainSearch' |
| | | import MainAction from './modules/mainAction' |
| | | import MainTable from './modules/mainTable' |
| | | import MainSearch from './mainSearch' |
| | | // import MainAction from './mainAction' |
| | | // import MainTable from './mainTable' |
| | | import NotFount from '@/components/404' |
| | | import Loading from '@/components/loading' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | loadingview: true, |
| | | viewlost: false, |
| | | config: {}, |
| | | searchlist: null, |
| | | actions: null, |
| | | columns: null, |
| | |
| | | MenuID: this.props.MenuID |
| | | } |
| | | let result = await Api.getSystemConfig(param) |
| | | if (result.status) { |
| | | let newconfig = {} |
| | | if (result.searches && result.searches.length > 0) { |
| | | newconfig.searchlist = result.searches.map(search => { |
| | | search.DynOptions = search.DynOptions ? JSON.parse(search.DynOptions) : '' |
| | | return search |
| | | if (result.status && result.LongParam) { |
| | | |
| | | let config = window.decodeURIComponent(window.atob(result.LongParam)) |
| | | try { |
| | | config = JSON.parse(config) |
| | | this.setState({ |
| | | loadingview: false |
| | | }) |
| | | } catch (e) { |
| | | this.setState({ |
| | | loadingview: false, |
| | | viewlost: true |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message || '页面配置错误', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | if (result.actions && result.actions.length > 0) { |
| | | newconfig.actions = result.actions.map(action => { |
| | | return action |
| | | }) |
| | | } |
| | | if (result.columns && result.columns.length > 0) { |
| | | newconfig.columns = result.columns.map(column => { |
| | | return column |
| | | }) |
| | | newconfig.columns.length = 3 |
| | | } |
| | | newconfig.fixed = { |
| | | fixaction: true, |
| | | fixtable: true |
| | | } |
| | | newconfig.select = result.select |
| | | this.setState(newconfig) |
| | | this.setState({config}) |
| | | } else { |
| | | this.setState({ |
| | | loadingview: false, |
| | | viewlost: true |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message || '页面配置错误', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | | this.loadmaindata() |
| | | // this.loadmaindata() |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, loadingview, viewlost } = this.state |
| | | |
| | | return ( |
| | | <div className="commontable"> |
| | | {!this.state.searchlist && <Loading />} |
| | | {this.state.searchlist && |
| | | {loadingview && <Loading />} |
| | | {config.search && config.search.length > 0 ? |
| | | <MainSearch |
| | | refreshdata={this.refreshbysearch} |
| | | searchlist={this.state.searchlist} |
| | | searchlist={config.search} |
| | | dict={this.state.dict} |
| | | /> |
| | | /> : null |
| | | } |
| | | {this.state.actions && |
| | | {/* {this.state.actions && |
| | | <MainAction |
| | | MenuNo={this.props.MenuNo} |
| | | fixed={this.state.fixed.fixaction} |
| | |
| | | loading={this.state.loading} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | } */} |
| | | <BackTop> |
| | | <div className="ant-back-top"> |
| | | <div className="ant-back-top-content"> |
| | |
| | | </div> |
| | | </div> |
| | | </BackTop> |
| | | {viewlost ? <NotFount /> : null} |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | .commontable { |
| | | min-height: calc(100vh - 94px); |
| | | padding-top: 16px; |
| | | .box404 { |
| | | padding-top: 30px; |
| | | } |
| | | } |
| | | .ant-back-top { |
| | | bottom: 30px; |
File was renamed from src/tabviews/commontable/modules/mainSearch/index.jsx |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let formats = {} |
| | | let match = {} |
| | | this.props.searchlist.forEach(item => { |
| | | if (item.Type === 'date') { |
| | | // formats[item.FieldName] = dateFormat |
| | | formats[item.FieldName] = weekFormat |
| | | } else if (item.ID === 'WHE1400200905') { |
| | | formats[item.FieldName] = monthFormat |
| | | } |
| | | match[item.FieldName] = item.Op |
| | | }) |
| | | this.setState({ |
| | | formats: formats, |
| | | match: match |
| | | }) |
| | | console.log(this.props.searchlist) |
| | | // let formats = {} |
| | | // let match = {} |
| | | // this.props.searchlist.forEach(item => { |
| | | // if (item.Type === 'date') { |
| | | // // formats[item.FieldName] = dateFormat |
| | | // formats[item.FieldName] = weekFormat |
| | | // } else if (item.ID === 'WHE1400200905') { |
| | | // formats[item.FieldName] = monthFormat |
| | | // } |
| | | // match[item.FieldName] = item.Op |
| | | // }) |
| | | // this.setState({ |
| | | // formats: formats, |
| | | // match: match |
| | | // }) |
| | | } |
| | | |
| | | // shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | this.props.searchlist.forEach((item, index) => { |
| | | if (item.Type === 'text' || item.Type === 'string') { // 文本搜索 |
| | | if (item.type === 'text') { // 文本搜索 |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.Label}> |
| | | {getFieldDecorator(item.FieldName)(<Input placeholder="" autoComplete="off" />)} |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.Type === 'select') { // 下拉搜索 |
| | | } else if (item.type === 'select') { // 下拉搜索 |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.Label}> |
| | | {getFieldDecorator(item.FieldName, {initialValue: item.DynOptions[0].id })( |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval })( |
| | | <Select |
| | | showSearch |
| | | onChange={(val) => {this.selectChange(item.FieldName, val)}} |
| | | onChange={(val) => {this.selectChange(item.field, val)}} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | > |
| | | {item.DynOptions.map(option => |
| | | <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>{option.text}</Select.Option> |
| | | {item.options.map(option => |
| | | <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.Type === 'date') { // 时间搜索 |
| | | } else if (item.type === 'date') { // 时间搜索 |
| | | if (item.ID === 'WHE14002009024') { |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.Label}> |
| | | {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09-14', dateFormat) })( |
| | | <DatePicker format={dateFormat} onChange={(val) => {this.timeChange(item.FieldName, val)}} /> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: moment('2019-09-14', dateFormat) })( |
| | | <DatePicker format={dateFormat} onChange={(val) => {this.timeChange(item.field, val)}} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | } else if (item.ID === 'WHE1400200905') { |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.Label}> |
| | | {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09', monthFormat) })( |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: moment('2019-09', monthFormat) })( |
| | | <MonthPicker format={monthFormat} onChange={(val) => {this.timeChange(item.FieldName, val)}} /> |
| | | )} |
| | | </Form.Item> |
| | |
| | | import ItemTypes from './itemtypes' |
| | | import './index.scss' |
| | | |
| | | const { MonthPicker, WeekPicker } = DatePicker |
| | | const { MonthPicker, WeekPicker, RangePicker } = DatePicker |
| | | |
| | | const Card = ({ id, type, card, moveCard, findCard, editCard, copyCard, hasDrop }) => { |
| | | const originalIndex = findCard(id).index |
| | |
| | | copyCard(id) |
| | | } |
| | | |
| | | let selectval = '' |
| | | if (type === 'search' && card.type === 'select') { |
| | | if (card.initval) { |
| | | let _option = card.options.filter(option => option.Value === card.initval)[0] |
| | | if (_option) { |
| | | selectval = _option.Text || '' |
| | | } else { |
| | | selectval = '' |
| | | } |
| | | } else if (card.setAll === 'true') { |
| | | selectval = '全部' |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <div className="page-card" style={type === 'columns' ? { flex: card.Width, opacity: opacity} : { opacity: opacity}}> |
| | | <div ref={node => drag(drop(node))}> |
| | |
| | | <Input style={{marginTop: '4px'}} defaultValue={card.initval} /> : null |
| | | } |
| | | {(card.type === 'select' || card.type === 'link') ? |
| | | <Select defaultValue={card.initval}></Select> : null |
| | | <Select defaultValue={selectval}></Select> : null |
| | | } |
| | | {card.type === 'date' ? |
| | | <DatePicker defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null |
| | |
| | | {card.type === 'datemonth' ? |
| | | <MonthPicker defaultValue={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null |
| | | } |
| | | {card.type === 'datetime' ? |
| | | <DatePicker showTime defaultValue={card.initval ? moment(card.initval, 'YYYY-MM-DD HH:mm:ss') : null} /> : null |
| | | {card.type === 'daterange' ? |
| | | <RangePicker |
| | | placeholder={['开始日期', '结束日期']} |
| | | renderExtraFooter={() => 'extra footer'} |
| | | defaultValue={card.initval ? [moment().subtract(card.initval, 'days'), moment().subtract(card.initval === 1 ? 1 : 0, 'days')] : [null, null]} |
| | | /> : null |
| | | } |
| | | <div className="input-mask"></div> |
| | | </div> |
| | |
| | | <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected}> |
| | | <Radio value="text">text</Radio> |
| | | <Radio value="select">select</Radio> |
| | | <Radio value="date">date</Radio> |
| | | <Radio value="daterange">daterange</Radio> |
| | | </Radio.Group> : null |
| | | } |
| | | {type === 'columns' ? |
| | |
| | | * 2、设置操作类型、原始菜单信息(每次保存后重置)、已使用表及基本信息表单 |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { menu } = this.props |
| | | const { menu, type } = this.props |
| | | |
| | | let _LongParam = menu.LongParam |
| | | let _config = '' |
| | | if (this.props.type === 'add' || !_LongParam) { |
| | | let _type = type |
| | | |
| | | if (_type === 'add' || !_LongParam) { |
| | | _type = 'add' |
| | | _config = JSON.parse(JSON.stringify((Source.baseConfig))) |
| | | } else { |
| | | let _setting = Source.baseConfig.setting |
| | |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | operaType: this.props.type, |
| | | operaType: _type, |
| | | originMenu: JSON.parse(JSON.stringify({...menu})), |
| | | selectedTables: _config.tables || [], |
| | | menuformlist: [ |
| | |
| | | value: 'datemonth', |
| | | text: this.state.dict['header.form.datemonth'] |
| | | }, { |
| | | value: 'dateyear', |
| | | text: this.state.dict['header.form.dateyear'] |
| | | value: 'daterange', |
| | | text: this.state.dict['header.form.daterange'] |
| | | }] |
| | | }, |
| | | { |
| | |
| | | return item |
| | | } |
| | | }) |
| | | _config[res.type] = _config[res.type].filter(item => !item.origin) |
| | | // _config[res.type] = _config[res.type].filter(item => !item.origin) |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | item.match = textmatch[cell.datatype] |
| | | } else if (cell.type === 'select') { |
| | | item.match = selectmatch[cell.datatype] |
| | | } else if (cell.type === 'date') { |
| | | } else if (cell.type === 'daterange') { |
| | | item.match = datematch[cell.datatype] |
| | | } |
| | | |
| | | item.type = cell.type |
| | | item.initval = '' |
| | | items.push(item) |
| | | } |
| | |
| | | _match = textmatch[item.datatype] |
| | | } else if (item.type === 'select') { |
| | | _match = selectmatch[item.datatype] |
| | | } else if (item.type === 'date') { |
| | | } else if (item.type === 'daterange') { |
| | | _match = datematch[item.datatype] |
| | | } |
| | | |
| | |
| | | right: 0; |
| | | bottom: 0; |
| | | opacity: 0; |
| | | z-index: 2; |
| | | } |
| | | .ant-calendar-picker-input { |
| | | padding: 4px 20px 4px 5px; |
| | | font-size: 13px; |
| | | } |
| | | } |
| | | } |
| | |
| | | date: [{value: '', text: '空'}, {value: '0', text: '当天'}, {value: 1, text: '前一天'}, {value: 3, text: '前三天'}, {value: 7, text: '前七天'}, {value: 30, text: '前30天'}], |
| | | dateweek: [{value: '', text: '空'}, {value: '0', text: '本周'}, {value: 1, text: '上周'}, {value: 3, text: '前三周'}, {value: 7, text: '前七周'}], |
| | | datemonth: [{value: '', text: '空'}, {value: '0', text: '本月'}, {value: 1, text: '上月'}, {value: 3, text: '前三月'}, {value: 7, text: '前七月'}], |
| | | dateyear: [{value: '', text: '空'}, {value: '0', text: '当年'}, {value: 1, text: '去年'}, {value: 3, text: '前年'}], |
| | | daterange: [{value: '', text: '空'}, {value: '0', text: '今天'}, {value: 1, text: '昨天'}, {value: 3, text: '前三天'}, {value: 7, text: '前七天'}, {value: 30, text: '前30天'}], |
| | | } |
| | | } |
| | | |