king
2021-11-12 0c84df247914f893ef5e41d57a422e10a2dc814c
src/views/appmanage/index.jsx
@@ -1,6 +1,7 @@
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'
@@ -16,7 +17,7 @@
const { Search } = Input
const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
const Header = asyncComponent(() => import('@/mob/header'))
const Header = asyncComponent(() => import('./header'))
const MutilForm = asyncComponent(() => import('./mutilform'))
const TransForm = asyncComponent(() => import('./transform'))
const ScriptForm = asyncComponent(() => import('./scriptform'))
@@ -74,7 +75,9 @@
    visible: false,
    subVisible: false,
    transcolumns: [
      { title: '传输号', dataIndex: 'VersionName', key: 'VersionName', align: 'left' },
      { title: '传输号', dataIndex: 'VersionName', key: 'VersionName', align: 'left', render: (text, record) => (
        <Paragraph copyable={{text}}>{text}</Paragraph>
      )},
      { title: '说明', dataIndex: 'ProgramName', key: 'ProgramName', align: 'left' },
      { title: '状态', dataIndex: 'StatusName', key: 'StatusName', align: 'left' },
      { title: '创建时间', dataIndex: 'CreateDate', key: 'CreateDate', align: 'left' },
@@ -303,45 +306,68 @@
  }
  submitScript = () => {
    // const { selectTran } = this.state
    const { selectTran } = this.state
    this.scriptRef.handleConfirm().then(res => {
      this.setState({
        confirmloading: true
      })
      // let param = {}
      // s_sVersionDetail_Add
      // s_sVersionDetail_CloudAdd
      // Api.getCloudConfig(param).then(result => {
      //   if (result.status) {
      //     notification.success({
      //       top: 92,
      //       message: '操作成功!',
      //       duration: 3
      //     })
      //     this.setState({
      //       scriptIndex: 1,
      //       confirmloading: false,
      //       scriptVisible: false
      //     }, () => {
      //       this.getScriptList()
      //     })
      //   } else {
      //     this.setState({
      //       confirmloading: false
      //     })
      //     notification.warning({
      //       top: 92,
      //       message: result.message,
      //       duration: 5
      //     })
      //   }
      // }, () => {
      //   this.setState({
      //     confirmloading: false
      //   })
      // })
      let kei_no = res.appId.split(',')[1]
      let lang = res.subAppId ? res.subAppId.split(',')[1] : ''
      let kei_no_detail = res.subAppId ? res.subAppId.split(',')[2] : ''
      let param = {
        func: 's_sVersionDetail_CloudAdd',
        kei_no: kei_no,
        kei_no_detail: kei_no_detail,
        lang: lang,
        BID: selectTran.ID
      }
      if (res.VType === 'subapp') {
        param.VType = 'mob_menu'
        param.TrdMenuID = ''
        param.upid = md5(window.GLOB.appkey + kei_no + kei_no_detail + lang)
      } else if (res.VType === 'view') {
        param.VType = 'mob_menu'
        param.TrdMenuID = res.viewId
      } else if (res.VType === 'role') {
        param.VType = 'mob_roletree'
        param.upid = md5(window.GLOB.appkey + kei_no + kei_no_detail + lang)
      } else if (res.VType === 'app') {
        param.VType = 'Vkei'
      }
      Api.getCloudConfig(param).then(result => {
        if (result.status) {
          notification.success({
            top: 92,
            message: '操作成功!',
            duration: 3
          })
          this.setState({
            scriptIndex: 1,
            confirmloading: false,
            scriptVisible: false
          }, () => {
            this.getScriptList()
          })
        } else {
          this.setState({
            confirmloading: false
          })
          notification.warning({
            top: 92,
            message: result.message,
            duration: 5
          })
        }
      }, () => {
        this.setState({
          confirmloading: false
        })
      })
    })
  }
@@ -433,6 +459,21 @@
          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'
            }
            return cell
          })
@@ -446,13 +487,12 @@
        if (!selectApp && applist[0]) {
          selectApp = applist[0]
        }
        this.setState({
          loading: false,
          applist: applist,
          selectApp
        })
      } else {
        this.setState({
          loading: false
@@ -553,6 +593,7 @@
      exec_type: 'y',
      remark: selectApp.remark,
      kei_no: selectApp.kei_no,
      cus_param_type: 'A',
      LText: ''
    }
@@ -563,7 +604,7 @@
    sublist = sublist.filter(item => item.ID !== record.ID)
    // 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 || ''}','${item.login_types || 'true'}','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_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 || ''}','${item.sms_id || ''}','${window.btoa(window.encodeURIComponent(JSON.stringify({copyright: item.copyright || '', logo: item.logo || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black'})))}'`)
    param.LText = param.LText.join(' union all ')
    param.LText = Utils.formatOptions(param.LText)
    
@@ -610,6 +651,12 @@
    }
    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'})))}`))
  }
  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'})))}`))
  }
  onSelectChange = selectedRowKeys => {
@@ -736,19 +783,35 @@
  }
  
  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',
@@ -756,6 +819,7 @@
        exec_type: 'y',
        remark: res.remark,
        kei_no: res.kei_no,
        cus_param_type: 'A',
        LText: ''
      }
@@ -764,7 +828,7 @@
      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 || ''}','${item.login_types || 'true'}','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_id || ''}'`)
        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 || ''}','${window.btoa(window.encodeURIComponent(JSON.stringify({copyright: item.copyright || '', logo: item.logo || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black'})))}'`)
        param.LText = param.LText.join(' union all ')
        param.LText = Utils.formatOptions(param.LText)
      }
@@ -825,6 +889,7 @@
        exec_type: 'y',
        remark: selectApp.remark,
        kei_no: selectApp.kei_no,
        cus_param_type: 'A',
        LText: ''
      }
@@ -849,7 +914,7 @@
      }
      // 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 || ''}','${item.login_types || 'true'}','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_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 || ''}','${item.sms_id || ''}','${window.btoa(window.encodeURIComponent(JSON.stringify({copyright: item.copyright || '', logo: item.logo || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black'})))}'`)
      param.LText = param.LText.join(' union all ')
      param.LText = Utils.formatOptions(param.LText)
@@ -998,8 +1063,8 @@
                      </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}>
@@ -1012,7 +1077,7 @@
                        <div className="app-item">
                          {binding ? <div className="label">
                            <Tooltip placement="topLeft" title="微信公众号登录时,系统用户与微信用户的绑定方式。">
                              <Icon type="question-circle" />
                              <QuestionCircleOutlined className="mk-form-tip" />
                              用户绑定:
                            </Tooltip>
                          </div> : null}
@@ -1027,12 +1092,25 @@
                      </Col>
                      <Col span={12}>
                        <div className="app-item">
                          <div className="label">网站图标:</div>
                          <div className="content">{item.favicon ? <img style={{width: '30px', height: '30px'}} src={item.favicon} alt="" /> : '无'}</div>
                          <div className="label">网站头像:</div>
                          <div className="content">{item.favicon ? <img style={{width: '18px', height: '18px'}} src={item.favicon} alt="" /> : '无'}</div>
                        </div>
                      </Col>
                      <Col span={12}>
                        <div className="app-item">
                          <div className="label">版权:</div>
                          <div className="content">{item.copyright || '无'}</div>
                        </div>
                      </Col>
                      <Col span={12}>
                        <div className="app-item">
                          <div className="label">LOGO:</div>
                          <div className="content">{item.logo ? <img style={{height: '18px'}} src={item.logo} alt="" /> : '无'}</div>
                        </div>
                      </Col>
                    </Row>
                    <div className="action">
                      <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>