king
2024-10-11 6ca240a14ccf55d4e0a94fff77e95f64db2cdfcc
src/views/appmanage/index.jsx
@@ -1,14 +1,13 @@
import React, {Component} from 'react'
import { fromJS } from 'immutable'
import { Spin, notification, Input, Button, Table, Modal, ConfigProvider, Typography, Row, Col, Tooltip } from 'antd'
import { Spin, notification, Input, Button, Table, Modal, 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'
import zhCN from 'antd/es/locale/zh_CN'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import { langs } from '@/store/options.js'
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
@@ -16,12 +15,12 @@
const { Paragraph } = Typography
const { Search } = Input
const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
const Header = asyncComponent(() => import('./header'))
const MutilForm = asyncComponent(() => import('./mutilform'))
const TransForm = asyncComponent(() => import('./transform'))
const ScriptForm = asyncComponent(() => import('./scriptform'))
const SubMutilForm = asyncComponent(() => import('./submutilform'))
const TransMenu = asyncComponent(() => import('./transmenu'))
const skinStyle = {
  bg_black_style_blue: {name: '蓝色', color: '#1890ff'},
@@ -378,7 +377,7 @@
  }
  deleteTran = (record) => {
    const _this = this
    const that = this
    let param = {
      func: 's_sVersion_del',
@@ -396,7 +395,7 @@
                message: '操作成功!',
                duration: 3
              })
              _this.getTransList()
              that.getTransList()
            } else {
              notification.warning({
                top: 92,
@@ -415,7 +414,7 @@
  }
  enableTran = (record) => {
    const _this = this
    const that = this
    let param = {
      func: 's_sVersion_sub',
@@ -433,7 +432,7 @@
                message: '操作成功!',
                duration: 3
              })
              _this.getTransList()
              that.getTransList()
            } else {
              Modal.error({
                title: result.message,
@@ -486,6 +485,10 @@
              cell.share_des = _param.share_des || '' // 分享描述
              cell.share_url = _param.share_url || '' // 分享图片
              cell.share_link = _param.share_link || '' // 分享链接
              cell.wxAppId = _param.wxAppId || ''
              cell.wxAppName = _param.wxAppName || ''
              cell.wxMerchId = _param.wxMerchId || ''
              cell.wxMerchName = _param.wxMerchName || ''
              if (cell.adapter && (cell.adapter === 'true' || cell.adapter === 'false')) {
                cell.adapter = ''
@@ -517,8 +520,7 @@
        })
        if (!selectApp && applist[0]) {
          let _href = window.location.href.split('#')[0] + 'app_record'
          let record = localStorage.getItem(_href)
          let record = localStorage.getItem(window.GLOB.sysSign + 'app_record')
          record = record ? JSON.parse(record) : null
          if (record && record.dates) {
@@ -537,7 +539,7 @@
            })
            if (reset) {
              localStorage.setItem(_href, JSON.stringify(record))
              localStorage.setItem(window.GLOB.sysSign + 'app_record', JSON.stringify(record))
            }
          }
        }
@@ -599,7 +601,7 @@
  }
  deleteApp = (record) => {
    const _this = this
    const that = this
    confirm({
      content: '确定删除《' + record.remark + '》吗?',
@@ -619,12 +621,12 @@
                duration: 5
              })
              _this.setState({
              that.setState({
                selectApp: null,
                selectSubApp: null,
                loading: true
              })
              _this.getAppList()
              that.getAppList()
            } else {
              if (result.message.indexOf('kei_no已被菜单使用,不可删除') > -1) {
                result.message = 'kei_no已被菜单使用,不可删除'
@@ -647,7 +649,7 @@
  
  deleteSubApp = (record) => {
    const { selectApp } = this.state
    const _this = this
    const that = this
    let param = {
      func: 's_kei_addupt',
@@ -674,7 +676,11 @@
    })
    // 子应用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 = sublist.map(item => {
      let _par = this.getCusParam(item)
      return `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(_par)))}'`
    })
    param.LText = param.LText.join(' union all ')
    param.LText = Utils.formatOptions(param.LText, 'x')
    
@@ -690,11 +696,11 @@
                duration: 5
              })
      
              _this.setState({
              that.setState({
                selectSubApp: null,
                loading: true
              })
              _this.getAppList()
              that.getAppList()
            } else {
              notification.warning({
                top: 92,
@@ -715,17 +721,16 @@
  jumpApp = (item) => {
    const { selectApp } = this.state
    let _href = window.location.href.split('#')[0] + 'app_record'
    let record = localStorage.getItem(_href)
    let record = localStorage.getItem(window.GLOB.sysSign + 'app_record')
    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()}}))
      localStorage.setItem(window.GLOB.sysSign + 'app_record', 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()}}))
        localStorage.setItem(window.GLOB.sysSign + 'app_record', 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}))
        localStorage.setItem(window.GLOB.sysSign + 'app_record', JSON.stringify({...record, preId: selectApp.ID}))
      }
    }
@@ -733,7 +738,23 @@
    if (item.typename === 'pc') {
      route = 'pcdesign'
    }
    let param = {...item, kei_no: selectApp.kei_no, remark: selectApp.remark, type: 'app'}
    let applangList = []
    if (item.lang === 'zh-CN') {
      selectApp.sublist.forEach(cell => {
        if (cell.typename === item.typename && cell.lang !== 'zh-CN') {
          applangList.push(cell.lang)
        }
      })
    }
    if (applangList.length) {
      applangList.unshift('zh-CN')
      applangList = JSON.stringify(applangList)
    } else {
      applangList = ''
    }
    let param = {...item, kei_no: selectApp.kei_no, remark: selectApp.remark, applangList, type: 'app'}
    window.open(window.location.href.replace(/#.+/ig, `#/${route}/${window.btoa(window.encodeURIComponent(JSON.stringify(param)))}`))
  }
@@ -741,7 +762,22 @@
  jumpMenu = (item) => {
    const { selectApp } = this.state
    window.open(window.location.href.replace(/#.+/ig, `#/role/${window.btoa(window.encodeURIComponent(JSON.stringify({...item, kei_no: selectApp.kei_no, remark: selectApp.remark, type: 'app'})))}`))
    let applangList = []
    if (item.lang === 'zh-CN') {
      selectApp.sublist.forEach(cell => {
        if (cell.typename === item.typename && cell.lang !== 'zh-CN') {
          applangList.push(cell.lang)
        }
      })
    }
    if (applangList.length) {
      applangList.unshift('zh-CN')
      applangList = JSON.stringify(applangList)
    } else {
      applangList = ''
    }
    window.open(window.location.href.replace(/#.+/ig, `#/role/${window.btoa(window.encodeURIComponent(JSON.stringify({...item, kei_no: selectApp.kei_no, remark: selectApp.remark, applangList, type: 'app'})))}`))
  }
  onSelectChange = selectedRowKeys => {
@@ -785,7 +821,7 @@
      }
    })
    const _this = this
    const that = this
    confirm({
      content: '确定要执行吗?',
@@ -821,10 +857,10 @@
                message: '执行成功。',
                duration: 3
              })
              _this.setState({
              that.setState({
                scriptIndex: 1
              }, () => {
                _this.getScriptList()
                that.getScriptList()
              })
            }
            resolve()
@@ -876,10 +912,10 @@
        ID = selectApp.ID
      } else {
        let lowerKei = res.kei_no.toLowerCase()
        if (lowerKei === 'mob') {
        if (['mob', 'pad', 'pc', 'admin'].includes(lowerKei)) {
          notification.warning({
            top: 92,
            message: '应用编码不允许使用mob!',
            message: '应用编码不允许使用mob、pad、pc、admin!',
            duration: 3
          })
          return
@@ -920,7 +956,11 @@
          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 = selectApp.sublist.map(item => {
          let _par = this.getCusParam(item)
          return `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(_par)))}'`
        })
        param.LText = param.LText.join(' union all ')
        param.LText = Utils.formatOptions(param.LText, 'x')
      }
@@ -957,6 +997,56 @@
        })
      })
    })
  }
  getCusParam = (item) => {
    let _par = {
      sysBgColor: item.sysBgColor || '#ffffff'
    }
    if (item.userbind) {
      _par.userbind = item.userbind
    }
    if (item.instantMessage) {
      _par.instantMessage = item.instantMessage
    }
    if (item.apptype) {
      _par.apptype = item.apptype
    }
    if (item.topHeight) {
      _par.topHeight = item.topHeight
    }
    if (item.typename === 'pad') {
      _par.direction = item.direction || 'vertical'
    }
    if (item.typename !== 'pc') {
      _par.statusBarColor = item.statusBarColor || 'black'
      _par.delay = item.delay || 0
    }
    if (item.adapter) {
      _par.adapter = item.adapter
    }
    if (item.share) {
      _par.share = item.share
    }
    if (item.share_des) {
      _par.share_des = item.share_des
    }
    if (item.share_url) {
      _par.share_url = item.share_url
    }
    if (item.share_link) {
      _par.share_link = item.share_link
    }
    if (item.wxAppId) {
      _par.wxAppId = item.wxAppId
      _par.wxAppName = item.wxAppName || item.wxAppId
    }
    if (item.wxMerchId) {
      _par.wxMerchId = item.wxMerchId
      _par.wxMerchName = item.wxMerchName || item.wxMerchId
    }
    return _par
  }
  submitSubCard = () => {
@@ -1013,7 +1103,11 @@
        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 = sublist.map(item => {
        let _par = this.getCusParam(item)
        return `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(_par)))}'`
      })
      param.LText = param.LText.join(' union all ')
      param.LText = Utils.formatOptions(param.LText, 'x')
@@ -1055,7 +1149,6 @@
    return (
      <div className="mk-app-manage">
        <ConfigProvider locale={_locale}>
          <Header view="manage" />
          {loading ?
            <div className="loading-mask">
@@ -1150,7 +1243,7 @@
                      <Col span={12}>
                        <div className="app-item">
                          <div className="label">语言:</div>
                          <div className="content" style={{textDecoration: 'underline'}}>{item.lang === 'en-US' ? '英文' : '中文'}</div>
                        <div className="content" style={{textDecoration: 'underline'}}>{langs[item.lang]}</div>
                        </div>
                      </Col>
                      <Col span={12}>
@@ -1161,8 +1254,10 @@
                      </Col>
                      <Col span={12}>
                        <div className="app-item">
                          {/* <div className="label">皮肤:</div>
                          <div className="content" style={{color: color}}>{css}</div> */}
                        {item.wxAppName || item.wxMerchName ? <>
                          <div className="label">关联应用:</div>
                          <div className="content">{`${item.wxAppName}${item.wxAppName && item.wxMerchName ? ' / ' + item.wxMerchName : item.wxMerchName || ''}`}</div>
                        </> : null}
                        </div>
                      </Col>
                      <Col span={12}>
@@ -1202,11 +1297,12 @@
                      </Col>
                    </Row>
                    <div className="action">
                    {item.lang !== 'zh-CN' ? <TransMenu app={item} supApp={selectApp} /> : null}
                      <Button type="link" onClick={() => this.jumpMenu(item)} style={{color: 'rgba(30, 228, 224, 1)'}}>菜单&权限</Button>
                      <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: `${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>
                    <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}${item.wxAppId ? '/' + item.wxAppId : ''}` }}></Paragraph>
                    </div>
                  </div>
                )
@@ -1257,7 +1353,7 @@
          </Modal>
          <Modal
            title={subVisible === 'plus' ? '添加子应用' : '编辑子应用'}
            width={'850px'}
          width={'970px'}
            maskClosable={false}
            visible={subVisible !== false}
            onCancel={() => this.setState({subVisible: false, confirmloading: false})}
@@ -1269,7 +1365,6 @@
          >
            <SubMutilForm type={subVisible} card={subVisible === 'edit' ? selectSubApp : ''} wrappedComponentRef={(inst) => this.submobcardRef = inst} inputSubmit={this.submitSubCard} />
          </Modal>
        </ConfigProvider>
      </div>
    )
  }