workingFormCtr.js 60 KB

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