| | |
| | | import React, {Component} from 'react' |
| | | import { fromJS } from 'immutable' |
| | | import { Spin, notification, Input, Button, Table, Modal, ConfigProvider, Typography, Row, Col, Tooltip, Icon } from 'antd' |
| | | import { Spin, notification, Input, Button, Table, Modal, ConfigProvider, Typography, Row, Col, Tooltip } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | import md5 from 'md5' |
| | | import enUS from 'antd/es/locale/en_US' |
| | |
| | | const ScriptForm = asyncComponent(() => import('./scriptform')) |
| | | const SubMutilForm = asyncComponent(() => import('./submutilform')) |
| | | |
| | | let base_url = '' |
| | | if (process.env.NODE_ENV === 'production') { |
| | | base_url = document.location.origin + '/' + window.GLOB.service |
| | | } else { |
| | | base_url = window.GLOB.location + '/' + window.GLOB.service |
| | | } |
| | | |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | |
| | | const skinStyle = { |
| | | bg_black_style_blue: {name: '蓝色', color: '#1890ff'}, |
| | | bg_black_style_red: {name: '红色', color: '#f5222d'}, |
| | |
| | | bg_black_style_purple: {name: '紫色', color: '#722ed1'}, |
| | | bg_black_style_magenta: {name: '洋红色', color: '#eb2f96'}, |
| | | bg_black_style_grass_green: {name: '草绿色', color: '#aeb303'}, |
| | | bg_black_style_deep_red: {name: '深红色', color: '#c32539'} |
| | | bg_black_style_deep_red: {name: '深红色', color: '#c32539'}, |
| | | bg_black_style_deep_blue: {name: '深红色', color: '#1d3661'} |
| | | } |
| | | |
| | | class AppManage extends Component { |
| | |
| | | forbid = false |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | if (sessionStorage.getItem('devError') === 'true') { |
| | | sessionStorage.clear() |
| | | window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') |
| | | window.location.reload() |
| | | return |
| | | } |
| | | |
| | | if (!sessionStorage.getItem('UserID')) { |
| | | this.props.history.replace('/login') |
| | | return |
| | | } |
| | | |
| | | window.GLOB.developing = true |
| | | |
| | | document.body.className = '' |
| | | this.getAppList() |
| | | this.getSmStemp() |
| | |
| | | }) |
| | | |
| | | let kei_no = res.appId.split(',')[1] |
| | | let lang = res.subAppId.split(',')[1] |
| | | let kei_no_detail = res.subAppId.split(',')[2] |
| | | let lang = res.subAppId ? res.subAppId.split(',')[1] : '' |
| | | let kei_no_detail = res.subAppId ? res.subAppId.split(',')[2] : '' |
| | | |
| | | let param = { |
| | | func: 's_sVersionDetail_CloudAdd', |
| | |
| | | item.sublist = item.data_detail || [] |
| | | item.sublist = item.sublist.map(cell => { |
| | | cell.ID = cell.d_id |
| | | |
| | | if (cell.customize_param) { |
| | | let _param = {} |
| | | try { |
| | | _param = JSON.parse(window.decodeURIComponent(window.atob(cell.customize_param))) |
| | | } catch (e) { |
| | | _param = {} |
| | | } |
| | | // cell.copyright = _param.copyright || '' |
| | | // cell.logo = _param.logo || '' |
| | | cell.apptype = _param.apptype || '' |
| | | cell.delay = _param.delay || 0 |
| | | cell.statusBarColor = _param.statusBarColor || 'black' |
| | | cell.sysBgColor = _param.sysBgColor || '#ffffff' |
| | | cell.direction = _param.direction || 'vertical' |
| | | cell.adapter = _param.adapter || '' |
| | | cell.topHeight = _param.topHeight || '' |
| | | cell.share = _param.share || 'false' // 分享 |
| | | cell.share_des = _param.share_des || '' // 分享描述 |
| | | cell.share_url = _param.share_url || '' // 分享图片 |
| | | cell.share_link = _param.share_link || '' // 分享链接 |
| | | |
| | | if (cell.adapter && (cell.adapter === 'true' || cell.adapter === 'false')) { |
| | | cell.adapter = '' |
| | | } |
| | | |
| | | cell.userbind = _param.userbind || '' |
| | | cell.instantMessage = _param.instantMessage || '' |
| | | } |
| | | |
| | | if (cell.user_binding !== 'true') { |
| | | cell.user_binding = 'false' |
| | | } |
| | | if (cell.share !== 'true') { |
| | | cell.share = 'false' |
| | | } |
| | | |
| | | if (!cell.adapter && cell.apptype) { |
| | | cell.adapter = 'app' |
| | | } |
| | | |
| | | return cell |
| | | }) |
| | | |
| | |
| | | }) |
| | | |
| | | if (!selectApp && applist[0]) { |
| | | let _href = window.location.href.split('#')[0] + 'app_record' |
| | | let record = localStorage.getItem(_href) |
| | | record = record ? JSON.parse(record) : null |
| | | |
| | | if (record && record.dates) { |
| | | let ids = applist.map(item => item.ID) |
| | | let reset = false |
| | | |
| | | Object.keys(record.dates).forEach(key => { |
| | | if (!ids.includes(key)) { |
| | | delete record.dates[key] |
| | | reset = true |
| | | } |
| | | }) |
| | | |
| | | applist.sort((a, b) => { |
| | | return (record.dates[b.ID] || 0) - (record.dates[a.ID] || 0) |
| | | }) |
| | | |
| | | if (reset) { |
| | | localStorage.setItem(_href, JSON.stringify(record)) |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!selectApp && applist[0]) { |
| | | selectApp = applist[0] |
| | | } |
| | | |
| | | |
| | | this.setState({ |
| | | loading: false, |
| | | applist: applist, |
| | | selectApp |
| | | }) |
| | | |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | |
| | | } |
| | | |
| | | getSmStemp = () => { |
| | | let _sql = `select ID,TemplateCode,SignName from (select * from bd_msn_sms_temp where deleted=0 and status=20 ) a |
| | | inner join (select openid from sapp where id='${window.GLOB.appkey}') b |
| | | let _sql = `select ID,TemplateCode,SignName+'_'+describe as SignName from (select * from bd_msn_sms_temp where deleted=0 and status=20 ) a |
| | | inner join (select openid from sapp where id='${window.GLOB.appkey}') b |
| | | on a.openid=b.openid` |
| | | |
| | | _sql = Utils.formatOptions(_sql) |
| | |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证 |
| | | |
| | | Api.getSystemConfig(param).then(res => { |
| | | Api.getCloudConfig(param).then(res => { |
| | | let msgs = [] |
| | | if (!res.status) { |
| | | notification.warning({ |
| | |
| | | }) |
| | | _this.getAppList() |
| | | } else { |
| | | if (result.message.indexOf('kei_no已被菜单使用,不可删除') > -1) { |
| | | result.message = 'kei_no已被菜单使用,不可删除' |
| | | } |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | |
| | | exec_type: 'y', |
| | | remark: selectApp.remark, |
| | | kei_no: selectApp.kei_no, |
| | | cus_param_type: 'A', |
| | | LText: '' |
| | | } |
| | | |
| | | param.del_typename = record.typename |
| | | param.lang = record.lang |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | let sublist = fromJS(selectApp.sublist).toJS() |
| | | sublist = sublist.filter(item => item.ID !== record.ID) |
| | | sublist = sublist.map(item => { |
| | | if (item.typename !== 'pc') { |
| | | item.userbind = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{8}/, 'userbind') |
| | | item.instantMessage = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{14}/, 'instantmessage') |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | // param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','${item.login_types || 'true'}','${item.link_type || 'true'}','${item.role_type || 'true'}','${item.lang || 'zh-CN'}'`) |
| | | param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_id || ''}'`) |
| | | // 子应用ID、typename、应用ID、CloudUserID、appkey、login_types(是否需要登录,已弃用)、link_type(是否使用短连接,已弃用)、role_type(是否使用角色管理)、lang、css(皮肤)、title(标题)、favicon(图标)、user_binding(用户绑定)、sms_id(短信模板ID)、自定义 |
| | | param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || 'false'}','','${window.btoa(window.encodeURIComponent(JSON.stringify({userbind: item.userbind || '', instantMessage: item.instantMessage || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black', topHeight: item.topHeight || '', sysBgColor: item.sysBgColor || '#ffffff', direction: item.direction || 'vertical', adapter: item.adapter || '', share: item.share || '', share_des: item.share_des || '', share_url: item.share_url || '', share_link: item.share_link || ''})))}'`) |
| | | param.LText = param.LText.join(' union all ') |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | |
| | |
| | | jumpApp = (item) => { |
| | | const { selectApp } = this.state |
| | | |
| | | let _href = window.location.href.split('#')[0] + 'app_record' |
| | | let record = localStorage.getItem(_href) |
| | | record = record ? JSON.parse(record) : null |
| | | |
| | | if (!record || !record.dates) { |
| | | localStorage.setItem(_href, JSON.stringify({preId: selectApp.ID, activeId: selectApp.ID, dates: {[selectApp.ID]: new Date().getTime()}})) |
| | | } else { |
| | | if (record.preId === selectApp.ID || record.activeId === selectApp.ID) { |
| | | localStorage.setItem(_href, JSON.stringify({preId: selectApp.ID, activeId: selectApp.ID, dates: {...record.dates, [selectApp.ID]: new Date().getTime()}})) |
| | | } else { |
| | | localStorage.setItem(_href, JSON.stringify({...record, preId: selectApp.ID})) |
| | | } |
| | | } |
| | | |
| | | let route = 'mobdesign' |
| | | if (item.typename === 'pc') { |
| | | route = 'pcdesign' |
| | | } |
| | | let param = {...item, kei_no: selectApp.kei_no, remark: selectApp.remark, type: 'app'} |
| | | |
| | | window.open(window.location.href.replace(/#.+/ig, `#/${route}/${window.btoa(window.encodeURIComponent(JSON.stringify({...item, kei_no: selectApp.kei_no, remark: selectApp.remark, type: 'app'})))}`)) |
| | | window.open(window.location.href.replace(/#.+/ig, `#/${route}/${window.btoa(window.encodeURIComponent(JSON.stringify(param)))}`)) |
| | | } |
| | | |
| | | jumpMenu = (item) => { |
| | |
| | | } |
| | | |
| | | submitCard = () => { |
| | | const { selectApp, visible } = this.state |
| | | const { selectApp, visible, applist } = this.state |
| | | |
| | | this.mobcardRef.handleConfirm().then(res => { |
| | | this.setState({ |
| | | confirmloading: true |
| | | }) |
| | | |
| | | let ID = '' |
| | | if (visible === 'edit') { |
| | | ID = selectApp.ID |
| | | } else { |
| | | let lowerKei = res.kei_no.toLowerCase() |
| | | if (lowerKei === 'mob') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '应用编码不允许使用mob!', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } else if (applist.filter(app => app.kei_no.toLowerCase() === lowerKei).length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '应用编码已存在!', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | ID = md5(window.GLOB.appkey + res.kei_no) |
| | | } |
| | | |
| | | this.setState({ |
| | | confirmloading: true |
| | | }) |
| | | |
| | | let param = { |
| | | func: 's_kei_addupt', |
| | |
| | | exec_type: 'y', |
| | | remark: res.remark, |
| | | kei_no: res.kei_no, |
| | | cus_param_type: 'A', |
| | | LText: '' |
| | | } |
| | | |
| | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (visible === 'edit') { |
| | | // param.LText = selectApp.sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','${item.login_types || 'true'}','${item.link_type || 'true'}','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}'`) |
| | | param.LText = selectApp.sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_id || ''}'`) |
| | | selectApp.sublist = selectApp.sublist.map(item => { |
| | | if (item.typename !== 'pc') { |
| | | item.userbind = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{8}/, 'userbind') |
| | | item.instantMessage = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{14}/, 'instantmessage') |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | param.LText = selectApp.sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || 'false'}','','${window.btoa(window.encodeURIComponent(JSON.stringify({userbind: item.userbind || '', instantMessage: item.instantMessage || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black', topHeight: item.topHeight || '', sysBgColor: item.sysBgColor || '#ffffff', direction: item.direction || 'vertical', adapter: item.adapter || '', share: item.share || '', share_des: item.share_des || '', share_url: item.share_url || '', share_link: item.share_link || ''})))}'`) |
| | | param.LText = param.LText.join(' union all ') |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | } |
| | |
| | | exec_type: 'y', |
| | | remark: selectApp.remark, |
| | | kei_no: selectApp.kei_no, |
| | | cus_param_type: 'A', |
| | | LText: '' |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | // param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','${item.login_types || 'true'}','${item.link_type || 'true'}','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}'`) |
| | | param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_id || ''}'`) |
| | | sublist = sublist.map(item => { |
| | | if (item.typename !== 'pc') { |
| | | item.userbind = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{8}/, 'userbind') |
| | | item.instantMessage = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{14}/, 'instantmessage') |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || 'false'}','','${window.btoa(window.encodeURIComponent(JSON.stringify({userbind: item.userbind || '', instantMessage: item.instantMessage || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black', topHeight: item.topHeight || '', sysBgColor: item.sysBgColor || '#ffffff', direction: item.direction || 'vertical', adapter: item.adapter || '', share: item.share || '', share_des: item.share_des || '', share_url: item.share_url || '', share_link: item.share_link || ''})))}'`) |
| | | param.LText = param.LText.join(' union all ') |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | |
| | |
| | | let css = skinStyle[item.css] ? skinStyle[item.css].name : '' |
| | | let color = skinStyle[item.css] ? skinStyle[item.css].color : '#e8e8e8' |
| | | let binding = '' |
| | | if (item.user_binding) { |
| | | if (item.user_binding.indexOf('uname_pwd') > -1) { |
| | | binding = '用户名' |
| | | } |
| | | if (item.user_binding.indexOf('sms_vcode') > -1) { |
| | | binding = binding ? binding + ',手机号' : '手机号' |
| | | } |
| | | if (item.user_binding === 'true') { |
| | | binding = '用户绑定' |
| | | } |
| | | if (item.share === 'true') { |
| | | binding = binding ? binding + '、分享' : '分享' |
| | | } |
| | | |
| | | return ( |
| | | <div className="sub-app" key={index} style={{borderColor: color}}> |
| | | <Row> |
| | |
| | | </Col> |
| | | <Col span={12}> |
| | | <div className="app-item"> |
| | | {/* <div className="label">登录:</div> |
| | | <div className="content">{item.login_types === 'false' ? '不需要' : '需要'}</div> */} |
| | | {/* <div className="label">皮肤:</div> |
| | | <div className="content" style={{color: color}}>{css}</div> */} |
| | | </div> |
| | | </Col> |
| | | <Col span={12}> |
| | |
| | | </Col> |
| | | <Col span={12}> |
| | | <div className="app-item"> |
| | | {binding ? <div className="label"> |
| | | {/* {binding ? <div className="label"> |
| | | <Tooltip placement="topLeft" title="微信公众号登录时,系统用户与微信用户的绑定方式。"> |
| | | <Icon type="question-circle" /> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 用户绑定: |
| | | </Tooltip> |
| | | </div> : null} */} |
| | | {binding ? <div className="label"> |
| | | <Tooltip placement="topLeft" title="微信公众号或小程序中,绑定系统用户、自定义分享等功能。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 扩展功能: |
| | | </Tooltip> |
| | | </div> : null} |
| | | <div className="content">{binding}</div> |
| | |
| | | </Col> |
| | | <Col span={12}> |
| | | <div className="app-item"> |
| | | <div className="label">网站图标:</div> |
| | | <div className="content">{item.favicon ? <img style={{width: '18px', height: '18px'}} src={item.favicon} alt="" /> : '无'}</div> |
| | | <div className="label">网站头像:</div> |
| | | <div className="content">{item.favicon ? <img style={{width: '18px', height: '18px', borderRadius: '4px'}} src={item.favicon} alt="" /> : '无'}</div> |
| | | </div> |
| | | </Col> |
| | | </Row> |
| | |
| | | <Button type="link" onClick={() => this.setState({ selectSubApp: item, subVisible: 'edit' })} style={{color: '#8E44AD'}}>修改</Button> |
| | | <Button type="link" onClick={() => this.deleteSubApp(item)} style={{color: '#ff4d4f'}}>删除</Button> |
| | | <Button type="link" onClick={() => this.jumpApp(item)}>编辑应用</Button> |
| | | <Paragraph style={{display: 'inline-block', margin: 0}} copyable={{ text: `${base_url}${item.typename === 'pad' ? 'mob' : item.typename}/index.html#/index/${this.state.selectApp.kei_no}/${item.typename !== 'pc' ? item.typename + '/' : ''}${item.lang}` }}></Paragraph> |
| | | <Paragraph style={{display: 'inline-block', margin: 0}} copyable={{ text: `${window.GLOB.baseurl}${item.typename === 'pad' ? 'mob' : item.typename}/index.html#/index/${this.state.selectApp.kei_no}/${item.typename !== 'pc' ? item.typename + '/' : ''}${item.lang}` }}></Paragraph> |
| | | </div> |
| | | </div> |
| | | ) |
| | |
| | | </Modal> |
| | | <Modal |
| | | title={'添加脚本'} |
| | | width={750} |
| | | width={900} |
| | | maskClosable={false} |
| | | visible={scriptVisible} |
| | | onCancel={() => this.setState({scriptVisible: false, confirmloading: false})} |
| | |
| | | <ScriptForm applist={applist} wrappedComponentRef={(inst) => this.scriptRef = inst} inputSubmit={this.submitScript} /> |
| | | </Modal> |
| | | <Modal |
| | | title={'编辑子应用'} |
| | | title={subVisible === 'plus' ? '添加子应用' : '编辑子应用'} |
| | | width={'850px'} |
| | | maskClosable={false} |
| | | visible={subVisible !== false} |