pzxgl_wt.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  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. // 'iconname':'assets/images/cmdb/other.png'
  525. }
  526. }
  527. }
  528. // var addData = {
  529. // ciclassify: {
  530. // 'label': item.category,
  531. // 'parent': { 'id': element.id },
  532. // 'prefix': item.parent.prefix
  533. // }
  534. // }
  535. }
  536. console.log(item, item1, addData)
  537. // pi_report_data.addData('ciclassify', addData).then(function (data) {
  538. // console.log(data)
  539. // })
  540. $modalInstance.close(addData);
  541. }
  542. $scope.cancel = function () {
  543. $modalInstance.dismiss('cancel');
  544. };
  545. }, size: 'sm',
  546. resolve: {
  547. // datas: function () {
  548. // return $scope.subdata;
  549. // },
  550. // tree_data: function () {
  551. // return $scope.tree_data;
  552. // },
  553. // parent: function () {
  554. // return $scope.parent
  555. // },
  556. scope: function () {
  557. return $scope
  558. }
  559. }
  560. });
  561. modalInstance.result.then(function (selectedItem) {
  562. selectedItem.ciclassify['iconname']='assets/images/cmdb/other.png';
  563. api_report_data.addData('ciclassify', selectedItem).then(function (data) {
  564. console.log(data)
  565. if (data) {
  566. if (data.status == 200) {
  567. SweetAlert.swal({
  568. title: "提交成功!",
  569. type: "success"
  570. });
  571. dis1.disabled = true;
  572. dis2.disabled = true;
  573. $scope.wt_title = ""
  574. $scope.try_async_load()
  575. }
  576. }
  577. })
  578. })
  579. }
  580. /* -----start remove incidet category----- */
  581. //删除类型
  582. $scope.remove = function (element) {
  583. console.log(element)
  584. if (element.children.length == 0) {
  585. var modalInstance = $modal.open({
  586. templateUrl: 'assets/views/delete.html',
  587. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  588. // $scope.title = '优先级删除';
  589. // $scope.connect = '确定要删除此优先级?';
  590. $scope.title = "配置项分类删除";
  591. $scope.connect = "确定要删除此配置项分类?";
  592. $scope.ok = function () {
  593. $modalInstance.close(element);
  594. };
  595. $scope.cancel = function () {
  596. $modalInstance.dismiss('cancel');
  597. };
  598. },
  599. size: 'sm',
  600. resolve: {
  601. scope: function () {
  602. return $scope;
  603. }
  604. }
  605. });
  606. } else {
  607. var modalInstance = $modal.open({
  608. templateUrl: 'assets/views/wt_delete.html',
  609. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  610. // $scope.title = '优先级删除';
  611. // $scope.connect = '确定要删除此优先级?';
  612. $scope.title = "无法删除该分类";
  613. $scope.connect = "该分类下有子分类,请删除完该分类子分类才能删除该分类!";
  614. $scope.ok = function () {
  615. $modalInstance.close('');
  616. };
  617. $scope.cancel = function () {
  618. $modalInstance.dismiss('cancel');
  619. };
  620. },
  621. size: 'sm',
  622. resolve: {
  623. scope: function () {
  624. return $scope;
  625. }
  626. }
  627. });
  628. }
  629. modalInstance.result.then(function (selectedItem) {
  630. console.log(selectedItem)
  631. console.log($scope.content)
  632. if (selectedItem) {
  633. var rmvList = [];
  634. rmvList.push(selectedItem.id);
  635. // if (selectedItem.children.length > 0) {
  636. // SweetAlert.swal({
  637. // title: "删除失败!",
  638. // text: "请先删除选中的分类的子级",
  639. // type: "error"
  640. // })
  641. // } else {
  642. // api_bpm_data.rmvData('incidentcategory', rmvList).then(function (response) {
  643. // if (response.data) {
  644. // SweetAlert.swal({
  645. // title: "删除成功!",
  646. // type: "success",
  647. // confirmButtonColor: "#007AFF"
  648. // }, function () {
  649. // $scope.try_async_load();
  650. // $scope.$apply($scope.my_data);
  651. // });
  652. // } else {
  653. // SweetAlert.swal({
  654. // title: "操作异常!",
  655. // text: "系统异常,请稍后重试,或者联系管理员!",
  656. // type: "error"
  657. // });
  658. // }
  659. // })
  660. // }
  661. api_report_data.rmvData('cIClassify', rmvList).then(function (data) {
  662. console.log(data)
  663. if (data) {
  664. if (data.status = 200) {
  665. SweetAlert.swal({
  666. title: "删除成功!",
  667. // text: "请先删除选中的分类的子级",
  668. type: "success"
  669. });
  670. $scope.content = [];
  671. dis1.disabled = true;
  672. dis2.disabled = true;
  673. $scope.wt_title = ""
  674. $scope.try_async_load()
  675. }
  676. }
  677. })
  678. console.log(selectedItem)
  679. }
  680. })
  681. }
  682. /* -----end remove incidet category----- */
  683. // function convertchildToTree(datum) {
  684. // $scope.subdata = {};
  685. // console.log(datum.parent)
  686. // // console.log($scope.parentdata)
  687. // $scope.subdata =datum;
  688. // // if (datum.parent) {
  689. // // // angular.forEach($scope.parentdata, function(item, index) {
  690. // // // if (datum.id == item.id) return $scope.subdata = item;
  691. // // // });
  692. // // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'parent': datum.parent, 'hasArea': datum.hasArea, 'hasSimple': datum.hasSimple, 'group': datum.group, 'priority': datum.priority }
  693. // // } else {
  694. // // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'group': datum.group, 'hasSimple': datum.hasSimple, 'hasArea': datum.hasArea, 'priority': datum.priority }
  695. // // }
  696. // console.log($scope.subdata)
  697. // // if(datum.children.length==0){
  698. // // angular.forEach($scope.parentdata,function(item, index){
  699. // // if(datum.id==item.id) return $scope.subdata=item;
  700. // // });
  701. // // }else{$scope.subdata={id:datum.id,category:datum.label}}
  702. // }
  703. //预览
  704. $scope.preview = function (content, wt_title) {
  705. console.log(content, wt_title)
  706. if (content.length == 0 && !wt_title) {
  707. SweetAlert.swal({
  708. title: "请选择配置项分类",
  709. // text: "请先删除选中的分类的子级",
  710. type: "error"
  711. });
  712. return;
  713. } else {
  714. var modalInstance = $modal.open({
  715. templateUrl: 'assets/views/wt_preview.html',
  716. controller: function ($scope, $modalInstance, api_bpm_data, scope) {
  717. console.log(content, wt_title);
  718. $scope.contents = [];
  719. $scope.contents = content
  720. $scope.wt_title = wt_title;
  721. }, size: 'lg',
  722. resolve: {
  723. // datas: function () {
  724. // return $scope.subdata;
  725. // },
  726. // tree_data: function () {
  727. // return $scope.tree_data;
  728. // },
  729. // parent: function () {
  730. // return $scope.parent
  731. // },
  732. scope: function () {
  733. return $scope
  734. }
  735. }
  736. });
  737. }
  738. }
  739. //提交
  740. $scope.yes = function (content) {
  741. console.log(content)
  742. console.log($scope.cData)
  743. var upDate = {
  744. FormDefinition: $scope.cData
  745. }
  746. upDate.FormDefinition.modelUIDTOList = content;
  747. console.log(upDate.FormDefinition)
  748. // alert(2222)
  749. for (var i = 0; i < upDate.FormDefinition.modelUIDTOList.length; i++) {
  750. console.log(upDate.FormDefinition.modelUIDTOList[i])
  751. if(upDate.FormDefinition.modelUIDTOList[i].type=='input'&&upDate.FormDefinition.modelUIDTOList[i].readonly){
  752. upDate.FormDefinition.modelUIDTOList[i].uiWidget.id='20';
  753. }
  754. if(upDate.FormDefinition.modelUIDTOList[i].type=='input'&&!upDate.FormDefinition.modelUIDTOList[i].readonly){
  755. upDate.FormDefinition.modelUIDTOList[i].uiWidget.id='2';
  756. }
  757. if (upDate.FormDefinition.modelUIDTOList[i].label == '' || upDate.FormDefinition.modelUIDTOList[i].label == null) {
  758. SweetAlert.swal({
  759. title: "提交失败!",
  760. text: '提交组件标题为空',
  761. type: "error"
  762. })
  763. return;
  764. }
  765. delete (upDate.FormDefinition.modelUIDTOList[i].type);
  766. delete (upDate.FormDefinition.modelUIDTOList[i].$$hashKey);
  767. }
  768. console.log(upDate)
  769. api_report_data.updateForm('FormDefinition', upDate).then(function (data) {
  770. console.log(data)
  771. if (data) {
  772. if (data.status == 200) {
  773. $scope.typeModel = 'kj';
  774. $scope.controlsType = true;
  775. $scope.fieldType = false;
  776. // $scope.typeModel2 = '';
  777. // $scope.item = {}
  778. SweetAlert.swal({
  779. title: "提交成功!",
  780. type: "success"
  781. });
  782. console.log($scope.output)
  783. $scope.my_tree_handler($scope.output)
  784. console.log($scope.typeModel)
  785. }
  786. }
  787. // $scope.try_async_load()
  788. })
  789. console.log($scope.content)
  790. }
  791. function convertListToTree(data, treeMap) {
  792. console.log(data)
  793. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  794. var parentNode = null;
  795. var root = null; //Initially set our loop to null
  796. //loop over data
  797. for (var i = 0; i < data.length; i++) {
  798. var datum = data[i];
  799. //each node will have children, so let's give it a "children" poperty
  800. datum.children = [];
  801. //add an entry for this node to the map so that any future children can
  802. //lookup the parent
  803. idToNodeMap[datum.id] = datum;
  804. //Does this node have a parent?
  805. // console.log("datum="+JSON.stringify(datum))
  806. if (typeof datum.parent === "undefined") {
  807. //Doesn't look like it, so this node is the root of the tree
  808. root = datum;
  809. treeMap[datum.id] = root;
  810. } else {
  811. //This node has a parent, so let's look it up using the id
  812. parentNode = idToNodeMap[datum.parent.id];
  813. //We don't need this property, so let's delete it.
  814. // delete datum.parent;
  815. //Let's add the current node as a child of the parent node.
  816. parentNode.children.push(datum);
  817. }
  818. }
  819. return root;
  820. }
  821. function convertParentToChildList(data) {
  822. var treeMap = {};
  823. var list = [];
  824. convertListToTree(data, treeMap);
  825. angular.forEach(treeMap, function (item) {
  826. list.push(item);
  827. });
  828. console.log(list)
  829. return list;
  830. }
  831. // $scope.onFilterCallback = function(item){
  832. // $scope.addcategory.parent=item.label;
  833. // }
  834. $scope.parentdata = {};
  835. //获取类型数据
  836. $scope.try_async_load = function () {
  837. $scope.my_data = [];
  838. $scope.doing_async = true;
  839. var data = { "idx": 0, "sum": 1000, "ciclassify": { id: 0 } };
  840. api_report_data.fetchDataList1('ciclassify', data).then(function (response) {
  841. console.log(response.list)
  842. var data = response.list;
  843. var objects = [];
  844. $scope.parentdata = data;
  845. for (var i = 0; i < data.length; i++) {
  846. var object = {};
  847. object.id = data[i].id;
  848. if (angular.isDefined(data[i].parent)) {
  849. object.parent = data[i].parent;
  850. }
  851. if (angular.isDefined(data[i].hasArea)) {
  852. object.hasArea = data[i].hasArea;
  853. }
  854. if (angular.isDefined(data[i].hasSimple)) {
  855. object.hasSimple = data[i].hasSimple;
  856. }
  857. if (angular.isDefined(data[i].group)) {
  858. object.group = data[i].group;
  859. }
  860. if (angular.isDefined(data[i].priority)) {
  861. object.priority = data[i].priority;
  862. }
  863. if (angular.isDefined(data[i].prefix)) {
  864. object.prefix = data[i].prefix;
  865. }
  866. if (angular.isDefined(data[i].sign)) {
  867. object.sign = data[i].sign;
  868. }
  869. object.label = data[i].label;
  870. // object.actions = data[i][3]; //权限部分
  871. // object.group = "1";
  872. // object.user = "2";
  873. object.state = {
  874. "opened": true
  875. };
  876. object.typeName = "type";
  877. // if()
  878. // if (object.actions.indexOf("2") >= 0) { //知识库类型 具有增加权限--系统管理员
  879. $scope.showAddSolutionType = true;
  880. // }
  881. // if (object.actions.indexOf("5") >= 0) { //知识库类型 具有授权权限--系统管理员
  882. $scope.showReviewKnowledgeType = true;
  883. // }
  884. objects.push(object);
  885. }
  886. $scope.my_data = convertParentToChildList(objects);
  887. $scope.tree_data = angular.copy($scope.my_data);
  888. if ($scope.my_data.length > 0) {
  889. $scope.doing_async = false;
  890. }
  891. console.log($scope.tree_data)
  892. });
  893. };
  894. $scope.closethis = function (formdata) {
  895. formdata.category = "";
  896. formdata.parent.category = "";
  897. };
  898. /* -----start submit incidet category----- */
  899. $scope.submitchange = function (formdata) {
  900. if (formdata.hasArea) {
  901. formdata.hasArea = 1;
  902. formdata.hasPlace = 1;
  903. } else {
  904. formdata.hasArea = 0;
  905. formdata.hasPlace = 0;
  906. }
  907. // }
  908. if (formdata.hasSimple == true) {
  909. formdata.hasSimple = 1;
  910. } else {
  911. formdata.hasSimple = 0;
  912. }
  913. if (formdata.parent) {
  914. formdata.parent = { "id": formdata.parent.id };
  915. }
  916. var filedata = { "incidentcategory": formdata }
  917. api_bpm_data.updData('incidentcategory', filedata).then(function (response) {
  918. if (response) {
  919. if (response.status == 200) {
  920. $scope.try_async_load()
  921. SweetAlert.swal({
  922. title: "修改成功!",
  923. type: "success"
  924. }, function () {
  925. $scope.$apply($scope.my_data);
  926. })
  927. } else {
  928. SweetAlert.swal({
  929. title: "修改失败!",
  930. type: "error"
  931. })
  932. }
  933. }
  934. });
  935. };
  936. $scope.adddata = {};
  937. $scope.addparent = false;
  938. $scope.submitadd = function (formdata) {
  939. // var paret = {};
  940. // var filedata = {};
  941. // filedata = angular.copy(formdata);
  942. // delete filedata.addp
  943. // if (angular.isDefined(formdata.parent) && addparent) {
  944. // angular.forEach($scope.parentdata, function(data) {
  945. // if (formdata.parent.category.id == data.id) {
  946. // filedata = { "incidentcategory": { "category": formdata.category, "parent": { "id": data.id } } }
  947. // }
  948. // })
  949. // } else {
  950. // filedata = { "incidentcategory": { "category": formdata.category } }
  951. // }
  952. // filedata = { "incidentcategory": { "category": formdata.category, "parent": { "id": formdata.parentNode.id } } }
  953. // if (formdata.hasArea && formdata.hasArea == true) {
  954. if (formdata.hasArea) {
  955. formdata.hasArea = 1;
  956. formdata.hasPlace = 1;
  957. } else {
  958. formdata.hasArea = 0;
  959. formdata.hasPlace = 0;
  960. }
  961. if (formdata.hasSimple == true) {
  962. formdata.hasSimple = 1;
  963. } else {
  964. formdata.hasSimple = 0;
  965. }
  966. if (formdata.parent) {
  967. formdata.parent = { "id": formdata.parent.id };
  968. }
  969. var filedata = { "incidentcategory": formdata }
  970. api_bpm_data.addData('incidentcategory', filedata).then(function (response) {
  971. if (response) {
  972. if (response.status == 200) {
  973. $scope.userdata = [];
  974. $scope.outdata = [];
  975. $scope.try_async_load();
  976. SweetAlert.swal({
  977. title: "增加成功!",
  978. type: "success"
  979. })
  980. } else if (response.status == 408) {
  981. SweetAlert.swal({
  982. title: "增加失败!",
  983. text: response.error,
  984. type: "error"
  985. })
  986. } else {
  987. SweetAlert.swal({
  988. title: "增加失败!",
  989. type: "error"
  990. })
  991. }
  992. }
  993. });
  994. };
  995. /* -----end submit incidet category----- */
  996. $scope.try_async_load();
  997. // $scope.ldloading={};
  998. var filterData = {
  999. key: 'null',
  1000. status: 0,
  1001. pageIndex: 0,
  1002. pageSum: 10,
  1003. //treeIds:'[]',
  1004. userId: loginUser.id
  1005. }
  1006. }])