inspectForm.js 73 KB

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