meansdetailCtrl.js 39 KB

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