UAP扩展开发 - 新增按钮
UAP新增按鈕的實(shí)現(xiàn)
一、擴(kuò)展說(shuō)明
1.按鈕擴(kuò)展的實(shí)現(xiàn)有兩種方法
- 按鈕繼承:NCAction,MenuAction
- 攔截器實(shí)現(xiàn):ActionInterceptor
此處是通過(guò)按鈕繼承實(shí)現(xiàn)的
2.UAP擴(kuò)展開(kāi)發(fā)新增按鈕一般就三步
- 功能注冊(cè)找到對(duì)應(yīng)的節(jié)點(diǎn)查看全局配置xml文件
- 新建action類,擴(kuò)展xml文件
- 注冊(cè)配置文件到功能注冊(cè)節(jié)點(diǎn)下
此處以銷(xiāo)售訂單維護(hù)為例,效果如下
3.節(jié)點(diǎn)查找路徑
- 功能注冊(cè)節(jié)點(diǎn)
:動(dòng)態(tài)建模平臺(tái) -> 開(kāi)發(fā)配置 -> 功能管理 -> 功能注冊(cè)?
- 銷(xiāo)售訂單維護(hù)節(jié)點(diǎn)
:供應(yīng)鏈 -> 銷(xiāo)售管理 -> 銷(xiāo)售訂單 -> 銷(xiāo)售訂單維護(hù)
二、按鈕實(shí)現(xiàn)
第一步 - 功能節(jié)點(diǎn)查看
1.新建UAP項(xiàng)目
新建銷(xiāo)售po模塊的UAP項(xiàng)目,新建組件命名自定義;
選中項(xiàng)目右鍵啟動(dòng)中間件服務(wù);
本次擴(kuò)展添加的按鈕是銷(xiāo)售訂單維護(hù)節(jié)點(diǎn)下的。
進(jìn)入功能注冊(cè)找到采購(gòu)訂單維護(hù)節(jié)點(diǎn)
看到'B'部分參數(shù)注冊(cè)內(nèi)層紅框就是當(dāng)前節(jié)點(diǎn)的xml配置文件,這個(gè)后面要用到;
第二步 - 按鈕類及配置文件實(shí)現(xiàn)
1.創(chuàng)建action類及xml擴(kuò)展文件
在新建的項(xiàng)目中client下新建action類及xml配置文件;
命名最好規(guī)范化可以參考標(biāo)準(zhǔn)產(chǎn)品相似功能節(jié)點(diǎn)的命名
結(jié)構(gòu)如下:
action類就是按鈕對(duì)應(yīng)的java類,該類繼承NCAction,覆蓋doAction()方法,按鈕的響應(yīng)后的邏輯操作可在此方法中編寫(xiě);
xml文件就是擴(kuò)展按鈕的配置文件。
2.文件代碼
AddTestAction.java
pubapp_ext_config.xml
<?xml version="1.0" encoding="GBK"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 插入按鈕 --><bean class="nc.ui.pubapp.plugin.action.InsertActionInfo"> <property name="action" ref ="AddTestAction" /><!-- 這是插入按鈕的目標(biāo)位置配置 addMenuGroup即為查找的目標(biāo)按鈕 在其后插入測(cè)試按鈕--><property name="target" ref="addMenuGroup" /><property name="pos" value="before" /><property name="actionContainer" ref="actionsOfList" /><!-- 卡片,列表 --><property name="actionType" value="notedit" /><!-- notedit 或 edit --></bean><bean class="nc.ui.pubapp.plugin.action.InsertActionInfo"><property name="action" ref ="AddTestAction" /><property name="target" ref="addMenuGroup" /><!-- 目標(biāo)按鈕 --><property name="pos" value="before" /><!-- 位置 --><property name="actionContainer" ref="actionsOfCard" /><!-- 卡片,列表 --><property name="actionType" value="notedit" /><!-- notedit 或 edit --></bean><bean id="AddTestAction" class="nc.ui.extend.pubapp.action.AddTestAction"><property name="model" ref="manageAppModel" /><property name="editor" ref="billFormEditor" /></bean></beans>
3.xml配置中的參數(shù)說(shuō)明
<bean class="nc.ui.pubapp.plugin.action.InsertActionInfo"> 標(biāo)識(shí)了擴(kuò)展新增按鈕 < bean class="nc.ui.pubapp.plugin.action.ReplaceActionInfo">替換按鈕配置 <bean class=" nc.ui.uif2.uiextend.ActionExtInfo">刪除按鈕配置 <property name="target" ref="addMenuGroup" /> <property name="pos" value="before" />新增按鈕AddTestAction在按鈕addMenuGroup的前面 <bean id="AddTestAction" class="nc.ui.extend.pubapp.action.AddTestAction"> <property name="model" ref="manageAppModel" /> <property name="editor" ref="billFormEditor" /> </bean> id就是作為一個(gè)按鈕在xml配置文件中的標(biāo)識(shí), class是按鈕對(duì)應(yīng)的的Java類 model是銷(xiāo)售訂單維護(hù)節(jié)點(diǎn)的xml配置文件中注冊(cè)的AppModel editor也是在該節(jié)點(diǎn)的xml配置文件中;以上model,editor,目標(biāo)按鈕都是在xml配置中找;這個(gè)xml就是上面功能節(jié)點(diǎn)銷(xiāo)售訂單維護(hù)下的參數(shù)注冊(cè)中的saleorder_config.xml配置文件;
找源碼有個(gè)快捷鍵Ctrl+Shift+T,會(huì)彈出輸入框,輸入查找的文件名點(diǎn)擊確認(rèn)即可;
打開(kāi)文件后,可以找到actions,選一個(gè)作為目標(biāo)按鈕即可;
關(guān)于model可以去查或者按照已有的action跟它配置的model,editor保持一致即可;
第三步 - 配置文件注冊(cè)
1.注冊(cè)配置文件到功能節(jié)點(diǎn)
就是把xml的全路徑配置到銷(xiāo)售訂單維護(hù)節(jié)點(diǎn)下的參數(shù)注冊(cè)中;
注意參數(shù)的命名有一定的規(guī)范,一般PluginBeanConfigFilePath加下劃線后跟01,02這樣;
到此完成新增按鈕;到供應(yīng)鏈的銷(xiāo)售訂單維護(hù)打開(kāi),此時(shí)按鈕已被添加成功。
另:如果是二級(jí)按鈕,或者按鈕組;注意選擇目標(biāo)按鈕后,將<property name="actionType" value="notedit" />中的notedit換成edit即可。
總結(jié)
以上是生活随笔為你收集整理的UAP扩展开发 - 新增按钮的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【CVPR2020 论文翻译】 | Ex
- 下一篇: SG-UAP平台 : MX框架总结