inspectForm.js 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356
  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) {
  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. vm.model.inspection.status = {id:1716};//强制扭转状态为配置中
  584. if (vm.model.inspection.requestCategoryDTO) {
  585. vm.model.inspection.requestCategoryDTO = { id: vm.model.inspection.requestCategoryDTO.id }
  586. }
  587. vm.model.inspection
  588. serviceWatch.addData($scope.formData.modelName, vm.model).then(function(response) {
  589. if (response) {
  590. var resData = Restangular.stripRestangular(response);
  591. if (resData && resData.status == 200) {
  592. // SweetAlert.swal({
  593. // title: "提交成功!",
  594. // type: "success",
  595. // confirmButtonColor: "#007AFF"
  596. // }, function() {
  597. // $state.go($scope.formData.cancelUrl);
  598. // });
  599. $state.go('app.inspectionScope',{ 'id': resData.data.id });//跳转巡检范围设置-编辑
  600. } else {
  601. SweetAlert.swal({
  602. title: "提交失败",
  603. text: "提交失败,请稍后重试!",
  604. type: "error",
  605. confirmButtonColor: "#DD6B55"
  606. });
  607. }
  608. } else {
  609. SweetAlert.swal({
  610. title: "系统错误",
  611. text: "系统错误,请稍后重试!",
  612. type: "error",
  613. confirmButtonColor: "#DD6B55"
  614. });
  615. }
  616. $scope.ldloading[style.replace('-', '_')] = false;
  617. });
  618. } else {
  619. vm.model.inspection['createUser'] = $rootScope.user;
  620. vm.model.inspection.status = {id:1716};//强制扭转状态为配置中
  621. // vm.model.inspection['sign']=$scope.xjSign;
  622. serviceWatch.addData($scope.formData.modelName, vm.model).then(function(response) {
  623. if (response) {
  624. var resData = Restangular.stripRestangular(response);
  625. if (resData && resData.status == 200) {
  626. // SweetAlert.swal({
  627. // title: "提交成功!",
  628. // type: "success",
  629. // confirmButtonColor: "#007AFF"
  630. // }, function() {
  631. // $state.go($scope.formData.cancelUrl);
  632. // });
  633. $state.go('app.inspectionScope',{ 'id': resData.data.id });//跳转巡检范围设置-新增
  634. } else {
  635. SweetAlert.swal({
  636. title: "系统错误",
  637. text: "系统错误,请稍后重试!",
  638. type: "error",
  639. confirmButtonColor: "#DD6B55"
  640. });
  641. }
  642. } else {
  643. SweetAlert.swal({
  644. title: "系统错误",
  645. text: "系统错误,请稍后重试!",
  646. type: "error",
  647. confirmButtonColor: "#DD6B55"
  648. });
  649. }
  650. $scope.ldloading[style.replace('-', '_')] = false;
  651. });
  652. }
  653. break;
  654. case "save":
  655. //addData
  656. serviceWatch.addData($scope.formData.modelName, vm.model).then(function(response) {
  657. if (response) {
  658. var resData = Restangular.stripRestangular(response);
  659. modelWatch.model
  660. // console.log("resData="+JSON.stringify(resData.data.role[0].id));
  661. if (resData && resData.status == 200) {
  662. SweetAlert.swal({
  663. title: "提交成功!",
  664. type: "success",
  665. confirmButtonColor: "#007AFF"
  666. }, function() {
  667. $state.go($scope.formData.cancelUrl);
  668. });
  669. } else {
  670. SweetAlert.swal({
  671. title: "系统错误",
  672. text: "系统错误,请稍后重试!",
  673. type: "error",
  674. confirmButtonColor: "#DD6B55"
  675. });
  676. }
  677. } else {
  678. SweetAlert.swal({
  679. title: "系统错误",
  680. text: "系统错误,请稍后重试!",
  681. type: "error",
  682. confirmButtonColor: "#DD6B55"
  683. });
  684. }
  685. $scope.ldloading[style.replace('-', '_')] = false;
  686. });
  687. break;
  688. case "close":
  689. $state.go($scope.formData.cancelUrl);
  690. break;
  691. default:
  692. $scope.ldloading[style.replace('-', '_')] = false;
  693. break;
  694. }
  695. }
  696. } else {
  697. SweetAlert.swal({
  698. title: "校验错误",
  699. text: "请填写必填项!",
  700. type: "error",
  701. confirmButtonColor: "#DD6B55"
  702. });
  703. angular.forEach(vm.form.$error.required, function(item) {
  704. angular.forEach(vm.fields, function(f) {
  705. if (f.name == item.$name) {
  706. f.validation.show = true;
  707. }
  708. });
  709. })
  710. }
  711. // }else{
  712. // var role={};
  713. // var data1={};
  714. // console.log("data.role="+JSON.stringify(data.role));
  715. // role['rolecode']=data.role.rolecode;
  716. // role['id']=data.role.id;
  717. // console.log("role="+JSON.stringify(role));
  718. // data1['role']=role;
  719. // console.log("data1="+JSON.stringify(data1));
  720. // api_user_data.validate(data1,'role').then(function(response){
  721. // var resData = Restangular.stripRestangular(response);
  722. // console.log("resData11="+JSON.stringify(resData));
  723. // if(resData.status==200&&resData.data=="false"&&vm.form.$valid){
  724. // // if (vm.form.$valid ) {
  725. // vm.options.updateInitialValue();
  726. // $scope.ldloading[style.replace('-', '_')] = true;
  727. // // alert(JSON.stringify(vm.model), null, 2);
  728. // var _ = window._;
  729. // vm.model = (function filter(obj) {
  730. // var dateTransKeys = [];
  731. // var filtered = _.pick(obj, function (v, k, obj) {
  732. // if(_.isDate(v)){
  733. // dateTransKeys.push(k);
  734. // }
  735. // return angular.isDefined(v) && v !== null && (angular.isArray(v)?v.length>0:true) && (_.isPlainObject(v)?(!_.isEmpty(v)):true);
  736. // });
  737. // return _.cloneDeep(filtered, function (v, index, object) {
  738. // if(angular.isArray(dateTransKeys)&&dateTransKeys.length>0){
  739. // angular.forEach(dateTransKeys,function(item){
  740. // v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  741. // });
  742. // dateTransKey = [];
  743. // return v;
  744. // }
  745. // return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  746. // });
  747. // })(vm.model);
  748. // // console.log("$scope.formData="+$scope.formData);
  749. // switch($scope.formData.url){
  750. // case "create" :
  751. // //vm.model["initUser"]=$rootScope.user.id;
  752. // //addData
  753. // serviceWatch.addData($scope.formData.modelName,vm.model).then(function(response){
  754. // if(response){
  755. // var resData = Restangular.stripRestangular(response);
  756. // if(resData&&resData.status==200){
  757. // SweetAlert.swal({
  758. // title: "提交成功!",
  759. // confirmButtonColor: "#007AFF"
  760. // },function(){
  761. // $state.go($scope.formData.cancelUrl);
  762. // });
  763. // }else{
  764. // SweetAlert.swal({
  765. // title: "系统错误",
  766. // text: "系统错误,请稍后重试!",
  767. // type: "error",
  768. // confirmButtonColor: "#DD6B55"
  769. // });
  770. // }
  771. // }else{
  772. // SweetAlert.swal({
  773. // title: "系统错误",
  774. // text: "系统错误,请稍后重试!",
  775. // type: "error",
  776. // confirmButtonColor: "#DD6B55"
  777. // });
  778. // }
  779. // $scope.ldloading[style.replace('-', '_')] = false;
  780. // });
  781. // break;
  782. // case "save" :
  783. // //addData
  784. // serviceWatch.addData($scope.formData.modelName, vm.model).then(function(response){
  785. // if(response){
  786. // var resData = Restangular.stripRestangular(response);
  787. // // console.log("resData="+JSON.stringify(resData.data));
  788. // // console.log("modelWatch.model="+JSON.stringify(modelWatch.model));
  789. // if(resData&&resData.status==200){
  790. // SweetAlert.swal({
  791. // title: "提交成功!",
  792. // confirmButtonColor: "#007AFF"
  793. // },function(){
  794. // $state.go($scope.formData.cancelUrl);
  795. // });
  796. // }else{
  797. // SweetAlert.swal({
  798. // title: "系统错误",
  799. // text: "系统错误,请稍后重试!",
  800. // type: "error",
  801. // confirmButtonColor: "#DD6B55"
  802. // });
  803. // }
  804. // }else{
  805. // SweetAlert.swal({
  806. // title: "系统错误",
  807. // text: "系统错误,请稍后重试!",
  808. // type: "error",
  809. // confirmButtonColor: "#DD6B55"
  810. // });
  811. // }
  812. // $scope.ldloading[style.replace('-', '_')] = false;
  813. // });
  814. // break;
  815. // case "close" :
  816. // $state.go($scope.formData.cancelUrl);
  817. // break;
  818. // default:
  819. // $scope.ldloading[style.replace('-', '_')] = false;
  820. // break;
  821. // }
  822. // }else if(resData.status==200&&resData.data=="true"&&vm.form.$valid){
  823. // SweetAlert.swal({
  824. // title: "角色代码以存在",
  825. // text: "请重新填写角色代码!",
  826. // type: "error",
  827. // confirmButtonColor: "#DD6B55"
  828. // });
  829. // }else{
  830. // SweetAlert.swal({
  831. // title: "校验错误",
  832. // text: "请填写必填项!",
  833. // type: "error",
  834. // confirmButtonColor: "#DD6B55"
  835. // });
  836. // angular.forEach(vm.form.$error.required, function(item){
  837. // angular.forEach(vm.fields,function(f){
  838. // if(f.name == item.$name){
  839. // f.validation.show = true;
  840. // }
  841. // });
  842. // })
  843. // }
  844. // })
  845. // }
  846. };
  847. $scope.vm = vm;
  848. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  849. api_configure_form.renderForm($stateParams.formKey, '00000',$stateParams.dataId).then(function(responseData) {
  850. if (responseData) {
  851. //console.log("responseData>>>");console.log(responseData);
  852. var vmForm = Restangular.stripRestangular(responseData);
  853. if (vmForm) {
  854. //console.log("vmForm>>>");console.log(vmForm);
  855. var modelData = {};
  856. //modelData=myData.data;
  857. decodeVMForm(vmForm);
  858. }
  859. }
  860. });
  861. } else {
  862. //
  863. if (angular.isDefined(fieldsWatch) && fieldsWatch.length > 0) {
  864. var vmForm = {
  865. fields: fieldsWatch,
  866. model: modelWatch
  867. }
  868. angular.extend(vmForm, formWatch);
  869. //$scope.formData = vmForm;
  870. if (vmForm) {
  871. decodeVMForm(vmForm);
  872. }
  873. } else { //for form
  874. //TODO
  875. //测试数据 开始
  876. var testJson = {
  877. fields: [{
  878. key: 'formtitle',
  879. type: 'ui-title',
  880. noFormControl: true,
  881. templateOptions: {
  882. label: 'title is ',
  883. placeholder: 'Formly is terrific!'
  884. }
  885. },
  886. {
  887. key: 'b',
  888. type: 'ui-input',
  889. className: 'col-xs-4',
  890. templateOptions: {
  891. type: 'input',
  892. label: 'input a',
  893. placeholder: 'search a...',
  894. rBtn: {
  895. icon: 'fa fa-phone',
  896. onClick: function(val, opt, el, ev, model) { alert(val); }
  897. },
  898. lAddon: '<i class="fa fa-phone"/>'
  899. }
  900. },
  901. {
  902. key: 'id',
  903. type: 'ui-select',
  904. //initialValue:"false",
  905. templateOptions: {
  906. label: "测试默认值",
  907. optionsUrl: "abc",
  908. //options:[{"id":"false","name":"不取消"},{"id":"true","name":"取消"}],
  909. // refresh:function(){
  910. // 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}];
  911. // },
  912. //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}],
  913. valueProp: "id",
  914. labelProp: "name",
  915. pkey: "change.source"
  916. }
  917. },
  918. {
  919. key: 'systemType',
  920. type: 'ui-multiselect',
  921. className: 'col-xs-4',
  922. templateOptions: {
  923. label: "所属系统类型",
  924. pkey: "change",
  925. valueProp: "id",
  926. labelProp: "source",
  927. optionsUrl: "data/fetchDataList/changesystemtype",
  928. optionsDataKey: "list",
  929. onChange: function(value, options, that, event, model) {
  930. var field = null;
  931. angular.forEach(that.$parent.fields, function(item) {
  932. if (item.key == 'influenceDepartment') {
  933. field = item;
  934. }
  935. if (item.key == 'notificationDepartment') {
  936. notifyField = item;
  937. }
  938. })
  939. if (field != null) {
  940. field.templateOptions.optionsPostData = {
  941. 'systemIds': []
  942. }
  943. angular.forEach(value, function(vue) {
  944. field.templateOptions.optionsPostData['systemIds'].push({ 'id': vue });
  945. })
  946. field.value([]);
  947. if (value.length > 0) {
  948. field.templateOptions.refreshData(null, field);
  949. }
  950. }
  951. if (notifyField != null) {
  952. notifyField.templateOptions.optionsPostData = {
  953. 'systemIds': []
  954. }
  955. angular.forEach(value, function(vue) {
  956. notifyField.templateOptions.optionsPostData['systemIds'].push({ 'id': vue });
  957. })
  958. notifyField.value([]);
  959. if (value.length > 0) {
  960. notifyField.templateOptions.refreshData(null, notifyField);
  961. }
  962. }
  963. }
  964. }
  965. },
  966. {
  967. key: 'influenceDepartment',
  968. type: 'ui-multiselectplus',
  969. className: 'col-xs-4',
  970. templateOptions: {
  971. label: '所影响的应用系统、科室',
  972. pkey: "change",
  973. valueProp: '', //对应value
  974. labelProp: 'dept', //对应key
  975. optionsUrl: 'dept/findBySystemType', //对应后台地址,api/之前的部分省略
  976. optionsDataKey: 'list', //对应返回数组数据的键值,
  977. optionsPostData: function(options, model, scope) {
  978. return { "systemIds": [] };
  979. },
  980. refreshData: function(search, options, model, that) {
  981. options.templateOptions.options = [{ "id": 13, "dept": "村镇银行管理部" }, { "id": 14, "dept": "电子银行部" }];
  982. options.value(options.templateOptions.options);
  983. },
  984. optionsChecked: true,
  985. required: true,
  986. ApiService: UserRestangular
  987. }
  988. },
  989. {
  990. key: 'notificationDepartment',
  991. type: 'ui-multiselectplus',
  992. className: 'col-xs-4',
  993. templateOptions: {
  994. label: '需通知科室',
  995. pkey: "change",
  996. valueProp: 'id', //对应value
  997. labelProp: 'dept', //对应key
  998. optionsUrl: 'dept/findBySystemType', //对应后台地址,api/之前的部分省略
  999. optionsDataKey: 'list', //对应返回数组数据的键值,
  1000. optionsPostData: function(options, model, scope) {
  1001. return { "systemIds": [] };
  1002. },
  1003. optionsChecked: true,
  1004. required: true,
  1005. ApiService: UserRestangular
  1006. }
  1007. },
  1008. {
  1009. type: 'ui-label',
  1010. key: 'arrayData',
  1011. className: 'col-xs-4',
  1012. templateOptions: {
  1013. label: '数组label数据',
  1014. labelProp: 'dept'
  1015. }
  1016. },
  1017. {
  1018. key: 'selectUser',
  1019. type: 'ui-requesterselect',
  1020. className: 'col-xs-12',
  1021. templateOptions: {
  1022. label: '报修人信息',
  1023. modalTitle: '报修人列表',
  1024. fetchItems: function(filterData, APIService) {
  1025. return APIService.fetchDataList('requester', filterData);
  1026. },
  1027. Restangular: Restangular,
  1028. ApiService: api_user_data
  1029. // onClick:function(val, options, field, event , model){
  1030. // console.log(options);
  1031. // }
  1032. }
  1033. },
  1034. {
  1035. key: 'cabUser',
  1036. type: 'ui-multiuserselect',
  1037. className: 'col-xs-12',
  1038. templateOptions: {
  1039. label: 'CAB评审成员',
  1040. modalTitle: 'CAB成员列表',
  1041. fetchItems: function(filterData, APIService) {
  1042. return APIService.fetchDataList('user', filterData);
  1043. },
  1044. Restangular: Restangular,
  1045. ApiService: api_user_data,
  1046. onClick: function(val, options, field, event, model) {
  1047. console.log(model);
  1048. }
  1049. }
  1050. },
  1051. // {
  1052. // key:'incident',
  1053. // type:'ui-modelselect',
  1054. // className:'col-xs-3',
  1055. // templateOptions:{
  1056. // label:'关联事件工单',
  1057. // modalTitle:'事件列表',
  1058. // fetchItems:function(filterData,APIService){
  1059. // return APIService.fetchDataList('incident',filterData);
  1060. // },
  1061. // Restangular:"Restangular",
  1062. // ApiService:"api_bpm_data",
  1063. // columnDefs:[
  1064. // { name:'id', width:80, enableFiltering:false},
  1065. // { name:'title', displayName:'事件主题', width:140},
  1066. // { name:'type.name', displayName:'事件类型', width:140},
  1067. // { name:'emergency.name', displayName:'紧急度', width:80},
  1068. // { name:'state.name', displayName:'状态', width:100},
  1069. // { name:'emergency.name', displayName:'紧急度', width:80},
  1070. // { name:'influence.name', displayName:'影响度', width:80},
  1071. // { name:'priority.name', displayName:'优先级', width:80},
  1072. // { name:'handlerUser.name', displayName:'当前处理人', width:100},
  1073. // { name:'acceptDate', displayName:'创建时间', width:100}
  1074. // ],
  1075. // displayName:'title',
  1076. // onClick:function(val, options, field, event , model){
  1077. // //model.start_code++;
  1078. // console.log(options);
  1079. // }
  1080. // }
  1081. // },
  1082. // {
  1083. // key: 'worknumber',
  1084. // type: 'ui-workernumber',
  1085. // className:'col-xs-3',
  1086. // templateOptions: {
  1087. // label: 'work number',
  1088. // Restangular:Restangular,
  1089. // ApiService:api_bpm_domain,
  1090. // getWorkernumber: function(APIService){
  1091. // return APIService.workernumber('bg');
  1092. // }
  1093. // }
  1094. // },
  1095. // {
  1096. // key: 'chkme',
  1097. // type: 'ui-checkbox',
  1098. // className:'col-xs-3',
  1099. // templateOptions: {
  1100. // label: 'Check me out'
  1101. // }
  1102. // },
  1103. // {
  1104. // key: 'droplink',
  1105. // type: 'ui-link',
  1106. // className: 'col-xs-3',
  1107. // templateOptions:{
  1108. // label:'添加附件',
  1109. // onClick:function(val, options, field, event ,model){
  1110. // if(angular.isUndefined(field.form.dropState)){
  1111. // field.form.dropState=false;
  1112. // }
  1113. // field.form.dropState=!field.form.dropState;
  1114. // console.log(field);
  1115. // }
  1116. // }
  1117. // },
  1118. // {
  1119. // key: 'dropfile',
  1120. // type: 'ui-dropfile',
  1121. // className: 'col-xs-12',
  1122. // templateOptions:{
  1123. // label:'附件',
  1124. // uploadUrl:'http://127.0.0.1:9008/saveAttachments'
  1125. // }
  1126. // },
  1127. // {
  1128. // type: 'ui-label',
  1129. // key: 'changesign',
  1130. // className: 'col-xs-4',
  1131. // templateOptions: {
  1132. // label:'变更请求单号',
  1133. // pkey:'change'
  1134. // }
  1135. // },
  1136. // {
  1137. // type: 'ui-label',
  1138. // key: 'title',
  1139. // className: 'col-xs-4',
  1140. // templateOptions: {
  1141. // label:'变更标题',
  1142. // pkey:'change'
  1143. // }
  1144. // },
  1145. // //关联发布单号
  1146. // //新建发布
  1147. // {
  1148. // key: 'droplist',
  1149. // type: 'ui-dropfiletable',
  1150. // className: 'col-xs-12',
  1151. // templateOptions:{
  1152. // label:'附件下载列表',
  1153. // Restangular:Restangular,
  1154. // processInstanceId:'250033',
  1155. // ApiService:api_bpm_domain
  1156. // }
  1157. // },
  1158. // {
  1159. // type: 'ui-repeatSection',
  1160. // key: 'investments',
  1161. // className: 'col-xs-12',
  1162. // templateOptions: {
  1163. // btnText: '新增变更施工单',
  1164. // fields: [
  1165. // {
  1166. // className: 'col-xs-3',
  1167. // type: 'ui-input',
  1168. // key: 'aboutci',
  1169. // templateOptions: {
  1170. // label: '关联的配置项',
  1171. // required: true
  1172. // }
  1173. // },
  1174. // {
  1175. // className: 'col-xs-3',
  1176. // type: 'ui-datepicker',
  1177. // key: 'planbegintime',
  1178. // templateOptions: {
  1179. // label: '计划开始时间',
  1180. // required: true
  1181. // }
  1182. // },
  1183. // {
  1184. // className: 'col-xs-3',
  1185. // type: 'ui-datepicker',
  1186. // key: 'planendtime',
  1187. // templateOptions: {
  1188. // label: '计划完成时间',
  1189. // required: true
  1190. // }
  1191. // },
  1192. // {
  1193. // className: 'col-xs-12',
  1194. // type: 'ui-userselect',
  1195. // key: 'handleruser',
  1196. // templateOptions: {
  1197. // label: '实施人员信息',
  1198. // modalTitle:'实施人列表',
  1199. // required: true,
  1200. // fetchItems:function(filterData, APIService){
  1201. // return APIService.fetchDataList('user',filterData);
  1202. // },
  1203. // Restangular:Restangular,
  1204. // ApiService:api_user_data,
  1205. // onClick:function(val, options, field, event , model){
  1206. // //model.start_code++;
  1207. // console.log(options);
  1208. // }
  1209. // }
  1210. // },
  1211. // {
  1212. // className: 'col-xs-8',
  1213. // type: 'ui-textarea',
  1214. // key: 'handlerContent',
  1215. // templateOptions: {
  1216. // label: '实施内容',
  1217. // required: true,
  1218. // row:10
  1219. // }
  1220. // },{
  1221. // noFormControl: true,
  1222. // template:'<hr>'
  1223. // }]
  1224. // }
  1225. // },
  1226. // {
  1227. // key: 'droplist',
  1228. // type: 'ui-dropfiletable',
  1229. // className: 'col-xs-12',
  1230. // templateOptions:{
  1231. // label:'附件下载列表',
  1232. // Restangular:Restangular,
  1233. // processInstanceId:'250033',
  1234. // ApiService:api_bpm_domain
  1235. // }
  1236. // },
  1237. // {
  1238. // key: 'start_code',
  1239. // className:'col-xs-6',
  1240. // type: 'ui-hidden'
  1241. // },
  1242. // {
  1243. // key:'remark',
  1244. // type:'ui-textarea',
  1245. // className:'col-xs-12',
  1246. // templateOptions:{
  1247. // label:'remark is ',
  1248. // rows:3
  1249. // }
  1250. // },
  1251. // {
  1252. // key:'setStartCode',
  1253. // type:'ui-button',
  1254. // className:'col-xs-4',
  1255. // templateOptions:{
  1256. // label:'升级为变更',
  1257. // onClick:function(val, options, field, event ,model){
  1258. // console.log(options);
  1259. // event.preventDefault();
  1260. // //model.start_code++;
  1261. // //console.log(options);
  1262. // }
  1263. // }
  1264. // }
  1265. ],
  1266. model: {
  1267. username: "robin lau",
  1268. password: "123456",
  1269. change: { source: { id: 5 } },
  1270. chkme: false,
  1271. start_code: 0,
  1272. arrayData: [{ "id": 13, "dept": "村镇银行管理部" }, { "id": 14, "dept": "电子银行部" }],
  1273. formtitle: "Hey!I am title value!",
  1274. name: {
  1275. first: "robin",
  1276. last: "lau"
  1277. },
  1278. multiselectItem: []
  1279. //date:"2015-09-15 00:00:00"
  1280. }
  1281. };
  1282. setTimeout(function() {
  1283. decodeVMForm(testJson);
  1284. $scope.$apply();
  1285. }, 500);
  1286. //测试数据结束
  1287. }
  1288. }
  1289. console.log("end decode");
  1290. }
  1291. ]);