inspectForm.js 73 KB

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