inspectForm.js 70 KB

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