pzxgl_wt.js 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. 'use strict';
  2. app.controller('pzxgl_wtCtrl', ["$scope", "$http", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "Restangular", "api_bpm_domain", "api_text", "api_bpm_data", "api_user_data", "api_configure_data", "api_configure_form", "api_cmdb", 'api_bpm', 'ngDraggable', 'api_solution', 'api_report_data', function ($scope, $http, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, Restangular, api_bpm_domain, api_text, api_bpm_data, api_user_data, api_configure_data, api_configure_form, api_cmdb, api_bpm, ngDraggable, api_solution, api_report_data) {
  3. // alert(1111)
  4. $scope.myData = [];
  5. var loginUser = $rootScope.user;
  6. console.log(loginUser);
  7. $scope.typeModel = "kj";
  8. $scope.typeModel1 = '';
  9. $scope.typeModel2 = 9999;
  10. $scope.typeModel3 = false;
  11. $scope.wt_cld = false;
  12. var dis1 = document.getElementById('changes1')
  13. var dis2 = document.getElementById('remove')
  14. dis1.disabled = true;
  15. dis2.disabled = true;
  16. // $scope.wt_show = false;
  17. // $scope.selectedSite;
  18. // var input = document.getElementById('wt_input');
  19. // var input1 = document.getElementById('wt_input1');
  20. // var input2 = document.getElementById('wt_input2');
  21. // input.disabled = true;
  22. // input1.disabled = true;
  23. // input2.disabled = true;
  24. // $scope.content = [{ 'name': '张春玲', 'age': 28 }, { 'name': '王晰', 'age': 26 }, { 'name': '吴正青', 'age': 66 }];
  25. $scope.content = [];
  26. //增加控件
  27. $scope.add = function (type, id, style) {
  28. $scope.typeModel1 = type
  29. // $scope.text = {
  30. // 'type': type,
  31. // 'id': id,
  32. // 'label': '',
  33. // 'placeholder': '请编辑...',
  34. // 'selectedSite': '1'
  35. // }
  36. $scope.text = {
  37. 'editable': null,
  38. 'extjson': null,
  39. 'field': null,
  40. 'form': null,
  41. 'grid': null,
  42. 'hidden': null,
  43. 'id': null,
  44. 'key': null,
  45. 'label': null,
  46. 'layout': null,
  47. 'model': null,
  48. 'placeholder': "请输入...",
  49. 'readonly': true,
  50. 'required': false,
  51. 'style': style,
  52. 'title': null,
  53. 'type': type,
  54. 'uiWidget': { id: id },
  55. 'validatePattern': null,
  56. 'valueExpression': null,
  57. 'view': null
  58. }
  59. if (id == 61) {
  60. $scope.text.placeholder = '请选择...'
  61. }
  62. console.log($scope.content)
  63. console.log($scope.text)
  64. $scope.content.push($scope.text)
  65. console.log($scope.content)
  66. }
  67. //复制控件
  68. $scope.copy = function (item) {
  69. console.log(item)
  70. window.event ? window.event.cancelBubble = true : e.stopPropagation();
  71. $scope.copyData = {
  72. 'type': item.type,
  73. // 'id': item.id,
  74. // 'label': item.label,
  75. // 'placeholder': item.placeholder,
  76. // 'selectedSite': item.selectedSite,
  77. 'editable': null,
  78. 'extjson': null,
  79. 'field': null,
  80. 'form': null,
  81. 'grid': null,
  82. 'hidden': null,
  83. 'id': null,
  84. 'key': null,
  85. 'label': item.label,
  86. 'layout': null,
  87. 'model': null,
  88. 'placeholder': item.placeholder,
  89. 'readonly': item.readonly,
  90. 'required': item.required,
  91. 'style': item.style,
  92. 'title': null,
  93. // 'type': item.type,
  94. 'uiWidget': item.uiWidget,
  95. 'validatePattern': null,
  96. 'valueExpression': null,
  97. 'view': null
  98. }
  99. $scope.content.push($scope.copyData);
  100. console.log($scope.content)
  101. }
  102. //删除控件
  103. $scope.rem = function (item) {
  104. console.log($scope.content)
  105. console.log(item);
  106. $scope.typeModel = 'kj';
  107. $scope.typeModel1 = '';
  108. $scope.controlsType = true;
  109. $scope.fieldType = false;
  110. var formData = []
  111. if (item.id == null) {
  112. for (var i = 0; i < $scope.content.length; i++) {
  113. if ($scope.content[i].$$hashKey == item.$$hashKey) {
  114. $scope.content.splice(i, 1)
  115. SweetAlert.swal({
  116. title: "删除成功!",
  117. type: "success"
  118. })
  119. $scope.item = {}
  120. }
  121. }
  122. } else {
  123. formData.push(item.id)
  124. console.log(formData)
  125. api_report_data.formData('modelUI', formData).then(function (response) {
  126. console.log(response)
  127. if (response) {
  128. if (response.status == 200) {
  129. for (var i = 0; i < $scope.content.length; i++) {
  130. if ($scope.content[i].$$hashKey == item.$$hashKey) {
  131. $scope.content.splice(i, 1)
  132. // alert(1111)
  133. $scope.item = {}
  134. }
  135. }
  136. SweetAlert.swal({
  137. title: "删除成功!",
  138. type: "success"
  139. })
  140. }
  141. }
  142. })
  143. }
  144. // $scope.wt_show = false;
  145. // input.disabled = true;
  146. // input1.disabled = true;
  147. // input2.disabled = true;
  148. // for (var i = 0; i < $scope.content.length; i++) {
  149. // if ($scope.content[i].$$hashKey == item.$$hashKey) {
  150. // $scope.content.splice(i, 1)
  151. // // alert(1111)
  152. // $scope.item = {}
  153. // }
  154. // }
  155. window.event ? window.event.cancelBubble = true : e.stopPropagation();
  156. }
  157. //编辑控件
  158. $scope.editor = function (item, index) {
  159. console.log(item, index);
  160. // dis2.disabled = false;
  161. $scope.typeModel2 = index
  162. $scope.typeModel = 'zd';
  163. $scope.controlsType = false;
  164. $scope.fieldType = true;
  165. if(!item.readonly && item.type == 'input'){
  166. var id = {
  167. id: '2'
  168. }
  169. item.uiWidget = id;
  170. item.style = 'col-xs-4';
  171. }
  172. if (item.readonly && item.type == 'input') {
  173. var id = {
  174. id: '20'
  175. }
  176. item.uiWidget = id;
  177. item.style = 'col-xs-4';
  178. } if (item.type == 'binput') {
  179. var id = {
  180. id: '3'
  181. }
  182. item.uiWidget = id;
  183. item.style = 'col-xs-12';
  184. } if (item.type == 'time') {
  185. var id = {
  186. id: '61'
  187. }
  188. item.uiWidget = id;
  189. item.style = 'col-xs-4';
  190. } if (item.type == 'select') {
  191. var id = {
  192. id: '7'
  193. }
  194. item.uiWidget = id;
  195. item.style = 'col-xs-4';
  196. }
  197. console.log(item)
  198. // $scope.selectedSite=''
  199. // $scope.wt_show = true;
  200. // input.disabled = false;
  201. // input1.disabled = false;
  202. // input2.disabled = false;
  203. // $scope.selectedSite = item.selectedSite;
  204. $scope.item = item;
  205. // console.log($scope.selectedSite)
  206. }
  207. // $scope.accounted = [
  208. // // { name: '4/1', id: '4' },
  209. // { name: '3/1', id: '3' },
  210. // { name: '2/1', id: '2' },
  211. // { name: '1', id: '1' },
  212. // ]
  213. // $scope.change1 = function (selectedSite) {
  214. // // item.selectedSite=$scope.selectedSite;
  215. // console.log(selectedSite)
  216. // $scope.selectedSite = selectedSite;
  217. // $scope.item.selectedSite = selectedSite;
  218. // console.log($scope.item)
  219. // }
  220. /** 拖拽成功触发方法
  221. * index 拖拽后落下时的元素的序号(下标)
  222. * obj被拖动数据对象
  223. */
  224. $scope.dropComplete = function (index, obj) {
  225. //重新排序
  226. var idx = $scope.content.indexOf(obj);
  227. $scope.content.splice(idx, 1);
  228. $scope.content.splice(index, 0, obj);
  229. };
  230. $scope.controlsType = false;
  231. $scope.fieldType = false;
  232. //控件按钮
  233. $scope.controls = function (type) {
  234. // $scope.typeModel2 = 9999;
  235. console.log($scope.subdata)
  236. $scope.typeModel = type;
  237. if ($scope.subdata) {
  238. $scope.controlsType = true;
  239. $scope.fieldType = false;
  240. }
  241. }
  242. //属性按钮
  243. $scope.field = function (type) {
  244. console.log($scope.subdata)
  245. $scope.typeModel = type;
  246. if ($scope.subdata) {
  247. $scope.controlsType = false;
  248. $scope.fieldType = true;
  249. }
  250. }
  251. // $scope.langs=i18nService.getAllLangs();
  252. // $scope.lang = 'zh-cn';
  253. var loginUser = $rootScope.user;
  254. //组
  255. api_user_data.fetchDataList('group', { "idx": 0, "sum": 1000 }).then(function (data) {
  256. $scope.group = data.list;
  257. });
  258. //优先级
  259. api_bpm_data.fetchDataList('priority', { "idx": 0, "sum": 10 }).then(function (data) {
  260. $scope.priority = data.list;
  261. });
  262. /* ----- tree----- */
  263. var apple_selected, tree, treedata_avm, treedata_geography;
  264. //$scope.selectedTreeNode = {};ssss
  265. var i = 0;
  266. $scope.out = [];
  267. $scope.outdata = [];
  268. var systemtype = [];
  269. $scope.addcate = false;
  270. $scope.changecate = false;
  271. // $scope.refreshListData = function(){
  272. // var data ={"idx":0,"sum":1000};
  273. // api_bpm_data.fetchDataList('incidentcategory',data).then(function(response){
  274. // if(response){
  275. // if(response.status=200){
  276. // $scope.outdata = response.list;
  277. // }
  278. // }
  279. // })
  280. // }
  281. // $scope.refreshListData();
  282. var childdata = {};
  283. //选择类型
  284. $scope.my_tree_handler = function (branch) {
  285. console.log(branch);
  286. dis1.disabled = false;
  287. dis2.disabled = false;
  288. $scope.wt_label = branch.label;
  289. $scope.changecate = true;
  290. $scope.addcate = false;
  291. filterData.treeIds = branch.id;
  292. // $scope.parent = branch.parent;
  293. $scope.subdata = branch;
  294. // $scope.selectedTreeNode = branch;
  295. $scope.output = branch;
  296. // convertchildToTree(branch);
  297. // console.log($scope.subdata)
  298. var eqflag = false;
  299. $scope.typeModel2 = 9999;
  300. var aa = branch.prefix.toLowerCase()
  301. console.log(aa)
  302. var FormDefinition = {
  303. idx: 0,
  304. sum: 1000,
  305. FormDefinition: {
  306. name: 'ci_' + aa + branch.sign
  307. }
  308. }
  309. console.log(FormDefinition);
  310. $scope.cData = {}
  311. $scope.content = []
  312. api_report_data.fetchDataList1('FormDefinition', FormDefinition).then(function (response) {
  313. if (response) {
  314. if (response.list) {
  315. console.log(response);
  316. console.log(response.list)
  317. if (response.list[0]) {
  318. $scope.controlsType = true;
  319. $scope.fieldType = false;
  320. $scope.wt_title = response.list[0].url;
  321. if (response.list[0].modelUIDTOList) {
  322. $scope.content = response.list[0].modelUIDTOList;
  323. for (var i = 0; i < $scope.content.length; i++) {
  324. if ($scope.content[i].uiWidget.id == 2 || $scope.content[i].uiWidget.id == 20) {
  325. $scope.content[i]['type'] = 'input';
  326. // $scope.content[i]['placeholder'] = '请编辑...';
  327. } if ($scope.content[i].uiWidget.id == 3) {
  328. $scope.content[i]['type'] = 'binput';
  329. } if ($scope.content[i].uiWidget.id == 61) {
  330. $scope.content[i]['type'] = 'time';
  331. } if ($scope.content[i].uiWidget.id == 7) {
  332. $scope.content[i]['type'] = 'select';
  333. }
  334. };
  335. }
  336. } else {
  337. $scope.wt_title = branch.label + '属性';
  338. $scope.subdata = null
  339. $scope.controlsType = false;
  340. $scope.fieldType = false;
  341. }
  342. $scope.cData = response.list[0];
  343. // $scope.wt_title = response.list[0].url;
  344. }
  345. }
  346. console.log(response)
  347. // console.log(response.list[0].modelUIs)
  348. // $scope.content.push(response.list[0].modelUIs)
  349. })
  350. angular.forEach($scope.outdata, function (item) {
  351. if (item.id == $scope.output.id) eqflag = true;
  352. });
  353. if (eqflag) {
  354. } else {
  355. $scope.outdata.push({
  356. 'name': $scope.output.label,
  357. 'id': $scope.output.id,
  358. // 'parent': $scope.output.parent
  359. });
  360. var postData = {
  361. typeList: []
  362. };
  363. if ($scope.outdata.length > 0) {
  364. angular.forEach($scope.outdata, function (data) {
  365. postData.typeList.push({ id: data.id });
  366. })
  367. }
  368. // api_solution.findSolutionTypesUser(postData).then(function(response){
  369. // //Restangular.
  370. // $scope.userdata = response.data;
  371. // });
  372. }
  373. };
  374. //修改类型
  375. $scope.changes = function (data) {
  376. console.log(data)
  377. // $scope.subdata = data;
  378. // console.log($scope.subdata);
  379. var modalInstance = $modal.open({
  380. templateUrl: 'assets/views/delete_wt.html',
  381. controller: function ($scope, $modalInstance, scope) {
  382. $scope.addcate = false
  383. $scope.changecate = true
  384. console.log(scope.subdata)
  385. $scope.subdata = {};
  386. $scope.subdata = data;
  387. $scope.tree_data = {};
  388. // console.log(data)
  389. console.log(scope.my_data)
  390. // $scope.subdata = datas
  391. // if(parent){
  392. // $scope.subdata['parent']= parent
  393. // }
  394. console.log($scope.subdata)
  395. $scope.submitchange = function (subdata) {
  396. $modalInstance.close(subdata);
  397. };
  398. $scope.cancel = function () {
  399. $modalInstance.dismiss('cancel');
  400. };
  401. $scope.change1 = function (data) {
  402. console.log(data)
  403. $scope.btn = document.getElementById('submitchange');
  404. if (data == '') {
  405. // console.log(btn.disabled)
  406. $scope.btn.disabled = true;
  407. } else {
  408. $scope.btn.disabled = false;
  409. }
  410. }
  411. },
  412. size: 'sm',
  413. resolve: {
  414. // datas: function () {
  415. // return $scope.subdata;
  416. // },
  417. // tree_data: function () {
  418. // return $scope.tree_data;
  419. // },
  420. // parent: function () {
  421. // return $scope.parent
  422. // },
  423. scope: function () {
  424. return $scope
  425. }
  426. }
  427. });
  428. modalInstance.result.then(function (selectedItem) {
  429. if (selectedItem) {
  430. console.log(selectedItem);
  431. var changeData = {
  432. ciclassify: {
  433. 'id': selectedItem.id,
  434. 'label': selectedItem.label
  435. }
  436. }
  437. if (changeData.ciclassify.label == '') {
  438. // SweetAlert.swal({
  439. // title: "修改失败!",
  440. // text: "配置项类型名称不能为空",
  441. // type: "error"
  442. // })
  443. return;
  444. } else {
  445. console.log(changeData)
  446. api_report_data.updData('ciclassify', changeData).then(function (data) {
  447. console.log(data)
  448. if (data) {
  449. if (data.status == 200) {
  450. SweetAlert.swal({
  451. title: "修改成功!",
  452. type: "success"
  453. });
  454. dis1.disabled = true;
  455. dis2.disabled = true;
  456. $scope.wt_title = ""
  457. $scope.try_async_load()
  458. }
  459. }
  460. })
  461. }
  462. }
  463. })
  464. }
  465. //新增类型
  466. $scope.addType = function (element) {
  467. var modalInstance = $modal.open({
  468. templateUrl: 'assets/views/delete_wt.html',
  469. controller: function ($scope, $modalInstance, api_bpm_data, scope) {
  470. // api_bpm_data.fetchDataList('closecode',filterData).then(function(data){
  471. // var myData = Restangular.stripRestangular(data);
  472. // }
  473. $scope.tree_data = scope.my_data;
  474. $scope.addcate = true
  475. $scope.changecate = false
  476. console.log(scope.tree_data, element)
  477. $scope.onFilterCallback = function (item) {
  478. console.log(item)
  479. element = item;
  480. if (element) {
  481. if (element.parent) {
  482. if (element.parent.parent) {
  483. $scope.wt_cld = true;
  484. } else {
  485. $scope.wt_cld = false;
  486. }
  487. } else {
  488. $scope.wt_cld = false;
  489. }
  490. }
  491. }
  492. $scope.submitadd = function (item, item1) {
  493. console.log(element, item, item1)
  494. if (!item1) {
  495. var addData = {
  496. ciclassify: {
  497. 'label': item.category,
  498. }
  499. }
  500. } else {
  501. if (element) {
  502. if (element.parent) {
  503. if (element.parent.parent) {
  504. $scope.wt_cld = true;
  505. return;
  506. } else {
  507. $scope.wt_cld = false;
  508. }
  509. var addData = {
  510. ciclassify: {
  511. 'label': item.category,
  512. 'parent': { 'id': element.id },
  513. 'prefix': element.parent.prefix
  514. }
  515. }
  516. }else {
  517. $scope.wt_cld = false;
  518. }
  519. var addData = {
  520. ciclassify: {
  521. 'label': item.category,
  522. 'parent': { 'id': element.id },
  523. 'prefix': element.prefix
  524. }
  525. }
  526. }
  527. // var addData = {
  528. // ciclassify: {
  529. // 'label': item.category,
  530. // 'parent': { 'id': element.id },
  531. // 'prefix': item.parent.prefix
  532. // }
  533. // }
  534. }
  535. console.log(item, item1, addData)
  536. // pi_report_data.addData('ciclassify', addData).then(function (data) {
  537. // console.log(data)
  538. // })
  539. $modalInstance.close(addData);
  540. }
  541. $scope.cancel = function () {
  542. $modalInstance.dismiss('cancel');
  543. };
  544. }, size: 'sm',
  545. resolve: {
  546. // datas: function () {
  547. // return $scope.subdata;
  548. // },
  549. // tree_data: function () {
  550. // return $scope.tree_data;
  551. // },
  552. // parent: function () {
  553. // return $scope.parent
  554. // },
  555. scope: function () {
  556. return $scope
  557. }
  558. }
  559. });
  560. modalInstance.result.then(function (selectedItem) {
  561. api_report_data.addData('ciclassify', selectedItem).then(function (data) {
  562. console.log(data)
  563. if (data) {
  564. if (data.status == 200) {
  565. SweetAlert.swal({
  566. title: "提交成功!",
  567. type: "success"
  568. });
  569. dis1.disabled = true;
  570. dis2.disabled = true;
  571. $scope.wt_title = ""
  572. $scope.try_async_load()
  573. }
  574. }
  575. })
  576. })
  577. }
  578. /* -----start remove incidet category----- */
  579. //删除类型
  580. $scope.remove = function (element) {
  581. console.log(element)
  582. if (element.children.length == 0) {
  583. var modalInstance = $modal.open({
  584. templateUrl: 'assets/views/delete.html',
  585. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  586. // $scope.title = '优先级删除';
  587. // $scope.connect = '确定要删除此优先级?';
  588. $scope.title = "配置项分类删除";
  589. $scope.connect = "确定要删除此配置项分类?";
  590. $scope.ok = function () {
  591. $modalInstance.close(element);
  592. };
  593. $scope.cancel = function () {
  594. $modalInstance.dismiss('cancel');
  595. };
  596. },
  597. size: 'sm',
  598. resolve: {
  599. scope: function () {
  600. return $scope;
  601. }
  602. }
  603. });
  604. } else {
  605. var modalInstance = $modal.open({
  606. templateUrl: 'assets/views/wt_delete.html',
  607. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  608. // $scope.title = '优先级删除';
  609. // $scope.connect = '确定要删除此优先级?';
  610. $scope.title = "无法删除该分类";
  611. $scope.connect = "该分类下有子分类,请删除完该分类子分类才能删除该分类!";
  612. $scope.ok = function () {
  613. $modalInstance.close('');
  614. };
  615. $scope.cancel = function () {
  616. $modalInstance.dismiss('cancel');
  617. };
  618. },
  619. size: 'sm',
  620. resolve: {
  621. scope: function () {
  622. return $scope;
  623. }
  624. }
  625. });
  626. }
  627. modalInstance.result.then(function (selectedItem) {
  628. console.log(selectedItem)
  629. console.log($scope.content)
  630. if (selectedItem) {
  631. var rmvList = [];
  632. rmvList.push(selectedItem.id);
  633. // if (selectedItem.children.length > 0) {
  634. // SweetAlert.swal({
  635. // title: "删除失败!",
  636. // text: "请先删除选中的分类的子级",
  637. // type: "error"
  638. // })
  639. // } else {
  640. // api_bpm_data.rmvData('incidentcategory', rmvList).then(function (response) {
  641. // if (response.data) {
  642. // SweetAlert.swal({
  643. // title: "删除成功!",
  644. // type: "success",
  645. // confirmButtonColor: "#007AFF"
  646. // }, function () {
  647. // $scope.try_async_load();
  648. // $scope.$apply($scope.my_data);
  649. // });
  650. // } else {
  651. // SweetAlert.swal({
  652. // title: "操作异常!",
  653. // text: "系统异常,请稍后重试,或者联系管理员!",
  654. // type: "error"
  655. // });
  656. // }
  657. // })
  658. // }
  659. api_report_data.rmvData('cIClassify', rmvList).then(function (data) {
  660. console.log(data)
  661. if (data) {
  662. if (data.status = 200) {
  663. SweetAlert.swal({
  664. title: "删除成功!",
  665. // text: "请先删除选中的分类的子级",
  666. type: "success"
  667. });
  668. $scope.content = [];
  669. dis1.disabled = true;
  670. dis2.disabled = true;
  671. $scope.wt_title = ""
  672. $scope.try_async_load()
  673. }
  674. }
  675. })
  676. console.log(selectedItem)
  677. }
  678. })
  679. }
  680. /* -----end remove incidet category----- */
  681. // function convertchildToTree(datum) {
  682. // $scope.subdata = {};
  683. // console.log(datum.parent)
  684. // // console.log($scope.parentdata)
  685. // $scope.subdata =datum;
  686. // // if (datum.parent) {
  687. // // // angular.forEach($scope.parentdata, function(item, index) {
  688. // // // if (datum.id == item.id) return $scope.subdata = item;
  689. // // // });
  690. // // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'parent': datum.parent, 'hasArea': datum.hasArea, 'hasSimple': datum.hasSimple, 'group': datum.group, 'priority': datum.priority }
  691. // // } else {
  692. // // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'group': datum.group, 'hasSimple': datum.hasSimple, 'hasArea': datum.hasArea, 'priority': datum.priority }
  693. // // }
  694. // console.log($scope.subdata)
  695. // // if(datum.children.length==0){
  696. // // angular.forEach($scope.parentdata,function(item, index){
  697. // // if(datum.id==item.id) return $scope.subdata=item;
  698. // // });
  699. // // }else{$scope.subdata={id:datum.id,category:datum.label}}
  700. // }
  701. //预览
  702. $scope.preview = function (content, wt_title) {
  703. console.log(content, wt_title)
  704. if (content.length == 0 && !wt_title) {
  705. SweetAlert.swal({
  706. title: "请选择配置项分类",
  707. // text: "请先删除选中的分类的子级",
  708. type: "error"
  709. });
  710. return;
  711. } else {
  712. var modalInstance = $modal.open({
  713. templateUrl: 'assets/views/wt_preview.html',
  714. controller: function ($scope, $modalInstance, api_bpm_data, scope) {
  715. console.log(content, wt_title);
  716. $scope.contents = [];
  717. $scope.contents = content
  718. $scope.wt_title = wt_title;
  719. }, size: 'lg',
  720. resolve: {
  721. // datas: function () {
  722. // return $scope.subdata;
  723. // },
  724. // tree_data: function () {
  725. // return $scope.tree_data;
  726. // },
  727. // parent: function () {
  728. // return $scope.parent
  729. // },
  730. scope: function () {
  731. return $scope
  732. }
  733. }
  734. });
  735. }
  736. }
  737. //提交
  738. $scope.yes = function (content) {
  739. console.log(content)
  740. console.log($scope.cData)
  741. var upDate = {
  742. FormDefinition: $scope.cData
  743. }
  744. upDate.FormDefinition.modelUIDTOList = content;
  745. console.log(upDate.FormDefinition)
  746. // alert(2222)
  747. for (var i = 0; i < upDate.FormDefinition.modelUIDTOList.length; i++) {
  748. console.log(upDate.FormDefinition.modelUIDTOList[i])
  749. if(upDate.FormDefinition.modelUIDTOList[i].type=='input'&&upDate.FormDefinition.modelUIDTOList[i].readonly){
  750. upDate.FormDefinition.modelUIDTOList[i].uiWidget.id='20';
  751. }
  752. if(upDate.FormDefinition.modelUIDTOList[i].type=='input'&&!upDate.FormDefinition.modelUIDTOList[i].readonly){
  753. upDate.FormDefinition.modelUIDTOList[i].uiWidget.id='2';
  754. }
  755. if (upDate.FormDefinition.modelUIDTOList[i].label == '' || upDate.FormDefinition.modelUIDTOList[i].label == null) {
  756. SweetAlert.swal({
  757. title: "提交失败!",
  758. text: '提交组件标题为空',
  759. type: "error"
  760. })
  761. return;
  762. }
  763. delete (upDate.FormDefinition.modelUIDTOList[i].type);
  764. delete (upDate.FormDefinition.modelUIDTOList[i].$$hashKey);
  765. }
  766. console.log(upDate)
  767. api_report_data.updateForm('FormDefinition', upDate).then(function (data) {
  768. console.log(data)
  769. if (data) {
  770. if (data.status == 200) {
  771. $scope.typeModel = 'kj';
  772. $scope.controlsType = true;
  773. $scope.fieldType = false;
  774. // $scope.typeModel2 = '';
  775. // $scope.item = {}
  776. SweetAlert.swal({
  777. title: "提交成功!",
  778. type: "success"
  779. });
  780. console.log($scope.output)
  781. $scope.my_tree_handler($scope.output)
  782. console.log($scope.typeModel)
  783. }
  784. }
  785. // $scope.try_async_load()
  786. })
  787. console.log($scope.content)
  788. }
  789. function convertListToTree(data, treeMap) {
  790. console.log(data)
  791. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  792. var parentNode = null;
  793. var root = null; //Initially set our loop to null
  794. //loop over data
  795. for (var i = 0; i < data.length; i++) {
  796. var datum = data[i];
  797. //each node will have children, so let's give it a "children" poperty
  798. datum.children = [];
  799. //add an entry for this node to the map so that any future children can
  800. //lookup the parent
  801. idToNodeMap[datum.id] = datum;
  802. //Does this node have a parent?
  803. // console.log("datum="+JSON.stringify(datum))
  804. if (typeof datum.parent === "undefined") {
  805. //Doesn't look like it, so this node is the root of the tree
  806. root = datum;
  807. treeMap[datum.id] = root;
  808. } else {
  809. //This node has a parent, so let's look it up using the id
  810. parentNode = idToNodeMap[datum.parent.id];
  811. //We don't need this property, so let's delete it.
  812. // delete datum.parent;
  813. //Let's add the current node as a child of the parent node.
  814. parentNode.children.push(datum);
  815. }
  816. }
  817. return root;
  818. }
  819. function convertParentToChildList(data) {
  820. var treeMap = {};
  821. var list = [];
  822. convertListToTree(data, treeMap);
  823. angular.forEach(treeMap, function (item) {
  824. list.push(item);
  825. });
  826. console.log(list)
  827. return list;
  828. }
  829. // $scope.onFilterCallback = function(item){
  830. // $scope.addcategory.parent=item.label;
  831. // }
  832. $scope.parentdata = {};
  833. //获取类型数据
  834. $scope.try_async_load = function () {
  835. $scope.my_data = [];
  836. $scope.doing_async = true;
  837. var data = { "idx": 0, "sum": 1000, "ciclassify": { id: 0 } };
  838. api_report_data.fetchDataList1('ciclassify', data).then(function (response) {
  839. console.log(response.list)
  840. var data = response.list;
  841. var objects = [];
  842. $scope.parentdata = data;
  843. for (var i = 0; i < data.length; i++) {
  844. var object = {};
  845. object.id = data[i].id;
  846. if (angular.isDefined(data[i].parent)) {
  847. object.parent = data[i].parent;
  848. }
  849. if (angular.isDefined(data[i].hasArea)) {
  850. object.hasArea = data[i].hasArea;
  851. }
  852. if (angular.isDefined(data[i].hasSimple)) {
  853. object.hasSimple = data[i].hasSimple;
  854. }
  855. if (angular.isDefined(data[i].group)) {
  856. object.group = data[i].group;
  857. }
  858. if (angular.isDefined(data[i].priority)) {
  859. object.priority = data[i].priority;
  860. }
  861. if (angular.isDefined(data[i].prefix)) {
  862. object.prefix = data[i].prefix;
  863. }
  864. if (angular.isDefined(data[i].sign)) {
  865. object.sign = data[i].sign;
  866. }
  867. object.label = data[i].label;
  868. // object.actions = data[i][3]; //权限部分
  869. // object.group = "1";
  870. // object.user = "2";
  871. object.state = {
  872. "opened": true
  873. };
  874. object.typeName = "type";
  875. // if()
  876. // if (object.actions.indexOf("2") >= 0) { //知识库类型 具有增加权限--系统管理员
  877. $scope.showAddSolutionType = true;
  878. // }
  879. // if (object.actions.indexOf("5") >= 0) { //知识库类型 具有授权权限--系统管理员
  880. $scope.showReviewKnowledgeType = true;
  881. // }
  882. objects.push(object);
  883. }
  884. $scope.my_data = convertParentToChildList(objects);
  885. $scope.tree_data = angular.copy($scope.my_data);
  886. if ($scope.my_data.length > 0) {
  887. $scope.doing_async = false;
  888. }
  889. console.log($scope.tree_data)
  890. });
  891. };
  892. $scope.closethis = function (formdata) {
  893. formdata.category = "";
  894. formdata.parent.category = "";
  895. };
  896. /* -----start submit incidet category----- */
  897. $scope.submitchange = function (formdata) {
  898. if (formdata.hasArea) {
  899. formdata.hasArea = 1;
  900. formdata.hasPlace = 1;
  901. } else {
  902. formdata.hasArea = 0;
  903. formdata.hasPlace = 0;
  904. }
  905. // }
  906. if (formdata.hasSimple == true) {
  907. formdata.hasSimple = 1;
  908. } else {
  909. formdata.hasSimple = 0;
  910. }
  911. if (formdata.parent) {
  912. formdata.parent = { "id": formdata.parent.id };
  913. }
  914. var filedata = { "incidentcategory": formdata }
  915. api_bpm_data.updData('incidentcategory', filedata).then(function (response) {
  916. if (response) {
  917. if (response.status == 200) {
  918. $scope.try_async_load()
  919. SweetAlert.swal({
  920. title: "修改成功!",
  921. type: "success"
  922. }, function () {
  923. $scope.$apply($scope.my_data);
  924. })
  925. } else {
  926. SweetAlert.swal({
  927. title: "修改失败!",
  928. type: "error"
  929. })
  930. }
  931. }
  932. });
  933. };
  934. $scope.adddata = {};
  935. $scope.addparent = false;
  936. $scope.submitadd = function (formdata) {
  937. // var paret = {};
  938. // var filedata = {};
  939. // filedata = angular.copy(formdata);
  940. // delete filedata.addp
  941. // if (angular.isDefined(formdata.parent) && addparent) {
  942. // angular.forEach($scope.parentdata, function(data) {
  943. // if (formdata.parent.category.id == data.id) {
  944. // filedata = { "incidentcategory": { "category": formdata.category, "parent": { "id": data.id } } }
  945. // }
  946. // })
  947. // } else {
  948. // filedata = { "incidentcategory": { "category": formdata.category } }
  949. // }
  950. // filedata = { "incidentcategory": { "category": formdata.category, "parent": { "id": formdata.parentNode.id } } }
  951. // if (formdata.hasArea && formdata.hasArea == true) {
  952. if (formdata.hasArea) {
  953. formdata.hasArea = 1;
  954. formdata.hasPlace = 1;
  955. } else {
  956. formdata.hasArea = 0;
  957. formdata.hasPlace = 0;
  958. }
  959. if (formdata.hasSimple == true) {
  960. formdata.hasSimple = 1;
  961. } else {
  962. formdata.hasSimple = 0;
  963. }
  964. if (formdata.parent) {
  965. formdata.parent = { "id": formdata.parent.id };
  966. }
  967. var filedata = { "incidentcategory": formdata }
  968. api_bpm_data.addData('incidentcategory', filedata).then(function (response) {
  969. if (response) {
  970. if (response.status == 200) {
  971. $scope.userdata = [];
  972. $scope.outdata = [];
  973. $scope.try_async_load();
  974. SweetAlert.swal({
  975. title: "增加成功!",
  976. type: "success"
  977. })
  978. } else if (response.status == 408) {
  979. SweetAlert.swal({
  980. title: "增加失败!",
  981. text: response.error,
  982. type: "error"
  983. })
  984. } else {
  985. SweetAlert.swal({
  986. title: "增加失败!",
  987. type: "error"
  988. })
  989. }
  990. }
  991. });
  992. };
  993. /* -----end submit incidet category----- */
  994. $scope.try_async_load();
  995. // $scope.ldloading={};
  996. var filterData = {
  997. key: 'null',
  998. status: 0,
  999. pageIndex: 0,
  1000. pageSum: 10,
  1001. //treeIds:'[]',
  1002. userId: loginUser.id
  1003. }
  1004. }])