| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取业务通用接口 |
| | | */ |
| | | genericInterface (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | return axios({ |
| | | url: '/webapi/dostar', |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取页面配置信息 |
| | | * @param {String} MenuNo 页面菜单参数 |
| | | */ |
| | |
| | | 'header.form.resourceType': '选项来源', |
| | | 'header.form.custom': '自定义', |
| | | 'header.form.datasource': '数据源', |
| | | 'header.form.datasource.actionhelp': '使用系统函数时,请填写数据源。', |
| | | 'header.form.valueField': '值·字段', |
| | | 'header.form.valueText': '文本·字段', |
| | | 'header.form.orderBy': '排序·字段', |
| | |
| | | 'header.form.dropdown': '下拉菜单', |
| | | 'header.form.button': '按钮', |
| | | 'header.form.selectItem.error': '下拉选项设置错误!', |
| | | 'header.form.request.method': '请求方式', |
| | | 'form.required.input': 'Please enter the ', |
| | | 'form.required.select': '请选择' |
| | | } |
| | |
| | | 'main.reset': 'Reset', |
| | | 'main.confirm': 'OK', |
| | | 'main.return': 'Cancel', |
| | | 'main.all': 'All', |
| | | 'main.copy.success': 'Copy success', |
| | | 'main.pagination.of': 'of', |
| | | 'main.pagination.items': 'items', |
| | | 'main.page.settingerror': '页面配置错误!', |
| | | 'main.action.settingerror': 'Button setting error!', |
| | | 'main.action.confirm.tip': 'Do you want to execute?', |
| | | 'main.action.confirm.success': 'Execute successfully!', |
| | |
| | | 'header.form.resourceType': '选项来源', |
| | | 'header.form.custom': '自定义', |
| | | 'header.form.datasource': '数据源', |
| | | 'header.form.datasource.actionhelp': '使用系统函数时,请填写数据源。', |
| | | 'header.form.valueField': '值·字段', |
| | | 'header.form.valueText': '文本·字段', |
| | | 'header.form.orderBy': '排序·字段', |
| | |
| | | 'header.form.dropdown': '下拉菜单', |
| | | 'header.form.button': '按钮', |
| | | 'header.form.selectItem.error': '下拉选项设置错误!', |
| | | 'header.form.request.method': '请求方式', |
| | | 'form.required.input': '请输入', |
| | | 'form.required.select': '请选择' |
| | | } |
| | |
| | | 'main.reset': '重置', |
| | | 'main.confirm': '确定', |
| | | 'main.return': '返回', |
| | | 'main.all': '全部', |
| | | 'main.copy.success': '复制成功', |
| | | 'main.pagination.of': '共', |
| | | 'main.pagination.items': '条', |
| | | 'main.page.settingerror': '页面配置错误!', |
| | | 'main.datasource.settingerror': '数据源配置错误!', |
| | | 'main.action.settingerror': '按钮设置错误!', |
| | | 'main.action.confirm.tip': '确定要执行吗?', |
| | | 'main.action.confirm.success': '执行成功!', |
| | |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message || '页面配置错误', |
| | | message: this.state.dict['main.page.settingerror'], |
| | | duration: 10 |
| | | }) |
| | | } |
| | |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message || '页面配置错误', |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | |
| | | item.options.unshift({ |
| | | key: Utils.getuuid(), |
| | | Value: '', |
| | | Text: '全部' |
| | | Text: this.state.dict['main.all'] |
| | | }) |
| | | } |
| | | |
| | |
| | | } else if (item.resourceType === '1' && !item.dataSource) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: item.label + '数据源配置错误', |
| | | message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], |
| | | duration: 10 |
| | | }) |
| | | } |
| | |
| | | // }) |
| | | } |
| | | |
| | | refreshbyaction = () => { |
| | | refreshbyaction = (btn, type) => { |
| | | // 按钮操作后刷新表格,重置页码及选择项 |
| | | this.refs.mainTable.resetTable() |
| | | this.loadmaindata(1, this.state.param.pageSize, this.state.param.orderColumn, this.state.param.orderType, this.state.param.search) |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | console.log(btn) |
| | | console.log(type) |
| | | // this.refs.mainTable.resetTable() |
| | | // this.loadmaindata(1, this.state.param.pageSize, this.state.param.orderColumn, this.state.param.orderType, this.state.param.search) |
| | | // this.setState({ |
| | | // loading: true |
| | | // }) |
| | | } |
| | | |
| | | gettableselected = () => { |
| | |
| | | {actions && |
| | | <MainAction |
| | | MenuID={this.props.MenuID} |
| | | fixed={setting && setting.actionfixed} |
| | | setting={setting} |
| | | refreshdata={this.refreshbyaction} |
| | | gettableselected={this.gettableselected} |
| | | actions={actions} |
| | |
| | | MenuID: PropTypes.string, |
| | | actions: PropTypes.array, // 搜索条件列表 |
| | | dict: PropTypes.object, // 字典项 |
| | | fixed: PropTypes.any |
| | | setting: PropTypes.any |
| | | } |
| | | |
| | | state = { |
| | |
| | | formdata: null, |
| | | tabledata: null, |
| | | confirmLoading: false, |
| | | execAction: null |
| | | execAction: null, |
| | | loadingUuid: '' |
| | | } |
| | | |
| | | refreshdata = () => { |
| | | this.props.refreshdata() |
| | | refreshdata = (item, type) => { |
| | | this.props.refreshdata(item, type) |
| | | } |
| | | actionTrigger = (item) => { |
| | | const { setting } = this.props |
| | | let _this = this |
| | | let data = this.props.gettableselected() || [] |
| | | console.log(item) |
| | | console.log(data) |
| | | |
| | | if (item.Ot !== 'notRequired' && data.length === 0) { |
| | | // 需要选择行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['main.action.confirm.selectline'] |
| | | message: this.props.dict['main.action.confirm.selectline'], |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (item.Ot === 'requiredSgl' && data.length !== 1) { |
| | | // 需要选择单行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['main.action.confirm.selectSingleLine'] |
| | | message: this.props.dict['main.action.confirm.selectSingleLine'], |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { |
| | | // 需要选择行时,校验是否设置主键 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未设置主键!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | |
| | | confirm({ |
| | | title: this.props.dict['main.action.confirm.tip'], |
| | | onOk() { |
| | | return Api.setActionSubmit({ |
| | | func: 'SetActionSubmitSuccess' |
| | | // func: 'SetActionSubmitError' |
| | | }).then((res) => { |
| | | if (res.status) { |
| | | notification.success({ |
| | | top: 92, |
| | | message: _this.props.dict['main.action.confirm.success'] |
| | | // duration: 0 |
| | | // description: |
| | | }) |
| | | _this.refreshdata() |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message |
| | | }) |
| | | } |
| | | return new Promise(resolve => { |
| | | _this.execSubmit(item, data, resolve) |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else if (item.OpenType === 'exec') { |
| | | Api.getModelFormData(item.MenuID).then(res => { |
| | | if (res.status) { |
| | | this.setState({ |
| | | formdata: res.data.map(input => { |
| | | let validate = input.Validate && JSON.parse(input.Validate) |
| | | input.DynOptions = JSON.parse(input.DynOptions) |
| | | input.required = (validate && validate.required) || false |
| | | return input |
| | | }), |
| | | visible: true, |
| | | execAction: item, |
| | | tabledata: data[0] |
| | | }) |
| | | } |
| | | this.setState({loadingUuid: item.uuid}) |
| | | this.execSubmit(item, data, () => { |
| | | this.setState({loadingUuid: ''}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | execSubmit = (btn, data, _resolve) => { |
| | | const { setting } = this.props |
| | | if (btn.intertype === 'inner') { |
| | | // 使用内部接口时,内部函数和数据源不可同时为空 |
| | | if (!btn.innerFunc && !btn.sql) { |
| | | this.actionSettingError() |
| | | _resolve() |
| | | return |
| | | } |
| | | |
| | | if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { |
| | | // 获取id |
| | | let param = { |
| | | func: 'sPC_TableData_InUpDe' |
| | | } |
| | | let ID = '' |
| | | if (btn.Ot === 'notRequired') { |
| | | |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | ID = data[0][setting.primaryKey] |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ID = ids.join(',') |
| | | } |
| | | |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | param.ID = ID |
| | | param.BID = '' |
| | | } else if (btn.sql) { |
| | | param.LText = btn.sql // 数据源 |
| | | } |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess(btn) |
| | | } else { |
| | | this.execError(res, btn) |
| | | } |
| | | _resolve() |
| | | }) |
| | | } else if (btn.Ot === 'required') { |
| | | let deffers = data.map(cell => { |
| | | let param = { |
| | | func: 'sPC_TableData_InUpDe' |
| | | } |
| | | let ID = cell[setting.primaryKey] |
| | | |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | param.ID = ID |
| | | param.BID = '' |
| | | } else if (btn.sql) { |
| | | param.LText = btn.sql // 数据源 |
| | | } |
| | | |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(param).then(res => { |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | }) |
| | | Promise.all(deffers).then(result => { |
| | | let iserror = false |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (res.status) { |
| | | |
| | | } else { |
| | | iserror = true |
| | | errorMsg = res.message |
| | | } |
| | | }) |
| | | if (!iserror) { |
| | | this.execSuccess(btn) |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | } |
| | | _resolve() |
| | | }) |
| | | } else { |
| | | this.actionSettingError() |
| | | _resolve() |
| | | return |
| | | } |
| | | } else if (btn.intertype === 'outer') { |
| | | /** *********************调用外部接口************************* */ |
| | | let param = { |
| | | ID: '', |
| | | BID: '' |
| | | } |
| | | |
| | | if (!btn.interface) { // 接口地址不存在时报错 |
| | | this.actionSettingError() |
| | | _resolve() |
| | | return |
| | | } |
| | | |
| | | if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { |
| | | // 获取id |
| | | if (btn.Ot === 'notRequired') { |
| | | |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | param.ID = data[0][setting.primaryKey] |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | param.ID = ids.join(',') |
| | | } |
| | | |
| | | new Promise(resolve => { |
| | | // 内部请求 |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | // 存在内部函数时,数据预处理 |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | delete res.ErrCode |
| | | delete res.ErrMesg |
| | | delete res.message |
| | | delete res.status |
| | | |
| | | res.rduri = btn.interface |
| | | // res.method = btn.method |
| | | if (btn.outerFunc) { |
| | | res.func = btn.outerFunc |
| | | } |
| | | // 使用处理后的数据调用外部接口 |
| | | resolve(res) |
| | | } else { |
| | | this.execError(res, btn) |
| | | _resolve() |
| | | } |
| | | }) |
| | | } else { |
| | | // 不存在内部函数时,生成外部请求参数 |
| | | param.rduri = btn.interface |
| | | // param.method = btn.method |
| | | if (btn.outerFunc) { |
| | | param.func = btn.outerFunc |
| | | } |
| | | resolve(param) |
| | | } |
| | | }).then(res => { |
| | | if (!res) return |
| | | // 外部请求 |
| | | console.log(res) |
| | | return Api.genericInterface(res) |
| | | }).then(response => { |
| | | // 回调请求 |
| | | if (response.status) { |
| | | if (btn.callbackFunc) { |
| | | // 存在回调函数时,调用 |
| | | delete response.ErrCode |
| | | delete response.ErrMesg |
| | | delete response.message |
| | | delete response.status |
| | | |
| | | response.func = btn.callbackFunc |
| | | return Api.genericInterface(response) |
| | | } else { |
| | | this.execSuccess(btn) |
| | | _resolve() |
| | | } |
| | | } else { |
| | | this.execError(response, btn) |
| | | _resolve() |
| | | } |
| | | }).then(res => { |
| | | if (!res) return |
| | | |
| | | if (res.status) { |
| | | this.execSuccess(btn) |
| | | } else { |
| | | this.execError(res, btn) |
| | | } |
| | | _resolve() |
| | | }) |
| | | |
| | | } else if (btn.Ot === 'required') { |
| | | // 选择多行,循环调用 |
| | | |
| | | new Promise(resolve => { |
| | | // 内部请求 |
| | | if (btn.innerFunc) { |
| | | let deffers = data.map(cell => { |
| | | let _param = { |
| | | BID: '', |
| | | func: btn.innerFunc |
| | | } |
| | | _param.ID = cell[setting.primaryKey] |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(_param).then(res => { |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | }) |
| | | Promise.all(deffers).then(result => { |
| | | let iserror = false |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | iserror = true |
| | | errorMsg = res.message |
| | | } |
| | | }) |
| | | if (!iserror) { |
| | | resolve(result) |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | _resolve() |
| | | } |
| | | }) |
| | | } else { |
| | | let params = data.map(cell => { |
| | | return { |
| | | BID: '', |
| | | ID: cell[setting.primaryKey] |
| | | } |
| | | }) |
| | | resolve(params) |
| | | } |
| | | }).then(result => { |
| | | // 外部请求 |
| | | if (!result) return |
| | | |
| | | let deffers = result.map(res => { |
| | | delete res.ErrCode |
| | | delete res.ErrMesg |
| | | delete res.message |
| | | delete res.status |
| | | |
| | | res.rduri = btn.interface |
| | | // res.method = btn.method |
| | | if (btn.outerFunc) { |
| | | res.func = btn.outerFunc |
| | | } |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(res).then(response => { |
| | | resolve(response) |
| | | }) |
| | | }) |
| | | }) |
| | | return Promise.all(deffers) |
| | | |
| | | }).then(result => { |
| | | // 回调请求 |
| | | let iserror = false |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | iserror = true |
| | | errorMsg = res.message |
| | | } |
| | | }) |
| | | if (iserror) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | _resolve() |
| | | return |
| | | } |
| | | |
| | | if (btn.callbackFunc) { |
| | | // 存在回调函数时,调用 |
| | | let deffers = result.map(res => { |
| | | delete res.ErrCode |
| | | delete res.ErrMesg |
| | | delete res.message |
| | | delete res.status |
| | | |
| | | res.func = btn.callbackFunc |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(res).then(response => { |
| | | resolve(response) |
| | | }) |
| | | }) |
| | | }) |
| | | return Promise.all(deffers) |
| | | } else { |
| | | _resolve() |
| | | this.execSuccess(btn) |
| | | } |
| | | }).then(result => { |
| | | if (!result) return |
| | | |
| | | let iserror = false |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | iserror = true |
| | | errorMsg = res.message |
| | | } |
| | | }) |
| | | if (iserror) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | return |
| | | } else { |
| | | this.execSuccess(btn) |
| | | } |
| | | _resolve() |
| | | }) |
| | | |
| | | } else { |
| | | this.actionSettingError() |
| | | _resolve() |
| | | return |
| | | } |
| | | |
| | | } else { |
| | | this.actionSettingError() |
| | | _resolve() |
| | | return |
| | | } |
| | | } |
| | | |
| | | execSuccess = (btn) => { |
| | | notification.success({ |
| | | top: 92, |
| | | message: this.props.dict['main.action.confirm.success'], |
| | | duration: 5 |
| | | }) |
| | | this.refreshdata(btn, 'success') |
| | | } |
| | | |
| | | execError = (res, btn) => { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 15 |
| | | }) |
| | | this.refreshdata(btn, 'error') |
| | | } |
| | | |
| | | actionSettingError = () => { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['main.action.settingerror'], |
| | | duration: 10 |
| | | }) |
| | | } |
| | | |
| | | getModels = () => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | if (this.props.fixed) { // 按钮是否固定在头部 |
| | | const { loadingUuid } = this.state |
| | | |
| | | if (this.props.setting.actionfixed) { // 按钮是否固定在头部 |
| | | return ( |
| | | <Affix offsetTop={48}> |
| | | <div className="button-list" id={this.props.MenuID + 'mainaction'}> |
| | | {this.props.actions.map((item, index) => { |
| | | if (loadingUuid === item.uuid) { |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | | icon={item.icon} |
| | | key={'action' + index} |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | loading |
| | | >{item.label}</Button> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | | icon={item.icon} |
| | | key={'action' + index} |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | >{item.label}</Button> |
| | | ) |
| | | } |
| | | })} |
| | | {this.getModels()} |
| | | </div> |
| | | </Affix> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <div className="button-list"> |
| | | {this.props.actions.map((item, index) => { |
| | | if (loadingUuid === item.uuid) { |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | | icon={item.icon} |
| | | key={'action' + index} |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | loading |
| | | >{item.label}</Button> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | >{item.label}</Button> |
| | | ) |
| | | })} |
| | | {this.getModels()} |
| | | </div> |
| | | </Affix> |
| | | } |
| | | })} |
| | | </div> |
| | | ) |
| | | } |
| | | return ( |
| | | <div className="button-list"> |
| | | {this.props.actions.map((item, index) => { |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | | icon={item.icon} |
| | | key={'action' + index} |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | >{item.label}</Button> |
| | | ) |
| | | })} |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification } from 'antd' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | const btnIcons = [{ |
| | | MenuID: '', |
| | |
| | | _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position'] |
| | | } else { |
| | | if (_intertype === 'outer') { |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'method'] |
| | | } else { |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql'] |
| | | } |
| | | } |
| | | this.setState({ |
| | |
| | | _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position'] |
| | | } else { |
| | | if (this.state.interType === 'inner') { |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql'] |
| | | } else { |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc'] |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc', 'method'] |
| | | } |
| | | } |
| | | this.setState({ |
| | |
| | | if (key === 'intertype') { |
| | | let _options = null |
| | | if (value === 'inner') { |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql'] |
| | | } else { |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc'] |
| | | _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc', 'method'] |
| | | } |
| | | this.setState({ |
| | | interType: value, |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'textarea') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label} help={this.props.dict['header.form.datasource.actionhelp']} className="textarea"> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal |
| | | })(<TextArea rows={4} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | }) |
| | | return fields |
| | |
| | | if (!err) { |
| | | values.id = this.props.card.id |
| | | values.uuid = this.props.card.uuid |
| | | resolve({ |
| | | type: 'action', |
| | | values |
| | | }) |
| | | |
| | | if (values.innerFunc === '' && values.sql === '') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['header.form.datasource.actionhelp'], |
| | | duration: 10 |
| | | }) |
| | | } else { |
| | | resolve({ |
| | | type: 'action', |
| | | values |
| | | }) |
| | | } |
| | | } else { |
| | | reject(err) |
| | | } |
| | |
| | | color: #1890ff; |
| | | cursor: pointer; |
| | | } |
| | | .textarea { |
| | | .ant-col-sm-7 { |
| | | width: 14%; |
| | | } |
| | | .ant-col-sm-17 { |
| | | width: 86%; |
| | | } |
| | | } |
| | | } |
| | |
| | | import ItemTypes from './itemtypes' |
| | | import './index.scss' |
| | | |
| | | const Container = ({list, setting, type, placeholder, handleList, handleMenu }) => { |
| | | const Container = ({list, setting, type, placeholder, handleList, handleMenu, copyElement }) => { |
| | | let target = null |
| | | const [cards, setCards] = useState(list) |
| | | const moveCard = (id, atIndex) => { |
| | |
| | | let copycard = JSON.parse(JSON.stringify(card)) |
| | | copycard.uuid = Utils.getuuid() |
| | | copycard.origin = false |
| | | let names = cards.map(car => { return car.label }) |
| | | let index = 1 |
| | | let origin = copycard.label.split('(copy')[0] || 'button' |
| | | let label = origin + '(copy)' |
| | | while (names.includes(label)) { |
| | | label = origin + `(copy${index})` |
| | | index++ |
| | | } |
| | | // let names = cards.map(car => { return car.label }) |
| | | // let index = 1 |
| | | // let origin = copycard.label.split('(copy')[0] || 'button' |
| | | // let label = origin + '(copy)' |
| | | // while (names.includes(label)) { |
| | | // label = origin + `(copy${index})` |
| | | // index++ |
| | | // } |
| | | |
| | | copycard.label = label |
| | | copycard.label = copycard.label + '(copy)' |
| | | |
| | | let indexes = cards.map(car => { return car.id }) |
| | | let newid = 0 |
| | |
| | | } |
| | | copycard.id = newid |
| | | |
| | | const { index: overIndex } = findCard(`${card.id}`) |
| | | // const { index: overIndex } = findCard(`${card.id}`) |
| | | |
| | | const _cards = update(cards, { $splice: [[overIndex + 1, 0, copycard]] }) |
| | | setCards(_cards) |
| | | handleList({action: _cards}) |
| | | // const _cards = update(cards, { $splice: [[overIndex + 1, 0, copycard]] }) |
| | | // setCards(_cards) |
| | | // handleList({action: _cards}) |
| | | |
| | | copyElement(copycard) |
| | | } |
| | | |
| | | const hasDrop = (item) => { |
| | |
| | | newcard.label = 'button' |
| | | newcard.innerFunc = '' |
| | | newcard.outerFunc = '' |
| | | newcard.sql = '' |
| | | newcard.Ot = 'requiredSgl' |
| | | newcard.OpenType = item.subType |
| | | newcard.icon = '' |
| | | newcard.class = 'default' |
| | | newcard.intertype = 'inner' |
| | | newcard.interface = '' |
| | | newcard.method = 'POST' |
| | | newcard.position = 'toolbar' |
| | | newcard.execSuccess = 'grid' |
| | | newcard.execError = 'never' |
| | |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'method', |
| | | label: this.state.dict['header.form.request.method'], |
| | | initVal: card.method || 'POST', |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'POST', |
| | | text: 'POST' |
| | | }, { |
| | | MenuID: 'GET', |
| | | text: 'GET' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'icon', |
| | | label: this.state.dict['header.form.icon'], |
| | | initVal: card.icon, |
| | |
| | | initVal: card.class, |
| | | required: false, |
| | | options: [] |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'sql', |
| | | label: this.state.dict['header.form.datasource'], |
| | | initVal: card.sql || '', |
| | | required: false |
| | | } |
| | | ] |
| | | }) |
| | |
| | | handleSubmit = () => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | let _config = this.state.config |
| | | let isupdate = false |
| | | |
| | | if (res.type === 'search') { |
| | | if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { |
| | |
| | | if (this.state.operaType === 'add') { |
| | | _config[res.type] = _config[res.type].map(item => { |
| | | if (item.uuid === res.values.uuid) { |
| | | isupdate = true |
| | | return res.values |
| | | } else { |
| | | return item |
| | |
| | | } else { |
| | | _config[res.type] = _config[res.type].map(item => { |
| | | if (item.uuid === res.values.uuid) { |
| | | isupdate = true |
| | | return res.values |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (!isupdate) { // 操作不是修改,添加元素至列表 |
| | | _config[res.type].push(res.values) |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | placeholder={this.state.dict['header.form.action.placeholder']} |
| | | handleList={this.handleList} |
| | | handleMenu={this.handleAction} |
| | | copyElement={this.handleAction} |
| | | /> : null |
| | | } |
| | | </div> |
| | |
| | | <Form {...formItemLayout} className="ant-advanced-search-form commontable-setting-form" id="commontable-setting-form"> |
| | | <Row gutter={24}> |
| | | <Col span={12}> |
| | | <Form.Item label="固定按钮"> |
| | | {getFieldDecorator('actionfixed', { |
| | | initialValue: data.actionfixed |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value={true}>是</Radio> |
| | | <Radio value={false}>否</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="固定列"> |
| | | {getFieldDecorator('columnfixed', { |
| | | initialValue: data.columnfixed |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value={true}>是</Radio> |
| | | <Radio value={false}>否</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="表名"> |
| | | {getFieldDecorator('tableName', { |
| | | initialValue: data.tableName, |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="固定按钮"> |
| | | {getFieldDecorator('actionfixed', { |
| | | initialValue: data.actionfixed |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value={true}>是</Radio> |
| | | <Radio value={false}>否</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="固定列"> |
| | | {getFieldDecorator('columnfixed', { |
| | | initialValue: data.columnfixed |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value={true}>是</Radio> |
| | | <Radio value={false}>否</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="主键"> |
| | | {getFieldDecorator('primaryKey', { |
| | | initialValue: primaryKey |
| | |
| | | intertype: 'inner', |
| | | innerFunc: '', |
| | | interface: '', |
| | | method: 'POST', |
| | | outerFunc: '', |
| | | sql: '', |
| | | callbackFunc: '', |
| | | Ot: 'notRequired', |
| | | position: 'toolbar', |
| | |
| | | intertype: 'inner', |
| | | innerFunc: '', |
| | | interface: '', |
| | | method: 'POST', |
| | | outerFunc: '', |
| | | sql: '', |
| | | callbackFunc: '', |
| | | Ot: 'requiredSgl', |
| | | position: 'grid', |
| | |
| | | intertype: 'inner', |
| | | innerFunc: '', |
| | | interface: '', |
| | | method: 'POST', |
| | | outerFunc: '', |
| | | sql: '', |
| | | callbackFunc: '', |
| | | Ot: 'required', |
| | | position: 'toolbar', |
| | |
| | | intertype: 'inner', |
| | | innerFunc: '', |
| | | interface: '', |
| | | method: 'POST', |
| | | outerFunc: '', |
| | | sql: '', |
| | | callbackFunc: '', |
| | | Ot: 'requiredOnce', |
| | | position: 'toolbar', |