Teamcenter AWC开发,简单表格开发入门案例
第一步:分别在自己的模块下的html、viewmodel、js文件夹下,加入下列三个文件
simpleTableTestPageTableView.html、simpleTableTestPageTableViewModel.json、simpleTableTestPageService.js
第二步:simpleTableTestPageTableView.html
<aw-splm-table gridid="exampleTable"></aw-splm-table>
第三步:simpleTableTestPageTableViewModel.json
{
"schemaVersion": "1.0.0",
"imports": [
"js/aw-splm-table.directive"
],
"actions": {
"loadData": {
"actionType": "JSFunctionAsync",
"method": "getUserData",
"inputData": {
},
"outputData": {
"response": "response",
"totalFound": "totalFound"
},
"deps": "js/wsgTableTestPageService"
}
},
"data": {
"pageSize": 40
},
"i18n": {},
"dataProviders": {
"exampleSortDataProvider": {
"action": "loadData",
"response": "{{data.response}}",
"totalFound": "{{data.totalFound}}",
"commandsAnchor": "aw_splmTableContextMenu"
}
},
"columnProviders": {
"exampleColumnProvider": {
"frozenColumnIndex": -1,
"columns": [
{
"name": "login_group",
"displayName": "登录组",
"minWidth": 60,
"width": 150,
"isTableCommand": true
}
]
}
},
"grids": {
"exampleTable": {
"dataProvider": "exampleSortDataProvider",
"columnProvider": "exampleColumnProvider",
"addIconColumn": false,
"gridOptions": {
"enablePinning": false,
"enableSorting": true
}
}
}
}
第四步:simpleTableTestPageService.js
import app from 'app';
import soaService from 'soa/kernel/soaService';
var exports = {};
export let getUserData = async function () {
let userData = await getUserDataFromTC();
return {
response: userData.objects,
totalFound: userData.objects.length
}
}
let getUserDataFromTC = async function () {
//1.取得查询对象
let userQuery = {
inputCriteria: [{
queryNames: ['__WEB_find_user'],
queryType: 1
}]
}
return await soaService.post("Query-2010-04-SavedQuery", "findSavedQueries", userQuery).then(async (findQuery) => {
var savedQuery = findQuery.savedQueries[0];
let queryCondition = {
query: savedQuery,
entries: ["用户 ID"],
values: ["*"]
}
//2.调用查询,传入条件,执行查询
return await soaService.post("Query-2006-03-SavedQuery", "executeSavedQuery", queryCondition).then(async (queryUserResponse) => {
//3.默认情况下只返回最基本的几属性(userId,user_name)等,如果想取得user对象的其它属性,要调用getProperties 方法, 获取user 对象的相关属性
let attributes = ["login_group"];
await soaService.post("Core-2006-03-DataManagement", "getProperties", {
objects: queryUserResponse.objects,
attributes: attributes
});
return queryUserResponse;
});
});
};
export default exports = {
getUserData
}
app.factory('firstService', () => exports);
展示效果:
感兴趣的朋友可以关注我的公众号呀。定期分享Teamcenter 开发知识,一起学习交流!