通过awc开发一个创建对象的功能需要三个文件,html文件通过awc提供的ui控件去画一个创建对象的页面(awcui控件在文档中心有详细描述),json文件可以查看源码查询如何使用,js文件中执行调用创建对象的soa服务(api可以通过genSoaApi命令获取)
创建
{
"schemaVersion": "1.0.0",
"imports": [
"js/aw-panel.directive",
"js/aw-panel-body.directive",
"js/aw-textbox.directive",
"js/aw-form.directive",
"js/aw-button.directive",
"js/enable-when.directive",
"js/aw-i18n.directive",
"js/aw-break.directive"
],
"data": {
"itemid": {
"displayName": "零件id",
"type": "STRING",
"isRequired": "true",
"isEditable": "true",
"dbValue": "",
"dispValue": ""
},
"itemname": {
"displayName": "零件名称",
"type": "STRING",
"isRequired": "true",
"isEditable": "true",
"dbValue": "",
"dispValue": ""
},
"itemdesc": {
"displayName": "描述",
"type": "STRING",
"isRequired": "true",
"isEditable": "true",
"dbValue": "",
"dispValue": ""
}
},
"actions": {
"buttonAction": {
"actionType": "JSFunction",
"method": "createitem",
"inputData": {
"itemid": "{{data.itemid.dbValue}}",
"itemname": "{{data.itemname.dbValue}}",
"itemdesc": "{{data.itemdesc.dbValue}}"
},
"deps": "js/myCreateItem"
}
},
"i18n": {
"submitButtonTitle": [
"TCUICommandPanelsMessages"
]
}
}
exports.createitem = function( itemid ,itemname,itemdesc) {
var deferred = _$q.defer();
var inputData = {
properties:
[{
clientId: "",
itemId: itemid,
name: itemname,
type: "Item",
revId: "A",
uom: "String",
description:itemdesc,
extendedAttributes:
[{
objectType: "",
attributes:
{
SampleStringKey: ""
}
}]
}],
container: "",
relationType: "",
}
_soaSvc.post("Core-2006-03-DataManagement", "createItems", inputData).then(function (response) {
var output=response.output[0];
var item=output.item;
_dmSvc.getProperties( [item.uid], [ "item_id","object_name"] ).then( function() {
_msg.showInfo("id为"+item.props.item_id.dbValues+"的对象创建完成");
})
deferred.resolve();
})
};