This commit is contained in:
谷成伟 2024-10-15 16:46:53 +08:00
commit ed6761244c
27 changed files with 270 additions and 110 deletions

View File

@ -3,7 +3,7 @@ project (application C CXX)
set (VERSION 1.0.1)
option (USE_MQTT "use mqtt protocol" ON)
option (USE_WEBSOCKET "use websocket" OFF)
option (USE_WEBSOCKET "use websocket" ON)
option (USE_SQLITE3 "use sqlite3" ON)
if (USE_SQLITE3)
@ -41,9 +41,6 @@ else ()
message ("else:${CMAKE_BUILD_TYPE}")
message ("else:${CMAKE_C_FLAGS_RELEASE}")
endif()
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc")
add_definitions (-DMCU_BIG_ENDIAN)
endif ()
option (HAVE_FTP_PROCESS "use ry ftp" ON)
if (HAVE_FTP_PROCESS)
@ -79,7 +76,6 @@ set (APP_SRCS
hostmodbustcp/host_modbus_tcp.cpp
rtustatusproc/rtustatus.cpp
subiec104/sub_iec104.cpp
submodbustcp/sub_modbus_rtu_tcp.cpp
zjd3100proc/zjd3100pro.cpp
)
@ -207,7 +203,6 @@ endif (USE_MQTT)
if (USE_SQLITE3)
set (APP_SRCS ${APP_SRCS}
subgdw104/sub_gdw104.cpp
third_party/sqlite/KompexSQLiteBlob.cpp
third_party/sqlite/KompexSQLiteDatabase.cpp
third_party/sqlite/KompexSQLiteStatement.cpp

View File

@ -4,7 +4,6 @@
#include "../subiec104/sub_iec104.h"
#include "../hostmodbusrtu/host_modbus_rtu.h"
#include "../hostmodbustcp/host_modbus_tcp.h"
#include "../submodbustcp/sub_modbus_rtu_tcp.h"
#include "../rtustatusproc/rtustatus.h"
#include "../zjd3100proc/zjd3100pro.h"
//#include "../bfftpfile2issmqtt/bfftpfile2issmqtt.h"
@ -351,11 +350,6 @@ void CChangeMaster::StartUp(void)
vLog(LOG_INFO, "协议<%d>创建为: modbus tcp主协议.\n", i);
procs[i] = new CHostModbusTcpProcess(m_conn);
}
else if (PROTOCOL_SUB_MODBUS_TCP == config.processes[i].proto)
{
vLog(LOG_INFO, "协议<%d>创建为: modbus tcp从协议.\n", i);
procs[i] = new CSubModbusTcpProcess();
}
else if (PROTOCOL_HOST_IEC104 == config.processes[i].proto)
{
vLog(LOG_INFO, "协议<%d>创建为: iec104主协议.\n", i);
@ -376,13 +370,6 @@ void CChangeMaster::StartUp(void)
vLog(LOG_INFO, "协议<%d>创建为: 网关状态协议.\n", i);
procs[i] = new CRTUStatusProcess();
}
#if 0
else if (PROTOCOL_BF_FTP == config.processes[i].proto)
{//倍福FTP文件协议
vLog(LOG_INFO, "协议<%d>创建为: 倍福FTP文件协议.\n", i);
procs[i] = new CBFFTPFile2ISSMQTTProcess();
}
#endif
else
{
vLog(LOG_ERROR, "(%s,%d)系统不支持该协议或该协议未知.\n", config.processes[i].name, config.processes[i].proto);

View File

@ -5,14 +5,13 @@
//The individual slave devices are assigned addresses in the range of 1 锟?C 247. //
//Address 0 is used for the broadcast address, which all slave devices recognize.//
///////////////////////////////////////////////////////////////////////////////////
#define HAVE_FTP_PROCESS
#ifdef HAVE_FTP_PROCESS
#define MODBUSP_READ_ID 100 //读取文件及文件夹ID
#define MODBUSP_READ_ID 100 //读取文件及文件夹ID
#define MODBUSP_READ_ID_FUNCCODE 0x03 //读取文件及文件夹ID功能码。
#define MODBUSP_READ_ID_REGISTER_ADDRESS 0x01 //读取文件及文件夹ID寄存器地址。
#define MODBUSP_READ_ID_REGISTER_LENGTH 0x6 //读取文件及文件夹ID寄存器长须
#define MODBUSP_READ_ID_REGISTER_ADDRESS 150 //读取文件及文件夹ID寄存器地址。
#define MODBUSP_READ_ID_REGISTER_LENGTH 9 //读取文件及文件夹ID寄存器长度
#include <curl/curl.h>
@ -129,6 +128,14 @@ static void* ryftp_process(void* param)
char password[128] = "123456";
char ipaddress[128] = "127.0.0.1";
//根据协议创建一个本地协议目录
int pid = mbt->GetCurID();
if (pid < 0 || pid >= PROCESSES_NUM) return ((void*)0);
char pathName[128];
snprintf(pathName, sizeof(pathName), "%d", pid);
if (mbt->_mkdir(pathName) < 0) return ((void*)0);
//配置的用户名和密码
#if 0
snprintf(user, sizeof(user), "%s", mbt->m_user);
snprintf(password, sizeof(password), "%s", mbt->m_password);
@ -143,23 +150,26 @@ static void* ryftp_process(void* param)
while (TRUE) {
sleep(1); //每秒执行一次
//ftp获取文件
snprintf(name, sizeof(name), "%d.rtd", mbt->m_currentFileNo + 1);
snprintf(remote, sizeof(remote), "ftp://%s/data/rtdatalog/%d/%d.rtd", str, mbt->m_currentDirNo + 1, mbt->m_currentFileNo + 1);
if (mbt->m_iv == 1) {
//文件目录无效
continue;
}
snprintf(name, sizeof(name), "%s/%d", pathName, mbt->m_currentFileNo);
snprintf(remote, sizeof(remote), "ftp://%s/data/rtdatalog/%d/%d", str, mbt->m_currentDirNo, mbt->m_currentFileNo);
if (ftpget(remote, name, user, password)) {
//成功,处理文件
vLog(LOG_DEBUG, "get a file, then send to ws.\n");
mbt->m_lastDirNo = mbt->m_currentDirNo;
mbt->m_lastFileNo = mbt->m_currentFileNo;
mbt->m_currentFileNo++;
if (mbt->m_currentFileNo % 1000 == 0)
{ //一个文件夹最多存放1000个文件
mbt->m_currentFileNo = 0;
if ((mbt->m_currentFileNo - mbt->m_lastStartFileNo) % 1000 == 0) {
//一个文件夹最多存放1000个文件, mbt->m_currentFileNo = 0;
mbt->m_currentDirNo++;
if (mbt->m_currentDirNo >= 56)
{ //7天数据大约有56个文件夹
mbt->m_lastStartFileNo = mbt->m_currentFileNo;
if (mbt->m_currentDirNo >= 56) { //7天数据大约有56个文件夹
mbt->m_currentDirNo = 0;
}
//保存文件信息
}
}
}
@ -269,11 +279,17 @@ CHostModbusTcpProcess::CHostModbusTcpProcess(noPollConn *conn)
m_nNeedSend = FALSE;
//websocket接口
m_conn = NULL;
if (conn != NULL)
{
m_conn = conn;
}
m_pid = 0;
//目录无效
m_iv = 1;
m_currentDirNo = -1; //当前目录编号
m_currentFileNo = -1; //当前文件编号
m_lastDirNo = -1; //上一目录编号
@ -440,7 +456,17 @@ void CHostModbusTcpProcess::calc2(void)
if (yccount) ycparam = new STRUCT_PARAM[yccount];
if (ymcount) ymparam = new STRUCT_PARAM[ymcount];
if (yxcount) yxparam = new STRUCT_PARAM[yxcount];
#if 0
//插入一帧读取信息的报文
ycframes[0].FrameType = MODBUSP_READ_ID;
ycframes[0].FuncCode = MODBUSP_READ_ID_FUNCCODE;
ycframes[0].RegBegin = MODBUSP_READ_ID_REGISTER_ADDRESS;
ycframes[0].RegCount = MODBUSP_READ_ID_REGISTER_LENGTH;
j = 1;
#else
j = 0;
#endif
if (ycparam)
{
memset(ycparam, 0, sizeof(STRUCT_PARAM) * yccount);
@ -457,7 +483,7 @@ void CHostModbusTcpProcess::calc2(void)
{
WORD addr = MAKEWORD(ycparam[n].param[1], ycparam[n].param[2]);
if (addr >= 65535) continue;
for (j = 0; j < MODBUS_RTU_AUTOMATIC_FRAME; j++)
for (; j < MODBUS_RTU_AUTOMATIC_FRAME; j++)
{
if (ycframes[j].FuncCode == 0)
{
@ -600,7 +626,25 @@ BOOLEAN CHostModbusTcpProcess::OnPreCreate(int id)
m_nTimeout = 200;
calc2();
//启动后,读取本地文件更新最后一次的文件夹及文件序号
//启动后创建ftp线程
if (m_pid <= 0) {
vLog(LOG_DEBUG, "create a ftp thread.\n");
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, MEMERY_1M);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
if (pthread_create(&m_pid, &attr, ryftp_process, this) < 0) {
vLog(LOG_ERROR, "create ryftp_process error(%d,%s).\n", errno, strerror(errno));
return TRUE;
}
char name[17];
snprintf(name, 16, "%s_ftp", GetCurProcessName());
pthread_setname_np(m_pid, name);
pthread_attr_destroy(&attr);
}
return TRUE;
}
@ -661,6 +705,8 @@ BOOLEAN CHostModbusTcpProcess::Run(void)
pItem->m_nNum++;
m_nSendPoint = system32.ticks;//0;
m_nNeedSend = FALSE;
//fprintf(stderr, "tx<%d>: ", count+6); for (int a = 0; a < count+6; a++) fprintf(stderr, "%02X ", buffer[a]); fprintf(stderr, "\n");
FeedDog();
}
}
@ -701,10 +747,11 @@ BOOLEAN CHostModbusTcpProcess::OnTimer(void)
pItem = (CHostModbusTcpProcessItem *)GetNextItem();
if (pItem == NULL) return TRUE;
m_nNeedSend = TRUE;
#if 1
//启动时读取一次,后面自己维护序号
if ((m_currentDirNo == -1) && (m_currentFileNo == -1))
{ //当前文件和目录都为-1程序第一次启动。需要获取ftp目录及文件ID
/* code */
vLog(LOG_DEBUG, "here..... add read id frame.\n");
m_nFrameType = MODBUSP_READ_ID;
m_nCurFuncCode = MODBUSP_READ_ID_FUNCCODE;
m_nCurBeginReg = MODBUSP_READ_ID_REGISTER_ADDRESS;
@ -712,6 +759,7 @@ BOOLEAN CHostModbusTcpProcess::OnTimer(void)
pItem->m_nFramePoll |= MODBUSP_GET_DATA_FRAME;
return TRUE;
}
#endif
struModbusExtFrame* frame = pItem->GetNextFrame();
if (frame != NULL)
{
@ -1179,29 +1227,30 @@ BOOLEAN CHostModbusTcpProcess::OnReceiveIDData(CHostModbusTcpProcessItem *pItem,
pBuf = pData;
//根据结构来处理得到id信息
/*
1 byte
2 dint10
3 dint
4 dint;
5 dint
*/
//路径有效性判断
int iv = ((pBuf[0] << 8) | pBuf[1]); pBuf += 2;
//
m_currentDirNo = 0;
m_currentFileNo = 0;
vLog(LOG_DEBUG, "create a ftp thread.\n");
//创建ftp线程
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, MEMERY_1M);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
if (pthread_create(&m_pid, &attr, ryftp_process, this) < 0) {
vLog(LOG_ERROR, "create ryftp_process error(%d,%s).\n", errno, strerror(errno));
return TRUE;
m_iv = iv;
if (iv) {
vLog(LOG_DEBUG, "路径信息无效\n");
return FALSE;
}
char name[16];
snprintf(name, 16, "%s_ftp", GetCurProcessName());
pthread_setname_np(m_pid, name);
pthread_attr_destroy(&attr);
//当前文件夹路径名
m_currentDirNo = (DWORD)((pBuf[2] << 24) | (pBuf[3] << 16) | (pBuf[0] << 8) | pBuf[1]); pBuf += 4;
//当前文件夹下最后新文件
m_currentFileNo = (DWORD)((pBuf[2] << 24) | (pBuf[3] << 16) | (pBuf[0] << 8) | pBuf[1]); pBuf += 4;
//当前文件夹下第一个文件
m_lastStartFileNo = (DWORD)((pBuf[2] << 24) | (pBuf[3] << 16) | (pBuf[0] << 8) | pBuf[1]); pBuf += 4;
vLog(LOG_DEBUG, "dir: %d, file: %d: start: %d\n", m_currentDirNo, m_currentFileNo, m_lastStartFileNo);
return TRUE;
}

View File

@ -4,6 +4,7 @@
#include "netproc.h"
#include "modbus_def.h"
#include <dirent.h>
#include <nopoll.h>
#include <nopoll_decl.h>
@ -60,16 +61,28 @@ private:
public:
noPollConn *m_conn;
int m_currentDirNo; //当前目录编号
int m_currentFileNo; //当前文件编号
int m_lastDirNo; //上一目录编号
int m_lastFileNo; //上一文件编号
int m_iv;
LONG m_currentDirNo; //当前目录编号
LONG m_currentFileNo; //当前文件编号
LONG m_lastDirNo; //上一目录编号
LONG m_lastFileNo; //上一文件编号
LONG m_lastStartFileNo; //文件开始编号
//ftp参数信息
char m_user[128];
char m_password[128];
char m_remoteIp[64];
int _mkdir(const char* pathName) {
if (access(pathName, F_OK) == 0) return 0;
// 创建目录
if (mkdir(pathName, 0777) == -1) {
vLog(LOG_ERROR, "创建文件夹 %s失败<%d,%s>\r\n", pathName, errno, strerror(errno));
return -1;
}
return 1;
}
public:
CHostModbusTcpProcess(noPollConn *conn);
virtual ~CHostModbusTcpProcess();

View File

@ -47,11 +47,15 @@ public:
config.processes[m_nProcess].softdog = 0;
}
inline char* GetCurProcessName() const
inline char* GetCurProcessName(void) const
{
if (m_nProcess < 0 || m_nProcess >= PROCESSES_NUM) return NULL;
return config.processes[m_nProcess].name;
}
inline int GetCurID(void) const
{
return m_nProcess;
}
inline int GetCurOrder() const
{

View File

@ -339,4 +339,12 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return c;
}
public static boolean isAllEnglishLetters(String str) {
if (str == null || str.isEmpty()) {
return false;
}
// 正则表达式 [a-zA-Z] 匹配英文字母
return str.matches("[a-zA-Z]+");
}
}

View File

@ -5,6 +5,7 @@ import com.das.common.config.SessionUtil;
import com.das.common.constant.SysAuthorityIds;
import com.das.common.result.R;
import com.das.common.utils.PageDataInfo;
import com.das.common.utils.StringUtils;
import com.das.modules.auth.domain.dto.DeleteDto;
import com.das.modules.auth.domain.dto.SysMenuDto;
import com.das.modules.auth.domain.dto.SysMenuQueryDto;
@ -35,12 +36,14 @@ public class SysMenusController {
*/
@PostMapping("/add")
public R<?> createMenu(@RequestBody SysMenuDto sysMenuDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
if(!hasPermission){
return R.fail("没有系统管理权限");
}
if (StringUtils.isAllEnglishLetters(sysMenuDto.getMenuName())){
return R.fail("菜单名称,必须为英文");
}
return R.success(sysMenuService.createMenu(sysMenuDto));
}
@ -55,7 +58,9 @@ public class SysMenusController {
if(!hasPermission){
return R.fail("没有系统管理权限");
}
if (StringUtils.isAllEnglishLetters(sysMenuDto.getMenuName())){
return R.fail("菜单名称,必须为英文");
}
sysMenuService.updateMenu(sysMenuDto);
return R.success();
}

View File

@ -14,6 +14,8 @@ public class SysMenuDto implements Serializable {
private Long id ;
/** 菜单名称 */
private String menuName ;
/** 菜单名称中文描述 */
private String menuDesc ;
/** 菜单排列顺序 */
private Integer menuOrder ;
/** 菜单图标名称 */

View File

@ -12,8 +12,11 @@ public class SysMenuQueryDto implements Serializable {
@JsonSerialize(using = ToStringSerializer.class)
private Long id ;
/** 菜单名称 */
/** 菜单英文名称 */
private String menuName ;
/** 菜单中文名称 */
private String menuDesc ;
/** 上级菜单ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long parentMenuId ;

View File

@ -19,6 +19,8 @@ public class SysMenuVo implements Serializable {
private Long id ;
/** 菜单名称 */
private String menuName ;
/** 菜单中文名称 */
private String menuDesc ;
/** 菜单排列顺序 */
private Integer menuOrder ;
/** 菜单图标名称 */

View File

@ -40,6 +40,10 @@ public class SysMenu extends BaseEntity {
@TableField("menu_name")
private String menuName ;
/** 菜单名称,中文描述 */
@TableField("menu_desc")
private String menuDesc ;
/** 菜单排列顺序 */
@TableField("menu_order")
private Integer menuOrder ;

View File

@ -95,4 +95,16 @@ public class SysEquipmentDto {
* 当前页数
*/
private Integer pageNum;
/**
* 所属线路
*/
private String belongLine;
/**
* 是否为标杆机组
*/
private Integer standard;
}

View File

@ -102,4 +102,15 @@ public class SysEquipmentVo{
*/
@TableField(exist = false)
private List<SysEquipment> equipChildren;
/**
* 所属线路
*/
private String belongLine;
/**
* 是否为标杆机组
*/
private Integer standard;
}

View File

@ -119,4 +119,16 @@ public class SysEquipment extends BaseEntity {
@TableField(value = "iot_model_id")
@JsonSerialize(using = ToStringSerializer.class)
private Long iotModelId;
/**
* 所属线路
*/
@TableField(value = "belong_line")
private String belongLine;
/**
* 是否为标杆机组
*/
@TableField(value = "standard")
private Integer standard;
}

View File

@ -17,6 +17,8 @@
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
<result property="belongLine" column="belong_line" jdbcType="VARCHAR"/>
<result property="standard" column="standard" jdbcType="INTEGER"/>
</resultMap>
<resultMap type="com.das.modules.equipment.domain.vo.SysEquipmentVo" id="SysEquipmentListMap">

View File

@ -5,6 +5,7 @@
<resultMap type="com.das.modules.auth.entity.SysMenu" id="SysMenuMap">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="menuName" column="menu_name" jdbcType="VARCHAR"/>
<result property="menuDesc" column="menu_desc" jdbcType="VARCHAR"/>
<result property="menuOrder" column="menu_order" jdbcType="INTEGER"/>
<result property="menuIcon" column="menu_icon" jdbcType="VARCHAR"/>
<result property="funType" column="fun_type" jdbcType="INTEGER"/>
@ -22,6 +23,7 @@
<resultMap id="SysMenuChildMap" type="com.das.modules.auth.domain.vo.SysMenuVo">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="menuName" column="menu_name" jdbcType="VARCHAR"/>
<result property="menuDesc" column="menu_desc" jdbcType="VARCHAR"/>
<result property="menuOrder" column="menu_order" jdbcType="INTEGER"/>
<result property="menuIcon" column="menu_icon" jdbcType="VARCHAR"/>
<result property="funType" column="fun_type" jdbcType="INTEGER"/>
@ -48,6 +50,9 @@
<if test="sysMenu.menuName != null and sysMenu.menuName != ''">
and menu_name like concat('%',#{sysMenu.menuName},'%')
</if>
<if test="sysMenu.menuDesc != null and sysMenu.menuDesc != ''">
and menu_desc like concat('%',#{sysMenu.menuDesc},'%')
</if>
</where>
order by menu_order
</select>

View File

@ -6,9 +6,9 @@ VITE_BASE_PATH = './'
# 代理配置(开发使用),必须在一行中
# 本地
# VITE_APP_PROXY=[["/api","http://192.168.130.12:8080/api"]]
# VITE_APP_PROXY=[["/api","http://10.65.57.55:8080/api"]]
# 线上
VITE_APP_PROXY=[["/api","https://test.jsspisoft.com/api"]]
VITE_APP_PROXY=[["/api","https://test.jsspisoft.com/api"]]

View File

@ -4,7 +4,7 @@
<el-sub-menu @click="onClickSubMenu(menu)" :index="menu.path" :key="menu.path">
<template #title>
<Icon :color="config.getColorVal('menuColor')" :name="menu.meta?.icon ? menu.meta?.icon : config.layout.menuDefaultIcon" />
<span>{{ menu.meta?.title ? menu.meta?.title : $t('noTitle') }}</span>
<span>{{ menu.meta?.menuDesc ? menu.meta?.menuDesc : $t('noTitle') }}</span>
</template>
<menu-tree :extends="{ ...props.extends, level: props.extends.level + 1 }" :menus="menu.children"></menu-tree>
</el-sub-menu>
@ -12,7 +12,7 @@
<template v-else>
<el-menu-item :index="menu.path" :key="menu.path" @click="onClickMenu(menu)">
<Icon :color="config.getColorVal('menuColor')" :name="menu.meta?.icon ? menu.meta?.icon : config.layout.menuDefaultIcon" />
<span>{{ menu.meta?.title ? menu.meta?.title : $t('noTitle') }}</span>
<span>{{ menu.meta?.menuDesc ? menu.meta?.menuDesc : $t('noTitle') }}</span>
</el-menu-item>
</template>
</template>

View File

@ -9,7 +9,7 @@
:ref="tabsRefs.set"
:key="idx"
>
{{ item.meta.title }}
{{ item.meta.menuDesc }}
<transition @after-leave="selectNavTab(tabsRefs[navTabs.state.activeIndex])" name="el-fade-in">
<Icon v-show="navTabs.state.tabsView.length > 1" class="close-icon" @click.stop="closeTab(item)" size="15" name="el-icon-Close" />
</transition>

View File

@ -350,7 +350,7 @@ const menu = [
],
},
]
debugger
function transformNode(menu: any) {
menu = menu.map((node: any) => {
return {
@ -358,6 +358,7 @@ function transformNode(menu: any) {
pid: node.parentMenuId,
type: node.children.length != 0 ? 'menu_dir' : 'menu',
title: node.menuName,
menuDesc: node.menuDesc,
name: node.menuName,
path: node.menuName,
icon: node.menuIcon,

View File

@ -1,13 +1,13 @@
<template>
<el-main class="layout-main">
<el-scrollbar view-class="layout-main-scrollbar" :view-style="layoutMainScrollbarStyle" ref="layoutMainScrollbarRef">
<router-view v-slot="{ Component }">
<transition :name="config.layout.mainAnimation" mode="out-in">
<transition :name="config.layout.mainAnimation" mode="out-in">
<router-view v-slot="{ Component }">
<keep-alive :include="state.keepAliveComponentNameList">
<component :is="Component" :key="state.componentKey" />
</keep-alive>
</transition>
</router-view>
</router-view>
</transition>
</el-scrollbar>
</el-main>
</template>

View File

@ -186,6 +186,7 @@ const handleMenuRule = (routes: any, pathPrefix = '/', type = ['menu', 'menu_dir
meta: {
id: routes[key].id,
title: routes[key].title,
menuDesc: routes[key].menuDesc,
icon: routes[key].icon,
keepalive: routes[key].keepalive,
menu_type: routes[key].menu_type,
@ -279,6 +280,7 @@ export const addRouteItem = (viewsComponent: Record<string, any>, route: any, pa
component: component,
meta: {
title: route.title,
menuDesc: route.menuDesc,
extend: route.extend,
icon: route.icon,
keepalive: route.keepalive,

View File

@ -26,6 +26,7 @@
<el-main class="defaultMain">
<el-table :data="tableData" class="tablePart">
<el-table-column prop="menuName" label="菜单名称" />
<el-table-column prop="menuDesc" label="菜单描述" />
<el-table-column prop="funParam" label="菜单路径" />
<el-table-column prop="menuOrder" label="菜单排序" />
<el-table-column label="图标">
@ -56,6 +57,10 @@
<el-input v-model="fromUpDate.menuName" placeholder="" clearable />
</el-form-item>
<el-form-item label="菜单描述:" prop="menuDesc">
<el-input v-model="fromUpDate.menuDesc" placeholder="" clearable />
</el-form-item>
<el-form-item label="&nbsp;&nbsp;菜单图标:">
<BaInput type="icon" v-model="fromUpDate.menuIcon" />
</el-form-item>
@ -102,6 +107,10 @@
<el-input v-model="formInlineAdd.menuName" placeholder="" clearable />
</el-form-item>
<el-form-item label="菜单描述:" prop="menuDesc">
<el-input v-model="formInlineAdd.menuDesc" placeholder="" clearable />
</el-form-item>
<el-form-item label="&nbsp;&nbsp;菜单图标:">
<BaInput type="icon" v-model="formInlineAdd.menuIcon" />
</el-form-item>
@ -225,6 +234,7 @@ interface Tree {
id: number
menuIcon: string
menuName: string
menuDesc: string
menuOrder: number
parentMenuId: number
revision: number
@ -242,11 +252,11 @@ const handleNodeClick = (data: Tree) => {
//
const input2 = ref('')
const queryListData = {
menuName: '',
menuDesc: '',
parentMenuId: '',
}
const clickQuery = () => {
queryListData.menuName = input2.value
queryListData.menuDesc = input2.value
queryMenuMethod(queryListData)
}
@ -266,7 +276,7 @@ const queryMenuMethod = (data: any) => {
const defaultProps = {
children: 'children',
label: 'menuName',
label: 'menuDesc',
}
//
@ -276,6 +286,7 @@ const menuEdit = (data: any) => {
fromUpDate.id = data.row.id
fromUpDate.revision = data.row.revision
fromUpDate.menuName = data.row.menuName
fromUpDate.menuDesc = data.row.menuDesc
fromUpDate.menuOrder = data.row.menuOrder
fromUpDate.menuIcon = data.row.menuIcon
fromUpDate.funType = data.row.funType
@ -293,6 +304,7 @@ const handleCloseAdd = () => {
interface RuleForm {
menuName: string | undefined
menuDesc: string | undefined
menuOrder: number
menuIcon: string
funType: number
@ -339,6 +351,13 @@ const rules = reactive<FormRules<RuleForm>>({
trigger: 'blur',
},
],
menuDesc: [
{
required: true,
message: '菜单描述不能为空',
trigger: 'blur',
},
]
})
//
@ -353,6 +372,7 @@ interface RyReplaceFields {
const fromUpDate = reactive({
id: '',
menuName: '',
menuDesc:'',
menuOrder: 0,
menuIcon: '',
funType: 0,
@ -451,6 +471,7 @@ const visibleAdd = ref(false)
const formInlineAdd = reactive<RuleForm>({
menuName: '',
menuDesc: '',
menuOrder: 0,
menuIcon: '',
funType: 1,
@ -470,6 +491,7 @@ const formInlineAdd = reactive<RuleForm>({
const fromAdd = () => {
visibleAdd.value = true
formInlineAdd.menuName = ''
formInlineAdd.menuDesc =''
formInlineAdd.menuOrder = 0
formInlineAdd.menuIcon = ''
formInlineAdd.funType = 1

View File

@ -322,7 +322,7 @@ const addInstitutional = (rightClick = false) => {
const submitAddForm = () => {
console.log(formModel.value)
if (!formRef.value) return
formRef.value.validate((valid:boolean) => {
formRef.value.validate((valid: boolean) => {
if (valid) {
if (dialogTitle.value === '新增机构') {
formModel.value.parentOrgId = formModel.value.parentOrgId ?? '0'
@ -330,7 +330,7 @@ const submitAddForm = () => {
.then((res) => {
if (res.success) {
ElMessage.success('新增成功')
getInstitutionList()
getInstitutionList({parentOrgId:rightClickMenuData.value?.parentOrgId})
dialogVible.value = false
refreshTreeData(formModel.value.parentOrgId)
} else {
@ -345,7 +345,7 @@ const submitAddForm = () => {
.then((res) => {
if (res.success) {
ElMessage.success('编辑成功')
getInstitutionList()
getInstitutionList({parentOrgId:rightClickMenuData.value?.parentOrgId})
dialogVible.value = false
refreshTreeData(rightClickMenuData.value!.parentOrgId).then(() => {
refreshTreeData(formModel.value.parentOrgId)
@ -368,7 +368,14 @@ const closeAddForm = () => {
const getInstitutionList = (data: getDataType = { name: null }) => {
getInstitutionalListReq(data).then((res) => {
pageTotal.value = res.total
originData.value = res.rows
console.log(res.rows);
originData.value = res.rows.map(item=>{
return {
...item,
parentOrgName:item.parentOrgName ? item.parentOrgName : '无'
}
})
})
}
@ -450,7 +457,7 @@ const delForm = (column: getTreeDataReturnType) => {
.then((res) => {
if (res.success) {
ElMessage.success('删除成功')
getInstitutionList()
getInstitutionList({parentOrgId:rightClickMenuData.value?.parentOrgId})
refreshTreeData(column.parentOrgId)
} else {
ElMessage.error(res?.msg ?? '删除失败')
@ -470,6 +477,7 @@ const treeReplaceProps = {
const treeSelectReplaceProps = {
label: 'name',
children: 'children',
isLeaf: 'isLeaf',
}
const loadTreeData = (node: Node, resolve: any) => {
if (node.level === 0) {
@ -489,7 +497,6 @@ const loadTreeData = (node: Node, resolve: any) => {
})
}
const loadSelectTreeData = (node: Node, resolve: any) => {
console.log(node)
if (node.level === 0) {
return getTreeData(null)
@ -497,7 +504,8 @@ const loadSelectTreeData = (node: Node, resolve: any) => {
if (!res.length) {
node.data.isLeaf = true
}
resolve(res)
resolve([{ id: '0', name: '无', isLeaf: true }, ...res])
})
.catch((err) => {
console.log(err)
@ -552,8 +560,6 @@ const refreshTreeData = (parentOrgId: string | number | null) => {
return new Promise((resolve) => {
const data = parentOrgId === 0 || parentOrgId === '0' ? null : parentOrgId
getTreeData(data).then((res) => {
console.log('res,', res)
console.log(data)
if (data) {
treeRef.value?.updateKeyChildren(parentOrgId!, res)
} else {

View File

@ -5,7 +5,7 @@
<template v-for="item in formColumnList" :key="item.prop">
<el-form-item :label="item.label" :rules="item.rule" :label-width="80" :prop="item.prop">
<template v-if="item.type === 'input'">
<el-input v-model="formModel[item.prop]" :placeholder="'请输入' + item.label"></el-input>
<el-input v-model="formModel[item.prop] as string" :placeholder="'请输入' + item.label"></el-input>
</template>
<template v-if="item.type === 'custom'">
<template v-if="item.prop === 'authList'">
@ -241,13 +241,15 @@ const getRoleList = (roleName = '') => {
getRoleListReq({
roleName,
}).then((res) => {
console.log(res)
pageTotal.value = res.total
originData.value = res.rows.map((item) => {
return {
roleCode: item.roleCode,
roleName: item.roleName,
listName: item.list.map((item) => item.authorityName).join(','),
authList: item.list.map((item) => item.id),
authList: item.list.map((item) => parseInt(item.id)),
id: item.id,
revision: item.revision,
}

View File

@ -12,6 +12,8 @@ export type formDataType = {
roleCode: string
}
export type formDataEnumKeyJointType = keyof typeof formDataEnum
export type formColumnListType<T extends formDataEnumKeyJointType> = {
@ -49,7 +51,7 @@ export type tableDataType<T extends authorityDataListType> = {
roleCode: number
roleName: string
listName: T['authorityName']
authList: T['id'][]
authList: number[]
}
export type tableColumnType<T extends tableDataColumnTypeJointType> = {

View File

@ -131,7 +131,7 @@
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="editDeviceData.objectType !== '风电场'">
<el-form-item label="所属风电场:">
<el-tree-select
:disabled="editDeviceData.objectType === '风电场'"
@ -145,14 +145,14 @@
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="editDeviceData.objectType !== '风电场'">
<el-form-item label="所属线路:">
<el-input placeholder="请输入所属线路" v-model="editDeviceData.belongingLine" style="width: 200px" />
<el-input placeholder="请输入所属线路" v-model="editDeviceData.belongLine" style="width: 200px" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="editDeviceData.objectType !== '风电场'">
<el-form-item label="标杆机组:">
<el-switch v-model="editDeviceData.isbenchMarkUnit" />
<el-switch @change="edithandleSwitchChange" :active-value="1" :inactive-value="0" v-model="editDeviceData.standard" />
</el-form-item>
</el-col>
</el-row>
@ -286,7 +286,7 @@
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="editAddDeviceData.objectType !== '风电场'">
<el-form-item label="所属风电场:">
<el-tree-select
:disabled="editAddDeviceData.objectType === '风电场'"
@ -300,14 +300,19 @@
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="editAddDeviceData.objectType !== '风电场'">
<el-form-item label="所属线路:">
<el-input placeholder="请输入所属线路" v-model="editAddDeviceData.belongingLine" style="width: 200px" />
<el-input placeholder="请输入所属线路" v-model="editAddDeviceData.belongLine" style="width: 200px" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="editAddDeviceData.objectType !== '风电场'">
<el-form-item label="标杆机组:">
<el-switch v-model="editAddDeviceData.isbenchMarkUnit" />
<el-switch
@change="addhandleSwitchChange"
:active-value="1"
:inactive-value="0"
v-model="editAddDeviceData.standard"
/>
</el-form-item>
</el-col>
</el-row>
@ -536,6 +541,7 @@ const handleNodeClick = (data: any) => {
formQuery.objectType = data.equipmentTypeId
equipQuery(formQuery).then((res) => {
deviceList.value = res.rows
pageTotal.value = res.total
})
equipModeList({
@ -626,8 +632,8 @@ const addDeviceList = () => {
editAddDeviceData.orgId = ''
editAddDeviceData.parentEquipmentId = ''
editAddDeviceData.iotModelId = ''
editAddDeviceData.belongingLine = ''
editAddDeviceData.isbenchMarkUnit = false
editAddDeviceData.belongLine = ''
editAddDeviceData.standard = 0
}
//
@ -648,8 +654,8 @@ const editDeviceData = reactive({
parentEquipmentId: '',
iotModelId: '',
id: '',
belongingLine: '',
isbenchMarkUnit: false,
belongLine: '',
standard: 0,
})
const size = ref<'default' | 'large' | 'small'>('default')
@ -677,8 +683,8 @@ const viewDeviceDetails = (data: any) => {
editDeviceData.orgId = data.row.orgId
editDeviceData.parentEquipmentId = data.row.parentEquipmentId
editDeviceData.iotModelId = data.row.iotModelId
editDeviceData.belongingLine = data.row.belongingLine
editDeviceData.isbenchMarkUnit = data.row.isbenchMarkUnit
editDeviceData.belongLine = data.row.belongLine
editDeviceData.standard = data.row.standard || 0
}
//
@ -798,9 +804,15 @@ const editAddDeviceData = reactive({
orgId: '',
parentEquipmentId: '',
iotModelId: '',
belongingLine: '',
isbenchMarkUnit: false,
belongLine: '',
standard: 0,
})
const addhandleSwitchChange = (value: any) => {
editAddDeviceData.standard = value ? 1 : 0
}
const edithandleSwitchChange = (value: any) => {
editDeviceData.standard = value ? 1 : 0
}
//
const editAddDeviceRules = reactive({
@ -832,7 +844,6 @@ const saveAddData = () => {
editAddDeviceData.objectType = ele.equipmentTypeId
}
})
equipAdd(editAddDeviceData).then((res) => {
if (res.code == 200) {
ElMessage({