systemFormCtrl.js 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  1. var sysFormly = angular.module('formlySystem', [
  2. 'formly', 'formlyBootstrap', 'ui.bootstrap',
  3. 'ngSanitize', 'ui.select', 'ui.grid'
  4. ]);
  5. app.requires.push('formlySystem');
  6. // var appFormly = angular.module('formlyExample', [
  7. // 'formly', 'formlyBootstrap','ui.bootstrap',
  8. // 'ngSanitize','ui.select','ui.grid'],
  9. sysFormly.config(
  10. function config(formlyConfigProvider) {
  11. //格式转换方法 XXX-XXX转驼峰命名
  12. });
  13. sysFormly.controller('SystemformCtrl', ['$rootScope', '$scope', '$parse', '$filter', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'moment', 'Restangular', 'UserRestangular', 'BpmRestangular', 'WechatRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_apply',
  14. function ($rootScope, $scope, $parse, $filter, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, moment, Restangular, UserRestangular, BpmRestangular, WechatRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data, api_apply) {
  15. //console.log($stateParams);
  16. var vm = this;
  17. vm.options = {};
  18. vm.exampleTitle = ['expressionProperties', 'model property'];
  19. vm.fields = [];
  20. vm.model = {};
  21. $scope.langs = i18nService.getAllLangs();
  22. $scope.lang = 'zh-cn';
  23. //alert($rootScope.user.id,null,2);
  24. vm.model["loginUser"] = $rootScope.user;
  25. var that = $injector;
  26. var parse = $parse;
  27. var modelWatch = "";
  28. var fieldsWatch = [];
  29. var serviceWatch = null;
  30. var formWatch = {};
  31. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  32. modelWatch = JSON.parse($stateParams.model);
  33. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  34. }
  35. if (angular.isDefined($stateParams.fields) && $stateParams.fields != "") {
  36. fieldsWatch = JSON.parse($stateParams.fields);
  37. }
  38. if (angular.isDefined($stateParams.extjson) && $stateParams.extjson != "") {
  39. formWatch.extjson = JSON.parse($stateParams.extjson);
  40. }
  41. if (angular.isDefined($stateParams.cancelUrl) && $stateParams.cancelUrl != "") {
  42. formWatch.cancelUrl = $stateParams.cancelUrl;
  43. }
  44. if (angular.isDefined($stateParams.url) && $stateParams.url != "") {
  45. formWatch.url = $stateParams.url;
  46. }
  47. if (angular.isDefined($stateParams.service) && $stateParams.service != "") {
  48. if (that.has($stateParams.service)) {
  49. serviceWatch = that.get($stateParams.service);
  50. } else {
  51. serviceWatch = $stateParams.service;
  52. }
  53. }
  54. //用户测试数据,后续从header的auth中获取
  55. var userId = 2;
  56. userId = $rootScope.user.id;
  57. //==============处理表单设计数据 开始====================
  58. //处理组件加载后台数据选项的方法
  59. function refreshSelectOptions(searchVal, field) {
  60. //todo
  61. console.log(field);
  62. if (field.key == 'id' && field.templateOptions.pkey == 'change.source') {
  63. field.templateOptions.options = [{ "id": 1, "name": "事件", "code": 1 }, { "id": 2, "name": "问题", "code": 2 }, { "id": 3, "name": "配置", "code": 3 }, { "id": 4, "name": "服务级别", "code": 4 }, { "id": 5, "name": "内部需求", "code": 5 }];
  64. } else if (field.templateOptions.optionsUrl) {
  65. var datakey = { "idx": 0, "sum": 1000 };
  66. if (field.templateOptions.modelreasondata) {
  67. datakey = field.templateOptions.modelreasondata
  68. }
  69. var process = BpmRestangular.all("");
  70. if (field.templateOptions.ApiService) {
  71. process = UserRestangular.all("");
  72. }
  73. if (field.templateOptions.Apicommon) {
  74. process = WechatRestangular.all("");
  75. field.templateOptions.Apicommon.getDictionary(datakey).then(function (result) {
  76. if (!field.templateOptions.options) {
  77. field.templateOptions.options = [];
  78. }
  79. if (field.templateOptions.optionsDataKey) {
  80. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  81. } else {
  82. field.templateOptions.options = result;
  83. }
  84. })
  85. } else {
  86. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  87. if (!field.templateOptions.options) {
  88. field.templateOptions.options = [];
  89. }
  90. if (field.templateOptions.optionsDataKey) {
  91. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  92. } else {
  93. field.templateOptions.options = result;
  94. }
  95. });
  96. }
  97. }
  98. }
  99. //解析自定义表单设计数据
  100. function decodeVMForm(vmForm) {
  101. var result = { model: {}, fields: [] };
  102. //设置模型实体数据 begin
  103. // var mdata = vmForm.model;
  104. //解析数据实体
  105. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  106. angular.extend(result.model, mdata);
  107. if (modelWatch != null && modelWatch != '') {
  108. //angular.extend(result.model.incident,modelWatch.incident);
  109. //result.model.alarmType = modelWatch.alarmType;
  110. // vmForm.cancelUrl = modelWatch.cancelUrl;
  111. for (var index in modelWatch.model) {
  112. console.log(JSON.stringify(index + " " + JSON.stringify(modelWatch.model[index])));
  113. if (result.model[index] != null) {
  114. angular.extend(result.model[index], modelWatch.model[index]);
  115. } else {
  116. result.model[index] = modelWatch.model[index];
  117. }
  118. }
  119. }
  120. //设置模型实体数据 end
  121. //解析设计数据生成表单项 begin
  122. var fields = [];
  123. //处理修改设计数据中展示设置
  124. angular.forEach(vmForm.fields, function (field) {
  125. if (field.key == "") {
  126. delete field.key;
  127. }
  128. if (angular.isDefined(field.extjson)) {
  129. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  130. angular.extend(field.templateOptions, extObj.templateOptions);
  131. delete extObj.templateOptions;
  132. for (var prop in extObj) {
  133. if (new RegExp("Expression").test(prop)) {
  134. //var obj = $scope.$eval(extObj[prop]);
  135. //extObj[prop] = $scope.$eval(extObj[prop]);
  136. if (extObj[prop] != null) {
  137. if (new RegExp("function").test(extObj[prop])) {
  138. var propValue = eval(extObj[prop]);
  139. extObj[prop] = propValue;
  140. } else {
  141. //console.log(extObj[prop]);
  142. var obj = $scope.$eval(extObj[prop]);
  143. extObj[prop] = obj;
  144. //console.log(obj);
  145. }
  146. }
  147. } else if (new RegExp("expressionProperties").test(prop)) {
  148. for (var p in extObj[prop]) {
  149. if (new RegExp("function").test(extObj[prop][p])) {
  150. var propValue = eval(extObj[prop][p]);
  151. extObj[prop][p] = propValue;
  152. } else {
  153. }
  154. }
  155. } else if ("watcher" == prop) {
  156. if (angular.isArray(extObj[prop])) {
  157. angular.forEach(extObj[prop], function (item, index) {
  158. for (var p in item) {
  159. if (new RegExp("function").test(item[p])) {
  160. var propValue = eval(item[p]);
  161. extObj[prop][index][p] = propValue;
  162. }
  163. }
  164. });
  165. } else if (angular.isObject(extObj[prop])) {
  166. for (var p in extObj[prop]) {
  167. if (new RegExp("function").test(extObj[prop][p])) {
  168. var propValue = eval(extObj[prop][p]);
  169. extObj[prop][p] = propValue;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. angular.extend(field, extObj);
  176. delete field.extjson;
  177. }
  178. if (angular.isDefined(field.templateOptions)) {
  179. var templateOs = field.templateOptions;
  180. for (var property in templateOs) {
  181. //console.log(property);
  182. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  183. if (new RegExp("function").test(templateOs[property])) {
  184. var propValue = eval(templateOs[property]);
  185. field.templateOptions[property] = propValue;
  186. } else {
  187. if (that.has(templateOs[property])) {
  188. field.templateOptions[property] = that.get(templateOs[property]);
  189. } else {
  190. field.templateOptions[property] = templateOs[property];
  191. }
  192. }
  193. } else if (templateOs[property] == null) {
  194. //delete field.templateOptions[property];
  195. } else { }
  196. }
  197. }
  198. //console.log(field);
  199. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  200. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  201. angular.extend(field.templateOptions, extObj);
  202. delete field.templateOptions.extjson;
  203. }
  204. //...
  205. if (field.templateOptions) {
  206. //处理远程获取数据控件方法调用
  207. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  208. field.templateOptions.refresh = refreshSelectOptions;
  209. }
  210. //处理嵌套属性数据绑定/
  211. if (field.templateOptions.pkey) {
  212. var pmodel, i = 0;
  213. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  214. if (i == 0) {
  215. if (result.model[p] == null) {
  216. result.model[p] = {};
  217. }
  218. pmodel = result.model[p];
  219. i++;
  220. } else {
  221. if (pmodel[p] == null) {
  222. pmodel[p] = {};
  223. }
  224. pmodel = pmodel[p];
  225. }
  226. });
  227. if (pmodel != null) {
  228. field.model = pmodel;
  229. if (pmodel[field.key] == null) {
  230. pmodel[field.key] = null;
  231. }
  232. }
  233. } else {
  234. if (result.model[field.key] == null) {
  235. result.model[field.key] = null;
  236. }
  237. }
  238. //处理弹出框组件初始化
  239. if (field.type == "ui-input-selectmodal") {
  240. field.templateOptions.modal = $modal;
  241. //field.templateOptions.Restangular = Restangular;
  242. } else if (field.type == "ui-requesterselect") {
  243. //field.templateOptions.language = $scope.lang;
  244. field.templateOptions.modal = $modal;
  245. field.templateOptions.UserService = api_user_data;
  246. } else if (field.type == "ui-userselect") {
  247. field.templateOptions.modal = $modal;
  248. //field.templateOptions.Restangular = Restangular;
  249. } else if (field.type == "ui-multiuserselect") {
  250. field.templateOptions.modal = $modal;
  251. } else if (field.type == "ui-search") {
  252. field.templateOptions.modal = $modal;
  253. } else if (field.type == "ui-modelselect") {
  254. field.templateOptions.modal = $modal;
  255. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  256. field.templateOptions.loginUser = $rootScope.user;
  257. //field.templateOptions.Restangular = Restangular;
  258. } else if (field.type == "ui-dropfile") {
  259. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  260. url: '/uploader'
  261. });
  262. field.templateOptions.taskId = $stateParams.taskId;
  263. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  264. field.templateOptions.userId = $rootScope.user.id;
  265. //field.ApiService=api_bpm_domain;
  266. } else if (field.type == "ui-dropfiletable") {
  267. if (field.templateOptions.processInstanceId) {
  268. } else {
  269. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  270. }
  271. } else if (field.type == "ui-repeatSection") {
  272. var repeatForm = {
  273. model: {
  274. },
  275. fields: field.templateOptions.fields
  276. };
  277. repeatForm.model[field.key] = [];
  278. decodeVMForm(repeatForm);
  279. } else if (field.type == "ui-currentuser") {
  280. field.templateOptions.user = vm.model["loginUser"];
  281. }
  282. }
  283. // console.log(field);
  284. result.fields.push(field);
  285. });
  286. angular.extend($scope.vm.fields, result.fields);
  287. angular.extend($scope.vm.model, result.model);
  288. // console.log($rootScope.user);
  289. //vm.model["loginUser"] = $rootScope.user;
  290. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  291. vmForm.cancelUrl = modelWatch.cancelUrl;
  292. }
  293. $scope.formData = vmForm;
  294. //console.log($scope.vm);
  295. //解析设计数据生成表单项 end
  296. return result;
  297. }
  298. //======================处理表单设计数据 结束========================
  299. $scope.ldloading = {};
  300. function filter(obj) {
  301. angular.forEach(obj, function (key, value) {
  302. if (value === "" || value === null) {
  303. delete obj[key];
  304. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  305. filter(value);
  306. } else if (angular.isArray(value)) {
  307. angular.forEach(value, function (item) {
  308. filter(item);
  309. });
  310. }
  311. });
  312. }
  313. $scope.statego = function (data) {
  314. data.state_model.model.incident.area = data.state_model.model.incident.place.areas;
  315. $state.go(data.gourl, { 'model': JSON.stringify(data.state_model) });
  316. event.preventDefault();
  317. }
  318. $scope.closeModel = function () {
  319. // console.log("$stateParams.formKey="+JSON.stringify($stateParams.formKey))
  320. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  321. // if ($stateParams.formKey == "system_edit") {
  322. // $state.go('app.system.user.user', {});
  323. // } else if ($stateParams.formKey == "system_edit_role") {
  324. // $state.go('app.system.user.role', {});
  325. // } else if ($stateParams.formKey == "system_edit_roletype") {
  326. // $state.go('app.system.user.role', {});
  327. // } else if ($stateParams.formKey == "system_edit_navmanager") {
  328. // $state.go('app.system.navmanager', {});
  329. // } else if ($stateParams.formKey == "system_edit_requester") {
  330. // $state.go('app.system.userdesign.requester', {});
  331. // } else if ($stateParams.formKey == "noticeEditor") {
  332. // $state.go('app.system.notice.list', {});
  333. // } else if ($stateParams.formKey == "noticeDetail") {
  334. // $state.go('app.system.notice.list', {});
  335. // } else if ($stateParams.formKey == "desk_detail") {
  336. // $state.go('app.desk.chart', {});
  337. // } else if ($stateParams.formKey == "system_add_service") {
  338. // $state.go('app.system.navmanager', {});
  339. // } else if ($stateParams.formKey == "system_add_menu") {
  340. // // $state.go('app.system.user.power', {});
  341. // $state.go('app.system.navmanager', {});
  342. // } else if ($stateParams.formKey == "system_add_service") {
  343. // $state.go('app.system.navmanager', {});
  344. // }
  345. $state.go($scope.formData.cancelUrl, {});
  346. event.preventDefault();
  347. }
  348. }
  349. console.log(vm)
  350. $scope.submit = function (model) {
  351. if (model.rejectRemark && model.rejectRemark != "") {
  352. api_apply.wxIncidentReject(model.incident.id, { "rejectRemark": model.rejectRemark }).then(function (data) {
  353. if (data && data.state == 200) {
  354. SweetAlert.swal({
  355. title: "提交成功",
  356. text: '不受理提交成功',
  357. type: "success"
  358. }, function () {
  359. $state.go('app.desk.chart', {});
  360. });
  361. } else {
  362. SweetAlert.swal({
  363. title: "提交失败",
  364. text: '不受理提交失败',
  365. type: "error"
  366. });
  367. }
  368. });
  369. } else {
  370. SweetAlert.swal({
  371. title: "提交错误",
  372. text: "请填写不受理原因!",
  373. type: "error",
  374. confirmButtonColor: "#DD6B55"
  375. });
  376. }
  377. }
  378. vm.submit = function (data, style) {
  379. if ($stateParams.formKey == "system_edit" || $stateParams.formKey == "system_edit_requester" || $stateParams.formKey == "system_add_menu" || $stateParams.formKey == "system_add_service" || $stateParams.formKey == "noticeEditor") {
  380. // console.log("roleid="+$scope.roleid);
  381. if (vm.form.$valid) {
  382. vm.options.updateInitialValue();
  383. $scope.ldloading[style.replace('-', '_')] = true;
  384. // alert(JSON.stringify(vm.model), null, 2);
  385. var _ = window._;
  386. vm.model = (function filter(obj) { //过滤
  387. var dateTransKeys = [];
  388. var filtered = _.pick(obj, function (v, k, obj) {
  389. if (_.isDate(v)) {
  390. dateTransKeys.push(k);
  391. }
  392. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  393. });
  394. return _.cloneDeep(filtered, function (v, index, object) {
  395. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  396. angular.forEach(dateTransKeys, function (item) {
  397. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  398. });
  399. dateTransKey = [];
  400. return v;
  401. }
  402. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  403. });
  404. })(vm.model);
  405. if ($scope.formData.modelName) {
  406. if (vm.model[$scope.formData.modelName]) {
  407. for (var key in vm.model[$scope.formData.modelName]) {
  408. if (vm.model[$scope.formData.modelName][key] &&
  409. (vm.model[$scope.formData.modelName][key] == null || vm.model[$scope.formData.modelName][key] == undefined || JSON.stringify(vm.model[$scope.formData.modelName][key]) == "{}")) {
  410. delete vm.model[$scope.formData.modelName][key];
  411. }
  412. }
  413. }
  414. }
  415. switch ($scope.formData.url) {
  416. case "create":
  417. //vm.model["initUser"]=$rootScope.user.id;
  418. //addData
  419. // if (vm.model.id) {
  420. // if ($stateParams.formKey == "system_add_menu") {
  421. // vm.model.parent = vm.model.menu.parent;
  422. // delete vm.model.menu;
  423. // }
  424. // serviceWatch.updData($scope.formData.modelName, vm.model).then(function(response) {
  425. // if (response && response.status == 200) {
  426. // SweetAlert.swal({
  427. // title: "修改成功!",
  428. // confirmButtonColor: "#007AFF"
  429. // }, function() {
  430. // // $state.go($scope.formData.cancelUrl);
  431. // });
  432. // } else {
  433. // SweetAlert.swal({
  434. // title: "系统错误",
  435. // text: "系统错误,请稍后重试!",
  436. // type: "error",
  437. // confirmButtonColor: "#DD6B55"
  438. // });
  439. // }
  440. // $scope.ldloading[style.replace('-', '_')] = false;
  441. // });
  442. // } else {
  443. if ($stateParams.formKey == "system_add_menu" && vm.model.menu) {
  444. vm.model.parent = vm.model.menu.parent;
  445. delete vm.model.menu;
  446. }
  447. if ($stateParams.formKey == "system_add_service") {
  448. if (vm.model.menu) {
  449. vm.model.menu = vm.model.menu.menu;
  450. delete vm.model.menu.menu;
  451. }
  452. serviceWatch.addData("linkConfigure", vm.model).then(function (response) {
  453. if (response) {
  454. var resData = Restangular.stripRestangular(response);
  455. if (resData && resData.status == 200) {
  456. SweetAlert.swal({
  457. title: "提交成功!",
  458. type: "success",
  459. confirmButtonColor: "#007AFF"
  460. }, function () {
  461. $state.go($scope.formData.cancelUrl);
  462. });
  463. } else {
  464. SweetAlert.swal({
  465. title: "系统错误",
  466. text: "系统错误,请稍后重试!",
  467. type: "error",
  468. confirmButtonColor: "#DD6B55"
  469. });
  470. }
  471. } else {
  472. SweetAlert.swal({
  473. title: "系统错误",
  474. text: "系统错误,请稍后重试!",
  475. type: "error",
  476. confirmButtonColor: "#DD6B55"
  477. });
  478. }
  479. $scope.ldloading[style.replace('-', '_')] = false;
  480. });
  481. } else {
  482. serviceWatch.addData($scope.formData.modelName, vm.model).then(function (response) {
  483. if (response) {
  484. var resData = Restangular.stripRestangular(response);
  485. if (resData && resData.status == 200) {
  486. SweetAlert.swal({
  487. title: "提交成功!",
  488. type: "success",
  489. confirmButtonColor: "#007AFF"
  490. }, function () {
  491. $state.go($scope.formData.cancelUrl);
  492. });
  493. } else {
  494. SweetAlert.swal({
  495. title: "系统错误",
  496. text: "系统错误,请稍后重试!",
  497. type: "error",
  498. confirmButtonColor: "#DD6B55"
  499. });
  500. }
  501. } else {
  502. SweetAlert.swal({
  503. title: "系统错误",
  504. text: "系统错误,请稍后重试!",
  505. type: "error",
  506. confirmButtonColor: "#DD6B55"
  507. });
  508. }
  509. $scope.ldloading[style.replace('-', '_')] = false;
  510. });
  511. }
  512. // }
  513. break;
  514. case "save":
  515. //addData
  516. // if ($scope.formData.name == "system_edit" && !vm.model.user.role) {
  517. // vm.form.$valid = false;
  518. // SweetAlert.swal({
  519. // title: "校验错误",
  520. // text: "请填写必填项!",
  521. // type: "error",
  522. // confirmButtonColor: "#DD6B55"
  523. // });
  524. // angular.forEach(vm.form.$error.required, function(item) {
  525. // angular.forEach(vm.fields, function(f) {
  526. // if (f.name == item.$name) {
  527. // f.validation.show = true;
  528. // }
  529. // });
  530. // })
  531. // } else {
  532. if ($scope.formData.name == "system_edit") {
  533. if (vm.model.user.dept) {
  534. delete vm.model.user.dept.children;
  535. }
  536. }
  537. if($scope.formData.name == "system_edit"){
  538. if(vm.model.user){
  539. console.log(vm.model);
  540. if(vm.model.user.role==undefined||vm.model.user.group==undefined){
  541. SweetAlert.swal({
  542. title: "提交失败",
  543. text: "必填项没有填写完整,请重新再填!",
  544. type: "error",
  545. confirmButtonColor: "#DD6B55"
  546. });
  547. $state.go($scope.formData.cancelUrl);
  548. return false;
  549. }
  550. }
  551. }
  552. if($scope.formData.name == "system_edit_requester"){
  553. if(vm.model.requester){
  554. if(vm.model.requester.dept==undefined){
  555. SweetAlert.swal({
  556. title: "提交失败",
  557. text: "必填项没有填写完整,请重新再填!",
  558. type: "error",
  559. confirmButtonColor: "#DD6B55"
  560. });
  561. $state.go($scope.formData.cancelUrl);
  562. return false;
  563. }
  564. }
  565. }
  566. serviceWatch.addData($scope.formData.modelName, vm.model).then(function (response) {
  567. if (response) {
  568. var resData = Restangular.stripRestangular(response);
  569. if (resData && resData.status == 200) {
  570. if ($scope.formData.name == "system_edit") {
  571. if (!response.data.account) {
  572. SweetAlert.swal({
  573. title: "提交失败",
  574. text: "工号已存在,请重新填写!",
  575. type: "error",
  576. confirmButtonColor: "#DD6B55"
  577. }, function () {
  578. renderform();
  579. });
  580. } else if (!response.data.name) {
  581. SweetAlert.swal({
  582. title: "提交失败",
  583. text: "用户名已存在,请重新填写!",
  584. type: "error",
  585. confirmButtonColor: "#DD6B55"
  586. }, function () {
  587. renderform();
  588. });
  589. } else {
  590. SweetAlert.swal({
  591. title: "提交成功!",
  592. type: "success",
  593. confirmButtonColor: "#007AFF"
  594. }, function () {
  595. console.log(vm.model);
  596. if (vm.fields[0].templateOptions.label == '新增/编辑用户') {
  597. var modalInstance = $modal.open({
  598. templateUrl: 'assets/views/system/qxts.html',
  599. controller: function ($scope, $modalInstance, scope, state) {
  600. $scope.wt_ok = function () {
  601. state.go('app.system.qxgl');
  602. $modalInstance.dismiss('cancel');
  603. console.log(state);
  604. }
  605. $scope.wt_cancel = function () {
  606. state.go(scope.formData.cancelUrl);
  607. $modalInstance.dismiss('cancel');
  608. console.log(state);
  609. }
  610. }, size: 'sm',
  611. backdrop: 'static',
  612. resolve: {
  613. scope: function () {
  614. return $scope
  615. },
  616. state: function () {
  617. return $state
  618. }
  619. }
  620. });
  621. }
  622. // $state.go($scope.formData.cancelUrl);
  623. });
  624. }
  625. } else {
  626. SweetAlert.swal({
  627. title: "提交成功!",
  628. type: "success",
  629. confirmButtonColor: "#007AFF"
  630. }, function () {
  631. $state.go($scope.formData.cancelUrl);
  632. });
  633. }
  634. } else {
  635. SweetAlert.swal({
  636. title: "系统错误",
  637. text: "系统错误,请稍后重试!",
  638. type: "error",
  639. confirmButtonColor: "#DD6B55"
  640. });
  641. }
  642. } else {
  643. SweetAlert.swal({
  644. title: "系统错误",
  645. text: "系统错误,请稍后重试!",
  646. type: "error",
  647. confirmButtonColor: "#DD6B55"
  648. });
  649. }
  650. $scope.ldloading[style.replace('-', '_')] = false;
  651. });
  652. // }
  653. break;
  654. case "close":
  655. $state.go($scope.formData.cancelUrl);
  656. break;
  657. default:
  658. $scope.ldloading[style.replace('-', '_')] = false;
  659. break;
  660. }
  661. } else {
  662. SweetAlert.swal({
  663. title: "校验错误",
  664. text: "请填写必填项!",
  665. type: "error",
  666. confirmButtonColor: "#DD6B55"
  667. });
  668. angular.forEach(vm.form.$error.required, function (item) {
  669. angular.forEach(vm.fields, function (f) {
  670. if (f.name == item.$name) {
  671. f.validation.show = true;
  672. }
  673. });
  674. })
  675. }
  676. } else {
  677. var role = {};
  678. var data1 = {};
  679. // console.log("data.role="+JSON.stringify(data.role));
  680. role['rolecode'] = data.role.rolecode;
  681. role['id'] = data.role.id;
  682. // console.log("role="+JSON.stringify(role));
  683. data1['role'] = role;
  684. // console.log("data1="+JSON.stringify(data1));
  685. api_user_data.validate(data1, 'role').then(function (response) {
  686. var resData = Restangular.stripRestangular(response);
  687. // console.log("resData11="+JSON.stringify(resData));
  688. if (resData.status == 200 && resData.data == "false" && vm.form.$valid) {
  689. // if (vm.form.$valid ) {
  690. vm.options.updateInitialValue();
  691. $scope.ldloading[style.replace('-', '_')] = true;
  692. // alert(JSON.stringify(vm.model), null, 2);
  693. var _ = window._;
  694. vm.model = (function filter(obj) {
  695. var dateTransKeys = [];
  696. var filtered = _.pick(obj, function (v, k, obj) {
  697. if (_.isDate(v)) {
  698. dateTransKeys.push(k);
  699. }
  700. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  701. });
  702. return _.cloneDeep(filtered, function (v, index, object) {
  703. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  704. angular.forEach(dateTransKeys, function (item) {
  705. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  706. });
  707. dateTransKey = [];
  708. return v;
  709. }
  710. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  711. });
  712. })(vm.model);
  713. // console.log("$scope.formData="+$scope.formData);
  714. switch ($scope.formData.url) {
  715. case "create":
  716. //vm.model["initUser"]=$rootScope.user.id;
  717. //addData
  718. serviceWatch.addData($scope.formData.modelName, vm.model).then(function (response) {
  719. if (response) {
  720. var resData = Restangular.stripRestangular(response);
  721. if (resData && resData.status == 200) {
  722. SweetAlert.swal({
  723. title: "提交成功!",
  724. type: "success",
  725. confirmButtonColor: "#007AFF"
  726. }, function () {
  727. $state.go($scope.formData.cancelUrl);
  728. });
  729. } else {
  730. SweetAlert.swal({
  731. title: "系统错误",
  732. text: "系统错误,请稍后重试!",
  733. type: "error",
  734. confirmButtonColor: "#DD6B55"
  735. });
  736. }
  737. } else {
  738. SweetAlert.swal({
  739. title: "系统错误",
  740. text: "系统错误,请稍后重试!",
  741. type: "error",
  742. confirmButtonColor: "#DD6B55"
  743. });
  744. }
  745. $scope.ldloading[style.replace('-', '_')] = false;
  746. });
  747. break;
  748. case "save":
  749. //addData
  750. serviceWatch.addData($scope.formData.modelName, vm.model).then(function (response) {
  751. if (response) {
  752. var resData = Restangular.stripRestangular(response);
  753. // console.log("resData="+JSON.stringify(resData.data));
  754. // console.log("modelWatch.model="+JSON.stringify(modelWatch.model));
  755. if (resData && resData.status == 200) {
  756. SweetAlert.swal({
  757. title: "提交成功!",
  758. type: "success",
  759. confirmButtonColor: "#007AFF"
  760. }, function () {
  761. $state.go($scope.formData.cancelUrl);
  762. });
  763. } else {
  764. SweetAlert.swal({
  765. title: "系统错误",
  766. text: "系统错误,请稍后重试!",
  767. type: "error",
  768. confirmButtonColor: "#DD6B55"
  769. });
  770. }
  771. } else {
  772. SweetAlert.swal({
  773. title: "系统错误",
  774. text: "系统错误,请稍后重试!",
  775. type: "error",
  776. confirmButtonColor: "#DD6B55"
  777. });
  778. }
  779. $scope.ldloading[style.replace('-', '_')] = false;
  780. });
  781. break;
  782. case "close":
  783. $state.go($scope.formData.cancelUrl);
  784. break;
  785. default:
  786. $scope.ldloading[style.replace('-', '_')] = false;
  787. break;
  788. }
  789. } else if (resData.status == 200 && resData.data == "true" && vm.form.$valid) {
  790. SweetAlert.swal({
  791. title: "角色代码以存在",
  792. text: "请重新填写角色代码!",
  793. type: "error",
  794. confirmButtonColor: "#DD6B55"
  795. });
  796. } else {
  797. SweetAlert.swal({
  798. title: "校验错误",
  799. text: "请填写必填项!",
  800. type: "error",
  801. confirmButtonColor: "#DD6B55"
  802. });
  803. angular.forEach(vm.form.$error.required, function (item) {
  804. angular.forEach(vm.fields, function (f) {
  805. if (f.name == item.$name) {
  806. f.validation.show = true;
  807. }
  808. });
  809. })
  810. }
  811. })
  812. }
  813. };
  814. $scope.vm = vm;
  815. function renderform() {
  816. api_configure_form.renderForm($stateParams.formKey, '00000').then(function (responseData) {
  817. if (responseData) {
  818. //console.log("responseData>>>");console.log(responseData);
  819. var vmForm = Restangular.stripRestangular(responseData);
  820. if (vmForm) {
  821. //console.log("vmForm>>>");console.log(vmForm);
  822. var modelData = {};
  823. //modelData=myData.data;
  824. decodeVMForm(vmForm);
  825. }
  826. }
  827. });
  828. }
  829. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  830. renderform();
  831. // api_configure_form.renderForm($stateParams.formKey, '00000').then(function(responseData) {
  832. // if (responseData) {
  833. // //console.log("responseData>>>");console.log(responseData);
  834. // var vmForm = Restangular.stripRestangular(responseData);
  835. // if (vmForm) {
  836. // //console.log("vmForm>>>");console.log(vmForm);
  837. // var modelData = {};
  838. // //modelData=myData.data;
  839. // decodeVMForm(vmForm);
  840. // }
  841. // }
  842. // });
  843. } else {
  844. //
  845. if (angular.isDefined(fieldsWatch) && fieldsWatch.length > 0) {
  846. var vmForm = {
  847. fields: fieldsWatch,
  848. model: modelWatch
  849. }
  850. angular.extend(vmForm, formWatch);
  851. //$scope.formData = vmForm;
  852. if (vmForm) {
  853. decodeVMForm(vmForm);
  854. }
  855. } else { //for form
  856. //TODO
  857. //测试数据 开始
  858. var testJson = {
  859. fields: [{
  860. key: 'formtitle',
  861. type: 'ui-title',
  862. noFormControl: true,
  863. templateOptions: {
  864. label: 'title is ',
  865. placeholder: 'Formly is terrific!'
  866. }
  867. },
  868. {
  869. key: 'b',
  870. type: 'ui-input',
  871. className: 'col-xs-4',
  872. templateOptions: {
  873. type: 'input',
  874. label: 'input a',
  875. placeholder: 'search a...',
  876. rBtn: {
  877. icon: 'fa fa-phone',
  878. onClick: function (val, opt, el, ev, model) { alert(val); }
  879. },
  880. lAddon: '<i class="fa fa-phone"/>'
  881. }
  882. },
  883. {
  884. key: 'id',
  885. type: 'ui-select',
  886. //initialValue:"false",
  887. templateOptions: {
  888. label: "测试默认值",
  889. optionsUrl: "abc",
  890. //options:[{"id":"false","name":"不取消"},{"id":"true","name":"取消"}],
  891. // refresh:function(){
  892. // return [{"id":1,"name":"事件","code":1},{"id":2,"name":"问题","code":2},{"id":3,"name":"配置","code":3},{"id":4,"name":"服务级别","code":4},{"id":5,"name":"内部需求","code":5}];
  893. // },
  894. //options:[{"id":1,"name":"事件","code":1},{"id":2,"name":"问题","code":2},{"id":3,"name":"配置","code":3},{"id":4,"name":"服务级别","code":4},{"id":5,"name":"内部需求","code":5}],
  895. valueProp: "id",
  896. labelProp: "name",
  897. pkey: "change.source"
  898. }
  899. },
  900. {
  901. key: 'systemType',
  902. type: 'ui-multiselect',
  903. className: 'col-xs-4',
  904. templateOptions: {
  905. label: "所属系统类型",
  906. pkey: "change",
  907. valueProp: "id",
  908. labelProp: "source",
  909. optionsUrl: "data/fetchDataList/changesystemtype",
  910. optionsDataKey: "list",
  911. onChange: function (value, options, that, event, model) {
  912. var field = null;
  913. angular.forEach(that.$parent.fields, function (item) {
  914. if (item.key == 'influenceDepartment') {
  915. field = item;
  916. }
  917. if (item.key == 'notificationDepartment') {
  918. notifyField = item;
  919. }
  920. })
  921. if (field != null) {
  922. field.templateOptions.optionsPostData = {
  923. 'systemIds': []
  924. }
  925. angular.forEach(value, function (vue) {
  926. field.templateOptions.optionsPostData['systemIds'].push({ 'id': vue });
  927. })
  928. field.value([]);
  929. if (value.length > 0) {
  930. field.templateOptions.refreshData(null, field);
  931. }
  932. }
  933. if (notifyField != null) {
  934. notifyField.templateOptions.optionsPostData = {
  935. 'systemIds': []
  936. }
  937. angular.forEach(value, function (vue) {
  938. notifyField.templateOptions.optionsPostData['systemIds'].push({ 'id': vue });
  939. })
  940. notifyField.value([]);
  941. if (value.length > 0) {
  942. notifyField.templateOptions.refreshData(null, notifyField);
  943. }
  944. }
  945. }
  946. }
  947. },
  948. {
  949. key: 'influenceDepartment',
  950. type: 'ui-multiselectplus',
  951. className: 'col-xs-4',
  952. templateOptions: {
  953. label: '所影响的应用系统、部门',
  954. pkey: "change",
  955. valueProp: '', //对应value
  956. labelProp: 'dept', //对应key
  957. optionsUrl: 'dept/findBySystemType', //对应后台地址,api/之前的部分省略
  958. optionsDataKey: 'list', //对应返回数组数据的键值,
  959. optionsPostData: function (options, model, scope) {
  960. return { "systemIds": [] };
  961. },
  962. refreshData: function (search, options, model, that) {
  963. options.templateOptions.options = [{ "id": 13, "dept": "村镇银行管理部" }, { "id": 14, "dept": "电子银行部" }];
  964. options.value(options.templateOptions.options);
  965. },
  966. optionsChecked: true,
  967. required: true,
  968. ApiService: UserRestangular
  969. }
  970. },
  971. {
  972. key: 'notificationDepartment',
  973. type: 'ui-multiselectplus',
  974. className: 'col-xs-4',
  975. templateOptions: {
  976. label: '需通知部门',
  977. pkey: "change",
  978. valueProp: 'id', //对应value
  979. labelProp: 'dept', //对应key
  980. optionsUrl: 'dept/findBySystemType', //对应后台地址,api/之前的部分省略
  981. optionsDataKey: 'list', //对应返回数组数据的键值,
  982. optionsPostData: function (options, model, scope) {
  983. return { "systemIds": [] };
  984. },
  985. optionsChecked: true,
  986. required: true,
  987. ApiService: UserRestangular
  988. }
  989. },
  990. {
  991. type: 'ui-label',
  992. key: 'arrayData',
  993. className: 'col-xs-4',
  994. templateOptions: {
  995. label: '数组label数据',
  996. labelProp: 'dept'
  997. }
  998. },
  999. {
  1000. key: 'selectUser',
  1001. type: 'ui-requesterselect',
  1002. className: 'col-xs-12',
  1003. templateOptions: {
  1004. label: '请求人信息',
  1005. modalTitle: '请求人列表',
  1006. fetchItems: function (filterData, APIService) {
  1007. return APIService.fetchDataList('requester', filterData);
  1008. },
  1009. Restangular: Restangular,
  1010. ApiService: api_user_data
  1011. // onClick:function(val, options, field, event , model){
  1012. // console.log(options);
  1013. // }
  1014. }
  1015. },
  1016. {
  1017. key: 'cabUser',
  1018. type: 'ui-multiuserselect',
  1019. className: 'col-xs-12',
  1020. templateOptions: {
  1021. label: 'CAB评审成员',
  1022. modalTitle: 'CAB成员列表',
  1023. fetchItems: function (filterData, APIService) {
  1024. return APIService.fetchDataList('user', filterData);
  1025. },
  1026. Restangular: Restangular,
  1027. ApiService: api_user_data,
  1028. onClick: function (val, options, field, event, model) {
  1029. console.log(model);
  1030. }
  1031. }
  1032. },
  1033. // {
  1034. // key:'incident',
  1035. // type:'ui-modelselect',
  1036. // className:'col-xs-3',
  1037. // templateOptions:{
  1038. // label:'关联事件工单',
  1039. // modalTitle:'事件列表',
  1040. // fetchItems:function(filterData,APIService){
  1041. // return APIService.fetchDataList('incident',filterData);
  1042. // },
  1043. // Restangular:"Restangular",
  1044. // ApiService:"api_bpm_data",
  1045. // columnDefs:[
  1046. // { name:'id', width:80, enableFiltering:false},
  1047. // { name:'title', displayName:'事件主题', width:140},
  1048. // { name:'type.name', displayName:'事件类型', width:140},
  1049. // { name:'emergency.name', displayName:'紧急度', width:80},
  1050. // { name:'state.name', displayName:'状态', width:100},
  1051. // { name:'emergency.name', displayName:'紧急度', width:80},
  1052. // { name:'influence.name', displayName:'影响度', width:80},
  1053. // { name:'priority.name', displayName:'优先级', width:80},
  1054. // { name:'handlerUser.name', displayName:'当前处理人', width:100},
  1055. // { name:'acceptDate', displayName:'创建时间', width:100}
  1056. // ],
  1057. // displayName:'title',
  1058. // onClick:function(val, options, field, event , model){
  1059. // //model.start_code++;
  1060. // console.log(options);
  1061. // }
  1062. // }
  1063. // },
  1064. // {
  1065. // key: 'worknumber',
  1066. // type: 'ui-workernumber',
  1067. // className:'col-xs-3',
  1068. // templateOptions: {
  1069. // label: 'work number',
  1070. // Restangular:Restangular,
  1071. // ApiService:api_bpm_domain,
  1072. // getWorkernumber: function(APIService){
  1073. // return APIService.workernumber('bg');
  1074. // }
  1075. // }
  1076. // },
  1077. // {
  1078. // key: 'chkme',
  1079. // type: 'ui-checkbox',
  1080. // className:'col-xs-3',
  1081. // templateOptions: {
  1082. // label: 'Check me out'
  1083. // }
  1084. // },
  1085. // {
  1086. // key: 'droplink',
  1087. // type: 'ui-link',
  1088. // className: 'col-xs-3',
  1089. // templateOptions:{
  1090. // label:'添加附件',
  1091. // onClick:function(val, options, field, event ,model){
  1092. // if(angular.isUndefined(field.form.dropState)){
  1093. // field.form.dropState=false;
  1094. // }
  1095. // field.form.dropState=!field.form.dropState;
  1096. // console.log(field);
  1097. // }
  1098. // }
  1099. // },
  1100. // {
  1101. // key: 'dropfile',
  1102. // type: 'ui-dropfile',
  1103. // className: 'col-xs-12',
  1104. // templateOptions:{
  1105. // label:'附件',
  1106. // uploadUrl:'http://127.0.0.1:9008/saveAttachments'
  1107. // }
  1108. // },
  1109. // {
  1110. // type: 'ui-label',
  1111. // key: 'changesign',
  1112. // className: 'col-xs-4',
  1113. // templateOptions: {
  1114. // label:'变更请求单号',
  1115. // pkey:'change'
  1116. // }
  1117. // },
  1118. // {
  1119. // type: 'ui-label',
  1120. // key: 'title',
  1121. // className: 'col-xs-4',
  1122. // templateOptions: {
  1123. // label:'变更标题',
  1124. // pkey:'change'
  1125. // }
  1126. // },
  1127. // //关联发布单号
  1128. // //新建发布
  1129. // {
  1130. // key: 'droplist',
  1131. // type: 'ui-dropfiletable',
  1132. // className: 'col-xs-12',
  1133. // templateOptions:{
  1134. // label:'附件下载列表',
  1135. // Restangular:Restangular,
  1136. // processInstanceId:'250033',
  1137. // ApiService:api_bpm_domain
  1138. // }
  1139. // },
  1140. // {
  1141. // type: 'ui-repeatSection',
  1142. // key: 'investments',
  1143. // className: 'col-xs-12',
  1144. // templateOptions: {
  1145. // btnText: '新增变更施工单',
  1146. // fields: [
  1147. // {
  1148. // className: 'col-xs-3',
  1149. // type: 'ui-input',
  1150. // key: 'aboutci',
  1151. // templateOptions: {
  1152. // label: '关联的配置项',
  1153. // required: true
  1154. // }
  1155. // },
  1156. // {
  1157. // className: 'col-xs-3',
  1158. // type: 'ui-datepicker',
  1159. // key: 'planbegintime',
  1160. // templateOptions: {
  1161. // label: '计划开始时间',
  1162. // required: true
  1163. // }
  1164. // },
  1165. // {
  1166. // className: 'col-xs-3',
  1167. // type: 'ui-datepicker',
  1168. // key: 'planendtime',
  1169. // templateOptions: {
  1170. // label: '计划完成时间',
  1171. // required: true
  1172. // }
  1173. // },
  1174. // {
  1175. // className: 'col-xs-12',
  1176. // type: 'ui-userselect',
  1177. // key: 'handleruser',
  1178. // templateOptions: {
  1179. // label: '实施人员信息',
  1180. // modalTitle:'实施人列表',
  1181. // required: true,
  1182. // fetchItems:function(filterData, APIService){
  1183. // return APIService.fetchDataList('user',filterData);
  1184. // },
  1185. // Restangular:Restangular,
  1186. // ApiService:api_user_data,
  1187. // onClick:function(val, options, field, event , model){
  1188. // //model.start_code++;
  1189. // console.log(options);
  1190. // }
  1191. // }
  1192. // },
  1193. // {
  1194. // className: 'col-xs-8',
  1195. // type: 'ui-textarea',
  1196. // key: 'handlerContent',
  1197. // templateOptions: {
  1198. // label: '实施内容',
  1199. // required: true,
  1200. // row:10
  1201. // }
  1202. // },{
  1203. // noFormControl: true,
  1204. // template:'<hr>'
  1205. // }]
  1206. // }
  1207. // },
  1208. // {
  1209. // key: 'droplist',
  1210. // type: 'ui-dropfiletable',
  1211. // className: 'col-xs-12',
  1212. // templateOptions:{
  1213. // label:'附件下载列表',
  1214. // Restangular:Restangular,
  1215. // processInstanceId:'250033',
  1216. // ApiService:api_bpm_domain
  1217. // }
  1218. // },
  1219. // {
  1220. // key: 'start_code',
  1221. // className:'col-xs-6',
  1222. // type: 'ui-hidden'
  1223. // },
  1224. // {
  1225. // key:'remark',
  1226. // type:'ui-textarea',
  1227. // className:'col-xs-12',
  1228. // templateOptions:{
  1229. // label:'remark is ',
  1230. // rows:3
  1231. // }
  1232. // },
  1233. // {
  1234. // key:'setStartCode',
  1235. // type:'ui-button',
  1236. // className:'col-xs-4',
  1237. // templateOptions:{
  1238. // label:'升级为变更',
  1239. // onClick:function(val, options, field, event ,model){
  1240. // console.log(options);
  1241. // event.preventDefault();
  1242. // //model.start_code++;
  1243. // //console.log(options);
  1244. // }
  1245. // }
  1246. // }
  1247. ],
  1248. model: {
  1249. username: "robin lau",
  1250. password: "123456",
  1251. change: { source: { id: 5 } },
  1252. chkme: false,
  1253. start_code: 0,
  1254. arrayData: [{ "id": 13, "dept": "村镇银行管理部" }, { "id": 14, "dept": "电子银行部" }],
  1255. formtitle: "Hey!I am title value!",
  1256. name: {
  1257. first: "robin",
  1258. last: "lau"
  1259. },
  1260. multiselectItem: []
  1261. //date:"2015-09-15 00:00:00"
  1262. }
  1263. };
  1264. setTimeout(function () {
  1265. decodeVMForm(testJson);
  1266. $scope.$apply();
  1267. }, 500);
  1268. //测试数据结束
  1269. }
  1270. }
  1271. console.log("end decode");
  1272. }
  1273. ]);