From c71b5c29fea2b90ffac2045ce45bc1bd74236446 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 二月 2021 09:57:02 +0800 Subject: [PATCH] 2021-02-18 --- src/tabviews/zshare/mutilform/index.jsx | 6 src/views/mobmanage/index.jsx | 132 ++++++++++++++++++++++---- src/templates/modalconfig/settingform/index.jsx | 4 src/templates/zshare/verifycard/callbackcustomscript/index.jsx | 7 - src/views/mobmanage/mutilform/index.jsx | 122 ++++++++++++++++++++++++ src/views/mobmanage/mutilform/index.scss | 4 src/templates/zshare/verifycard/customscript/index.jsx | 2 7 files changed, 245 insertions(+), 32 deletions(-) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 2c79f04..8cb2174 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -229,7 +229,7 @@ if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && item.resourceType === '1') { deForms.push(item) } else if (['select', 'link', 'radio'].includes(item.type) && item.resourceType !== '1') { // 閫変腑绗竴椤� - if (item.initval && item.initval.indexOf('$first') > -1) { + if (typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { item.initval = item.options[0] ? item.options[0].Value : '' } } @@ -462,7 +462,7 @@ } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } - if (['select', 'link', 'radio'].includes(item.type) && item.initval && item.initval.indexOf('$first') > -1) { // 閫変腑绗竴椤� + if (['select', 'link', 'radio'].includes(item.type) && typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { // 閫変腑绗竴椤� item.initval = item.options[0] ? item.options[0].Value : '' values.push({field: item.field, value: item.initval}) } @@ -569,7 +569,7 @@ } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } - if (['select', 'link', 'radio'].includes(item.type) && item.initval && item.initval.indexOf('$first') > -1) { // 閫変腑绗竴椤� + if (['select', 'link', 'radio'].includes(item.type) && typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { // 閫変腑绗竴椤� item.initval = item.options[0] ? item.options[0].Value : '' values.push({field: item.field, value: item.initval}) } diff --git a/src/templates/modalconfig/settingform/index.jsx b/src/templates/modalconfig/settingform/index.jsx index c5af7aa..e4c44a3 100644 --- a/src/templates/modalconfig/settingform/index.jsx +++ b/src/templates/modalconfig/settingform/index.jsx @@ -23,14 +23,14 @@ if (config.groups.length > 0) { config.groups.forEach(group => { group.sublist.forEach(item => { - if (item.field && (item.type === 'text' || item.type === 'number') && item.hidden !== 'true' && item.readonly !== 'true') { + if (item.field && ['select', 'link', 'text', 'number'].includes(item.type) && item.hidden !== 'true' && item.readonly !== 'true') { fields.push(item) } }) }) } else if (config.fields.length > 0) { config.fields.forEach(f => { - if (f.field && (f.type === 'text' || f.type === 'number') && f.hidden !== 'true' && f.readonly !== 'true') { + if (f.field && ['select', 'link', 'text', 'number'].includes(f.type) && f.hidden !== 'true' && f.readonly !== 'true') { fields.push(f) } }) diff --git a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx index aca9271..bdfb92e 100644 --- a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx +++ b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx @@ -258,12 +258,7 @@ </Button> </Col> <Col span={24} className="sql"> - <Form.Item label={ - <Tooltip placement="topLeft" title={'鏁版嵁妫�鏌ユ浛鎹㈢ $check@ -> /* 鎴� \'\'銆� @check$ -> */ 鎴� \'\''}> - <Icon type="question-circle" /> - sql - </Tooltip> - }> + <Form.Item label="sql"> {getFieldDecorator('sql', { initialValue: '', rules: [ diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index 7cd554e..e94e463 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -267,7 +267,7 @@ </Col> <Col span={24} className="sql"> <Form.Item label={ - <Tooltip placement="topLeft" title={'鏁版嵁妫�鏌ユ浛鎹㈢ $check@ -> /* 鎴� \'\'銆� @check$ -> */ 鎴� \'\''}> + <Tooltip placement="topLeft" title={'鏁版嵁妫�鏌ユ浛鎹㈢ $check@ -> \'\'銆� @check$ -> \'\'锛孍rrorCode绛変簬C鏃� $check@ -> /*銆� @check$ -> */'}> <Icon type="question-circle" /> sql </Tooltip> diff --git a/src/views/mobmanage/index.jsx b/src/views/mobmanage/index.jsx index b5249f3..261e72c 100644 --- a/src/views/mobmanage/index.jsx +++ b/src/views/mobmanage/index.jsx @@ -1,19 +1,20 @@ import React, {Component} from 'react' // import { fromJS } from 'immutable' -import { Spin, notification, Button, Table } from 'antd' +import { Spin, notification, Button, Table, Modal } from 'antd' import Api from '@/api' -// import Utils from '@/utils/utils.js' +import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' import './index.scss' const Header = asyncComponent(() => import('@/mob/header')) -// const MobCard = asyncComponent(() => import('@/mob/mobcard')) +const MutilForm = asyncComponent(() => import('./mutilform')) class AppManage extends Component { state = { loading: false, applist: [], + appsublist: [], columns: [ { title: '搴旂敤鍚嶇О', dataIndex: 'remark', key: 'remark', align: 'center' }, { title: '搴旂敤鍙傛暟', dataIndex: 'kei_no', key: 'kei_no', align: 'center' }, @@ -21,7 +22,7 @@ title: 'Action', key: 'action', align: 'center', - render: (text, record) => (<Button type="link" style={{color: '#ff4d4f'}}>鍒犻櫎</Button>), + render: (text, record) => (<Button type="link" onClick={() => this.deleteApp(record)} style={{color: '#ff4d4f'}}>鍒犻櫎</Button>), }, ], subcolumns: [ @@ -48,7 +49,12 @@ title: 'Action', key: 'action', align: 'center', - render: (text, record) => (<Button type="link" style={{color: '#ff4d4f'}}>鍒犻櫎</Button>), + render: (text, record) => ( + <div> + <Button type="link" onClick={() => this.deleteSubApp(record)} style={{color: '#ff4d4f'}}>鍒犻櫎</Button> + <Button type="link" onClick={() => this.jumpMenu(record)}>缂栬緫搴旂敤</Button> + </div> + ) }, ], selectApp: null, @@ -104,12 +110,21 @@ }) } + deleteApp = (record) => { + console.log(record) + } + + deleteSubApp = (record) => { + console.log(record) + } + jumpMenu = (card) => { - let _type = 'mob' - if (card.type === 'pc') { - _type = 'pc' - } - this.props.history.replace(`/mobdesign/${card.uuid}/${_type}/${card.keiNo}/${card.name}`) + console.log(card) + // let _type = 'mob' + // if (card.type === 'pc') { + // _type = 'pc' + // } + // this.props.history.replace(`/mobdesign/${card.uuid}/${_type}/${card.keiNo}/${card.name}`) } /** @@ -126,7 +141,6 @@ * */ onSubChange = selectedSubRowKeys => { - this.setState({ selectedSubRowKeys }) } @@ -134,7 +148,7 @@ * @description 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝 鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔 */ changeRow = (record) => { - this.setState({ selectedRowKeys: [record.ID], selectApp: record }) + this.setState({ selectedRowKeys: [record.ID], selectApp: record, appsublist: record.sublist || [] }) } /** @@ -144,8 +158,72 @@ this.setState({ selectedSubRowKeys: [record.ID], selectSubApp: record }) } + trigerApp = (type) => { + if ((type === 'appedit' && !this.state.selectApp) || (type === 'subappedit' && !this.state.selectSubApp)) { + notification.warning({ + top: 92, + message: '璇烽�夋嫨闇�瑕佺紪杈戠殑搴旂敤锛�', + duration: 5 + }) + return + } + + this.setState({ + visible: type + }) + } + + + submitCard = () => { + const { card } = this.state + + this.mobcardRef.handleConfirm().then(res => { + this.setState({ + confirmloading: true + }) + + let param = { + func: 's_kei_addupt', + ID: card ? card.uuid : Utils.getuuid(), + TypeName: res.type, + remark: res.name, + kei_no: res.keiNo + } + + Api.getCloudConfig(param).then(result => { + if (result.status) { + notification.success({ + top: 92, + message: card ? '淇敼鎴愬姛锛�' : '娣诲姞鎴愬姛锛�', + duration: 5 + }) + + this.setState({ + confirmloading: false, + visible: false, + loading: true + }) + this.getMobCards() + } else { + this.setState({ + confirmloading: false + }) + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } + }, () => { + this.setState({ + confirmloading: false + }) + }) + }) + } + render () { - const { loading, columns, applist, selectedRowKeys, selectedSubRowKeys, selectApp, subcolumns } = this.state + const { loading, visible, columns, applist, appsublist, selectedRowKeys, selectedSubRowKeys, subcolumns, selectApp, selectSubApp } = this.state return ( <div className="mk-app-manage"> @@ -158,8 +236,8 @@ } <div className="app-table"> <div className="app-action"> - <Button className="mk-green">娣诲姞</Button> - <Button className="mk-purple">淇敼</Button> + <Button className="mk-green" onClick={() => this.trigerApp('appplus')}>娣诲姞</Button> + <Button className="mk-purple" onClick={() => this.trigerApp('appedit')}>淇敼</Button> </div> <Table rowKey="ID" @@ -173,19 +251,33 @@ <div className="app-table"> <div className="sub-app-title"><span>瀛愬簲鐢�</span></div> <div className="app-action"> - <Button className="mk-green">娣诲姞</Button> - <Button className="mk-purple">淇敼</Button> + <Button className="mk-green" onClick={() => this.trigerApp('subappplus')}>娣诲姞</Button> + <Button className="mk-purple" onClick={() => this.trigerApp('subappedit')}>淇敼</Button> </div> <Table rowKey="ID" columns={subcolumns} - dataSource={selectApp ? selectApp.sublist : []} + dataSource={appsublist} pagination={false} - rowSelection={{ type: 'radio', selectedSubRowKeys, onChange: this.onSubChange }} + rowSelection={{ type: 'radio', selectedRowKeys: selectedSubRowKeys, onChange: this.onSubChange }} onRow={(record) => ({ onClick: () => {this.changeSubRow(record)} })} /> </div> - {/* <MobCard jumpMenu={this.jumpMenu}/> */} + <Modal + // className="mob-card-modal" + title={'缂栬緫搴旂敤'} + width={'600px'} + maskClosable={false} + visible={!!visible} + onCancel={() => this.setState({visible: ''})} + confirmLoading={this.state.confirmloading} + onOk={this.submitCard} + cancelText="鍙栨秷" + okText="纭畾" + destroyOnClose + > + <MutilForm card={visible === 'appedit' ? selectApp : (visible === 'subappedit' ? selectSubApp : '')} wrappedComponentRef={(inst) => this.mobcardRef = inst} inputSubmit={this.submitCard} /> + </Modal> </div> ) } diff --git a/src/views/mobmanage/mutilform/index.jsx b/src/views/mobmanage/mutilform/index.jsx new file mode 100644 index 0000000..dbdf288 --- /dev/null +++ b/src/views/mobmanage/mutilform/index.jsx @@ -0,0 +1,122 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, Input, Select, Radio } from 'antd' +import './index.scss' + +class MainSearch extends Component { + static propTpyes = { + card: PropTypes.any, // 缂栬緫搴旂敤 + inputSubmit: PropTypes.func // input鍥炶溅鎻愪氦 + } + + state = {} + + /** + * @description 鑾峰彇琛ㄥ崟鍊� + */ + handleConfirm = () => { + return new Promise(resolve => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + resolve(values) + } + }) + }) + } + + /** + * @description 鍥炶溅鎻愪氦 + */ + handleSubmit = (e) => { + e.preventDefault() + this.props.inputSubmit() + } + + render() { + const { card } = this.props + const { getFieldDecorator } = this.props.form + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + return ( + <Form {...formItemLayout} className="mob-card-edit-form"> + <Row gutter={24}> + <Col span={24}> + <Form.Item label="搴旂敤鍚�"> + {getFieldDecorator('name', { + initialValue: card ? card.name : '', + rules: [{ + required: true, + message: '璇疯緭鍏ュ簲鐢ㄥ悕!' + }, { + max: 20, + message: '搴旂敤鍚嶄笉鍙秴杩�20涓瓧绗�!' + }] + })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="搴旂敤绫诲瀷"> + {getFieldDecorator('type', { + initialValue: card ? card.type : 'mob', + rules: [ + { + required: true, + message: '璇烽�夋嫨搴旂敤绫诲瀷!' + } + ] + })( + <Select> + <Select.Option value="mob">绉诲姩绔�</Select.Option> + <Select.Option value="pc">PC绔�</Select.Option> + </Select> + )} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="搴旂敤缂栫爜"> + {getFieldDecorator('keiNo', { + initialValue: card ? card.keiNo : '', + rules: [{ + required: true, + message: '璇疯緭鍏ュ簲鐢ㄧ紪鐮�!' + }, { + pattern: /^[a-zA-Z_]*$/ig, + message: '搴旂敤缂栫爜鍙厑璁稿寘鍚ぇ灏忓啓瀛楁瘝鍙奯!' + }, { + max: 20, + message: '搴旂敤缂栫爜涓嶅彲瓒呰繃20涓瓧绗�!' + }] + })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="鏉冮檺绠$悊"> + {getFieldDecorator('role_manage', { + initialValue: card ? card.role_manage || 'false' : 'false', + rules: [{ + required: true, + message: '璇烽�夋嫨鏄惁鍚敤鏉冮檺绠$悊!' + }] + })( + <Radio.Group> + <Radio value="true">鍚敤</Radio> + <Radio value="false">涓嶅惎鐢�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + </Row> + </Form> + ) + } +} + +export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/views/mobmanage/mutilform/index.scss b/src/views/mobmanage/mutilform/index.scss new file mode 100644 index 0000000..28344fe --- /dev/null +++ b/src/views/mobmanage/mutilform/index.scss @@ -0,0 +1,4 @@ +.mob-card-edit-form { + padding: 0px 24px 20px; + +} \ No newline at end of file -- Gitblit v1.8.0