前情摘要
在可操作对象一栏中,默认IS_ALL所有人可见,还可以指定用户和部门,可操作对象存在CODE_SYSTEM_OPERATION(晶码-接入系统操作项)表中,部门/用户ID&NAME存在CODE_SYSTEM_OPERATION_AUTH(晶码-系统操作项权限配置表)表中 ,之间通过字段SYSTEM_OPERATION_ID连接。
表结构:
逻辑关系:
默认IS_ALL,当用户选择“指定部门或角色”则将选定的部门/用户存入权限配置表
但是现实却是单选项之间可以切换&存入,但是另外的字段只能展示,无法存入。
要实现的功能:
1、鼠标点击设备编码和设备名称可查看生成的二维码
(最好能复制,复制不了就复制链接,蒋老师说不是什么问题,截个图的事儿)
在对应字段上设置标识,将原本的“文本”改为“链接”,设置链接跳转的内容
这样就能实现点击设备编码和设备名称可查看生成的二维码
效果展示:
没显示事因为对话框大小和样式限制。
2、控制部门/用户选框的显示和隐藏
可根据可操作对象的选择控制部门/用户选框的显示和隐藏
对应的项→创建动态操作→执行JavaScript代码
代码
if ($v('P243_AUTH_RANGE') == 'IS_ALL') {
$x_Hide('P243_AUTH_ID');
$x_Hide('P243_AUTH_NAME');
} else {
$x_Show('P243_AUTH_ID');
$x_Show('P243_AUTH_NAME');
}
效果展示
3、二维码操作入口设置-新增、编辑
光有可操作对象的值还不行,还得校验指定部门或角色两个都不为空,否则只是勾选“指定角色或部门”但是不去勾选内容不符合规则
修改后
if (($v('P243_AUTH_RANGE').length == 0 || ($v('P243_AUTH_ID').length == 0 && $v('P243_AUTH_NAME').length ==0) ) {
alert('可操作对象不能为空');
return false;
}
效果展示:
【错误记录】PL/SQL: ORA-00971: 缺失 SET 关键字。
Ajax 调用为Execute Server-Side Code返回了服务器错误ORA-06550: 第 40 行, 第 35 列:
PL/SQL: ORA-00971: 缺失 SET 关键字。
清晰易懂的Update多表联合修改方法
SQL Update多表联合修改_update连表修改_辰辰辰cc的博客-CSDN博客https://blog.csdn.net/weixin_44635886/article/details/125196255我参考范例写的修改语句:
UPDATE CODE_SYSTEM_OPERATION SET AUTH_RANGE =
(SELECT AUTH_NAME,JOB_NUMBER FROM CODE_SYSTEM_OPERATION_AUTH
WHERE CODE_SYSTEM_OPERATION_AUTH.SYSTEM_OPERATION_ID = CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID)
WHERE EXISTS
(SELECT * FROM CODE_SYSTEM_OPERATION_AUTH
WHERE CODE_SYSTEM_OPERATION_AUTH.SYSTEM_OPERATION_ID = CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID
AND CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID =:P243_SYSTEM_OPERATION_ID );
v_row_count := SQL%ROWCOUNT;
apex_util.set_session_state('P243_ROW_COUNT',v_row_count);
【问题记录】PLS-00372: 在一个过程中, RETURN 语句无法包含表达式。
Ajax 调用为Execute Server-Side Code返回了服务器错误ORA-06550: 第 14 行, 第 1 列:
PLS-00372: 在一个过程中, RETURN 语句无法包含表达式。
declare
v_err_msg nvarchar2(2000);
v_user_ids varchar2(2000);
v_dept_ids varchar2(2000);
v_row_count number(10) := 0;
-- v_user_ids varchar2(2000) := 'JA063198';
-- v_dept_ids varchar2(2000) := '100';
begin
if :AUTH_RANGE = 'IS_ALL' then
-- 主表新增一条数据(验证是否存在);
update CODE_SYSTEM_OPERATION
set OPERATION_NAME = :P243_OPERATION_NAME,
DESCRIPTION =:P243_DESCRIPTION,
AUTH_RANGE =:P243_AUTH_RANGE
where SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID;
v_row_count := SQL%ROWCOUNT;
apex_util.set_session_state('P243_ROW_COUNT', v_row_count);
else
-- 主表新增一条数据 (验证是否存在)
--- 查询本次要新增的人员数据
for c in ( select u.JOB_NUMBER
from (select JOB_NUMBER
from MPF_USER_DEPT_MAIN_ASSO_V
where EXT_USER_ID in (
select *
from JA_UTILS_PKG.SPLIT_STR(v_user_ids, ',')
)
union
select JOB_NUMBER
from MPF_USER_DEPT_MAIN_ASSO_V
where EXT_ORG_ID in (
select *
from JA_UTILS_PKG.SPLIT_STR(v_dept_ids, ',')
)) u
left join CODE_SYSTEM_OPERATION_AUTH a on u.JOB_NUMBER = a.JOB_NUMBER
where a.SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID
AND TENANT_ID = :USERTENANT
AND DEL_FLAG = 0)
loop
UPDATE CODE_SYSTEM_OPERATION
SET OPERATION_NAME = :P243_OPERATION_NAME,
DESCRIPTION =:P243_DESCRIPTION,
AUTH_RANGE = (SELECT AUTH_NAME
FROM CODE_SYSTEM_OPERATION_AUTH
WHERE CODE_SYSTEM_OPERATION_AUTH.SYSTEM_OPERATION_ID =
CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID)
WHERE EXISTS
(SELECT *
FROM CODE_SYSTEM_OPERATION_AUTH
WHERE CODE_SYSTEM_OPERATION_AUTH.SYSTEM_OPERATION_ID =
CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID
AND CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID);
v_row_count := SQL%ROWCOUNT;
apex_util.set_session_state('P243_ROW_COUNT', v_row_count);
end loop;
end if;
exception
when others then
v_err_msg := sqlerrm || chr(13) || dbms_utility.format_error_backtrace;
DBMS_OUTPUT.PUT_LINE(v_err_msg);
end;
明明获取到但是提示没获取到
【问题原因】未在页中设置项
【解决办法】添加对应的项
【问题】编辑数据后保存,提示“保存失败”
【原因】查看会话发现状态是“已插入”,但是项值还是为0,所以修改后提示失败
declare
v_err_msg nvarchar2(2000);
v_user_ids varchar2(2000);
v_dept_ids varchar2(2000);
v_row_count number(10) := 0;
-- v_user_ids varchar2(2000) := 'JA063198';
-- v_dept_ids varchar2(2000) := '100';
begin
if :P243_AUTH_RANGE = 'IS_ALL' then
-- 主表新增一条数据(验证是否存在);
update CODE_SYSTEM_OPERATION
set OPERATION_NAME = :P243_OPERATION_NAME,
DESCRIPTION =:P243_DESCRIPTION,
AUTH_RANGE =:P243_AUTH_RANGE
where SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID;
v_row_count := SQL%ROWCOUNT;
apex_util.set_session_state('P243_ROW_COUNT', v_row_count);
else
-- 主表新增一条数据 (验证是否存在)
--- 查询本次要新增的人员数据
for c in ( select u.JOB_NUMBER
from (select JOB_NUMBER
from MPF_USER_DEPT_MAIN_ASSO_V
where EXT_USER_ID in (
select *
from JA_UTILS_PKG.SPLIT_STR(v_user_ids, ',')
)
union
select JOB_NUMBER
from MPF_USER_DEPT_MAIN_ASSO_V
where EXT_ORG_ID in (
select *
from JA_UTILS_PKG.SPLIT_STR(v_dept_ids, ',')
)) u
left join CODE_SYSTEM_OPERATION_AUTH a on u.JOB_NUMBER = a.JOB_NUMBER
where a.SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID
AND TENANT_ID = :USERTENANT
AND DEL_FLAG = 0)
loop
UPDATE CODE_SYSTEM_OPERATION
SET OPERATION_NAME = :P243_OPERATION_NAME,
DESCRIPTION =:P243_DESCRIPTION,
AUTH_RANGE = (SELECT AUTH_NAME
FROM CODE_SYSTEM_OPERATION_AUTH
WHERE CODE_SYSTEM_OPERATION_AUTH.SYSTEM_OPERATION_ID =
CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID)
WHERE EXISTS
(SELECT *
FROM CODE_SYSTEM_OPERATION_AUTH
WHERE CODE_SYSTEM_OPERATION_AUTH.SYSTEM_OPERATION_ID =
CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID
AND CODE_SYSTEM_OPERATION.SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID);
v_row_count := SQL%ROWCOUNT;
apex_util.set_session_state('P243_ROW_COUNT', v_row_count);
end loop;
end if;
exception
when others then
v_err_msg := sqlerrm || chr(13) || dbms_utility.format_error_backtrace;
DBMS_OUTPUT.PUT_LINE(v_err_msg);
end;
【解决方法】在数据定义将v_row_count初始值从0→1
declare
v_err_msg nvarchar2(2000);
v_row_count number(10) := 1;
begin
update CODE_SYSTEM_OPERATION
set OPERATION_NAME = :P243_OPERATION_NAME,
DESCRIPTION =:P243_DESCRIPTION,
AUTH_RANGE =:P243_AUTH_RANGE
where SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID;
if :P243_AUTH_RANGE = 'IS_ALL' then
delete CODE_SYSTEM_OPERATION_AUTH
where SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID
and TENANT_ID = :USERTENANT;
else
--- 查询本次要新增的人员数据
for c in ( select u.EXT_USER_ID,u.JOB_NUMBER, u.NAME
from (select EXT_USER_ID,JOB_NUMBER, NAME, :P243_SYSTEM_OPERATION_ID SYSTEM_OPERATION_ID
from MPF_USER_DEPT_MAIN_ASSO_V
where EXT_USER_ID in (
select *
from JA_UTILS_PKG.SPLIT_STR(:P243_USER_ID, ':')
)
union
select EXT_USER_ID,JOB_NUMBER, NAME, :P243_SYSTEM_OPERATION_ID SYSTEM_OPERATION_ID
from MPF_USER_DEPT_MAIN_ASSO_V
where EXT_ORG_ID in (
select *
from JA_UTILS_PKG.SPLIT_STR(:P243_DEPT_ID, ':')
)) u
left join CODE_SYSTEM_OPERATION_AUTH a
on u.EXT_USER_ID=a.AUTH_ID AND u.JOB_NUMBER = a.JOB_NUMBER and a.TENANT_ID = :USERTENANT
and a.SYSTEM_OPERATION_ID = :P243_SYSTEM_OPERATION_ID)
loop
insert into CODE_SYSTEM_OPERATION_AUTH(system_operation_id, auth_id, auth_name, job_number, tenant_id,
created_by, creation_time)
values (:P243_SYSTEM_OPERATION_ID, c.EXT_USER_ID, c.NAME, c.JOB_NUMBER, :USERTENANT, :USER_ID, sysdate);
end loop;
end if;
apex_util.set_session_state('P243_ROW_COUNT', v_row_count);
exception
when
others then
rollback;
apex_util.set_session_state('P243_ROW_COUNT', 0);
v_err_msg := sqlerrm || chr(13) || dbms_utility.format_error_backtrace;
JA_WRITE_LOG('P' || :APP_PAGE_ID || ':' || :APP_PAGE_ALIAS, 'error', v_err_msg, :USER_ID, :USERTENANT,
:APP_NAME || ':' || :APP_ID);
end;
存在的问题:
级联树形列表刷新后只能保存一次数据(后续需刷新)
二维码操作入口-列表展示-可操作对象应该设置成仅展示,不能更改(更改在设置里)
重点和难点:
二维码的生成、预览、批量下载
设备模板下载和设备导入
厂区-区域的级联展示
二维码操作入口-操作项设置-设置可操作对象