| | |
| | | |
| | | import VerifyCard from './verifycard' |
| | | import CreateFunc from '@/templates/zshare/createfunc' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | class DataSource extends Component { |
| | |
| | | mainSearch: [], |
| | | visible: false, |
| | | loading: false, |
| | | setting: null, |
| | | record: {} |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config } = this.props |
| | | |
| | | this.setState({setting: fromJS(config.setting).toJS()}) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | editDataSource = () => { |
| | | const { config } = this.props |
| | | const { appType } = this.state |
| | | |
| | | if (config.type === 'interface') { // 公共数据源不使用搜索 |
| | | this.setState({visible: true}) |
| | | return |
| | | } |
| | | |
| | | let search = [] |
| | | let menu = fromJS(window.GLOB.customMenu).toJS() |
| | |
| | | }) |
| | | }) |
| | | } |
| | | } else if (config.type === 'interface') { |
| | | menu.components.forEach(item => { |
| | | if (item.type !== 'search') return |
| | | search = item.search |
| | | }) |
| | | } else { |
| | | let filterComponent = (box, mainSearch) => { |
| | | box.components.forEach(item => { |
| | |
| | | res.setting.supModule = ['empty'] |
| | | } |
| | | |
| | | if (!res.setting.primaryKey && res.columns && res.columns.length > 0) { |
| | | res.columns.forEach(col => { |
| | | if (col.field.toLowerCase() === 'id') { |
| | | res.setting.primaryKey = col.field |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (res.columns) { |
| | | res.columns = res.columns.map(item => { |
| | | |
| | | if (/int/ig.test(item.datatype)) { |
| | | item.type = 'number' |
| | | item.decimal = 0 |
| | | } else if (/Decimal/ig.test(item.datatype)) { |
| | | item.type = 'number' |
| | | item.decimal = +item.datatype.replace(/^Decimal\(18,/ig, '').replace(/\)/ig, '') |
| | | } else if (/^date/ig.test(item.datatype)) { |
| | | item.type = 'text' |
| | | item.fieldlength = 50 |
| | | } else { |
| | | item.type = 'text' |
| | | item.fieldlength = +item.datatype.replace(/^Nvarchar\(/ig, '').replace(/\)/ig, '') |
| | |
| | | return item |
| | | }) |
| | | |
| | | res.columns.reverse() |
| | | if (!config.fixedCol) { |
| | | res.columns.reverse() |
| | | } |
| | | } |
| | | |
| | | let maxScript = 0 |
| | |
| | | |
| | | if (config.subtype !== 'dualdatacard') { |
| | | delete res.subColumns |
| | | if (config.type === 'interface') { |
| | | res.setting.laypage = 'false' |
| | | } |
| | | } else { |
| | | res.subColumns = res.subColumns.map(item => { |
| | | if (/int/ig.test(item.datatype)) { |
| | | item.type = 'number' |
| | | item.decimal = 0 |
| | | } else if (/Decimal/ig.test(item.datatype)) { |
| | | item.type = 'number' |
| | | item.decimal = +item.datatype.replace(/^Decimal\(18,/ig, '').replace(/\)/ig, '') |
| | | } else if (/^date/ig.test(item.datatype)) { |
| | | item.type = 'text' |
| | | item.fieldlength = 50 |
| | | } else { |
| | | item.type = 'text' |
| | | item.fieldlength = +item.datatype.replace(/^Nvarchar\(/ig, '').replace(/\)/ig, '') |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | res.subColumns.reverse() |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | this.setState({loading: false, visible: false}) |
| | | |
| | | if (res.cols) { |
| | | res.cols = [...config.cols, ...res.cols] |
| | | } else { |
| | | delete res.cols |
| | | } |
| | | this.props.updateConfig({...config, ...res}) |
| | | |
| | | if (res.setting && res.setting.tableName && config.setting && !config.setting.tableName) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('publicTableChange', res.setting.tableName, 'init') |
| | | }, 150) |
| | | } |
| | | }, () => { |
| | | this.setState({loading: false}) |
| | | }) |