meansdetailCtrl.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  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-deptinformation") {
  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. }else if (field.type == "ui-repair-photos") {
  273. field.templateOptions.user = vm.model["loginUser"];
  274. }
  275. }
  276. }
  277. //解析自定义表单设计数据
  278. $scope.oldfromtype = true;
  279. function decodeVMForm(vmForm) {
  280. if (vmForm.formType == "1") {
  281. $scope.oldfromtype = false;
  282. } else {
  283. $scope.oldfromtype = true;
  284. }
  285. var result = { model: {}, fields: [] };
  286. //设置模型实体数据 begin
  287. // var mdata = vmForm.model;
  288. //解析数据实体
  289. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  290. angular.extend(result.model, mdata);
  291. //设置模型实体数据 end
  292. //解析设计数据生成表单项 begin
  293. var fields = [];
  294. //处理修改设计数据中展示设置
  295. angular.forEach(vmForm.fields, function(fields) {
  296. if (vmForm.formType == "1") {
  297. angular.forEach(fields.fields, function(field) {
  298. formfield(field, result);
  299. });
  300. } else {
  301. formfield(fields, result);
  302. }
  303. // console.log(field);
  304. result.fields.push(fields);
  305. });
  306. angular.extend($scope.vm.fields, result.fields);
  307. angular.extend($scope.vm.model, result.model);
  308. // angular.extend($scope.vm.formType, result.formType);
  309. // $scope.vm.tabs[0] = { "fields": $scope.vm.fields };
  310. // angular.extend($scope.vm.tabs[0].fields, result.fields);
  311. // angular.extend($scope.vm.tabs[0].model, result.model);
  312. // console.log("$scope.vm.model="+JSON.stringify($scope.vm.model));
  313. vm.model["loginUser"] = $rootScope.user;
  314. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  315. vmForm.cancelUrl = modelWatch.cancelUrl;
  316. }
  317. $scope.formData = vmForm;
  318. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  319. if ($scope.formData.url == "start") {
  320. $scope.Reset = true;
  321. $scope.close = false;
  322. } else if ($scope.formData.url == "complete") {
  323. $scope.Reset = false;
  324. $scope.close = true;
  325. }
  326. $scope.formData = vmForm;
  327. //console.log($scope.vm);
  328. //解析设计数据生成表单项 end
  329. return result;
  330. }
  331. //======================处理表单设计数据 结束========================
  332. $scope.closeModel = function() {
  333. // if (pdKey == "incident") {
  334. $state.go('app.means.applylist', {});
  335. // }
  336. event.preventDefault();
  337. };
  338. vm.submit = function(data, style) {
  339. };
  340. $scope.vm = vm;
  341. var dataId = $stateParams.dataId;
  342. var pdKey = $stateParams.pdKey;
  343. var detailFormKey = $stateParams.formKey;
  344. var processInstanceId = $stateParams.processInstanceId;
  345. if (angular.isDefined(detailFormKey) && detailFormKey != "") {
  346. var dataId = parseInt(dataId);
  347. if (angular.isDefined(processInstanceId) && processInstanceId != "") {
  348. api_configure_form.renderForm(detailFormKey, '00000', processInstanceId,dataId).then(function(responseData) {
  349. if (responseData) {
  350. var vmForm = Restangular.stripRestangular(responseData);
  351. if (vmForm) {
  352. var modelData = {};
  353. modelData[pdKey] = vmForm.model;
  354. decodeVMForm(vmForm, modelData);
  355. }
  356. }
  357. });
  358. } else if (angular.isDefined(dataId) && dataId != "") {
  359. api_bpm_data.fetchData(pdKey, dataId).then(function(response) {
  360. if (response) {
  361. var myData = Restangular.stripRestangular(response);
  362. var processInstanceId = myData.data.processInstanceId;
  363. //$scope.vm.model[pdKey]=myData.data;
  364. api_configure_form.renderForm(detailFormKey, '00000', processInstanceId).then(function(responseData) {
  365. if (responseData) {
  366. // console.log("responseData>>>");console.log(responseData);
  367. var vmForm = Restangular.stripRestangular(responseData);
  368. if (!processInstanceId) {
  369. vmForm.model[pdKey] = myData.data;
  370. }
  371. if (vmForm) {
  372. //console.log("vmForm>>>");console.log(vmForm);
  373. var modelData = {};
  374. modelData[pdKey] = vmForm.model;
  375. decodeVMForm(vmForm, modelData);
  376. }
  377. }
  378. });
  379. }
  380. })
  381. }
  382. } else {
  383. // create process instance
  384. if (pdKey != "") { //for process
  385. api_bpm_domain.startformkey(pdKey).then(function(response) {
  386. if (response) {
  387. var myData = Restangular.stripRestangular(response);
  388. api_configure_form.renderForm(myData.data).then(function(responseData) {
  389. if (responseData) {
  390. var vmForm = Restangular.stripRestangular(responseData);
  391. if (vmForm) {
  392. decodeVMForm(vmForm);
  393. console.log($scope);
  394. }
  395. }
  396. });
  397. }
  398. });
  399. } else { //for form
  400. //TODO
  401. //测试数据 开始
  402. var testJson = {
  403. fields: [{
  404. key: 'formtitle',
  405. type: 'ui-title',
  406. noFormControl: true,
  407. templateOptions: {
  408. label: 'title is ',
  409. placeholder: 'Formly is terrific!'
  410. }
  411. },
  412. {
  413. key: 'a',
  414. type: 'ui-input',
  415. className: 'col-xs-4',
  416. templateOptions: {
  417. type: 'input',
  418. label: 'input a',
  419. placeholder: 'search a...',
  420. lBtn: {
  421. label: 'input',
  422. onClick: function(val, opt, el, ev, model) { alert(val); }
  423. },
  424. rAddon: '@111.cc'
  425. }
  426. },
  427. {
  428. key: 'b',
  429. type: 'ui-input',
  430. className: 'col-xs-4',
  431. templateOptions: {
  432. type: 'input',
  433. label: 'input a',
  434. placeholder: 'search a...',
  435. rBtn: {
  436. icon: 'glyphicon-search',
  437. onClick: function(val, opt, el, ev, model) { alert(val); }
  438. },
  439. lAddon: '@'
  440. }
  441. },
  442. {
  443. key: 'first',
  444. type: 'ui-input',
  445. className: 'col-xs-2',
  446. templateOptions: {
  447. type: 'input',
  448. label: 'first name',
  449. pkey: 'name'
  450. }
  451. },
  452. {
  453. key: 'last',
  454. type: 'ui-input',
  455. className: 'col-xs-2',
  456. templateOptions: { type: 'input', label: 'last name', pkey: 'name' }
  457. },
  458. {
  459. key: 'username',
  460. type: 'ui-input',
  461. className: 'col-xs-6',
  462. templateOptions: {
  463. type: 'input',
  464. label: 'User Name',
  465. placeholder: 'Enter name',
  466. required: true,
  467. maxLength: 10
  468. }
  469. },
  470. {
  471. key: 'password',
  472. type: 'ui-input',
  473. className: 'col-xs-6',
  474. templateOptions: {
  475. type: 'password',
  476. label: 'Password',
  477. placeholder: 'Password',
  478. required: true
  479. },
  480. expressionProperties: {
  481. 'templateOptions.disabled': '!model.username'
  482. }
  483. },
  484. {
  485. key: 'selectmodal',
  486. type: 'ui-input-selectmodal',
  487. className: 'col-xs-6',
  488. templateOptions: {
  489. label: 'selectmodal',
  490. btnLabel: 'search',
  491. btnClassName: 'btn-o',
  492. modalParam: {
  493. items: function() {
  494. return ['a', 'b', 'c', 'd'];
  495. },
  496. title: function() {
  497. return '测试标题';
  498. }
  499. }
  500. }
  501. },
  502. {
  503. key: 'email',
  504. type: 'ui-input',
  505. className: 'col-xs-6',
  506. templateOptions: {
  507. type: 'email',
  508. maxlength: 10,
  509. minlength: 6,
  510. label: 'EMail'
  511. }
  512. },
  513. {
  514. key: 'date',
  515. type: 'ui-datepicker',
  516. className: 'col-xs-6',
  517. templateOptions: {
  518. label: 'Date',
  519. type: 'text',
  520. datepickerPopup: 'yyyy-MM-dd hh:mm:ss',
  521. initDate: function() {
  522. return new Date();
  523. }
  524. }
  525. },
  526. {
  527. key: 'multiselectItem',
  528. type: 'ui-multi-select-tree',
  529. className: 'col-xs-6',
  530. templateOptions: {
  531. label: 'multiSelect',
  532. placeholder: '请选择...',
  533. isMultiSelect: false,
  534. selLeafs: false, //只选叶子节点
  535. refreshData: function(APIService) {
  536. return APIService.fetchDataList('changeclassify', { 'idx': 0, 'sum': 100 });
  537. },
  538. APIService: api_bpm_data,
  539. optionsDataKey: 'list',
  540. refreshDelay: 1000,
  541. onDataCallback: function(item, selectItems, options, field, model) {
  542. model[options.key] = { id: item.id };
  543. }
  544. }
  545. },
  546. {
  547. key: 'selectItem',
  548. type: 'ui-select',
  549. className: 'col-xs-4',
  550. templateOptions: {
  551. label: 'ui-select',
  552. valueProp: 'code', //对应value
  553. labelProp: 'source', //对应key
  554. optionsUrl: 'data/fetchDataList/incidentsource', //对应后台地址,api/之前的部分省略
  555. optionsDataKey: 'list', //对应返回数组数据的键值,
  556. required: true,
  557. onChange: function(val, options, field, event, model) {
  558. model.start_code = val;
  559. }
  560. }
  561. },
  562. {
  563. key: 'multiselectItem',
  564. type: 'ui-multiselect',
  565. className: 'col-xs-4',
  566. templateOptions: {
  567. label: 'multi-select',
  568. valueProp: 'code', //对应value
  569. labelProp: 'source', //对应key
  570. optionsUrl: 'data/fetchDataList/incidentsource', //对应后台地址,api/之前的部分省略
  571. optionsDataKey: 'list', //对应返回数组数据的键值,
  572. required: true,
  573. onChange: function(val, options, field, event, model) {
  574. console.log(val);
  575. console.log(model);
  576. //model.start_code = val;
  577. }
  578. }
  579. },
  580. {
  581. key: 'checklistItem',
  582. type: 'ui-checklist',
  583. className: 'col-xs-4',
  584. templateOptions: {
  585. label: 'checklistItem',
  586. options: [
  587. { name: 'Iron Man', value: 'iron_man' },
  588. { name: 'Captain America', value: 'captain_america' },
  589. { name: 'Black Widow', value: 'black_widow' },
  590. { name: 'Hulk', value: 'hulk' },
  591. { name: 'Captain Marvel', value: 'captain_marvel' }
  592. ]
  593. }
  594. },
  595. {
  596. key: 'radioItem',
  597. type: 'ui-radio',
  598. className: 'col-xs-4',
  599. templateOptions: {
  600. label: 'radioItem',
  601. options: [
  602. { name: 'Iron Man', value: 'iron_man' },
  603. { name: 'Captain America', value: 'captain_america' },
  604. { name: 'Black Widow', value: 'black_widow' },
  605. { name: 'Hulk', value: 'hulk' },
  606. { name: 'Captain Marvel', value: 'captain_marvel' }
  607. ],
  608. type: 'number'
  609. }
  610. },
  611. {
  612. key: 'selectUser',
  613. type: 'ui-userselect',
  614. className: 'col-xs-12',
  615. templateOptions: {
  616. label: '请求人信息',
  617. modalTitle: '请求人列表',
  618. fetchItems: function(filterData, APIService) {
  619. return APIService.fetchDataList('user', filterData);
  620. },
  621. Restangular: Restangular,
  622. ApiService: api_user_data,
  623. onClick: function(val, options, field, event, model) {
  624. //model.start_code++;
  625. console.log(options);
  626. }
  627. }
  628. },
  629. {
  630. key: 'cabUser',
  631. type: 'ui-multiuserselect',
  632. className: 'col-xs-12',
  633. templateOptions: {
  634. label: 'CAB评审成员',
  635. modalTitle: 'CAB成员列表',
  636. fetchItems: function(filterData, APIService) {
  637. return APIService.fetchDataList('user', filterData);
  638. },
  639. Restangular: Restangular,
  640. ApiService: api_user_data,
  641. onClick: function(val, options, field, event, model) {
  642. console.log(model);
  643. }
  644. }
  645. },
  646. {
  647. key: 'incident',
  648. type: 'ui-modelselect',
  649. className: 'col-xs-3',
  650. templateOptions: {
  651. label: '关联事件工单',
  652. modalTitle: '事件列表',
  653. fetchItems: function(filterData, APIService) {
  654. return APIService.fetchDataList('incident', filterData);
  655. },
  656. Restangular: "Restangular",
  657. ApiService: "api_bpm_data",
  658. columnDefs: [
  659. { name: 'id', width: 80, enableFiltering: false },
  660. { name: 'title', displayName: '事件主题', width: 140 },
  661. { name: 'type.name', displayName: '事件类型', width: 140 },
  662. { name: 'emergency.name', displayName: '紧急度', width: 80 },
  663. { name: 'state.name', displayName: '状态', width: 100 },
  664. { name: 'emergency.name', displayName: '紧急度', width: 80 },
  665. { name: 'influence.name', displayName: '影响度', width: 80 },
  666. { name: 'priority.name', displayName: '优先级', width: 80 },
  667. { name: 'handlerUser.name', displayName: '当前处理人', width: 100 },
  668. { name: 'acceptDate', displayName: '创建时间', width: 100 }
  669. ],
  670. displayName: 'title',
  671. onClick: function(val, options, field, event, model) {
  672. //model.start_code++;
  673. console.log(options);
  674. }
  675. }
  676. },
  677. {
  678. key: 'worknumber',
  679. type: 'ui-workernumber',
  680. className: 'col-xs-3',
  681. templateOptions: {
  682. label: 'work number',
  683. Restangular: Restangular,
  684. ApiService: api_bpm_domain,
  685. getWorkernumber: function(APIService) {
  686. return APIService.workernumber('bg');
  687. }
  688. }
  689. },
  690. {
  691. key: 'chkme',
  692. type: 'ui-checkbox',
  693. className: 'col-xs-3',
  694. templateOptions: {
  695. label: 'Check me out'
  696. }
  697. },
  698. {
  699. key: 'droplink',
  700. type: 'ui-link',
  701. className: 'col-xs-3',
  702. templateOptions: {
  703. label: '添加附件',
  704. onClick: function(val, options, field, event, model) {
  705. if (angular.isUndefined(field.form.dropState)) {
  706. field.form.dropState = false;
  707. }
  708. field.form.dropState = !field.form.dropState;
  709. console.log(field);
  710. }
  711. }
  712. },
  713. {
  714. key: 'dropfile',
  715. type: 'ui-dropfile',
  716. className: 'col-xs-12',
  717. templateOptions: {
  718. label: '附件',
  719. uploadUrl: 'http://127.0.0.1:9008/saveAttachments'
  720. }
  721. },
  722. {
  723. key: 'droplist',
  724. type: 'ui-dropfiletable',
  725. className: 'col-xs-12',
  726. templateOptions: {
  727. label: '附件下载列表',
  728. Restangular: Restangular,
  729. ApiService: api_bpm_domain
  730. }
  731. },
  732. {
  733. key: 'start_code',
  734. className: 'col-xs-6',
  735. type: 'ui-hidden'
  736. },
  737. {
  738. key: 'remark',
  739. type: 'ui-textarea',
  740. className: 'col-xs-12',
  741. templateOptions: {
  742. label: 'remark is ',
  743. rows: 3
  744. }
  745. },
  746. {
  747. key: 'setStartCode',
  748. type: 'ui-button',
  749. className: 'col-xs-4',
  750. templateOptions: {
  751. label: 'customButton',
  752. onClick: function(val, options, field, event, model) {
  753. model.start_code++;
  754. console.log(options);
  755. }
  756. }
  757. }
  758. ],
  759. model: {
  760. username: "robin lau",
  761. password: "123456",
  762. chkme: false,
  763. start_code: 0,
  764. formtitle: "Hey!I am title value!",
  765. name: {
  766. first: "robin",
  767. last: "lau"
  768. },
  769. multiselectItem: []
  770. //date:"2015-09-15 00:00:00"
  771. }
  772. };
  773. setTimeout(function() {
  774. decodeVMForm(testJson);
  775. $scope.$apply();
  776. }, 500);
  777. //测试数据结束
  778. }
  779. }
  780. }
  781. ]);