| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | import { Table, Popover, Modal, message, notification } from 'antd' |
| | | import { PlusOutlined, PlusSquareOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined, InfoOutlined } from '@ant-design/icons' |
| | | import { PlusOutlined, PlusSquareOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncIconComponent from '@/utils/asyncIconComponent' |
| | |
| | | }) |
| | | } |
| | | |
| | | copyFields = () => { |
| | | const { config } = this.props |
| | | let m = [] |
| | | let n = [] |
| | | // copyFields = () => { |
| | | // const { config } = this.props |
| | | // let m = [] |
| | | // let n = [] |
| | | |
| | | config.columns.forEach(col => { |
| | | m.push(`${col.field} ${col.datatype}`) |
| | | n.push(col.field) |
| | | }) |
| | | // config.columns.forEach(col => { |
| | | // m.push(`${col.field} ${col.datatype}`) |
| | | // n.push(col.field) |
| | | // }) |
| | | |
| | | let oInput = document.createElement('input') |
| | | oInput.value = `/*${m.join(',')}*/ |
| | | ${n.join(',')}` |
| | | document.body.appendChild(oInput) |
| | | oInput.select() |
| | | document.execCommand('Copy') |
| | | document.body.removeChild(oInput) |
| | | // let oInput = document.createElement('input') |
| | | // oInput.value = `/*${m.join(',')}*/ |
| | | // ${n.join(',')}` |
| | | // document.body.appendChild(oInput) |
| | | // oInput.select() |
| | | // document.execCommand('Copy') |
| | | // document.body.removeChild(oInput) |
| | | |
| | | message.success('复制成功。') |
| | | } |
| | | // message.success('复制成功。') |
| | | // } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('plusColumns', this.plusColumns) |
| | |
| | | <FieldsComponent config={config} type="columns" /> |
| | | <CopyOutlined title="复制显示列" onClick={this.copycolumn} /> |
| | | <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} /> |
| | | <InfoOutlined title="复制字段" style={{color: 'orange'}} onClick={this.copyFields}/> |
| | | {/* <InfoOutlined title="复制字段" style={{color: 'orange'}} onClick={this.copyFields}/> */} |
| | | </div> |
| | | <DndProvider> |
| | | {groups ? groups.map((group, i) => { |
| | |
| | | config.cols.forEach(col => { |
| | | if (!col.field) return |
| | | if (['text', 'picture', 'video', 'textarea'].includes(col.type)) { |
| | | let datatype = `Nvarchar(${col.fieldlength || 50})` |
| | | let type = 'text' |
| | | |
| | | if (col.type === 'text') { |
| | | if (col.textFormat === 'YYYY-MM-DD') { |
| | | datatype = 'date' |
| | | } else if (col.textFormat === 'YYYY-MM-DD HH:mm:ss') { |
| | | datatype = 'datetime' |
| | | } |
| | | } |
| | | |
| | | config.columns.push({ |
| | | datatype: `Nvarchar(${col.fieldlength || 50})`, |
| | | datatype: datatype, |
| | | field: col.field, |
| | | fieldlength: col.fieldlength || 50, |
| | | label: col.label, |
| | | type: 'text', |
| | | type: type, |
| | | uuid: col.uuid |
| | | }) |
| | | } else if (col.type === 'link') { |
| | |
| | | columns.reverse() |
| | | subColumns.reverse() |
| | | |
| | | columns.forEach(col => { |
| | | if (!col.datatype) return |
| | | if (/^nvarchar/.test(col.datatype)) { |
| | | col.datatype = col.datatype.replace(/^nvarchar/, 'Nvarchar') |
| | | } else if (/^decimal/.test(col.datatype)) { |
| | | col.datatype = col.datatype.replace(/^decimal/, 'Decimal') |
| | | } else if (/^int/.test(col.datatype)) { |
| | | col.datatype = col.datatype.replace(/^int/, 'Int') |
| | | } |
| | | }) |
| | | subColumns.forEach(col => { |
| | | if (!col.datatype) return |
| | | if (/^nvarchar/.test(col.datatype)) { |
| | | col.datatype = col.datatype.replace(/^nvarchar/, 'Nvarchar') |
| | | } else if (/^decimal/.test(col.datatype)) { |
| | | col.datatype = col.datatype.replace(/^decimal/, 'Decimal') |
| | | } else if (/^int/.test(col.datatype)) { |
| | | col.datatype = col.datatype.replace(/^int/, 'Int') |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | scripts, |
| | | columns: columns, |
| | |
| | | const { columns } = this.state |
| | | let m = [] |
| | | let n = [] |
| | | let s = [] |
| | | |
| | | columns.forEach(col => { |
| | | m.push(`${col.field} ${col.datatype}`) |
| | | n.push(col.field) |
| | | m.unshift(`${col.field} ${col.datatype}`) |
| | | n.unshift(col.field) |
| | | if (/decimal|int/ig.test(col.datatype)) { |
| | | s.unshift(`${Math.round(Math.random() * 10)} as ${col.field}`) |
| | | } else if (/datetime/.test(col.datatype)) { |
| | | s.unshift(`'${moment().format('YYYY-MM-DD HH:mm:ss')}' as ${col.field}`) |
| | | } else if (/date/.test(col.datatype)) { |
| | | s.unshift(`'${moment().format('YYYY-MM-DD')}' as ${col.field}`) |
| | | } else { |
| | | s.unshift(`'${col.label}' as ${col.field}`) |
| | | } |
| | | }) |
| | | |
| | | if (window.debugger) { |
| | | console.info('select ' + s.join(', ')) |
| | | } |
| | | |
| | | let oInput = document.createElement('input') |
| | | oInput.value = `/*${m.join(',')}*/ |
| | |
| | | updatefield={this.updatefields} |
| | | /> |
| | | <EditTable actions={['edit', 'move', 'copy', 'del', 'clear']} searchKey={searchKey} type="datasourcefield" wrappedComponentRef={(inst) => this.datasource = inst} data={columns} columns={colColumns} onChange={(columns) => this.setState({columns})}/> |
| | | </TabPane> : null} |
| | | </TabPane> : <TabPane tab={ |
| | | <span> |
| | | 字段集 |
| | | {columns.length ? <span className="count-tip">{columns.length}</span> : null} |
| | | </span> |
| | | } key="columns"> |
| | | <div className="base-table-columns"></div> |
| | | <EditTable actions={[]} searchKey={searchKey} type="datasourcefield" data={columns} columns={colColumns}/> |
| | | </TabPane>} |
| | | {config.subtype === 'dualdatacard' ? <TabPane tab={ |
| | | <span> |
| | | 子表字段集 |
| | |
| | | top: 220px; |
| | | z-index: 1; |
| | | } |
| | | .base-table-columns { |
| | | height: 15px; |
| | | } |
| | | .base-table-columns + .modal-edit-table { |
| | | .editable-row > td:last-child { |
| | | padding: 14px 10px; |
| | | } |
| | | } |
| | | .data-source-card-box { |
| | | .ant-tabs-nav-scroll { |
| | | text-align: center; |
| | |
| | | } |
| | | |
| | | columns.forEach(col => { |
| | | if (col.field === 'works_flow_param') return |
| | | |
| | | if (col.type === 'colspan' || col.type === 'old_colspan') { |
| | | col.subcols.forEach(cell => { |
| | | setField(cell) |
| | |
| | | field: 'initval', |
| | | label: '初始值', |
| | | initval: wrap.initval || '', |
| | | tooltip: '可使用@username@、@fullName@', |
| | | required: false |
| | | }, |
| | | { |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {type === 'search' ? <Col span={12}> |
| | | <Form.Item label="初始值"> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="可使用@username@、@fullName@。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 初始值 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('initval', { |
| | | initialValue: config.setting.initval, |
| | | rules: [ |
| | |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props.data), fromJS(nextProps.data)) || (nextProps.syncData && !is(fromJS(this.props.syncData), fromJS(nextProps.syncData))) |
| | | return !is(fromJS(this.props.data), fromJS(nextProps.data)) || (nextProps.syncData ? !is(fromJS(this.props.syncData), fromJS(nextProps.syncData)) : false) |
| | | } |
| | | |
| | | /** |
| | |
| | | _orderBy = btn.verify.order || '' |
| | | } else { |
| | | _setting = {...setting} |
| | | _setting.$name = btn.logLabel |
| | | _setting.laypage = pagination |
| | | _setting.arr_field = _setting.all_field || _setting.arr_field |
| | | |
| | | delete _setting.sub_field |
| | | } |
| | | |
| | | let primaryId = '' |
| | |
| | | let _type = props.card.type |
| | | |
| | | if (!props.card.origin) { |
| | | if (props.type === 'columns') { |
| | | if (_type !== 'number') { |
| | | _type = 'text' |
| | | } |
| | | } else if (props.type === 'search') { |
| | | // if (props.type === 'columns') { |
| | | // if (_type !== 'number') { |
| | | // _type = 'text' |
| | | // } |
| | | // } |
| | | if (props.type === 'search') { |
| | | if (_type === 'date' || _type === 'datetime') { |
| | | _type = 'date' |
| | | } else if (_type !== 'select') { |
| | |
| | | |
| | | render() { |
| | | const { card, type } = this.state |
| | | |
| | | let hasPadding = type === 'search' || type === 'form' |
| | | |
| | | return ( |
| | | <div className={'ant-card ant-card-bordered ' + (card.selected ? 'selected' : '') + (card.origin ? ' fixed' : '')} > |
| | | <div className={'ant-card ant-card-bordered ' + (card.selected ? 'selected' : '') + (card.origin ? ' fixed' : '') + (hasPadding ? ' has-padding' : '')} > |
| | | <div className="base" onClick={this.changeSelect}> |
| | | <CheckOutlined /> |
| | | <p title={card.field}>字段: <span>{card.field}</span></p> |
| | |
| | | <Radio value="date">date</Radio> |
| | | </Radio.Group> : null |
| | | } |
| | | {type === 'columns' ? |
| | | {/* {type === 'columns' ? |
| | | <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected || card.origin}> |
| | | <Radio value="text">text</Radio> |
| | | <Radio value="number">number</Radio> |
| | | </Radio.Group> : null |
| | | } |
| | | } */} |
| | | {type === 'form' ? |
| | | <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected || card.origin}> |
| | | <Radio value="text">text</Radio> |
| | |
| | | .ant-col { |
| | | padding: 10px; |
| | | .ant-card { |
| | | padding: 0px 10px 10px; |
| | | padding: 0px; |
| | | p { |
| | | margin-bottom: 5px; |
| | | overflow: hidden; |
| | |
| | | opacity: 0.4; |
| | | } |
| | | .base { |
| | | padding-top: 10px; |
| | | padding: 10px; |
| | | cursor: pointer; |
| | | } |
| | | } |
| | | .ant-card.has-padding { |
| | | padding: 0px 10px 10px; |
| | | .base { |
| | | padding: 10px 0 0; |
| | | } |
| | | } |
| | | .ant-card.selected, .ant-card.fixed { |
| | | border-color: #1890ff; |
| | | box-shadow: 0px 0px 4px #1890ff; |
| | |
| | | if (res.FDName && res.FDName.length > 0) { |
| | | tabmsg.columns = res.FDName.map(item => { |
| | | let _type = item.FieldType.toLowerCase() |
| | | let _datatype = item.FieldType.toLowerCase() |
| | | let _decimal = 0 |
| | | let _length = 50 |
| | | if (/^nvarchar/.test(_type)) { |
| | |
| | | } else { |
| | | _type = 'text' |
| | | } |
| | | |
| | | if (/^nvarchar/.test(_datatype)) { |
| | | _datatype = _datatype.replace(/^nvarchar/, 'Nvarchar') |
| | | } else if (/^decimal/.test(_datatype)) { |
| | | _datatype = _datatype.replace(/^decimal/, 'Decimal') |
| | | } else if (/^int/.test(_datatype)) { |
| | | _datatype = _datatype.replace(/^int/, 'Int') |
| | | } |
| | | |
| | | return { |
| | | field: item.FieldName || '', |
| | |
| | | datatype: _type, |
| | | decimal: _decimal, |
| | | length: _length, |
| | | $datatype: item.FieldType.toLowerCase() |
| | | $datatype: _datatype |
| | | } |
| | | }) |
| | | } |
| | |
| | | field: item.field, |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | type: item.type, |
| | | type: item.type === 'number' ? 'number' : 'text', |
| | | Width: item.type === 'number' ? 80 : 120 |
| | | } |
| | | |
| | |
| | | newcard.decimal = item.decimal |
| | | } else { |
| | | newcard.fieldlength = item.length || 50 |
| | | } |
| | | |
| | | if (item.type === 'date') { |
| | | newcard.textFormat = 'YYYY-MM-DD' |
| | | } else if (item.type === 'datetime') { |
| | | newcard.textFormat = 'YYYY-MM-DD HH:mm:ss' |
| | | } |
| | | |
| | | items.push(newcard) |
| | |
| | | field: item.field, |
| | | datatype: _t |
| | | } |
| | | |
| | | items.unshift(newcard) |
| | | keys.push(item.field.toLowerCase()) |
| | | }) |
| | |
| | | type: 'text', |
| | | key: 'initval', |
| | | label: '初始值', |
| | | tooltip: '类型为下拉菜单时,初始值应为数据的Value值(使用数据源时,应为《值·字段》的值);类型为数值(区间)时,初始值使用逗号拼接,例如 3,10', |
| | | tooltip: '类型为下拉菜单时,初始值应为数据的Value值(使用数据源时,应为《值·字段》的值);类型为数值(区间)时,初始值使用逗号拼接,例如 3,10;文本与下拉菜单中可使用@username@、@fullName@', |
| | | initVal: card.initval, |
| | | required: false |
| | | }, |
| | |
| | | } |
| | | |
| | | if (item.type === 'text' || item.type === 'select') { |
| | | if (/@username@|@fullName@/ig.test(item.initval)) { |
| | | item.initval = item.initval.replace(/@username@/ig, sessionStorage.getItem('User_Name') || '').replace(/@fullName@/ig, sessionStorage.getItem('Full_Name') || '') |
| | | item.oriInitval = item.initval |
| | | } |
| | | if (/,/.test(item.field)) { |
| | | item.field.split(',').forEach(field => { |
| | | keys.push(field.toLowerCase()) |
| | |
| | | } |
| | | |
| | | columns.forEach(col => { |
| | | if (col.field === 'works_flow_param') return |
| | | |
| | | if (col.type === 'colspan' || col.type === 'old_colspan') { |
| | | col.subcols.forEach(cell => { |
| | | setField(cell) |