| | |
| | | _config.type = 'Template' |
| | | _config.uuid = Utils.getuuid() |
| | | |
| | | if (result.data && result.data[0] && result.data[0].TableName) { |
| | | this.loadFields(result.data[0].TableName) |
| | | let tables = [] |
| | | |
| | | if (result.data && result.data.length > 0) { |
| | | result.data.forEach(item => { |
| | | if (item.TableName) { |
| | | tables.push(item.TableName) |
| | | } |
| | | }) |
| | | |
| | | tables = Array.from(new Set(tables)) |
| | | } |
| | | |
| | | this.loadFields(tables) |
| | | |
| | | this.handleResize() |
| | | this.setState({ |
| | |
| | | /** |
| | | * @description 获取可用字段 |
| | | */ |
| | | async loadFields (TBName) { |
| | | let param = { |
| | | func: 'sPC_Get_FieldName', |
| | | TBName: TBName |
| | | loadFields (tables) { |
| | | if (tables.length === 0) { |
| | | let _fields = [{ |
| | | value: '', |
| | | text: '空', |
| | | type: '' |
| | | }, { |
| | | value: 'other_field', |
| | | text: '其他', |
| | | type: '' |
| | | }] |
| | | |
| | | this.setState({ |
| | | fields: _fields |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let result = await Api.getCloudConfig(param) |
| | | |
| | | if (result.status) { |
| | | let deffers = tables.map(name => { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: name}).then(res => { |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | }) |
| | | Promise.all(deffers).then(response => { |
| | | let _fields = [{ |
| | | value: '', |
| | | text: '空', |
| | | type: '' |
| | | }] |
| | | let error = null |
| | | let _f = new Map() |
| | | |
| | | result.FDName.forEach(item => { |
| | | if (item.FieldName && !_f.has(item.FieldName)) { |
| | | _f.set(item.FieldName, true) |
| | | |
| | | _fields.push({ |
| | | value: item.FieldName, |
| | | text: item.FieldDec + '(' + item.FieldName + ')', |
| | | type: item.FieldType |
| | | |
| | | response.forEach(res => { |
| | | if (res.status) { |
| | | res.FDName.forEach(item => { |
| | | if (item.FieldName && !_f.has(item.FieldName)) { |
| | | _f.set(item.FieldName, true) |
| | | |
| | | _fields.push({ |
| | | value: item.FieldName, |
| | | text: item.FieldDec + '(' + item.FieldName + ')', |
| | | type: item.FieldType |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | error = res |
| | | } |
| | | }) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error.ErrMesg, |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | _fields.push({ |
| | | value: 'other_field', |
| | |
| | | this.setState({ |
| | | fields: _fields |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.ErrMesg, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | dropcard = (item) => { |