Aurora基表功能开发文档
以系统中的功能 app页面定义 为例,介绍基表功能的开发步骤
1) 数据库中建表app_pages,脚本如下
-- Create table create table APP_PAGES ( page_id NUMBER not null, page_code VARCHAR2(30) not null, page_name_id NUMBER, enabled_flag VARCHAR2(1) not null, creation_date DATE default sysdate not null, created_by NUMBER default -1 not null, last_updated_by NUMBER default -1 not null, last_update_date DATE default sysdate not null ); -- Add comments to the table comment on table APP_PAGES is 'app页面'; -- Add comments to the columns comment on column APP_PAGES.page_id is '主键'; comment on column APP_PAGES.page_code is '页面代码'; comment on column APP_PAGES.page_name_id is '页面名称ID'; comment on column APP_PAGES.enabled_flag is '启用标志'; -- Create/Recreate indexes create unique index APP_PAGES_U1 on APP_PAGES (PAGE_CODE); -- Create/Recreate primary, unique and foreign key constraints alter table APP_PAGES add constraint APP_PAGES_PK primary key (PAGE_ID); --新建表序列 create sequence app_pages_s start with 100001;
2) 编写增删改查PKG
app_pages_pkg,可以看一下系统存在的
/* ============================================= * FUNCTION * NAME : insert_app_pages * DESCRIPTION: app页面元素插入 * HISTORY: * 1.00 2018/1/30 16:29:00 JIANGXZ * Creation Description * 1.01 yyyy/mm/dd Author Name * Changes Description * =============================================*/ procedure insert_app_pages(p_page_id out number, p_page_code in varchar2, p_page_name in varchar2, p_enabled_flag in varchar2, p_user_id in number) is v_page_record app_pages%rowtype; v_description_id number; begin v_description_id := fnd_description_pkg.get_fnd_description_id; fnd_description_pkg.reset_fnd_descriptions(p_description_id => v_description_id, p_ref_table => 'APP_PAGES', p_ref_field => 'PAGE_NAME_ID', p_description_text => p_page_name, p_function_name => '', p_created_by => p_user_id, p_last_updated_by => p_user_id, p_language_code => userenv('lang')); select app_pages_s.nextval into v_page_record.page_id from dual; v_page_record.page_code := p_page_code; v_page_record.page_name_id := v_description_id; v_page_record.enabled_flag := p_enabled_flag; v_page_record.creation_date := sysdate; v_page_record.created_by := p_user_id; v_page_record.last_updated_by := p_user_id; v_page_record.last_update_date := sysdate; insert into app_pages values v_page_record; p_page_id := v_page_record.page_id; exception when dup_val_on_index then --捕获 唯一索引错误 sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'APP1010_PAGE_CODE_UNIQUE_ERROR', p_created_by => p_user_id, p_package_name => g_package_name, p_procedure_function_name => 'INSERT_APP_PAGES'); raise_application_error(sys_raise_app_error_pkg.c_error_number, sys_raise_app_error_pkg.g_err_line_id); when others then sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' || sqlerrm, p_created_by => p_user_id, p_package_name => g_package_name, p_procedure_function_name => 'INSERT_APP_PAGES'); raise_application_error(sys_raise_app_error_pkg.c_error_number, sys_raise_app_error_pkg.g_err_line_id); end insert_app_pages; /* ============================================= * FUNCTION * NAME : update_app_pages * DESCRIPTION: app页面元素更新 * HISTORY: * 1.00 2018/1/30 16:29:27 JIANGXZ * Creation Description * 1.01 yyyy/mm/dd Author Name * Changes Description * =============================================*/ procedure update_app_pages(p_page_id in number, p_page_code in varchar2, p_page_name_id in number, p_page_name in varchar2, p_enabled_flag in varchar2, p_user_id in number) is begin fnd_description_pkg.reset_fnd_descriptions(p_description_id => p_page_name_id, p_ref_table => 'APP_PAGES', p_ref_field => 'PAGE_NAME_ID', p_description_text => p_page_name, p_function_name => '', p_created_by => p_user_id, p_last_updated_by => p_user_id, p_language_code => userenv('lang')); update app_pages ap set ap.page_code = p_page_code, ap.enabled_flag = p_enabled_flag, ap.last_updated_by = p_user_id, ap.last_update_date = sysdate where ap.page_id = p_page_id; exception when dup_val_on_index then --捕获 唯一索引错误 sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'APP1010_PAGE_CODE_UNIQUE_ERROR', p_created_by => p_user_id, p_package_name => g_package_name, p_procedure_function_name => 'UPDATE_APP_PAGES'); raise_application_error(sys_raise_app_error_pkg.c_error_number, sys_raise_app_error_pkg.g_err_line_id); when others then sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' || sqlerrm, p_created_by => p_user_id, p_package_name => g_package_name, p_procedure_function_name => 'UPDATE_APP_PAGES'); raise_application_error(sys_raise_app_error_pkg.c_error_number, sys_raise_app_error_pkg.g_err_line_id); end update_app_pages; /* ============================================= * FUNCTION * NAME : delete_app_pages * DESCRIPTION: app页面删除 * HISTORY: * 1.00 2018/1/30 16:29:50 JIANGXZ * Creation Description * 1.01 yyyy/mm/dd Author Name * Changes Description * =============================================*/ procedure delete_app_pages(p_page_id in number, p_user_id in number) is begin --删除app页面元素 for v_page_ele_record in (select ape.* from app_page_elements ape where ape.page_id = p_page_id) loop app_pages_pkg.delete_app_page_elements(p_element_id => v_page_ele_record.element_id, p_user_id => p_user_id); end loop; --删除app页面关联关系 for v_page_doc_ref_record in (select apdr.* from app_page_doc_reference apdr where apdr.page_id = p_page_id) loop app_pages_pkg.delete_app_page_doc_ref(p_ref_id => v_page_doc_ref_record.ref_id, p_user_id => p_user_id); end loop; delete from app_pages ap where ap.page_id = p_page_id; exception when others then sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' || sqlerrm, p_created_by => p_user_id, p_package_name => g_package_name, p_procedure_function_name => 'DELETE_APP_PAGES'); raise_application_error(sys_raise_app_error_pkg.c_error_number, sys_raise_app_error_pkg.g_err_line_id); end delete_app_pages;
3) BM文件
可以参考目前系统中已经存在的文件app.APP1010.app_pages,一共是4个方法,增删改查-insert、delete、update、query
<?xml version="1.0" encoding="UTF-8"?> <bm:model xmlns:bm="http://www.aurora-framework.org/schema/bm"> <bm:operations> <bm:operation name="query"> <bm:query-sql><![CDATA[ SELECT apv.page_id, apv.page_code, apv.page_name_id, apv.page_name, apv.enabled_flag FROM app_pages_vl apv #WHERE_CLAUSE# ]]></bm:query-sql> </bm:operation> <bm:operation name="insert"> <bm:parameters> <bm:parameter name="page_id" input="true" output="true"/> </bm:parameters> <bm:update-sql><![CDATA[ begin app_pages_pkg.insert_app_pages(p_page_id =>${@page_id}, p_page_code =>${@page_code}, p_page_name =>${@page_name}, p_enabled_flag =>${@enabled_flag}, p_user_id =>${/session/@user_id}); end; ]]></bm:update-sql> </bm:operation> <bm:operation name="update"> <bm:update-sql><![CDATA[ begin app_pages_pkg.update_app_pages(p_page_id =>${@page_id}, p_page_code =>${@page_code}, p_page_name_id =>${@page_name_id}, p_page_name =>${@page_name}, p_enabled_flag =>${@enabled_flag}, p_user_id =>${/session/@user_id}); end; ]]></bm:update-sql> </bm:operation> <bm:operation name="delete"> <bm:update-sql><![CDATA[ begin app_pages_pkg.delete_app_pages(p_page_id =>${@page_id}, p_user_id =>${/session/@user_id}); end; ]]></bm:update-sql> </bm:operation> <bm:operation name="execute"> <bm:update-sql><![CDATA[ begin app_pages_pkg.copy_app_pages(p_page_id =>${@page_id}, p_old_page_id =>${@old_page_id}, p_user_id =>${/session/@user_id}); end; ]]></bm:update-sql> </bm:operation> </bm:operations> <bm:fields> <bm:field name="page_id"/> <bm:field name="page_code" forDisplay="true" forQuery="true" prompt="APP_PAGES_VL.PAGE_CODE"/> <bm:field name="page_name_id"/> <bm:field name="page_name" forDisplay="true" forQuery="true" prompt="APP_PAGES_VL.PAGE_NAME"/> <bm:field name="enabled_flag"/> </bm:fields> <bm:query-fields> <bm:query-field name="page_id" queryExpression="apv.page_id=${@page_id}"/> <bm:query-field name="page_code" queryExpression="apv.page_code like '%'||${@page_code}||'%'"/> <bm:query-field name="page_name" queryExpression="apv.page_name like '%'||${@page_name}||'%'"/> </bm:query-fields> </bm:model>
4)screen页面
参考系统中已经存在的页面modules/app/APP1010/app_pages_main.screen
<?xml version="1.0" encoding="UTF-8"?> <!-- $Author: jiangxz $Date: 2018年1月30日 下午5:33:11 $Revision: 1.0 $Purpose: --> <a:screen xmlns:a="http://www.aurora-framework.org/application"> <a:init-procedure/> <a:view package="aurora.ui.std" template="default"> <a:link id="app1010_app_page_elements_main_id" url="${/request/@context_path}/modules/app/APP1010/app_page_component.screen"/> <a:link id="app1010_page_doc_reference_main_id" url="${/request/@context_path}/modules/app/APP1010/app_page_doc_reference_main.screen"/> <script><![CDATA[ function app1010_page_code_editorFunction(record, name) { if (name == 'page_code') { if (record.isNew) { return 'app1010_textField_id'; } return; } } function app1010_page_elementsDetail(value, record, name) { if (!record.isNew) { var url = $au('app1010_app_page_elements_main_id').getUrl() + '?page_id=' + record.get('page_id'); return '<a href="javascript:app1010_page_elementsDetailInfor(\'' + url + '\')">${l:APP_PAGES_VL.ELEMENTDETAIL}</a>'; } } function app1010_page_elementsDetailInfor(url) { new Aurora.Window({ id: 'app1010_app_page_elements_main_window', url: url, title: '${l:APP_PAGES_VL.ELEMENTDETAIL}', fullScreen: true }); } function app1010_page_docReferenceDetail(value, record, name) { if (!record.isNew) { var url = $au('app1010_page_doc_reference_main_id').getUrl() + '?page_id=' + record.get('page_id'); return '<a href="javascript:app1010_page_docReferenceDetailInfor(\'' + url + '\')">${l:APP_PAGES_VL.DOCDETAIL}</a>'; } } function app1010_page_docReferenceDetailInfor(url) { new Aurora.Window({ id: 'app1010_page_doc_reference_main_window', url: url, title: '${l:APP_PAGES_VL.DOCDETAIL}', fullScreen: false, width: 1020, side: 'right' }); } function app1010_pages_submitHandler(ds) { $au('app1010_app_pages_result_ds').query(); } ]]></script> <div/> <script/> <a:dataSets> <a:dataSet id="app1010_app_pages_query_ds"> <a:fields> <a:field name="page_code" prompt="APP_PAGES_VL.PAGE_CODE"/> <a:field name="page_name" prompt="APP_PAGES_VL.PAGE_NAME"/> </a:fields> </a:dataSet> <a:dataSet id="app1010_app_pages_result_ds" autoQuery="true" model="app.APP1010.app_pages" queryDataSet="app1010_app_pages_query_ds" selectable="true"> <a:fields> <a:field name="page_id"/> <a:field name="page_code" prompt="APP_PAGES_VL.PAGE_CODE" required="true"/> <a:field name="page_name_id"/> <a:field name="page_name" prompt="APP_PAGES_VL.PAGE_NAME" required="true"/> <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" prompt="APP_PAGES_VL.ENABLED_FLAG" uncheckedValue="N"/> </a:fields> <a:events> <a:event name="submitsuccess" handler="app1010_pages_submitHandler"/> </a:events> </a:dataSet> </a:dataSets> <span> <a:screenTopToolbar> <a:gridButton bind="grid" type="add" width="80"/> <a:gridButton bind="grid" type="save" width="80"/> <a:gridButton bind="grid" type="delete" width="80"/> </a:screenTopToolbar> <a:queryForm bindTarget="app1010_app_pages_query_ds" resultTarget="app1010_app_pages_result_ds" style="width:100%;border:none"> <a:formToolBar> <a:textField name="page_code" bindTarget="app1010_app_pages_query_ds"/> <a:textField name="page_name" bindTarget="app1010_app_pages_query_ds"/> </a:formToolBar> </a:queryForm> <a:grid id="grid" bindTarget="app1010_app_pages_result_ds" marginHeight="121" marginWidth="3" navBar="true"> <a:columns> <a:column name="page_code" align="center" editorFunction="app1010_page_code_editorFunction" width="80"/> <a:column name="page_name" align="center" editor="app1010_textField_id" width="120"/> <a:column name="enabled_flag" align="center" editor="app1010_checkBox_id" width="80"/> <a:column name="page_elementsDetail" align="center" renderer="app1010_page_elementsDetail"/> <a:column name="page_docReferenceDetail" align="center" renderer="app1010_page_docReferenceDetail"/> </a:columns> <a:editors> <a:textField id="app1010_textField_id"/> <a:checkBox id="app1010_checkBox_id"/> </a:editors> </a:grid> </span> </a:view> </a:screen>
页面还需要在功能 页面定义中注册
5) 功能定义
新增一个功能,主页面是modules/app/APP1010/app_pages_main.screen
分配一下我们用到的页面
分配一下我们用到的BM
6)功能分配
定义完一个功能后需要给角色分配功能
功能分配结束后需要系统缓冲重载一下
7)刷新一下页面,就能进入到新建的功能了