inspectForm.js 72 KB

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