king
2022-09-29 b883ae5d7d46fc7a3503236f16a250c2264ea7c7
src/menu/components/share/usercomponent/index.jsx
@@ -1,25 +1,26 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Icon, Modal, notification } from 'antd'
import { Modal, notification } from 'antd'
import { UserOutlined } from '@ant-design/icons'
import html2canvas from 'html2canvas'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import options from '@/store/options.js'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import UserForm from './settingform'
import MKEmitter from '@/utils/events.js'
import './index.scss'
class DataSource extends Component {
class UserComponent extends Component {
  static propTpyes = {
    btnlog: PropTypes.array,
    handlelog: PropTypes.func
    config: PropTypes.object
  }
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    visible: false,
    loading: false,
    name: '',
@@ -55,6 +56,7 @@
    _config.plot = config.plot || {}
    _config.html = config.html || ''
    _config.css = config.css || ''
    _config.js = config.js || ''
    _config.width = _config.wrap.width || _config.plot.width || config.width || 24
@@ -144,15 +146,26 @@
      document.getElementsByClassName('menu-view')[0].classList.add('saving')
      this.setState({loading: true})
      setTimeout(() => {
        let template = this.getUserComponent()
        // let template = this.getUserComponent()
        let template = fromJS(config).toJS()
        html2canvas(document.getElementById(config.uuid)).then(canvas => {
          let img = canvas.toDataURL('image/png') // 获取生成的图片
          Api.fileuploadbase64(img, 'cloud').then(result => {
          let param = {
            Base64Img: canvas.toDataURL('image/png') // 获取生成的图片
          }
          if (options.cloudServiceApi) {
            param.rduri = options.cloudServiceApi
            param.userid = sessionStorage.getItem('CloudUserID') || ''
            param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
          }
          Api.fileuploadbase64(param).then(result => {
            if (result.status) {
              Api.getSystemConfig({
                func: 's_custom_components_adduptdel',
                c_id: config.uuid,
                images: Utils.getcloudurl(result.Images),
                typename: sessionStorage.getItem('appType') || '',
                c_name: res.name,
                long_param: window.btoa(window.encodeURIComponent(JSON.stringify(template))),
                del_type: ''
@@ -199,9 +212,8 @@
    return (
      <div className="user-component-wrap">
        <Icon type="user" title="生成自定义组件" onClick={this.trigger} />
        <UserOutlined title="生成自定义组件" onClick={this.trigger} />
        <Modal
          wrapClassName="popview-modal"
          title="自定义组件"
          visible={visible}
          width={500}
@@ -218,4 +230,4 @@
  }
}
export default DataSource
export default UserComponent