customFormDetailCtrl.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. var appFormly = angular.module('formlyDetail', ['formlyExample']);
  2. app.requires.push('formlyDetail');
  3. // appFormly.controller('customFormDetailCtrl', ['$scope', function($scope) {
  4. // }]);
  5. appFormly.controller('customFormDetailCtrl', ['$ionicHistory', '$scope', '$rootScope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$timeout', '$interval', 'Restangular', 'BpmRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data',
  6. function($ionicHistory, $scope, $rootScope, $parse, $injector, $http, $q, $state, $stateParams, $timeout, $interval, Restangular, BpmRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data) {
  7. //console.log($parse('Restangular')($scope));
  8. //console.log($injector.get('Restangular'));
  9. console.log('customFormDetailCtrl is load');
  10. var vm = this;
  11. vm.options = {
  12. formState: {
  13. horizontalLabelClass: 'col-sm-5',
  14. horizontalFieldClass: 'col-sm-5',
  15. readOnly: true
  16. }
  17. };
  18. vm.exampleTitle = ['expressionProperties', 'model property'];
  19. vm.fields = [];
  20. vm.model = {};
  21. $scope.lang = 'zh-cn';
  22. $scope.goBack = function() {
  23. // $state.go('tab.myIncident');
  24. // $ionicHistory.goBack(-1);
  25. history.go(-1);
  26. // history.back();
  27. }
  28. var that = $injector;
  29. var parse = $parse;
  30. var formKey = "";
  31. var pdKey = "";
  32. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  33. pdKey = $state.current.pdKey;
  34. // console.log("pdKey::"+$state.current.pdKey);
  35. } else if ($stateParams.pdKey) {
  36. pdKey = $stateParams.pdKey;
  37. };
  38. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  39. formKey = $stateParams.formKey;
  40. // console.log("formKey::"+$stateParams.formKey);
  41. }
  42. //用户测试数据,后续从header的auth中获取
  43. var userId = 2;
  44. //==============处理表单设计数据 开始====================
  45. //处理组件加载后台数据选项的方法
  46. function refreshSelectOptions(searchVal, field) {
  47. if (field.templateOptions.optionsUrl) {
  48. var process = BpmRestangular.all("");
  49. process.customPOST({ "assignee": 2, "idx": 0, "sum": 1000 }, field.templateOptions.optionsUrl).then(function(result) {
  50. if (!field.templateOptions.options) {
  51. field.templateOptions.options = [];
  52. }
  53. if (field.templateOptions.optionsDataKey) {
  54. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  55. } else {
  56. field.templateOptions.options = result;
  57. }
  58. });
  59. }
  60. }
  61. //解析自定义表单设计数据
  62. function decodeVMForm(vmForm, mdata) {
  63. var result = { model: {}, fields: [] };
  64. //设置模型实体数据 begin
  65. // var mdata = vmForm.model;
  66. //解析数据实体
  67. //console.log("mdata="+JSON.stringify(mdata));
  68. var mdata = angular.fromJson(vmForm.model);
  69. angular.extend(result.model, mdata);
  70. //设置模型实体数据 end
  71. //解析设计数据生成表单项 begin
  72. var fields = [];
  73. //处理修改设计数据中展示设置
  74. angular.forEach(vmForm.fields, function(field) {
  75. if (field.key == "") {
  76. delete field.key;
  77. }
  78. if (angular.isDefined(field.extjson)) {
  79. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  80. angular.extend(field.templateOptions, extObj.templateOptions);
  81. delete extObj.templateOptions;
  82. for (var prop in extObj) {
  83. if (new RegExp("Expression").test(prop)) {
  84. //var obj = $scope.$eval(extObj[prop]);
  85. //extObj[prop] = $scope.$eval(extObj[prop]);
  86. if (extObj[prop] != null) {
  87. if (new RegExp("function").test(extObj[prop])) {
  88. var propValue = eval(extObj[prop]);
  89. extObj[prop] = propValue;
  90. } else {
  91. // console.log(extObj[prop]);
  92. var obj = $scope.$eval(extObj[prop]);
  93. extObj[prop] = obj;
  94. // console.log(obj);
  95. }
  96. }
  97. } else if (new RegExp("expressionProperties").test(prop)) {
  98. for (var p in extObj[prop]) {
  99. if (new RegExp("function").test(extObj[prop][p])) {
  100. var propValue = eval(extObj[prop][p]);
  101. extObj[prop][p] = propValue;
  102. } else {
  103. if (p.indexOf("'") >= 0) {
  104. var obj = $scope.$eval(extObj[prop][p]);
  105. extObj[prop][$scope.$eval(p)] = obj;
  106. }
  107. }
  108. }
  109. } else if ("watcher" == prop) {
  110. if (angular.isArray(extObj[prop])) {
  111. angular.forEach(extObj[prop], function(item, index) {
  112. for (var p in item) {
  113. if (new RegExp("function").test(item[p])) {
  114. var propValue = eval(item[p]);
  115. extObj[prop][index][p] = propValue;
  116. }
  117. }
  118. });
  119. } else if (angular.isObject(extObj[prop])) {
  120. for (var p in extObj[prop]) {
  121. if (new RegExp("function").test(extObj[prop][p])) {
  122. var propValue = eval(extObj[prop][p]);
  123. extObj[prop][p] = propValue;
  124. }
  125. }
  126. }
  127. }
  128. }
  129. angular.extend(field, extObj);
  130. delete field.extjson;
  131. }
  132. if (angular.isDefined(field.templateOptions)) {
  133. var templateOs = field.templateOptions;
  134. for (var property in templateOs) {
  135. // console.log(property);
  136. if (angular.isString(templateOs[property]) && (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])) || new RegExp("function").test(templateOs[property]))) {
  137. if (new RegExp("function").test(templateOs[property])) {
  138. var propValue = eval(templateOs[property]);
  139. field.templateOptions[property] = propValue;
  140. } else {
  141. if (that.has(templateOs[property])) {
  142. field.templateOptions[property] = that.get(templateOs[property]);
  143. } else {
  144. field.templateOptions[property] = templateOs[property];
  145. }
  146. }
  147. } else if (templateOs[property] == null) {
  148. //delete field.templateOptions[property];
  149. } else {
  150. }
  151. }
  152. }
  153. // console.log(field);
  154. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  155. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  156. angular.extend(field.templateOptions, extObj);
  157. delete field.templateOptions.extjson;
  158. }
  159. //...
  160. if (field.templateOptions) {
  161. //处理远程获取数据控件方法调用
  162. if (field.templateOptions.optionsUrl) {
  163. field.templateOptions.refresh = refreshSelectOptions;
  164. }
  165. //处理嵌套属性数据绑定/
  166. if (field.templateOptions.pkey) {
  167. var pmodel, i = 0;
  168. angular.forEach(field.templateOptions.pkey.split("."), function(p) {
  169. if (i == 0) {
  170. if (result.model[p] == null) {
  171. result.model[p] = {};
  172. }
  173. pmodel = result.model[p];
  174. i++;
  175. } else {
  176. if (pmodel[p] == null) {
  177. pmodel[p] = {};
  178. }
  179. pmodel = pmodel[p];
  180. }
  181. });
  182. if (pmodel != null) {
  183. field.model = pmodel;
  184. if (pmodel[field.key] == null) {
  185. pmodel[field.key] = null;
  186. }
  187. }
  188. } else {
  189. if (result.model[field.key] == null) {
  190. result.model[field.key] = null;
  191. }
  192. }
  193. //处理弹出框组件初始化
  194. if (field.type == "ui-input-selectmodal") {
  195. field.templateOptions.modal = $modal;
  196. //field.templateOptions.Restangular = Restangular;
  197. } else if (field.type == "ui-userselect") {
  198. field.templateOptions.modal = $modal;
  199. //field.templateOptions.Restangular = Restangular;
  200. } else if (field.type == "ui-multiuserselect") {
  201. field.templateOptions.modal = $modal;
  202. } else if (field.type == "ui-modelselect") {
  203. field.templateOptions.modal = $modal;
  204. //field.templateOptions.Restangular = Restangular;
  205. } else if (field.type == "ui-dropfile") {
  206. field.templateOptions.fileUploader = new FileUploader({
  207. url: '/uploader'
  208. });
  209. field.templateOptions.taskId = $stateParams.taskId;
  210. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  211. field.templateOptions.userId = $rootScope.user.id;
  212. //field.ApiService=api_bpm_domain;
  213. } else if (field.type == "ui-dropfiletable") {
  214. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  215. }
  216. }
  217. // console.log(field);
  218. result.fields.push(field);
  219. });
  220. angular.extend($scope.vm.fields, result.fields);
  221. angular.extend($scope.vm.model, result.model);
  222. $scope.formData = vmForm;
  223. //console.log($scope.vm);
  224. //解析设计数据生成表单项 end
  225. return result;
  226. }
  227. //======================处理表单设计数据 结束========================
  228. $scope.closeModel = function() {
  229. console.log("pdKey=" + pdKey);
  230. // if ($stateParams.pdKey) {
  231. // pdKey = $stateParams.pdKey;
  232. // }
  233. if (pdKey == "incident") {
  234. $state.go('tab.incidentHandler', {});
  235. } else if (pdKey == "change") {
  236. $state.go('app.change.list', {});
  237. } else if (pdKey == "problem") {
  238. $state.go('app.problem.list', {});
  239. } else if (pdKey == "release") {
  240. $state.go('app.release.list', {});
  241. } else if (pdKey == "schedule") {
  242. $state.go('app.scheduling.list', {});
  243. } else if (pdKey == "configure") {
  244. $state.go('app.cmdb.plist', {});
  245. } else if (pdKey == "serviceCatalogueProcessActual") {
  246. $state.go('app.reService.manager', {});
  247. } else if (pdKey == "inspectionListForm") {
  248. $state.go('app.inspection.inspectList', {});
  249. } else if (pdKey == "bpm_inspection") {
  250. $state.go('app.inspection.inspectList', {});
  251. } else if (pdKey == "bpm_service_request") {
  252. $state.go('app.reService.manager', {});
  253. };
  254. event.preventDefault();
  255. };
  256. vm.submit = function(data, style) {
  257. };
  258. $scope.vm = vm;
  259. var dataId = $stateParams.dataId;
  260. var pdKey = $stateParams.pdKey;
  261. var detailFormKey = $stateParams.formKey;
  262. var processInstanceId = $stateParams.processInstanceId;
  263. if (angular.isDefined(detailFormKey) && detailFormKey != "") {
  264. var dataId = parseInt(dataId);
  265. if (angular.isDefined(processInstanceId) && processInstanceId != "") {
  266. api_configure_form.renderForm(detailFormKey, '00000', processInstanceId).then(function(responseData) {
  267. if (responseData) {
  268. var vmForm = Restangular.stripRestangular(responseData);
  269. if (vmForm) {
  270. var modelData = {};
  271. modelData[pdKey] = vmForm.model;
  272. decodeVMForm(vmForm, modelData);
  273. }
  274. }
  275. });
  276. } else if (angular.isDefined(dataId) && dataId != "") {
  277. if (pdKey == 'bpm_incident') {
  278. api_bpm_domain.fetchData(pdKey, dataId).then(function(response) {
  279. if (response) {
  280. var myData = Restangular.stripRestangular(response);
  281. // var processInstanceId = myData.data.processInstanceId;
  282. //$scope.vm.model[pdKey]=myData.data;
  283. api_configure_form.renderForm(detailFormKey, '00000', processInstanceId).then(function(responseData) {
  284. if (responseData) {
  285. // console.log("responseData>>>");console.log(responseData);
  286. var vmForm = Restangular.stripRestangular(responseData);
  287. if (vmForm) {
  288. //console.log("vmForm>>>");console.log(vmForm);
  289. var modelData = {};
  290. modelData[pdKey] = vmForm.model;
  291. decodeVMForm(vmForm, modelData);
  292. }
  293. }
  294. });
  295. }
  296. })
  297. // api_configure_form.renderForm('requester_detail', '00000').then(function(responseData) {
  298. // if (responseData) {
  299. // var vmForm = Restangular.stripRestangular(responseData);
  300. // console.log(vmForm);
  301. // }
  302. // });
  303. // var vmForm = {
  304. // model: {
  305. // aa: 123,
  306. // bb: 456
  307. // }
  308. // }
  309. // if (vmForm) {
  310. // var modelData = {};
  311. // modelData[pdKey] = vmForm.model;
  312. // decodeVMForm(vmForm, modelData);
  313. // }
  314. } else {
  315. api_bpm_data.fetchData(pdKey, dataId).then(function(response) {
  316. if (response) {
  317. var myData = Restangular.stripRestangular(response);
  318. var processInstanceId = myData.data.processInstanceId;
  319. //$scope.vm.model[pdKey]=myData.data;
  320. api_configure_form.renderForm(detailFormKey, '00000', processInstanceId).then(function(responseData) {
  321. if (responseData) {
  322. // console.log("responseData>>>");console.log(responseData);
  323. var vmForm = Restangular.stripRestangular(responseData);
  324. if (vmForm) {
  325. //console.log("vmForm>>>");console.log(vmForm);
  326. var modelData = {};
  327. modelData[pdKey] = vmForm.model;
  328. decodeVMForm(vmForm, modelData);
  329. }
  330. }
  331. });
  332. }
  333. })
  334. }
  335. }
  336. } else {
  337. // create process instance
  338. if (pdKey != "") { //for process
  339. api_bpm_domain.startformkey(pdKey).then(function(response) {
  340. if (response) {
  341. var myData = Restangular.stripRestangular(response);
  342. api_configure_form.renderForm(myData.data).then(function(responseData) {
  343. if (responseData) {
  344. var vmForm = Restangular.stripRestangular(responseData);
  345. if (vmForm) {
  346. decodeVMForm(vmForm);
  347. console.log($scope);
  348. }
  349. }
  350. });
  351. }
  352. });
  353. } else { //for form
  354. //TODO
  355. //测试数据 开始
  356. var testJson = {
  357. fields: [{
  358. key: 'formtitle',
  359. type: 'ui-title',
  360. noFormControl: true,
  361. templateOptions: {
  362. label: 'title is ',
  363. placeholder: 'Formly is terrific!'
  364. }
  365. },
  366. {
  367. key: 'a',
  368. type: 'ui-input',
  369. className: 'col-xs-4',
  370. templateOptions: {
  371. type: 'input',
  372. label: 'input a',
  373. placeholder: 'search a...',
  374. lBtn: {
  375. label: 'input',
  376. onClick: function(val, opt, el, ev, model) { alert(val); }
  377. },
  378. rAddon: '@111.cc'
  379. }
  380. },
  381. {
  382. key: 'b',
  383. type: 'ui-input',
  384. className: 'col-xs-4',
  385. templateOptions: {
  386. type: 'input',
  387. label: 'input a',
  388. placeholder: 'search a...',
  389. rBtn: {
  390. icon: 'glyphicon-search',
  391. onClick: function(val, opt, el, ev, model) { alert(val); }
  392. },
  393. lAddon: '@'
  394. }
  395. },
  396. {
  397. key: 'first',
  398. type: 'ui-input',
  399. className: 'col-xs-2',
  400. templateOptions: {
  401. type: 'input',
  402. label: 'first name',
  403. pkey: 'name'
  404. }
  405. },
  406. {
  407. key: 'last',
  408. type: 'ui-input',
  409. className: 'col-xs-2',
  410. templateOptions: { type: 'input', label: 'last name', pkey: 'name' }
  411. },
  412. {
  413. key: 'username',
  414. type: 'ui-input',
  415. className: 'col-xs-6',
  416. templateOptions: {
  417. type: 'input',
  418. label: 'User Name',
  419. placeholder: 'Enter name',
  420. required: true,
  421. maxLength: 10
  422. }
  423. },
  424. {
  425. key: 'password',
  426. type: 'ui-input',
  427. className: 'col-xs-6',
  428. templateOptions: {
  429. type: 'password',
  430. label: 'Password',
  431. placeholder: 'Password',
  432. required: true
  433. },
  434. expressionProperties: {
  435. 'templateOptions.disabled': '!model.username'
  436. }
  437. },
  438. {
  439. key: 'selectmodal',
  440. type: 'ui-input-selectmodal',
  441. className: 'col-xs-6',
  442. templateOptions: {
  443. label: 'selectmodal',
  444. btnLabel: 'search',
  445. btnClassName: 'btn-o',
  446. modalParam: {
  447. items: function() {
  448. return ['a', 'b', 'c', 'd'];
  449. },
  450. title: function() {
  451. return '测试标题';
  452. }
  453. }
  454. }
  455. },
  456. {
  457. key: 'email',
  458. type: 'ui-input',
  459. className: 'col-xs-6',
  460. templateOptions: {
  461. type: 'email',
  462. maxlength: 10,
  463. minlength: 6,
  464. label: 'EMail'
  465. }
  466. },
  467. {
  468. key: 'date',
  469. type: 'ui-datepicker',
  470. className: 'col-xs-6',
  471. templateOptions: {
  472. label: 'Date',
  473. type: 'text',
  474. datepickerPopup: 'yyyy-MM-dd hh:mm:ss',
  475. initDate: function() {
  476. return new Date();
  477. }
  478. }
  479. },
  480. {
  481. key: 'multiselectItem',
  482. type: 'ui-multi-select-tree',
  483. className: 'col-xs-6',
  484. templateOptions: {
  485. label: 'multiSelect',
  486. placeholder: '请选择...',
  487. isMultiSelect: false,
  488. selLeafs: false, //只选叶子节点
  489. refreshData: function(APIService) {
  490. return APIService.fetchDataList('changeclassify', { 'idx': 0, 'sum': 100 });
  491. },
  492. APIService: api_bpm_data,
  493. optionsDataKey: 'list',
  494. refreshDelay: 1000,
  495. onDataCallback: function(item, selectItems, options, field, model) {
  496. model[options.key] = { id: item.id };
  497. }
  498. }
  499. },
  500. {
  501. key: 'selectItem',
  502. type: 'ui-select',
  503. className: 'col-xs-4',
  504. templateOptions: {
  505. label: 'ui-select',
  506. valueProp: 'code', //对应value
  507. labelProp: 'source', //对应key
  508. optionsUrl: 'data/fetchDataList/incidentsource', //对应后台地址,api/之前的部分省略
  509. optionsDataKey: 'list', //对应返回数组数据的键值,
  510. required: true,
  511. onChange: function(val, options, field, event, model) {
  512. model.start_code = val;
  513. }
  514. }
  515. },
  516. {
  517. key: 'multiselectItem',
  518. type: 'ui-multiselect',
  519. className: 'col-xs-4',
  520. templateOptions: {
  521. label: 'multi-select',
  522. valueProp: 'code', //对应value
  523. labelProp: 'source', //对应key
  524. optionsUrl: 'data/fetchDataList/incidentsource', //对应后台地址,api/之前的部分省略
  525. optionsDataKey: 'list', //对应返回数组数据的键值,
  526. required: true,
  527. onChange: function(val, options, field, event, model) {
  528. console.log(val);
  529. console.log(model);
  530. //model.start_code = val;
  531. }
  532. }
  533. },
  534. {
  535. key: 'checklistItem',
  536. type: 'ui-checklist',
  537. className: 'col-xs-4',
  538. templateOptions: {
  539. label: 'checklistItem',
  540. options: [
  541. { name: 'Iron Man', value: 'iron_man' },
  542. { name: 'Captain America', value: 'captain_america' },
  543. { name: 'Black Widow', value: 'black_widow' },
  544. { name: 'Hulk', value: 'hulk' },
  545. { name: 'Captain Marvel', value: 'captain_marvel' }
  546. ]
  547. }
  548. },
  549. {
  550. key: 'radioItem',
  551. type: 'ui-radio',
  552. className: 'col-xs-4',
  553. templateOptions: {
  554. label: 'radioItem',
  555. options: [
  556. { name: 'Iron Man', value: 'iron_man' },
  557. { name: 'Captain America', value: 'captain_america' },
  558. { name: 'Black Widow', value: 'black_widow' },
  559. { name: 'Hulk', value: 'hulk' },
  560. { name: 'Captain Marvel', value: 'captain_marvel' }
  561. ],
  562. type: 'number'
  563. }
  564. },
  565. {
  566. key: 'selectUser',
  567. type: 'ui-userselect',
  568. className: 'col-xs-12',
  569. templateOptions: {
  570. label: '请求人信息',
  571. modalTitle: '请求人列表',
  572. fetchItems: function(filterData, APIService) {
  573. return APIService.fetchDataList('user', filterData);
  574. },
  575. Restangular: Restangular,
  576. ApiService: api_user_data,
  577. onClick: function(val, options, field, event, model) {
  578. //model.start_code++;
  579. console.log(options);
  580. }
  581. }
  582. },
  583. {
  584. key: 'cabUser',
  585. type: 'ui-multiuserselect',
  586. className: 'col-xs-12',
  587. templateOptions: {
  588. label: 'CAB评审成员',
  589. modalTitle: 'CAB成员列表',
  590. fetchItems: function(filterData, APIService) {
  591. return APIService.fetchDataList('user', filterData);
  592. },
  593. Restangular: Restangular,
  594. ApiService: api_user_data,
  595. onClick: function(val, options, field, event, model) {
  596. console.log(model);
  597. }
  598. }
  599. },
  600. {
  601. key: 'incident',
  602. type: 'ui-modelselect',
  603. className: 'col-xs-3',
  604. templateOptions: {
  605. label: '关联事件工单',
  606. modalTitle: '事件列表',
  607. fetchItems: function(filterData, APIService) {
  608. return APIService.fetchDataList('incident', filterData);
  609. },
  610. Restangular: "Restangular",
  611. ApiService: "api_bpm_data",
  612. columnDefs: [
  613. { name: 'id', width: 80, enableFiltering: false },
  614. { name: 'title', displayName: '事件主题', width: 140 },
  615. { name: 'type.name', displayName: '事件类型', width: 140 },
  616. { name: 'emergency.name', displayName: '紧急度', width: 80 },
  617. { name: 'state.name', displayName: '状态', width: 100 },
  618. { name: 'emergency.name', displayName: '紧急度', width: 80 },
  619. { name: 'influence.name', displayName: '影响度', width: 80 },
  620. { name: 'priority.name', displayName: '优先级', width: 80 },
  621. { name: 'handlerUser.name', displayName: '当前处理人', width: 100 },
  622. { name: 'acceptDate', displayName: '创建时间', width: 100 }
  623. ],
  624. displayName: 'title',
  625. onClick: function(val, options, field, event, model) {
  626. //model.start_code++;
  627. console.log(options);
  628. }
  629. }
  630. },
  631. {
  632. key: 'worknumber',
  633. type: 'ui-workernumber',
  634. className: 'col-xs-3',
  635. templateOptions: {
  636. label: 'work number',
  637. Restangular: Restangular,
  638. ApiService: api_bpm_domain,
  639. getWorkernumber: function(APIService) {
  640. return APIService.workernumber('bg');
  641. }
  642. }
  643. },
  644. {
  645. key: 'chkme',
  646. type: 'ui-checkbox',
  647. className: 'col-xs-3',
  648. templateOptions: {
  649. label: 'Check me out'
  650. }
  651. },
  652. {
  653. key: 'droplink',
  654. type: 'ui-link',
  655. className: 'col-xs-3',
  656. templateOptions: {
  657. label: '添加附件',
  658. onClick: function(val, options, field, event, model) {
  659. if (angular.isUndefined(field.form.dropState)) {
  660. field.form.dropState = false;
  661. }
  662. field.form.dropState = !field.form.dropState;
  663. console.log(field);
  664. }
  665. }
  666. },
  667. {
  668. key: 'dropfile',
  669. type: 'ui-dropfile',
  670. className: 'col-xs-12',
  671. templateOptions: {
  672. label: '附件',
  673. uploadUrl: 'http://127.0.0.1:9008/saveAttachments'
  674. }
  675. },
  676. {
  677. key: 'droplist',
  678. type: 'ui-dropfiletable',
  679. className: 'col-xs-12',
  680. templateOptions: {
  681. label: '附件下载列表',
  682. Restangular: Restangular,
  683. ApiService: api_bpm_domain
  684. }
  685. },
  686. {
  687. key: 'start_code',
  688. className: 'col-xs-6',
  689. type: 'ui-hidden'
  690. },
  691. {
  692. key: 'remark',
  693. type: 'ui-textarea',
  694. className: 'col-xs-12',
  695. templateOptions: {
  696. label: 'remark is ',
  697. rows: 3
  698. }
  699. },
  700. {
  701. key: 'setStartCode',
  702. type: 'ui-button',
  703. className: 'col-xs-4',
  704. templateOptions: {
  705. label: 'customButton',
  706. onClick: function(val, options, field, event, model) {
  707. model.start_code++;
  708. console.log(options);
  709. }
  710. }
  711. }
  712. ],
  713. model: {
  714. username: "robin lau",
  715. password: "123456",
  716. chkme: false,
  717. start_code: 0,
  718. formtitle: "Hey!I am title value!",
  719. name: {
  720. first: "robin",
  721. last: "lau"
  722. },
  723. multiselectItem: []
  724. //date:"2015-09-15 00:00:00"
  725. }
  726. };
  727. setTimeout(function() {
  728. decodeVMForm(testJson);
  729. $scope.$apply();
  730. }, 500);
  731. //测试数据结束
  732. }
  733. }
  734. }
  735. ]);