阿里低代码插件扩展(系统管理插件)

在阿里低代码DEMO上扩展系统管理插件

效果如下: 能够进行系统的添加、编辑和删除在这里插入图片描述

新建一个react组件

(1)引入 ILowCodePluginContext,再调用skeleton的add方法进行配置添加

// 项目切换、添加插件
import React from 'react';
import {
  ILowCodePluginContext,
  config
} from '@alilc/lowcode-engine';
// fusion/next UI库
import { Select, Button, Dialog, Message } from '@alifd/next';
const { Option } = Select;

import PubSub from 'pubsub-js'

// 自定义组件
import PSTree from './child-components/PS-Tree'
import PSForm from './child-components/PS-Form'
// import scenarios from '../../universal/scenarios.json';

// api引入
import Api from 'src/api/api'
// 网络请求
import { getSystem, addSystem, updateSystem, delSystem } from 'src/network/data'
import { nanoid } from "nanoid";

import './index.scss';
// const getCurrentScenarioName = () => {
//   // return 'index'
//   const list = location.href.split('/');
//   return list[list.length - 1].replace('.html', '');
// }

class Switcher extends React.Component {

  state = {
    isShowDialog: false, // 是否显示弹框
    footerActions: [], // 控制底部按钮显示
    // 项目目录
    treeData: [
      {
        // label: "系统",
        // key: "system",
        // selectable: false,
        // children: [
        //   {
        //     label: "大数据分析",
        //     key: "bigdata",
        //     // row_id: 1,
        //     data: {
        //       "row_id": 4,
        //       "name": "实时舆情",
        //       "style": "2",
        //       "remark": "舆情分析系统",
        //     }


        //     // selectable: false,
        //     // disabled: true
        //   },
        // ]
      }
    ],
    // 项目配置
    formData: {

    },
    defaultData: [
      {
        "label": "DEMO",
        "key": "project1"
      }
    ],
    // 点击新增后默认选中
    // defaultSelectedKeys: []
    // 新增按钮是否禁用
    newAddBtnIsDisabled: false,
    selectValue: '', // 选择的系统

  };
  componentDidMount() {
    // 加载系统
    this.getSystemData().then(()=>{
      this.defaultChooseFirstNode()
    })
    

  }
  // 获取系统数据
  getSystemData = async () => {
    let params = {
      page: 1,
      pageNum: 10
    }
    let res = await getSystem(params)
    console.log("查询的数据", res);
    this.dealData(res?.data?.list.reverse())
    // })
    return new Promise((resolve, reject) => {
      resolve('success')
    })
  }
  // 新增系统
  addSystem = (data: any) => {
    let params = {
      name: data.name,
      style: data._style,
      remark: data.remark
    }
    addSystem(params).then(async (res) => {
      console.log(res, '新增');
      Message.success("添加成功!");
      await this.getSystemData()
      this.clickTreeNode()

    }).catch(err => {
      Message.error(err);
    })
    this.setState({
      newAddBtnIsDisabled: false
    })
  }
  // 修改系统
  updateSystem = (data: any, id: any) => {
    let params = {
      data: {
        name: data.name,
        style: data._style,
        remark: data.remark
      },
      row_id: id
    }
    updateSystem(params).then(res => {
      console.log(res, '修改');
      Message.success("修改成功!");
      this.getSystemData()
    }).catch(err => {
      Message.error(err);
    })
    this.setState({
      newAddBtnIsDisabled: false
    })
  }
  // 删除系统
  delSystem = (id: any) => {
    let flag: boolean = true
    let params = {
      row_id: id
    }
    delSystem(params).then(async (res) => {
      Message.success("删除成功!");
      flag = true
      await this.getSystemData()
      // 判断当前选择的系统是否是刚刚删除的
      // 若是,就清空当前选择的值
      let index = this.state.treeData[0].children.findIndex(item => {
        return item.row_id == this.state.selectValue
      })
      if (index == -1) {
        this.setState({
          selectValue: ''
        })
      }
    }).catch(err => {
      flag = false
      Message.error(err);
    })
    return new Promise((resolve, reject) => {
      if (flag) {
        resolve(flag)
      } else {
        reject(flag)
      }
    })
  }
  // 处理数据
  dealData = (data: any) => {
    let newData: Array<object> = []
    data.forEach((item: any) => {
      newData.push({
        label: item.name,
        key: item.row_id,
        row_id: item.row_id,
        data: {
          name: item.name,
          style: item.style,
          remark: item.remark
        }

      })
    });
    this.setState({
      treeData: [{
        label: "系统",
        key: "system",
        selectable: false,
        children: [...newData]
      }]
    })
  }
  // 点击系统回调
  handleShowProject = (e: any) => {
    console.log(e);
    this.setState({ isShowDialog: true })
  };
  // 关闭弹框
  onClose = (e: any) => {
    console.log(e);
    this.setState({ isShowDialog: false })
    this.getSystemData()
    this.setState({
      newAddBtnIsDisabled: false
    })
  };
  handleSystemChange = (value: any, actionType: String, item: any) => {
    console.log("当前系统row_id", value, actionType, item);
    PubSub.publish('currentSystem', value)

    let style = (this.state.treeData[0] as any).children.find(item => {
      return item.key == value
    })?.data.style
    // 全局设置当前编辑的系统
    config.set('currentSystem', {
      systemId: value,
      style,
      systemName: item.label,
    })
    this.setState({
      selectValue: value
    })
  }
  // 点击新增按钮 新增系统
  handleAddSystem = () => {
    let id = nanoid()
    const node = {
      label: "新增",
      key: id,
      row_id: id,
      data: {
        name: '新增',
        style: '0',
        remark: ''
      }
    }
    this.setState({
      treeData: [{
        label: "系统",
        key: "system",
        selectable: false,
        children: [...(this.state.treeData[0] as any).children, node]
      }],
      newAddBtnIsDisabled: true
    }, () => { // 更新完成后的回调
      // this.setState({
      //   defaultSelectedKeys: [node.key]
      // })
      this.clickTreeNode()
      // }, 1000)

    })



  }
  // 点击新增的树节点
  clickTreeNode = (index?: number) => {
    let elementNode = document.getElementsByClassName('next-tree-node-inner')
    // setTimeout(() => {
    // let elementNode = document.querySelector('.next-selected')
    console.log(elementNode[1], '新增节点');
    if (index !== undefined) {

      elementNode[index].click()
      console.log("点击第一个");

    } else {
      elementNode[elementNode.length - 1].click()
    }

  }
  // 默认选择第一个系统节点
  defaultChooseFirstNode = ()=>{
    
    
    
    // 获取系统下拉并点击
    (document.querySelector('.system-select') as any)?.click()
    // 获取系统option节点并点击第一个
    setTimeout(()=>{
      let elementNode = document.querySelectorAll('[role="option"]') as any
      // console.log(elementNode, '系统节点');
      elementNode[0]?.click()
      // 点击页面管理
      ;(document.querySelector('.page-manage') as any)?.click()
      // 点击第一个页面
      
    },100)
    setTimeout(()=>{
      (document.getElementsByClassName('next-nav-item')[0] as any)?.click()
    },1000)
    
    // 获取页面节点并点击
    
    
    // console.log(systemNode, '系统节点');
  }

  render(): React.ReactNode {
    const { isShowDialog, footerActions, treeData, newAddBtnIsDisabled } = this.state
    console.log("渲染");

    return (
      <div className='project-switcher'>
        {/* 弹框 */}
        <Dialog
          className='project-switcher-dialog'
          v2
          title="系统配置"
          visible={isShowDialog}
          onClose={this.onClose}
          footer={false}
        >
          {/* 左侧树 */}
          <div className='project'>
            <div className="p-left">
              <PSTree treeData={treeData} handleAddSystem={this.handleAddSystem} newAddBtnIsDisabled={newAddBtnIsDisabled} ></PSTree>
            </div>
            <div className="p-right">
              <PSForm addSystem={this.addSystem} updateSystem={this.updateSystem} delSystem={this.delSystem} newAddBtnIsDisabled={newAddBtnIsDisabled} />
            </div>
          </div>


          {/* 右侧属性配置 */}
        </Dialog>
        <Select
          id="basic-demo"
          onChange={this.handleSystemChange}
          placeholder="请选择系统"
          style={{ width: 220 }}
          value={this.state.selectValue}
          className='system-select'
        >
          {/* defaultValue={treeData[0]['children'][0].key} */}
          {
            (treeData as any)[0]['children']?.map((system: any) => <Option value={system.key} data={system.data}>{system.label}</Option>)
          }
        </Select>
        <Button type="primary" onClick={this.handleShowProject} className='project-btn'>
          系统
        </Button>
      </div >

    )
  }
}
projectSwitcher.pluginName = 'projectSwitcher';

// 在此处进行注册
export const projectSwitcher = (ctx: ILowCodePluginContext) => {
  return {
    name: 'projectSwitcher',
    async init() {
      const { skeleton } = ctx;

      skeleton.add({
        name: 'projectSwitcher',
        area: 'topArea', // 选择top区域
        type: 'Widget', // 插件类型Widget
        props: {
          align: 'right', // 右对齐,在右侧显示
          // width: 80,
        },
        content: Switcher, // 上方的组件
      });
    },
  };
};
// 插件名称
projectSwitcher.pluginName = 'projectSwitcher';

(2)在场景中引入并进行注册

在这里插入图片描述

### 关于ArcGIS License Server无法启动的解决方案 当遇到ArcGIS License Server无法启动的情况,可以从以下几个方面排查并解决问题: #### 1. **检查网络配置** 确保License Server所在的计算机能够被其他客户端正常访问。如果是在局域网环境中部署了ArcGIS Server Local,则需要确认该环境下的网络设置是否允许远程连接AO组件[^1]。 #### 2. **验证服务状态** 检查ArcGIS Server Object Manager (SOM) 的运行情况。通常情况下,在Host SOM机器上需将此服务更改为由本地系统账户登录,并重启相关服务来恢复其正常工作流程[^2]。 #### 3. **审查日志文件** 查看ArcGIS License Manager的日志记录,寻找任何可能指示错误原因的信息。这些日志可以帮助识别具体是什么阻止了许可服务器的成功初始化。 #### 4. **权限问题** 确认用于启动ArcGIS License Server的服务账号具有足够的权限执行所需操作。这包括但不限于读取/写入特定目录的权利以及与其他必要进程通信的能力。 #### 5. **软件版本兼容性** 保证所使用的ArcGIS产品及其依赖项之间存在良好的版本匹配度。不一致可能会导致意外行为完全失败激活license server的功能。 #### 示例代码片段:修改服务登录身份 以下是更改Windows服务登录凭据的一个简单PowerShell脚本例子: ```powershell $serviceName = "ArcGISServerObjectManager" $newUsername = ".\LocalSystemUser" # 替换为实际用户名 $newPassword = ConvertTo-SecureString "" -AsPlainText -Force Set-Service -Name $serviceName -StartupType Automatic New-ServiceCredential -ServiceName $serviceName -Account $newUsername -Password $newPassword Restart-Service -Name $serviceName ``` 上述脚本仅作为示范用途,请依据实际情况调整参数值后再实施。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值