| | |
| | | visible: false |
| | | } |
| | | |
| | | handleMenuClick = () => { |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | pasteSubmit = () => { |
| | | const { options } = this.props |
| | | this.pasteFormRef.handleConfirm().then(res => { |
| | |
| | | import './index.scss' |
| | | |
| | | const NormalForm = asyncIconComponent(() => import('@/components/normalform')) |
| | | const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) |
| | | const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) |
| | | |
| | | const Card = ({ id, card, sort, labelSize, active, moveCard, findCard, closeCard, selectCard, updateGroup }) => { |
| | | const Card = ({ id, card, sort, labelSize, active, moveCard, findCard, closeCard, selectCard, updateGroup, pasteForm }) => { |
| | | const originalIndex = findCard(id).index |
| | | const [{ isDragging }, drag] = useDrag({ |
| | | item: { type: 'form', id, originalIndex }, |
| | |
| | | <EditOutlined style={{color: '#1890ff'}} title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="formgroup" card={card}/> |
| | | <PasteComponent options={['form', 'forms']} updateConfig={(res) => pasteForm(res, id)} /> |
| | | <CloseOutlined className="close" type="close" onClick={close} /> |
| | | </div> |
| | | } trigger="hover"> |
| | |
| | | import Card from './card' |
| | | import './index.scss' |
| | | |
| | | const Container = ({list, labelSize, selectId, tabtype, handleList, handleGroup, closeGroup, selectGroup}) => { |
| | | const Container = ({list, labelSize, selectId, tabtype, handleList, handleGroup, handleForm, closeGroup, selectGroup}) => { |
| | | const [cards, setCards] = useState(list) |
| | | const moveCard = (id, atIndex) => { |
| | | const { card, index } = findCard(id) |
| | |
| | | closeGroup(card) |
| | | } |
| | | |
| | | const pasteForm = (res, id) => { |
| | | const { card } = findCard(id) |
| | | handleForm(card, res) |
| | | } |
| | | |
| | | const selectCard = id => { |
| | | const { card } = findCard(id) |
| | | selectGroup(card) |
| | |
| | | moveCard={moveCard} |
| | | closeCard={closeCard} |
| | | updateGroup={handleGroup} |
| | | pasteForm={pasteForm} |
| | | findCard={findCard} |
| | | selectCard={selectCard} |
| | | /> |
| | |
| | | let _config = fromJS(this.state.card).toJS() |
| | | |
| | | if (res.subButton) { |
| | | let _this = this |
| | | let that = this |
| | | |
| | | _config.subcards[0].setting.focus = res.focus |
| | | _config.subcards[0].setting.cache = res.cache |
| | |
| | | }) |
| | | |
| | | confirm({ |
| | | content: `替换表单及按钮配置?`, |
| | | content: '替换表单及按钮配置?', |
| | | onOk() { |
| | | _this.updateComponent(_config) |
| | | that.updateComponent(_config) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | return |
| | | } else if (res.fields) { |
| | | if (_config.subcards[0].fields.length > 0) { |
| | | let that = this |
| | | _config.subcards[0].fields = res.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | |
| | | confirm({ |
| | | title: '确定替换表单吗?', |
| | | content: '原表单将删除。', |
| | | onOk() { |
| | | that.updateComponent(_config) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | _config.subcards[0].fields = res.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | |
| | | this.updateComponent(_config) |
| | | } |
| | | |
| | | return |
| | | } |
| | | |
| | |
| | | <EditOutlined style={{color: '#1890ff'}} title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="simpleform" card={card}/> |
| | | <PasteComponent config={card} options={['form', 'formgroup']} updateConfig={this.pasteForm} /> |
| | | <PasteComponent config={card} options={['form', 'forms', 'formgroup']} updateConfig={this.pasteForm} /> |
| | | <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/> |
| | | <UserComponent config={card}/> |
| | | <DeleteOutlined className="close" title="删除组件" onClick={() => this.props.deletecomponent(card.uuid)} /> |
| | |
| | | this.updateComponent(_card) |
| | | } |
| | | |
| | | clearGroup = () => { |
| | | let group = fromJS(this.state.group).toJS() |
| | | let card = fromJS(this.state.card).toJS() |
| | | let _this = this |
| | | |
| | | group.fields = [] |
| | | |
| | | card.subcards = card.subcards.map(item => { |
| | | if (item.uuid === group.uuid) { |
| | | return group |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | confirm({ |
| | | content: `确定清空表单吗?`, |
| | | onOk() { |
| | | _this.setState({group}) |
| | | _this.updateComponent(card) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | parseForm = (g, res) => { |
| | | let _group = fromJS(g).toJS() |
| | | let _confirm = false |
| | | |
| | | if (res.copyType === 'form') { |
| | | let fieldrepet = false // 字段重复 |
| | | res.uuid = Utils.getuuid() |
| | | |
| | | _group.fields.forEach(item => { |
| | | if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { |
| | | fieldrepet = true |
| | | } |
| | | }) |
| | | |
| | | if (fieldrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | _group.fields.push(res) |
| | | } else { |
| | | if (_group.fields.length > 0) { |
| | | _confirm = true |
| | | } |
| | | |
| | | _group.fields = res.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | if (_confirm) { |
| | | let that = this |
| | | confirm({ |
| | | title: '确定替换表单吗?', |
| | | content: '原表单将删除。', |
| | | onOk() { |
| | | that.updateForms(_group) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | this.updateForms(_group) |
| | | } |
| | | } |
| | | |
| | | updateForms = (_group) => { |
| | | const { group } = this.state |
| | | let card = fromJS(this.state.card).toJS() |
| | | |
| | | card.subcards = card.subcards.map(item => { |
| | | if (item.uuid === _group.uuid) { |
| | | return _group |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | if (_group.uuid === group.uuid) { |
| | | this.setState({group: _group}) |
| | | this.updateComponent(card) |
| | | } else { |
| | | this.updateComponent(card) |
| | | } |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | |
| | | selectId={group ? group.uuid : ''} |
| | | handleList={this.changecards} |
| | | handleGroup={this.changeGroup} |
| | | handleForm={this.parseForm} |
| | | closeGroup={this.closeGroup} |
| | | selectGroup={this.selectGroup} |
| | | /> |
| | | {group ? <div className="form-area"> |
| | | <PlusOutlined className="plus" title="添加表单" onClick={this.addForm}/> |
| | | <FieldsComponent config={group} type="form" plusFields={this.plusFields} /> |
| | | <span style={{color: 'red', marginLeft: '30px', cursor: 'pointer'}} onClick={this.clearGroup}>清空</span> |
| | | <Switch checkedChildren="开" unCheckedChildren="关" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> |
| | | {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1列</Button> : null} |
| | | {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2列</Button> : null} |
| | |
| | | }) |
| | | } |
| | | |
| | | parseForm = (g, res) => { |
| | | let _group = fromJS(g).toJS() |
| | | let _confirm = false |
| | | |
| | | if (res.copyType === 'form') { |
| | | let fieldrepet = false // 字段重复 |
| | | res.uuid = Utils.getuuid() |
| | | |
| | | _group.fields.forEach(item => { |
| | | if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { |
| | | fieldrepet = true |
| | | } |
| | | }) |
| | | |
| | | if (fieldrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | _group.fields.push(res) |
| | | } else { |
| | | if (_group.fields.length > 0) { |
| | | _confirm = true |
| | | } |
| | | |
| | | _group.fields = res.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | if (_confirm) { |
| | | let that = this |
| | | confirm({ |
| | | title: '确定替换表单吗?', |
| | | content: '原表单将删除。', |
| | | onOk() { |
| | | that.updateForms(_group) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | this.updateForms(_group) |
| | | } |
| | | } |
| | | |
| | | updateForms = (_group) => { |
| | | const { group } = this.state |
| | | let card = fromJS(this.state.card).toJS() |
| | | |
| | | card.subcards = card.subcards.map(item => { |
| | | if (item.uuid === _group.uuid) { |
| | | return _group |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | if (_group.uuid === group.uuid) { |
| | | this.setState({group: _group}) |
| | | this.updateComponent(card) |
| | | } else { |
| | | this.updateComponent(card) |
| | | } |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | |
| | | selectId={group ? group.uuid : ''} |
| | | handleList={this.changecards} |
| | | handleGroup={this.updateGroup} |
| | | handleForm={this.parseForm} |
| | | closeGroup={this.closeGroup} |
| | | selectGroup={this.selectGroup} |
| | | /> |
| | |
| | | visible: false |
| | | } |
| | | |
| | | handleMenuClick = () => { |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | pasteSubmit = () => { |
| | | let appType = sessionStorage.getItem('appType') |
| | | let options = ['datacard', 'propcard', 'balcony', 'timeline', 'simpleform', 'stepform', 'tabform', 'normaltable', 'tablecard', 'line', 'bar', 'pie', 'scatter', 'sandbox'] |
| | |
| | | visible: false |
| | | } |
| | | |
| | | handleMenuClick = () => { |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | pasteSubmit = () => { |
| | | this.pasteFormRef.handleConfirm().then(res => { |
| | | if (res.copyType !== 'basetable') { |
| | |
| | | visible: false |
| | | } |
| | | |
| | | handleMenuClick = () => { |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | resetconfig = (item, config) => { |
| | | let _uuid = Utils.getuuid() |
| | | |
| | |
| | | pasteSubmit = () => { |
| | | const { options } = this.props |
| | | this.pasteFormRef.handleConfirm().then(res => { |
| | | |
| | | if (!options.includes(res.copyType)) { |
| | | notification.warning({ top: 92, message: '配置信息格式错误!', duration: 5 }) |
| | | return |
| | | } |
| | | |
| | | if (!this.props.config) { |
| | | this.props.updateConfig(res) |
| | | this.setState({visible: false}) |
| | | return |
| | | } |
| | | |
| | | let type = res.copyType |
| | | let config = fromJS(this.props.config).toJS() |
| | | |
| | |
| | | visible: false |
| | | } |
| | | |
| | | handleMenuClick = () => { |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | resetconfig = (item) => { |
| | | if (item.type === 'tabs') { |
| | | item.uuid = MenuUtils.getuuid() |
| | |
| | | import { DndProvider } from 'react-dnd' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import moment from 'moment' |
| | | import { Button, Card, Modal, Collapse, notification, Switch } from 'antd' |
| | | import { SettingOutlined } from '@ant-design/icons' |
| | | import { Button, Card, Modal, Collapse, notification, Switch, message } from 'antd' |
| | | import { SettingOutlined, CopyOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | }) |
| | | } |
| | | |
| | | plusFields = (items) => { |
| | | plusFields = (items, type) => { |
| | | let _config = fromJS(this.state.config).toJS() |
| | | |
| | | if (type === 'forms') { |
| | | if (_config.fields.length > 0) { |
| | | let that = this |
| | | _config.fields = items.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | |
| | | confirm({ |
| | | title: '确定替换表单吗?', |
| | | content: '原表单将删除。', |
| | | onOk() { |
| | | that.setState({ |
| | | config: _config |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | _config.fields = items.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | config: _config |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '粘贴成功!', |
| | | duration: 2 |
| | | }) |
| | | } |
| | | return |
| | | } |
| | | |
| | | _config.fields.push(...items) |
| | | |
| | |
| | | this.handleForm(items[0]) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | triggerCopy = () => { |
| | | const { config } = this.state |
| | | |
| | | let val = { |
| | | copyType: 'forms', |
| | | fields: config.fields || [] |
| | | } |
| | | |
| | | if (val.fields.length === 0) { |
| | | message.warning('表单元素不可为空!') |
| | | return |
| | | } |
| | | |
| | | try { |
| | | val = window.btoa(window.encodeURIComponent(JSON.stringify(val))) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | message.warning('复制失败,请重试!') |
| | | val = '' |
| | | } |
| | | |
| | | if (val) { |
| | | let oInput = document.createElement('input') |
| | | oInput.value = val |
| | | document.body.appendChild(oInput) |
| | | oInput.select() |
| | | document.execCommand('Copy') |
| | | document.body.removeChild(oInput) |
| | | |
| | | message.success('复制成功。') |
| | | } |
| | | } |
| | | |
| | | render () { |
| | |
| | | <Card title="表单配置" bordered={false} extra={ |
| | | <div> |
| | | <Button type="danger" onClick={this.clearConfig}>清空</Button> |
| | | <EditComponent options={['form']} type="formboard" config={this.state.config} plusFields={this.plusFields}/> |
| | | <EditComponent options={['form', 'forms']} type="formboard" config={this.state.config} plusFields={this.plusFields}/> |
| | | <Button type="primary" id="save-modal-config" loading={saving} onClick={this.submitConfig}>保存</Button> |
| | | <Button onClick={this.cancelConfig}>返回</Button> |
| | | </div> |
| | |
| | | <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2列</Button> |
| | | <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3列</Button> |
| | | <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4列</Button> |
| | | <CopyOutlined title="复制" onClick={this.triggerCopy} /> |
| | | <Switch checkedChildren="开" unCheckedChildren="关" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> |
| | | </div> |
| | | <div className="ant-modal-body"> |
| | |
| | | z-index: 10; |
| | | background: transparent; |
| | | min-height: 50px; |
| | | padding-right: 75px; |
| | | padding-right: 80px; |
| | | .ant-modal-title { |
| | | display: inline-block; |
| | | } |
| | | .anticon-copy { |
| | | position: absolute; |
| | | top: 18px; |
| | | color: #26C281; |
| | | right: 65px; |
| | | font-size: 16px; |
| | | } |
| | | .ant-switch { |
| | | position: absolute; |
| | | top: 15px; |
| | |
| | | import { DndProvider } from 'react-dnd' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import moment from 'moment' |
| | | import { Button, Modal, Collapse, notification, Switch } from 'antd' |
| | | import { Button, Modal, Collapse, notification, Switch, message } from 'antd' |
| | | import { LeftOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | |
| | | }) |
| | | } |
| | | |
| | | insert = (config) => { |
| | | insert = (config, type) => { |
| | | if (type === 'forms') { |
| | | let _config = fromJS(this.state.config).toJS() |
| | | |
| | | if (_config.fields.length > 0) { |
| | | let that = this |
| | | _config.fields = config.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | |
| | | confirm({ |
| | | title: '确定替换表单吗?', |
| | | content: '原表单将删除。', |
| | | onOk() { |
| | | that.setState({ |
| | | config: _config |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | _config.fields = config.fields.map(item => { |
| | | item.uuid = Utils.getuuid() |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | config: _config |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '粘贴成功!', |
| | | duration: 2 |
| | | }) |
| | | } |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | config |
| | | }, () => { |
| | | this.handleForm(config.fields[config.fields.length - 1]) |
| | | }) |
| | | } |
| | | |
| | | triggerCopy = () => { |
| | | const { config } = this.state |
| | | |
| | | let val = { |
| | | copyType: 'forms', |
| | | fields: config.fields || [] |
| | | } |
| | | |
| | | if (val.fields.length === 0) { |
| | | message.warning('表单元素不可为空!') |
| | | return |
| | | } |
| | | |
| | | try { |
| | | val = window.btoa(window.encodeURIComponent(JSON.stringify(val))) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | message.warning('复制失败,请重试!') |
| | | val = '' |
| | | } |
| | | |
| | | if (val) { |
| | | let oInput = document.createElement('input') |
| | | oInput.value = val |
| | | document.body.appendChild(oInput) |
| | | oInput.select() |
| | | document.execCommand('Copy') |
| | | document.body.removeChild(oInput) |
| | | |
| | | message.success('复制成功。') |
| | | } |
| | | } |
| | | |
| | | clearConfig = () => { |
| | |
| | | <Button icon="setting" onClick={this.changeSetting}>设置</Button> |
| | | <Button type="primary" id="save-modal-config" loading={saving} onClick={this.submitConfig}>保存</Button> |
| | | <Button onClick={this.cancelConfig}>返回</Button> |
| | | <Button type="primary" style={{background: '#26C281', border: 'none'}} onClick={this.triggerCopy}>复制</Button> |
| | | <PasteComponent config={config} updateConfig={this.insert} /> |
| | | <Button type="danger" onClick={this.clearConfig}>清空</Button> |
| | | <Switch checkedChildren="开" unCheckedChildren="关" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> |
| | |
| | | pasteSubmit = () => { |
| | | const { config } = this.props |
| | | this.pasteFormRef.handleConfirm().then(res => { |
| | | if (res.copyType !== 'form') { |
| | | if (res.copyType === 'forms') { |
| | | this.props.updateConfig(res, 'forms') |
| | | this.setState({visible: false}) |
| | | return |
| | | } else if (res.copyType !== 'form') { |
| | | notification.warning({ top: 92, message: '配置信息格式错误!', duration: 5 }) |
| | | return |
| | | } |
| | |
| | | delActions: [], // 删除按钮列表 |
| | | copyActions: [], // 复制按钮组 |
| | | tabviews: [], // 所有标签页 |
| | | thawButtons: [], // 已选择要解冻的按钮 |
| | | activeKey: '0', // 默认展开基本信息 |
| | | chartview: null, // 当前视图 |
| | | openEdition: '', // 编辑版本标记,防止多人操作 |
| | |
| | | */ |
| | | submitConfig = () => { |
| | | const { menu } = this.props |
| | | const { delActions, thawButtons, openEdition } = this.state |
| | | const { delActions, openEdition } = this.state |
| | | |
| | | let _config = fromJS(this.state.config).toJS() |
| | | |
| | |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | |
| | | if (thawButtons.length > 0) { |
| | | let defers = thawButtons.map(item => { |
| | | return new Promise((resolve) => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_MainMenu_ReDel', |
| | | MenuID: item |
| | | }).then(res => { |
| | | if (res.status) { |
| | | resolve('') |
| | | } else { |
| | | resolve(res.message) |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | return Promise.all(defers) |
| | | } else { |
| | | return true |
| | | } |
| | | return true |
| | | }).then(res => { |
| | | if (res === true || res === false) return res |
| | | |
| | |
| | | }) |
| | | return false |
| | | } else { |
| | | this.setState({ |
| | | thawButtons: [] |
| | | }) |
| | | return true |
| | | } |
| | | }).then(resp => { |
| | |
| | | */ |
| | | editConfig = (res) => { |
| | | this.setState({ |
| | | thawButtons: res.thawButtons, |
| | | config: res.config |
| | | }) |
| | | } |
| | |
| | | <Unattended config={config} updateConfig={this.updateconfig}/> |
| | | <Versions MenuId={menu.MenuID} open_edition={openEdition} updateConfig={this.refreshConfig}/> |
| | | <ReplaceField type="table" config={config} updateConfig={this.updateconfig}/> |
| | | <EditComponent type="table" options={['search', 'form', 'action', 'columns']} config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> |
| | | <EditComponent type="table" options={['search', 'form', 'action', 'columns']} config={this.state.config} refresh={this.editConfig}/> |
| | | <UpdateTable config={config}/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>保存</Button> |
| | |
| | | }) |
| | | } |
| | | |
| | | |
| | | render () { |
| | | const { editAction } = this.props |
| | | const { config, openEdition } = this.state |
| | |
| | | delActions: [], // 删除按钮列表 |
| | | copyActions: [], // 复制按钮组 |
| | | tabviews: [], // 所有标签页 |
| | | thawButtons: [], // 已选择要解冻的按钮 |
| | | activeKey: '0', // 默认展开基本信息 |
| | | chartview: null, // 当前视图 |
| | | openEdition: '', // 编辑版本标记,防止多人操作 |
| | |
| | | * @description 标签页保存 |
| | | */ |
| | | submitConfig = () => { |
| | | const { delActions, thawButtons, openEdition } = this.state |
| | | const { delActions, openEdition } = this.state |
| | | let _config = fromJS(this.state.config).toJS() |
| | | let copyreg = /\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/ig |
| | | |
| | |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | |
| | | if (thawButtons.length > 0) { |
| | | let defers = thawButtons.map(item => { |
| | | return new Promise((resolve) => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_MainMenu_ReDel', |
| | | MenuID: item |
| | | }).then(res => { |
| | | if (res.status) { |
| | | resolve('') |
| | | } else { |
| | | resolve(res.message) |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | return Promise.all(defers) |
| | | } else { |
| | | return true |
| | | } |
| | | return true |
| | | }).then(res => { |
| | | if (res === true || res === false) return res |
| | | |
| | |
| | | }) |
| | | return false |
| | | } else { |
| | | this.setState({ |
| | | thawButtons: [] |
| | | }) |
| | | return true |
| | | } |
| | | }).then(resp => { |
| | |
| | | */ |
| | | updateConfig = (res) => { |
| | | this.setState({ |
| | | thawButtons: res.thawButtons, |
| | | config: res.config |
| | | }) |
| | | } |
| | |
| | | <div> |
| | | <Versions MenuId={config.uuid} open_edition={openEdition} updateConfig={this.refreshConfig}/> |
| | | <ReplaceField type="table" config={config} updateConfig={this.updateconfig}/> |
| | | <EditComponent type="table" options={['search', 'form', 'action', 'columns']} config={config} MenuID={config.uuid} thawButtons={this.state.thawButtons} refresh={this.updateConfig}/> |
| | | <EditComponent type="table" options={['search', 'form', 'action', 'columns']} config={config} refresh={this.updateConfig}/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>保存</Button> |
| | | <Button onClick={this.cancelConfig}>返回</Button> |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Modal, Spin, notification, Button } from 'antd' |
| | | import { UnlockOutlined, SnippetsOutlined } from '@ant-design/icons' |
| | | import { Modal, notification, Button } from 'antd' |
| | | import { SnippetsOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import PasteForm from '@/templates/zshare/pasteform' |
| | | import TransferForm from '@/templates/zshare/basetransferform' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | class editComponent extends Component { |
| | | static propTpyes = { |
| | | options: PropTypes.array, |
| | | MenuID: PropTypes.any, |
| | | config: PropTypes.object, |
| | | thawButtons: PropTypes.any, |
| | | refresh: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | thawVisible: false, |
| | | thawbtnlist: null, |
| | | pasteVisible: false, |
| | | targetKeys: [] |
| | | } |
| | | |
| | | /** |
| | | * @description 解冻按钮 |
| | | */ |
| | | handleThaw = () => { |
| | | const { MenuID } = this.props |
| | | |
| | | this.setState({ |
| | | thawVisible: true, |
| | | targetKeys: [] |
| | | }) |
| | | |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_FrozenMenu', |
| | | ParentID: MenuID, |
| | | TYPE: 40 |
| | | }).then(res => { |
| | | if (res.status) { |
| | | let _list = [] |
| | | |
| | | res.data.forEach(menu => { |
| | | let _conf = '' |
| | | |
| | | if (menu.ParentParam) { |
| | | try { |
| | | _conf = JSON.parse(window.decodeURIComponent(window.atob(menu.ParentParam))) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | _conf = '' |
| | | } |
| | | } |
| | | |
| | | if (_conf) { |
| | | _list.push({ |
| | | key: menu.MenuID, |
| | | title: menu.MenuName, |
| | | btnParam: _conf |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | thawbtnlist: _list |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 解冻按钮提交 |
| | | */ |
| | | thawBtnSubmit = () => { |
| | | const { thawButtons } = this.props |
| | | const { thawbtnlist, targetKeys } = this.state |
| | | let config = fromJS(this.props.config).toJS() |
| | | |
| | | if (targetKeys.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择解冻按钮', |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | | thawbtnlist.forEach(item => { |
| | | if (targetKeys.includes(item.key)) { |
| | | config.action.push(item.btnParam) |
| | | } |
| | | }) |
| | | |
| | | this.props.refresh({ |
| | | type: 'thaw', |
| | | thawButtons: [...thawButtons, ...targetKeys], |
| | | config: config |
| | | }) |
| | | |
| | | this.setState({ |
| | | thawVisible: false, |
| | | targetKeys: [] |
| | | }) |
| | | } |
| | | visible: false |
| | | } |
| | | |
| | | pasteSubmit = () => { |
| | |
| | | } |
| | | |
| | | this.props.plusFields([res]) |
| | | } else if (res.copyType === 'forms') { |
| | | this.props.plusFields(res, 'forms') |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | return |
| | | } |
| | | this.setState({ |
| | | pasteVisible: false |
| | | visible: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | handleMenuClick = e => { |
| | | if (e.key === 'thaw') { |
| | | this.handleThaw() |
| | | } else if (e.key === 'paste') { |
| | | this.setState({pasteVisible: true}) |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { MenuID } = this.props |
| | | |
| | | return ( |
| | | <div style={{display: 'inline-block'}}> |
| | | {MenuID ? <Button className="mk-border-green" onClick={this.handleThaw}><UnlockOutlined /> 解冻按钮</Button> : null} |
| | | <Button style={{borderColor: '#40a9ff', color: '#40a9ff'}} onClick={() => this.setState({pasteVisible: true})}><SnippetsOutlined /> 粘贴</Button> |
| | | {/* 解冻按钮模态框 */} |
| | | <Modal |
| | | title="解冻按钮" |
| | | visible={this.state.thawVisible} |
| | | onOk={this.thawBtnSubmit} |
| | | onCancel={() => {this.setState({thawVisible: false, thawbtnlist: null, targetKeys: []})}} |
| | | destroyOnClose |
| | | > |
| | | {!this.state.thawbtnlist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />} |
| | | {this.state.thawbtnlist && <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawbtnlist}/>} |
| | | </Modal> |
| | | <Button style={{borderColor: '#40a9ff', color: '#40a9ff'}} onClick={() => this.setState({visible: true})}><SnippetsOutlined /> 粘贴</Button> |
| | | {/* 按钮配置信息粘贴复制 */} |
| | | <Modal |
| | | title="粘贴" |
| | | visible={this.state.pasteVisible} |
| | | visible={this.state.visible} |
| | | width={600} |
| | | maskClosable={false} |
| | | onOk={this.pasteSubmit} |
| | | onCancel={() => {this.setState({pasteVisible: false})}} |
| | | onCancel={() => {this.setState({visible: false})}} |
| | | destroyOnClose |
| | | > |
| | | <PasteForm wrappedComponentRef={(inst) => this.pasteFormRef = inst} inputSubmit={this.pasteSubmit}/> |
| | |
| | | cursor: pointer; |
| | | font-size: 14px; |
| | | } |
| | | >.ant-row >.ant-col { |
| | | display: inline-block; |
| | | vertical-align: top; |
| | | float: none; |
| | | } |
| | | } |
| | |
| | | * @description 按钮重置 |
| | | */ |
| | | static resetBtn (btn, commonId) { |
| | | if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.execMode === 'pop')) { |
| | | if (btn.modal && btn.modal.fields.length > 0) { |
| | | btn.modal.fields = btn.modal.fields.map(m => { |
| | | m.uuid = this.getuuid() |
| | | return m |
| | | }) |
| | | } |
| | | } |
| | | if (btn.switchTab && btn.switchTab.length > 0) { |
| | | btn.switchTab = btn.switchTab.map(m => md5(commonId + m)) |
| | | } |
| | |
| | | card.elements = card.elements.map(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (cell.modal && cell.modal.fields.length > 0) { |
| | | cell.modal.fields = cell.modal.fields.map(m => { |
| | | m.uuid = this.getuuid() |
| | | return m |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | cell.uuid = this.getuuid() |
| | | } |
| | |
| | | card.backElements = card.backElements.map(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (cell.modal && cell.modal.fields.length > 0) { |
| | | cell.modal.fields = cell.modal.fields.map(m => { |
| | | m.uuid = this.getuuid() |
| | | return m |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | cell.uuid = this.getuuid() |
| | | } |
| | |
| | | item.elements = item.elements.map(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (cell.modal && cell.modal.fields.length > 0) { |
| | | cell.modal.fields = cell.modal.fields.map(m => { |
| | | m.uuid = this.getuuid() |
| | | return m |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | cell.uuid = this.getuuid() |
| | | } |
| | |
| | | } |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (cell.modal && cell.modal.fields.length > 0) { |
| | | cell.modal.fields = cell.modal.fields.map(m => { |
| | | m.uuid = this.getuuid() |
| | | return m |
| | | }) |
| | | } |
| | | } |
| | | |
| | | return cell |
| | | }) |
| | |
| | | } |
| | | item.action = item.action.map(cell => { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (cell.modal && cell.modal.fields.length > 0) { |
| | | cell.modal.fields = cell.modal.fields.map(m => { |
| | | m.uuid = this.getuuid() |
| | | return m |
| | | }) |
| | | } |
| | | } |
| | | |
| | | return cell |
| | | }) |