| | |
| | | // import { is, fromJS } from 'immutable' |
| | | import { DndProvider } from 'react-dnd' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import { Button, Card, Modal, Collapse, notification, Spin, Row, Col, Select, List, Icon } from 'antd' |
| | | import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon } from 'antd' |
| | | import DragElement from './dragelement' |
| | | import SourceElement from './dragelement/source' |
| | | import Api from '@/api' |
| | |
| | | |
| | | const { Panel } = Collapse |
| | | const { Option } = Select |
| | | const HeaderDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS |
| | | const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS |
| | | |
| | | class ComTableConfig extends Component { |
| | | static propTpyes = { |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: HeaderDict, // 字典 |
| | | dict: CommonDict, // 字典 |
| | | config: null, // 页面配置 |
| | | visible: false, // 搜索条件、按钮、显示列,模态框显示控制 |
| | | tableVisible: false, // 数据表字段模态框 |
| | | addType: '', // 添加类型-搜索条件或显示列 |
| | | tableColumns: [], // 表格显示列 |
| | | option: {}, // 搜索条件及显示列,可选条件包括normal、others |
| | | fields: null, // 搜索条件及显示列,可选字段 |
| | | loading: false, // 加载中(获取表数据) |
| | | menuformlist: null, // 基本信息表单字段 |
| | | formlist: null, // 搜索条件、按钮、显示列表单字段 |
| | |
| | | label: 'date', |
| | | field: '', |
| | | initval: '', |
| | | type: 'dateday', |
| | | type: 'date', |
| | | resourceType: '0', |
| | | setAll: 'false', |
| | | options: [], |
| | |
| | | field: '', |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | type: 'text', |
| | | Width: 120 |
| | | }, { |
| | | origin: true, |
| | |
| | | field: '', |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | type: 'text', |
| | | Width: 120 |
| | | }, { |
| | | origin: true, |
| | |
| | | field: '', |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | type: 'text', |
| | | Width: 120 |
| | | }, { |
| | | origin: true, |
| | |
| | | field: '', |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | type: 'text', |
| | | Width: 120 |
| | | } |
| | | ] |
| | |
| | | { |
| | | type: 'search', |
| | | label: '时间框(天)', |
| | | subType: 'dateday', |
| | | subType: 'date', |
| | | url: '' |
| | | }, |
| | | { |
| | |
| | | actionItems: [ |
| | | { |
| | | type: 'action', |
| | | label: HeaderDict['header.form.pop'], |
| | | label: CommonDict['header.form.pop'], |
| | | subType: 'pop', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'action', |
| | | label: HeaderDict['header.form.prompt'], |
| | | label: CommonDict['header.form.prompt'], |
| | | subType: 'prompt', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'action', |
| | | label: HeaderDict['header.form.exec'], |
| | | label: CommonDict['header.form.exec'], |
| | | subType: 'exec', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'action', |
| | | label: HeaderDict['header.form.tab'], |
| | | label: CommonDict['header.form.tab'], |
| | | subType: 'tab', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'action', |
| | | label: HeaderDict['header.form.newpage'], |
| | | label: CommonDict['header.form.newpage'], |
| | | subType: 'newpage', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'action', |
| | | label: HeaderDict['header.form.blank'], |
| | | label: CommonDict['header.form.blank'], |
| | | subType: 'blank', |
| | | url: '' |
| | | } |
| | |
| | | columnItems: [ |
| | | { |
| | | type: 'columns', |
| | | label: '排序列', |
| | | subType: 'true', |
| | | label: CommonDict['header.form.text'], |
| | | subType: 'text', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'columns', |
| | | label: '非排序列', |
| | | subType: 'false', |
| | | label: CommonDict['header.form.picture'], |
| | | subType: 'picture', |
| | | url: '' |
| | | } |
| | | ] |
| | |
| | | MenuID: 'link', |
| | | text: this.state.dict['header.form.link'] |
| | | }, { |
| | | MenuID: 'dateday', |
| | | MenuID: 'date', |
| | | text: this.state.dict['header.form.dateday'] |
| | | }, { |
| | | MenuID: 'datetime', |
| | |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'type', |
| | | label: this.state.dict['header.form.type'], |
| | | initVal: card.type, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'text', |
| | | text: this.state.dict['header.form.text'] |
| | | }, { |
| | | MenuID: 'picture', |
| | | text: this.state.dict['header.form.picture'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'Align', |
| | | label: this.state.dict['header.form.align'], |
| | | initVal: card.Align, |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'spinner', |
| | | type: 'number', |
| | | key: 'Width', |
| | | decimal: 0, |
| | | label: this.state.dict['header.form.columnWidth'], |
| | | initVal: card.Width, |
| | | required: true |
| | |
| | | }) |
| | | |
| | | if (type === 'search') { |
| | | let others = [] |
| | | config.search.forEach(item => { |
| | | if (columns.has(item.field)) { |
| | | columns.set(item.field, item) |
| | | } else if (item.field) { |
| | | others.push(item) |
| | | columns.set(item.field, {...item, selected: true, type: item.type}) |
| | | } |
| | | }) |
| | | } else if (type === 'columns') { |
| | | config.columns.forEach(item => { |
| | | if (columns.has(item.field)) { |
| | | columns.set(item.field, {...item, selected: true, type: item.type}) |
| | | } |
| | | }) |
| | | } |
| | | this.setState({ |
| | | addType: type, |
| | | tableVisible: true, |
| | | option: { |
| | | normal: [...columns.values()], |
| | | others: others |
| | | } |
| | | }, () => { |
| | | console.log(this.state.option) |
| | | fields: [...columns.values()] |
| | | }) |
| | | } |
| | | // console.log(tableColumns) |
| | | // console.log(columns) |
| | | // console.log(config) |
| | | } |
| | | |
| | | addFieldSubmit = () => { |
| | | const {addType, config} = this.state |
| | | |
| | | let cards = this.refs.searchcard.getSelectedCard() |
| | | console.log(cards) |
| | | let columns = new Map() |
| | | cards.forEach(card => { |
| | | columns.set(card.field, card) |
| | | }) |
| | | |
| | | let items = [] |
| | | if (addType === 'search') { |
| | | config.search.forEach(item => { |
| | | if (columns.has(item.field)) { |
| | | let cell = columns.get(item.field) |
| | | |
| | | if (cell.selected) { |
| | | items.push(item) |
| | | } |
| | | columns.delete(item.field) |
| | | } else if (!item.origin) { |
| | | items.push(item) |
| | | } |
| | | }) |
| | | |
| | | let _columns = [...columns.values()] |
| | | let indexes = items.map(card => {return card.id}) |
| | | let id = Math.max(...indexes, 0) |
| | | |
| | | _columns.forEach(item => { |
| | | if (item.selected) { |
| | | let newcard = { |
| | | id: id, |
| | | uuid: Utils.getuuid(), |
| | | label: item.label, |
| | | field: item.field, |
| | | initval: '', |
| | | type: item.type, |
| | | resourceType: '0', |
| | | setAll: 'false', |
| | | options: [], |
| | | dataSource: '', |
| | | linkField: '', |
| | | valueField: '', |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc', |
| | | display: 'dropdown' |
| | | } |
| | | |
| | | items.push(newcard) |
| | | id++ |
| | | } |
| | | }) |
| | | } else { |
| | | config.columns.forEach(item => { |
| | | if (columns.has(item.field)) { |
| | | let cell = columns.get(item.field) |
| | | |
| | | if (cell.selected) { |
| | | items.push(item) |
| | | } |
| | | columns.delete(item.field) |
| | | } else if (!item.origin) { |
| | | items.push(item) |
| | | } |
| | | }) |
| | | |
| | | let _columns = [...columns.values()] |
| | | let indexes = items.map(card => {return card.id}) |
| | | let id = Math.max(...indexes, 0) |
| | | |
| | | _columns.forEach(item => { |
| | | if (item.selected) { |
| | | let newcard = { |
| | | id: id, |
| | | uuid: Utils.getuuid(), |
| | | Align: 'left', |
| | | label: item.label, |
| | | field: item.field, |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | Width: 120 |
| | | } |
| | | |
| | | items.push(newcard) |
| | | id++ |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | tableVisible: false, |
| | | [addType + 'loading']: true, |
| | | addType: '', |
| | | config: {...config, [addType]: items} |
| | | }) |
| | | setTimeout(() => { |
| | | this.setState({ |
| | | [addType + 'loading']: false |
| | | }) |
| | | }, 100) |
| | | } |
| | | |
| | | cancelFieldSubmit = () => { |
| | |
| | | } |
| | | ] |
| | | }) |
| | | let _text = "select TbName ,Remark from sDataDictionary where IsKey!='' and Deleted =0" |
| | | _text = Utils.formatOptions(_text) |
| | | console.log(_text) |
| | | // Api.getSystemConfig({func: 'sPC_Get_SelectedList', LText: _text, obj_name: ''}).then(res => { |
| | | |
| | | // }) |
| | | } |
| | | |
| | | onTableChange = (value) => { |
| | |
| | | this.setState({ |
| | | selectedTables: [...selectedTables, _table] |
| | | }) |
| | | let SUsers = [ |
| | | { |
| | | field: 'UID', |
| | | label: 'UID', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'UserCode', |
| | | label: 'UserCode', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'UserName', |
| | | label: 'UserName', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'PassWord', |
| | | label: 'PassWord', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'FullName', |
| | | label: 'FullName', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'RoleID', |
| | | label: 'RoleID', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'RoleName', |
| | | label: 'RoleName', |
| | | type: 'text' |
| | | } |
| | | ] |
| | | let SMenus = [ |
| | | { |
| | | field: 'RoleID', |
| | | label: 'RoleID', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'RoleName', |
| | | label: 'RoleName', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'DepartmentCode', |
| | | label: 'DepartmentCode', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'Organization', |
| | | label: 'Organization', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'CSS', |
| | | label: 'CSS', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'HeadImage', |
| | | label: 'HeadImage', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'StaffID', |
| | | label: 'StaffID', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'Remark', |
| | | label: 'Remark', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'Deleted', |
| | | label: 'Deleted', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'APICode', |
| | | label: 'APICode', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'Status', |
| | | label: 'Status', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'Type', |
| | | label: 'Type', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'CreateDate', |
| | | label: 'CreateDate', |
| | | type: 'date' |
| | | } |
| | | ] |
| | | let SColumns = [ |
| | | { |
| | | field: 'Type', |
| | | label: 'Type', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'CreateDate', |
| | | label: 'CreateDate', |
| | | type: 'date' |
| | | }, |
| | | { |
| | | field: 'CreateUserID', |
| | | label: 'CreateUserID', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'CreateUser', |
| | | label: 'CreateUser', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'CreateStaff', |
| | | label: 'CreateStaff', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'CreateDepartCode', |
| | | label: 'CreateDepartCode', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'ModifyDate', |
| | | label: 'ModifyDate', |
| | | type: 'date' |
| | | }, |
| | | { |
| | | field: 'ModifyUserID', |
| | | label: 'ModifyUserID', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'ModifyUser', |
| | | label: 'ModifyUser', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'ModifyDepartCode', |
| | | label: 'ModifyDepartCode', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'ModifyOrganCode', |
| | | label: 'ModifyOrganCode', |
| | | type: 'text' |
| | | } |
| | | ] |
| | | let SActions = [ |
| | | { |
| | | field: 'ModifyDepartCode', |
| | | label: 'ModifyDepartCode', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'ModifyOrganCode', |
| | | label: 'ModifyOrganCode', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'SubmitDate', |
| | | label: 'SubmitDate', |
| | | type: 'date' |
| | | }, |
| | | { |
| | | field: 'SubmitUserID', |
| | | label: 'SubmitUserID', |
| | | type: 'text' |
| | | }, |
| | | { |
| | | field: 'SubmitUser', |
| | | label: 'SubmitUser', |
| | | type: 'text' |
| | | } |
| | | ] |
| | | Api.getSystemConfig({func: 'sPC_Get_MainMenu'}).then(res => { |
| | | Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: 'SRMPurchaseOrder'}).then(res => { |
| | | if (res.status) { |
| | | let _change = { |
| | | SUsers: SUsers, |
| | | SMenus: SMenus, |
| | | SColumns: SColumns, |
| | | SActions: SActions |
| | | let tabmsg = { |
| | | tableName: _table.name, |
| | | columns: res.FDName.map(item => { |
| | | let _type = item.FieldType.toLowerCase() |
| | | let _decimal = 0 |
| | | if (/^nvarchar/.test(_type)) { |
| | | _type = 'text' |
| | | // } else if (/^int/.test(_type)) { |
| | | // _type = 'number' |
| | | // } else if (/^decimal/.test(_type)) { |
| | | // _decimal = _type.split(',')[1] |
| | | // _decimal = parseInt(_decimal) |
| | | // if (_decimal > 4) { |
| | | // _decimal = 4 |
| | | // } |
| | | // _type = 'number' |
| | | // } else if (/^decimal/.test(_type)) { |
| | | // _decimal = _type.split(',')[1] |
| | | // _decimal = parseInt(_decimal) |
| | | // if (_decimal > 4) { |
| | | // _decimal = 4 |
| | | // } |
| | | // _type = 'number' |
| | | } else if (/^datetime/.test(_type)) { |
| | | _type = 'datetime' |
| | | } else if (/^date/.test(_type)) { |
| | | _type = 'date' |
| | | } else { |
| | | _type = 'text' |
| | | } |
| | | |
| | | return { |
| | | field: item.FieldName, |
| | | label: item.FieldDec, |
| | | type: _type, |
| | | decimal: _decimal |
| | | } |
| | | }) |
| | | } |
| | | this.setState({ |
| | | tableColumns: tableColumns.concat([{ |
| | | tableName: _table.name, |
| | | columns: _change[_table.name] |
| | | }]) |
| | | tableColumns: [...tableColumns, tabmsg] |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | |
| | | } |
| | | |
| | | render () { |
| | | console.log(this.state.option) |
| | | return ( |
| | | <div className="common-table-board"> |
| | | <DndProvider backend={HTML5Backend}> |
| | |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </div> |
| | | <Button type="primary" block onClick={() => this.queryField('column')}>添加显示列</Button> |
| | | <Button type="primary" block onClick={() => this.queryField('columns')}>添加显示列</Button> |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | |
| | | onCancel={this.cancelFieldSubmit} |
| | | destroyOnClose |
| | | > |
| | | {this.state.addType === 'search' && |
| | | <div> |
| | | {this.state.option.normal.length > 0 && <EditCard data={this.state.option.normal} ref="searchcard" title="" />} |
| | | {this.state.option.others.length > 0 && <Row style={{marginLeft: '-10px', marginRight: '-10px'}}> |
| | | <p style={{margin: '10px 0px 0px 10px', color: '#1890ff'}}>自定义字段</p> |
| | | {this.state.option.others.map((item, index) => ( |
| | | <Col key={index} span={8} style={{padding: '10px'}}> |
| | | <div className="ant-card ant-card-bordered" style={{padding: '10px'}}> |
| | | <p>{item.label}</p> |
| | | <p>{item.field}</p> |
| | | </div> |
| | | </Col> |
| | | ))} |
| | | </Row>} |
| | | </div> |
| | | {this.state.addType === 'search' && this.state.fields.length > 0 && |
| | | <EditCard data={this.state.fields} ref="searchcard" type="search" /> |
| | | } |
| | | {this.state.addType === 'columns' && this.state.fields.length > 0 && |
| | | <EditCard data={this.state.fields} ref="searchcard" type="columns" /> |
| | | } |
| | | </Modal> |
| | | {this.state.loading && <Spin size="large" style={{position: 'fixed', left: '49vw', top: '230px'}} />} |