動作列 (BETA)
定義與用法
「動作列」元件是顯示使用者可使用之動作範圍的小器具。動作會顯示為一列按鈕,並顯示在伴隨的清單方塊中。元件組態與使用者螢幕的大小決定顯示為按鈕的動作數。不是以按鈕方式顯示的任何動作都會顯示在清單方塊中,此清單方塊在您按一下橢圓動作後顯示。
以下是顯示動作列元件的範例圖像:
您可以透過下列方式配置動作列元件:
定義動作列中包括的動作
設定要顯示為按鈕的最大動作數目
根據動作的可用性設定可見度選項
定義動作的順序
定義動作是否需要輸入
為動作列選取所需樣式
配置動作列中的選單按鈕
動作的設計目的是為了啟動服務或快顯。服務或快顯混搭必須在 ThingWorx 中單獨配置。您必須在 ThingWorx 的適當服務或混搭中配置其他任何功能,例如快顯訊息。也可以配置為從動作列開啟 URL;例如,配置「在 Windchill 中檢視」按鈕。
動作列可包括在「項目清單」與「項目標識」元件內。它也可以包括在「檢視零件清單」、「檢視零件結構」與「檢視文件結構」任務的預覽窗格內。預覽窗格取代了位於指定任務右上角的選定文件/零件窗格。
「動作列」、「零件動作列」與「文件動作列」是「動作列」元件的可用組態類型。下表列出了上述每個組態的可用動作:
組態類型
預設動作
動作列
核准、拒絕、分析及重新指派
零件動作列
在 Windchill 中報告及檢視問題
文件動作列
開啟文件、報告問題及在 Windchill 中檢視
繫結內容 
輸入
內容名稱
描述
內容類型
Disabled
在混搭中禁用此小器具。
布林值
Input
用來識別要從後端系統擷取的資料。
CCO 格式的 JSON
ServiceActionId
若按一下動作,此字串會更新為服務動作的動作 ID。
字串
SubComponentConfiguration
如果組態在執行時間變更,將其繫結至此內容。
JSON
輸出
內容名稱
描述
內容類型
EventTriggered
如果將動作的 fireEventOnFinish 組態內容配置為 true,會在服務完成執行或顯示快顯時觸發的事件。
事件
ServiceActionIdChanged
ServiceActionId 中的值變更時觸發的事件,這表示由動作列呼叫的服務已完成執行。
事件
PopupClosed
關閉開啟的快顯時觸發的事件。
事件
組態內容 
下表顯示用來配置此元件的 JSON 內容。
如需有關組態結構的詳細資訊,請參閱元件組態結構
如需有關子內容的詳細資訊,請參閱子內容與容器金鑰
內容名稱
描述
內容類型
預設值
必要或選用
maxItemsToShow
所顯示的動作按鈕數上限。如果存在的按鈕比所指定值多,將會在清單方塊中填入其他動作。
2
必要
modelThingName
包含具有下列簽名之服務的物件名稱:
public JSONObject GetActions(@ThingworxServiceParameter(name = "ccoJson", baseType = "JSON") JSONObject ccoJson)
此服務會接受 CCO 格式的輸入,其中包含單一項目。然後,它會傳回包含陣列的 JSONObject,該陣列將可用動作的 ID 對應至其從後端接收的標籤。請參閱下面範例 JSON 組態中的範例。
PTC.ActionBar Model.Thing
必要
actions
需要從後端系統擷取其資料之動作的清單。容器金鑰為 actionConfiguration。請參閱下列子內容:
N/A
必要
overrideLabel
此處設定的值會顯示為動作按鈕的標籤,以取代來自後端系統的值。欲本地化,請在值兩邊加上雙括弧。
N/A
選用
actionButtonVisibility
決定動作按鈕在何種條件下顯示,以及處於何種狀態。選項:AlwaysShownDisableUnavailableHideUnavailable。對於 AlwaysShown,按鈕始終可見且處於已啟用狀態。對於 DisableUnavailable,按鈕始終可見,但當動作無法用於所提供的選取項時,會禁用。對於 HideUnavailable,只有在動作適用于所提供的選取項時,按鈕才可見。
注意:有其他的組態會影響按鈕是啟用還是禁用狀態。
N/A
必要
buttonStyle
決定按鈕的視覺樣式。選項:primarysecondarytertiarydangertransparent
N/A
必要
overrideSetDisabled
如果設定此欄位,則其值是決定是否應啟用或禁用按鈕的唯一係數。選項:truefalse。true 可確保按鈕已禁用,而 false 可確保按鈕已啟用。
N/A
選用
fireEventOnFinish
如果此欄位設定為 true,當服務完成執行時,會觸發 EventTriggered 事件,當關閉快顯時,會觸發 PopupClosed 事件。
N/A
選用
inputConstraints
決定動作的輸入條件約束。選項:InputRequiredSingleInputOnlyNoInputRequired
InputRequired:此動作必須接收輸入才能運作。如果輸入為空且不包含任何項目,則會禁用此動作的按鈕。
SingleInputOnly:此動作必須接收單一輸入才能運作。如果輸入為空或包含多個項目,則會禁用此動作的按鈕。
NoInputRequired:此動作可在沒有任何輸入或有輸入的情況下運作。
N/A
選用
iconWhenEnabled
如果指定此欄位,當啟用動作按鈕時,動作的按鈕會包含圖示,位於標籤左側。
entityName
要作為圖示使用之媒體實體的名稱。
iconWhenDisabled
如果指定此欄位,當禁用動作按鈕時,動作的按鈕會包含圖示,位於標籤左側。
entityName
要作為圖示使用之媒體實體的名稱。
activityType
決定動作是執行服務還是顯示快顯混搭。選項:openUrl (適用於 ThingWorx Navigate 9.3.4 及更新版本)、popup serviceparent (適用於 ThingWorx Navigate 9.4.0 及更新版本)。請參閱下表以取得 popup、service 與 parent 的必要子内容。
N/A
必要
mashupName
顯示為快顯的混搭名稱。
只有當 activityType 設定為 popup 時,才會使用此內容。
N/A
必要
redirectAfterPopupSuccess
在成功操作後關閉快顯時,會重新導向至另一個混搭。
欲通知動作列快顯所執行的操作已成功完成,請設定名為 PTC.ActionBar.popupCloseParameters 的工作階段參數,以指示成功或失敗。例如,在快顯混搭中,可以有一個運算式,該運算式會在快顯執行的操作完成之後執行,且該運算式會設定工作階段參數。在下列範例中,因為操作成功,JSON 屬性 operationSuccessful 設定為 true:
sessionStorage.setItem("PTC.ActionBar.popupCloseParameters", JSON.stringify( { operationSuccessful: true } ));
只有當 activityType 設定為 popup 時,才會使用此內容。
N/A
選用
popupWidth
指定顯示的快顯寬度。
只有當 activityType 設定為 popup 時,才會使用此內容。
1024
選用
popupHeight
指定顯示的快顯寬度。
只有當 activityType 設定為 popup 時,才會使用此內容。
640
選用
thingWithService
包含要執行之服務的物件名稱。
只有當 activityType 設定為 service 時,才會使用此內容。
N/A
必要
serviceName
要執行的服務名稱。
只有當 activityType 設定為 service 時,才會使用此內容。
N/A
必要
parameters
此選用欄位可用於將硬編碼參數傳遞至服務或快顯混搭。參數在 JSONObject 中定義,且必須使用轉義引號轉換為字串格式的 JSON 物件。參數應以 "{\"myParamName\": \"hardcodedValue\"}" 形式輸入到組態檔案中。請參閱下面的其他資訊。
只有當 activityType 設定為 servicepopup 時,才會使用此內容。
N/A
選用
openUrl
允許在動作按鈕上設定 URL。設定為有效值時,新視窗或標籤會在選取動作按鈕時以設定的 URL 開啟。
只有當 activityType 設定為 openUrl 時,才會使用此內容。
N/A
選用
parentId
此選用欄位可用於設定父動作的 ID。當設定為有效值時,它會以符號顯示存在具有該 ID 的父動作,並將動作設定為父選單按鈕下的選項。如果不存在與在 parentId 中設定的 ID 相同的動作,則會略過且不顯示此動作。
只有當 activityType 設定為 parentId 時,才會使用此內容。
父項的 ID
選用
使用 parameters 配置服務動作:
這是名為 MyService 的範例服務的簽名:
@ThingworxServiceDefinition(name = "MyService", category = "MyCategory")
public void MyService(
@ThingworxServiceParameter(name = "exampleInt", baseType = "INTEGER") Integer exampleInt,
@ThingworxServiceParameter(name = "ExampleString", baseType = "STRING") String exampleString,
@ThingworxServiceParameter(name = "ExampleBoolean", baseType = "BOOLEAN") Boolean exampleBoolean)
MyService 之參數值的外觀如下:
{
\"exampleInt\": 123,
\"exampleString\": \"Hello\",
\"exampleBoolean\": true
}
* 
如果您定義服務簽名來接收它們,則您的服務會自動取得兩個參數:serviceParam_InputCcoserviceParam_ActionId。參數 serviceParam_InputCco 是 JSONObject,是提供給動作列的輸入。參數 serviceParam_ActionId 是字串,其中包含已按一下之動作的 ID。如果您的服務未在其簽名中包含這些參數,則不能使用它們。如果您想要使用它們,請使用下列内容定義您的服務簽名來使用其中之一或兩者:
@ThingworxServiceDefinition(name = "MyService", category = "MyCategory")
public void MyService(
@ThingworxServiceParameter(name = "serviceParam_InputCco", baseType = "JSON")
JSONObject serviceParam_InputCco,
@ThingworxServiceParameter(name = "serviceParam_ActionId", baseType = "STRING")
String serviceParam_ActionId)
範例組態 
具有標準按鈕的範例組態
{
"maxItemsToShow": {
"value": 3
},
"modelThingName": {
"entityName": "PTC.ActionBarModel.Thing"
},
"actions": {
"selectedValues": {
"data": [{
"itemListsData": [{
"items": [{
"id": "Approve",
"additionalData": {
"actionConfiguration": {
"actionButtonVisibility": {
"selectedKey": "HideUnavailable"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "popup"
},
"mashupName": {
"mashupName": "PTC.AccessApp.WindchillServices.RoutingOptionMashup"
},
"fireEventOnFinish": {
"value": false
},
"inputConstraints": {
"selectedKey": "SingleInputOnly"
}
}
},
"ordinal": 10
}, {
"id": "Reassign",
"additionalData": {
"actionConfiguration": {
"overrideLabel": {
"value": "Reassign"
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "popup"
},
"mashupName": {
"mashupName": "PTC.AccessApp.WindchillServices.ReassignActionMashup"
},
"fireEventOnFinish": {
"value": false
},
"inputConstraints": {
"selectedKey": "InputRequired"
}
}
},
"ordinal": 20
}, {
"id": "OpenDocument",
"additionalData": {
"actionConfiguration": {
"openUrl": {
"value": "https://www.ptc.com"
},
"overrideLabel": {
"selectedKey": "[[PTC.AccessApp.OpenDocument]]"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "openUrl"
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
}
},
"ordinal": 30
}
}, {
"id": "ProblemReport",
"additionalData": {
"actionConfiguration": {
"overrideLabel": {
"value": "[[PTC.Nav.CreateProblemReport.AppTitle]]"
},
"popupHeight": {
"value": 640
},
"popupWidth": {
"value": 800
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
},
"buttonStyle": {
"selectedKey": "primary"
},
"mashupName": {
"mashupName": "PTC.Nav.CreateProblemReportAppMashup"
},
"activityType": {
"selectedKey": "popup"
},
"parameters": {
"value": "{\"affectedItemsCCO\":{\"timeStamp\":\"2021-11-24 22:45:54.528\",\"data\":[{\"itemListsData\":[{\"items\":[{\"id\":{\"value\":\"OR:wt.part.WTPart:100447\"}}],\"objectType\":\"PTC.ProdMgmt.Part\"}],\"adapter\":{\"instanceName\":\"windchill\",\"thingName\":\"PTC.WCAdapter\"}}],\"version\":\"1.0.0\",\"statusMessage\":\"OK\",\"status\":\"200\"},\"isPopup\":true}"
}
}
},
"ordinal": 40
}
],
"objectType": "WT.WorkItem.Actions"
}
],
"adapter": {
"instanceName": "windchill",
"thingName": "PTC.WCAdapter"
}
}
]
}
}
}
具有選單按鈕的範例組態
{
"maxItemsToShow": {
"value": 3
},
"modelThingName": {
"entityName": "PTC.ActionBarModel.Thing"
},
"actions": {
"selectedValues": {
"data": [{
"itemListsData": [{
"items": [{
"id": "Approve",
"additionalData": {
"actionConfiguration": {
"actionButtonVisibility": {
"selectedKey": "HideUnavailable"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "popup"
},
"mashupName": {
"mashupName": "PTC.AccessApp.WindchillServices.RoutingOptionMashup"
},
"fireEventOnFinish": {
"value": false
},
"inputConstraints": {
"selectedKey": "SingleInputOnly"
}
}
},
"ordinal": 10
}, {
"id": "Reassign",
"additionalData": {
"actionConfiguration": {
"overrideLabel": {
"value": "Reassign"
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "popup"
},
"mashupName": {
"mashupName": "PTC.AccessApp.WindchillServices.ReassignActionMashup"
},
"fireEventOnFinish": {
"value": false
},
"inputConstraints": {
"selectedKey": "InputRequired"
}
}
},
"ordinal": 20
}, {
"id": "OpenDocument",
"additionalData": {
"actionConfiguration": {
"openUrl": {
"value": "https://www.ptc.com"
},
"overrideLabel": {
"selectedKey": "[[PTC.AccessApp.OpenDocument]]"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "openUrl"
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
}
},
"ordinal": 30
}
}, {
"id": "ProblemReport",
"additionalData": {
"actionConfiguration": {
"overrideLabel": {
"value": "[[PTC.Nav.CreateProblemReport.AppTitle]]"
},
"popupHeight": {
"value": 640
},
"popupWidth": {
"value": 800
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
},
"buttonStyle": {
"selectedKey": "primary"
},
"mashupName": {
"mashupName": "PTC.Nav.CreateProblemReportAppMashup"
},
"activityType": {
"selectedKey": "popup"
},
"parameters": {
"value": "{\"affectedItemsCCO\":{\"timeStamp\":\"2021-11-24 22:45:54.528\",\"data\":[{\"itemListsData\":[{\"items\":[{\"id\":{\"value\":\"OR:wt.part.WTPart:100447\"}}],\"objectType\":\"PTC.ProdMgmt.Part\"}],\"adapter\":{\"instanceName\":\"windchill\",\"thingName\":\"PTC.WCAdapter\"}}],\"version\":\"1.0.0\",\"statusMessage\":\"OK\",\"status\":\"200\"},\"isPopup\":true}"
}
}
},
"ordinal": 40
}
],
"objectType": "WT.WorkItem.Actions"
}
],
"adapter": {
"instanceName": "windchill",
"thingName": "PTC.WCAdapter"
}
}
]
}
}
}
這是否有幫助?