From 4d201e812c323b3d73e53607b83e6341568f2ab1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 19 十一月 2019 22:26:05 +0800 Subject: [PATCH] 2019-11-19update --- src/components/sidemenu/comtableconfig/index.jsx | 447 ++++++++++++++++++++++++------------------------------- 1 files changed, 198 insertions(+), 249 deletions(-) diff --git a/src/components/sidemenu/comtableconfig/index.jsx b/src/components/sidemenu/comtableconfig/index.jsx index 1beb384..d37cf2a 100644 --- a/src/components/sidemenu/comtableconfig/index.jsx +++ b/src/components/sidemenu/comtableconfig/index.jsx @@ -3,7 +3,7 @@ // 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' @@ -19,7 +19,7 @@ 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 = { @@ -31,13 +31,13 @@ } state = { - dict: HeaderDict, // 瀛楀吀 + dict: CommonDict, // 瀛楀吀 config: null, // 椤甸潰閰嶇疆 visible: false, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪锛屾ā鎬佹鏄剧ず鎺у埗 tableVisible: false, // 鏁版嵁琛ㄥ瓧娈垫ā鎬佹 addType: '', // 娣诲姞绫诲瀷-鎼滅储鏉′欢鎴栨樉绀哄垪 tableColumns: [], // 琛ㄦ牸鏄剧ず鍒� - option: {}, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夋潯浠跺寘鎷琻ormal銆乷thers + fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� loading: false, // 鍔犺浇涓紙鑾峰彇琛ㄦ暟鎹級 menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 @@ -106,7 +106,7 @@ label: 'date', field: '', initval: '', - type: 'dateday', + type: 'date', resourceType: '0', setAll: 'false', options: [], @@ -192,6 +192,7 @@ field: '', Hide: 'false', IsSort: 'true', + type: 'text', Width: 120 }, { origin: true, @@ -202,6 +203,7 @@ field: '', Hide: 'false', IsSort: 'true', + type: 'text', Width: 120 }, { origin: true, @@ -212,6 +214,7 @@ field: '', Hide: 'false', IsSort: 'true', + type: 'text', Width: 120 }, { origin: true, @@ -222,6 +225,7 @@ field: '', Hide: 'false', IsSort: 'true', + type: 'text', Width: 120 } ] @@ -242,7 +246,7 @@ { type: 'search', label: '鏃堕棿妗嗭紙澶╋級', - subType: 'dateday', + subType: 'date', url: '' }, { @@ -255,37 +259,37 @@ 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: '' } @@ -293,14 +297,14 @@ 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: '' } ] @@ -377,7 +381,7 @@ MenuID: 'link', text: this.state.dict['header.form.link'] }, { - MenuID: 'dateday', + MenuID: 'date', text: this.state.dict['header.form.dateday'] }, { MenuID: 'datetime', @@ -647,6 +651,20 @@ }, { 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, @@ -691,8 +709,9 @@ }] }, { - type: 'spinner', + type: 'number', key: 'Width', + decimal: 0, label: this.state.dict['header.form.columnWidth'], initVal: card.Width, required: true @@ -803,33 +822,126 @@ }) 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}) } }) - this.setState({ - addType: type, - tableVisible: true, - option: { - normal: [...columns.values()], - others: others + } else if (type === 'columns') { + config.columns.forEach(item => { + if (columns.has(item.field)) { + columns.set(item.field, {...item, selected: true, type: item.type}) } - }, () => { - console.log(this.state.option) }) } - // console.log(tableColumns) - // console.log(columns) - // console.log(config) + this.setState({ + addType: type, + tableVisible: true, + fields: [...columns.values()] + }) } 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 = () => { @@ -890,6 +1002,12 @@ } ] }) + 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) => { @@ -901,207 +1019,49 @@ 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({ @@ -1124,7 +1084,6 @@ } render () { - console.log(this.state.option) return ( <div className="common-table-board"> <DndProvider backend={HTML5Backend}> @@ -1187,7 +1146,7 @@ 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> @@ -1273,21 +1232,11 @@ 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'}} />} -- Gitblit v1.8.0