1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066 |
- 'use strict';
- 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) {
- // alert(1111)
- $scope.myData = [];
- var loginUser = $rootScope.user;
- console.log(loginUser);
- $scope.typeModel = "kj";
- $scope.typeModel1 = '';
- $scope.typeModel2 = 9999;
- $scope.typeModel3 = false;
- $scope.wt_cld = false;
- var dis1 = document.getElementById('changes1')
- var dis2 = document.getElementById('remove')
- dis1.disabled = true;
- dis2.disabled = true;
- // $scope.wt_show = false;
- // $scope.selectedSite;
- // var input = document.getElementById('wt_input');
- // var input1 = document.getElementById('wt_input1');
- // var input2 = document.getElementById('wt_input2');
- // input.disabled = true;
- // input1.disabled = true;
- // input2.disabled = true;
- // $scope.content = [{ 'name': '张春玲', 'age': 28 }, { 'name': '王晰', 'age': 26 }, { 'name': '吴正青', 'age': 66 }];
- $scope.content = [];
- //增加控件
- $scope.add = function (type, id, style) {
- $scope.typeModel1 = type
- // $scope.text = {
- // 'type': type,
- // 'id': id,
- // 'label': '',
- // 'placeholder': '请编辑...',
- // 'selectedSite': '1'
- // }
- $scope.text = {
- 'editable': null,
- 'extjson': null,
- 'field': null,
- 'form': null,
- 'grid': null,
- 'hidden': null,
- 'id': null,
- 'key': null,
- 'label': null,
- 'layout': null,
- 'model': null,
- 'placeholder': "请输入...",
- 'readonly': true,
- 'required': false,
- 'style': style,
- 'title': null,
- 'type': type,
- 'uiWidget': { id: id },
- 'validatePattern': null,
- 'valueExpression': null,
- 'view': null
- }
- if (id == 61) {
- $scope.text.placeholder = '请选择...'
- }
- console.log($scope.content)
- console.log($scope.text)
- $scope.content.push($scope.text)
- console.log($scope.content)
- }
- //复制控件
- $scope.copy = function (item) {
- console.log(item)
- window.event ? window.event.cancelBubble = true : e.stopPropagation();
- $scope.copyData = {
- 'type': item.type,
- // 'id': item.id,
- // 'label': item.label,
- // 'placeholder': item.placeholder,
- // 'selectedSite': item.selectedSite,
- 'editable': null,
- 'extjson': null,
- 'field': null,
- 'form': null,
- 'grid': null,
- 'hidden': null,
- 'id': null,
- 'key': null,
- 'label': item.label,
- 'layout': null,
- 'model': null,
- 'placeholder': item.placeholder,
- 'readonly': item.readonly,
- 'required': item.required,
- 'style': item.style,
- 'title': null,
- // 'type': item.type,
- 'uiWidget': item.uiWidget,
- 'validatePattern': null,
- 'valueExpression': null,
- 'view': null
- }
- $scope.content.push($scope.copyData);
- console.log($scope.content)
- }
- //删除控件
- $scope.rem = function (item) {
- console.log($scope.content)
- console.log(item);
- $scope.typeModel = 'kj';
- $scope.typeModel1 = '';
- $scope.controlsType = true;
- $scope.fieldType = false;
- var formData = []
- if (item.id == null) {
- for (var i = 0; i < $scope.content.length; i++) {
- if ($scope.content[i].$$hashKey == item.$$hashKey) {
- $scope.content.splice(i, 1)
- SweetAlert.swal({
- title: "删除成功!",
- type: "success"
- })
- $scope.item = {}
- }
- }
- } else {
- formData.push(item.id)
- console.log(formData)
- api_report_data.formData('modelUI', formData).then(function (response) {
- console.log(response)
- if (response) {
- if (response.status == 200) {
- for (var i = 0; i < $scope.content.length; i++) {
- if ($scope.content[i].$$hashKey == item.$$hashKey) {
- $scope.content.splice(i, 1)
- // alert(1111)
- $scope.item = {}
- }
- }
- SweetAlert.swal({
- title: "删除成功!",
- type: "success"
- })
- }
- }
- })
- }
- // $scope.wt_show = false;
- // input.disabled = true;
- // input1.disabled = true;
- // input2.disabled = true;
- // for (var i = 0; i < $scope.content.length; i++) {
- // if ($scope.content[i].$$hashKey == item.$$hashKey) {
- // $scope.content.splice(i, 1)
- // // alert(1111)
- // $scope.item = {}
- // }
- // }
- window.event ? window.event.cancelBubble = true : e.stopPropagation();
- }
- //编辑控件
- $scope.editor = function (item, index) {
- console.log(item, index);
- // dis2.disabled = false;
- $scope.typeModel2 = index
- $scope.typeModel = 'zd';
- $scope.controlsType = false;
- $scope.fieldType = true;
- if(!item.readonly && item.type == 'input'){
- var id = {
- id: '2'
- }
- item.uiWidget = id;
- item.style = 'col-xs-4';
- }
- if (item.readonly && item.type == 'input') {
- var id = {
- id: '20'
- }
- item.uiWidget = id;
- item.style = 'col-xs-4';
- } if (item.type == 'binput') {
- var id = {
- id: '3'
- }
- item.uiWidget = id;
- item.style = 'col-xs-12';
- } if (item.type == 'time') {
- var id = {
- id: '61'
- }
- item.uiWidget = id;
- item.style = 'col-xs-4';
- } if (item.type == 'select') {
- var id = {
- id: '7'
- }
- item.uiWidget = id;
- item.style = 'col-xs-4';
- }
- console.log(item)
- // $scope.selectedSite=''
- // $scope.wt_show = true;
- // input.disabled = false;
- // input1.disabled = false;
- // input2.disabled = false;
- // $scope.selectedSite = item.selectedSite;
- $scope.item = item;
- // console.log($scope.selectedSite)
- }
- // $scope.accounted = [
- // // { name: '4/1', id: '4' },
- // { name: '3/1', id: '3' },
- // { name: '2/1', id: '2' },
- // { name: '1', id: '1' },
- // ]
- // $scope.change1 = function (selectedSite) {
- // // item.selectedSite=$scope.selectedSite;
- // console.log(selectedSite)
- // $scope.selectedSite = selectedSite;
- // $scope.item.selectedSite = selectedSite;
- // console.log($scope.item)
- // }
- /** 拖拽成功触发方法
- * index 拖拽后落下时的元素的序号(下标)
- * obj被拖动数据对象
- */
- $scope.dropComplete = function (index, obj) {
- //重新排序
- var idx = $scope.content.indexOf(obj);
- $scope.content.splice(idx, 1);
- $scope.content.splice(index, 0, obj);
- };
- $scope.controlsType = false;
- $scope.fieldType = false;
- //控件按钮
- $scope.controls = function (type) {
- // $scope.typeModel2 = 9999;
- console.log($scope.subdata)
- $scope.typeModel = type;
- if ($scope.subdata) {
- $scope.controlsType = true;
- $scope.fieldType = false;
- }
- }
- //属性按钮
- $scope.field = function (type) {
- console.log($scope.subdata)
- $scope.typeModel = type;
- if ($scope.subdata) {
- $scope.controlsType = false;
- $scope.fieldType = true;
- }
- }
- // $scope.langs=i18nService.getAllLangs();
- // $scope.lang = 'zh-cn';
- var loginUser = $rootScope.user;
- //组
- api_user_data.fetchDataList('group', { "idx": 0, "sum": 1000 }).then(function (data) {
- $scope.group = data.list;
- });
- //优先级
- api_bpm_data.fetchDataList('priority', { "idx": 0, "sum": 10 }).then(function (data) {
- $scope.priority = data.list;
- });
- /* ----- tree----- */
- var apple_selected, tree, treedata_avm, treedata_geography;
- //$scope.selectedTreeNode = {};ssss
- var i = 0;
- $scope.out = [];
- $scope.outdata = [];
- var systemtype = [];
- $scope.addcate = false;
- $scope.changecate = false;
- // $scope.refreshListData = function(){
- // var data ={"idx":0,"sum":1000};
- // api_bpm_data.fetchDataList('incidentcategory',data).then(function(response){
- // if(response){
- // if(response.status=200){
- // $scope.outdata = response.list;
- // }
- // }
- // })
- // }
- // $scope.refreshListData();
- var childdata = {};
- //选择类型
- $scope.my_tree_handler = function (branch) {
- console.log(branch);
- dis1.disabled = false;
- dis2.disabled = false;
- $scope.wt_label = branch.label;
- $scope.changecate = true;
- $scope.addcate = false;
- filterData.treeIds = branch.id;
- // $scope.parent = branch.parent;
- $scope.subdata = branch;
- // $scope.selectedTreeNode = branch;
- $scope.output = branch;
- // convertchildToTree(branch);
- // console.log($scope.subdata)
- var eqflag = false;
- $scope.typeModel2 = 9999;
- var aa = branch.prefix.toLowerCase()
- console.log(aa)
- var FormDefinition = {
- idx: 0,
- sum: 1000,
- FormDefinition: {
- name: 'ci_' + aa + branch.sign
- }
- }
- console.log(FormDefinition);
- $scope.cData = {}
- $scope.content = []
- api_report_data.fetchDataList1('FormDefinition', FormDefinition).then(function (response) {
- if (response) {
- if (response.list) {
- console.log(response);
- console.log(response.list)
- if (response.list[0]) {
- $scope.controlsType = true;
- $scope.fieldType = false;
- $scope.wt_title = response.list[0].url;
- if (response.list[0].modelUIDTOList) {
- $scope.content = response.list[0].modelUIDTOList;
- for (var i = 0; i < $scope.content.length; i++) {
- if ($scope.content[i].uiWidget.id == 2 || $scope.content[i].uiWidget.id == 20) {
- $scope.content[i]['type'] = 'input';
- // $scope.content[i]['placeholder'] = '请编辑...';
- } if ($scope.content[i].uiWidget.id == 3) {
- $scope.content[i]['type'] = 'binput';
- } if ($scope.content[i].uiWidget.id == 61) {
- $scope.content[i]['type'] = 'time';
- } if ($scope.content[i].uiWidget.id == 7) {
- $scope.content[i]['type'] = 'select';
- }
- };
- }
- } else {
- $scope.wt_title = branch.label + '属性';
- $scope.subdata = null
- $scope.controlsType = false;
- $scope.fieldType = false;
- }
- $scope.cData = response.list[0];
- // $scope.wt_title = response.list[0].url;
- }
- }
- console.log(response)
- // console.log(response.list[0].modelUIs)
- // $scope.content.push(response.list[0].modelUIs)
- })
- angular.forEach($scope.outdata, function (item) {
- if (item.id == $scope.output.id) eqflag = true;
- });
- if (eqflag) {
- } else {
- $scope.outdata.push({
- 'name': $scope.output.label,
- 'id': $scope.output.id,
- // 'parent': $scope.output.parent
- });
- var postData = {
- typeList: []
- };
- if ($scope.outdata.length > 0) {
- angular.forEach($scope.outdata, function (data) {
- postData.typeList.push({ id: data.id });
- })
- }
- // api_solution.findSolutionTypesUser(postData).then(function(response){
- // //Restangular.
- // $scope.userdata = response.data;
- // });
- }
- };
- //修改类型
- $scope.changes = function (data) {
- console.log(data)
- // $scope.subdata = data;
- // console.log($scope.subdata);
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete_wt.html',
- controller: function ($scope, $modalInstance, scope) {
- $scope.addcate = false
- $scope.changecate = true
- console.log(scope.subdata)
- $scope.subdata = {};
- $scope.subdata = data;
- $scope.tree_data = {};
- // console.log(data)
- console.log(scope.my_data)
- // $scope.subdata = datas
- // if(parent){
- // $scope.subdata['parent']= parent
- // }
- console.log($scope.subdata)
- $scope.submitchange = function (subdata) {
- $modalInstance.close(subdata);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- $scope.change1 = function (data) {
- console.log(data)
- $scope.btn = document.getElementById('submitchange');
- if (data == '') {
- // console.log(btn.disabled)
- $scope.btn.disabled = true;
- } else {
- $scope.btn.disabled = false;
- }
- }
- },
- size: 'sm',
- resolve: {
- // datas: function () {
- // return $scope.subdata;
- // },
- // tree_data: function () {
- // return $scope.tree_data;
- // },
- // parent: function () {
- // return $scope.parent
- // },
- scope: function () {
- return $scope
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- console.log(selectedItem);
- var changeData = {
- ciclassify: {
- 'id': selectedItem.id,
- 'label': selectedItem.label
- }
- }
- if (changeData.ciclassify.label == '') {
- // SweetAlert.swal({
- // title: "修改失败!",
- // text: "配置项类型名称不能为空",
- // type: "error"
- // })
- return;
- } else {
- console.log(changeData)
- api_report_data.updData('ciclassify', changeData).then(function (data) {
- console.log(data)
- if (data) {
- if (data.status == 200) {
- SweetAlert.swal({
- title: "修改成功!",
- type: "success"
- });
- dis1.disabled = true;
- dis2.disabled = true;
- $scope.wt_title = ""
- $scope.try_async_load()
- }
- }
- })
- }
- }
- })
- }
- //新增类型
- $scope.addType = function (element) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete_wt.html',
- controller: function ($scope, $modalInstance, api_bpm_data, scope) {
- // api_bpm_data.fetchDataList('closecode',filterData).then(function(data){
- // var myData = Restangular.stripRestangular(data);
- // }
- $scope.tree_data = scope.my_data;
- $scope.addcate = true
- $scope.changecate = false
- console.log(scope.tree_data, element)
- $scope.onFilterCallback = function (item) {
- console.log(item)
- element = item;
- if (element) {
- if (element.parent) {
- if (element.parent.parent) {
- $scope.wt_cld = true;
- } else {
- $scope.wt_cld = false;
- }
- } else {
- $scope.wt_cld = false;
- }
- }
- }
- $scope.submitadd = function (item, item1) {
- console.log(element, item, item1)
- if (!item1) {
- var addData = {
- ciclassify: {
- 'label': item.category,
- }
- }
- } else {
- if (element) {
- if (element.parent) {
- if (element.parent.parent) {
- $scope.wt_cld = true;
- return;
- } else {
- $scope.wt_cld = false;
- }
- var addData = {
- ciclassify: {
- 'label': item.category,
- 'parent': { 'id': element.id },
- 'prefix': element.parent.prefix
- }
- }
- }else {
- $scope.wt_cld = false;
- }
- var addData = {
- ciclassify: {
- 'label': item.category,
- 'parent': { 'id': element.id },
- 'prefix': element.prefix,
- // 'iconname':'assets/images/cmdb/other.png'
- }
- }
- }
- // var addData = {
- // ciclassify: {
- // 'label': item.category,
- // 'parent': { 'id': element.id },
- // 'prefix': item.parent.prefix
- // }
- // }
- }
- console.log(item, item1, addData)
- // pi_report_data.addData('ciclassify', addData).then(function (data) {
- // console.log(data)
- // })
- $modalInstance.close(addData);
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- }, size: 'sm',
- resolve: {
- // datas: function () {
- // return $scope.subdata;
- // },
- // tree_data: function () {
- // return $scope.tree_data;
- // },
- // parent: function () {
- // return $scope.parent
- // },
- scope: function () {
- return $scope
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- selectedItem.ciclassify['iconname']='assets/images/cmdb/other.png';
- api_report_data.addData('ciclassify', selectedItem).then(function (data) {
- console.log(data)
- if (data) {
- if (data.status == 200) {
- SweetAlert.swal({
- title: "提交成功!",
- type: "success"
- });
- dis1.disabled = true;
- dis2.disabled = true;
- $scope.wt_title = ""
- $scope.try_async_load()
- }
- }
- })
- })
- }
- /* -----start remove incidet category----- */
- //删除类型
- $scope.remove = function (element) {
- console.log(element)
- if (element.children.length == 0) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- // $scope.title = '优先级删除';
- // $scope.connect = '确定要删除此优先级?';
- $scope.title = "配置项分类删除";
- $scope.connect = "确定要删除此配置项分类?";
- $scope.ok = function () {
- $modalInstance.close(element);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/wt_delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- // $scope.title = '优先级删除';
- // $scope.connect = '确定要删除此优先级?';
- $scope.title = "无法删除该分类";
- $scope.connect = "该分类下有子分类,请删除完该分类子分类才能删除该分类!";
- $scope.ok = function () {
- $modalInstance.close('');
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- }
- modalInstance.result.then(function (selectedItem) {
- console.log(selectedItem)
- console.log($scope.content)
- if (selectedItem) {
- var rmvList = [];
- rmvList.push(selectedItem.id);
- // if (selectedItem.children.length > 0) {
- // SweetAlert.swal({
- // title: "删除失败!",
- // text: "请先删除选中的分类的子级",
- // type: "error"
- // })
- // } else {
- // api_bpm_data.rmvData('incidentcategory', rmvList).then(function (response) {
- // if (response.data) {
- // SweetAlert.swal({
- // title: "删除成功!",
- // type: "success",
- // confirmButtonColor: "#007AFF"
- // }, function () {
- // $scope.try_async_load();
- // $scope.$apply($scope.my_data);
- // });
- // } else {
- // SweetAlert.swal({
- // title: "操作异常!",
- // text: "系统异常,请稍后重试,或者联系管理员!",
- // type: "error"
- // });
- // }
- // })
- // }
- api_report_data.rmvData('cIClassify', rmvList).then(function (data) {
- console.log(data)
- if (data) {
- if (data.status = 200) {
- SweetAlert.swal({
- title: "删除成功!",
- // text: "请先删除选中的分类的子级",
- type: "success"
- });
- $scope.content = [];
- dis1.disabled = true;
- dis2.disabled = true;
- $scope.wt_title = ""
- $scope.try_async_load()
- }
- }
- })
- console.log(selectedItem)
- }
- })
- }
- /* -----end remove incidet category----- */
- // function convertchildToTree(datum) {
- // $scope.subdata = {};
- // console.log(datum.parent)
- // // console.log($scope.parentdata)
- // $scope.subdata =datum;
- // // if (datum.parent) {
- // // // angular.forEach($scope.parentdata, function(item, index) {
- // // // if (datum.id == item.id) return $scope.subdata = item;
- // // // });
- // // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'parent': datum.parent, 'hasArea': datum.hasArea, 'hasSimple': datum.hasSimple, 'group': datum.group, 'priority': datum.priority }
- // // } else {
- // // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'group': datum.group, 'hasSimple': datum.hasSimple, 'hasArea': datum.hasArea, 'priority': datum.priority }
- // // }
- // console.log($scope.subdata)
- // // if(datum.children.length==0){
- // // angular.forEach($scope.parentdata,function(item, index){
- // // if(datum.id==item.id) return $scope.subdata=item;
- // // });
- // // }else{$scope.subdata={id:datum.id,category:datum.label}}
- // }
- //预览
- $scope.preview = function (content, wt_title) {
- console.log(content, wt_title)
- if (content.length == 0 && !wt_title) {
- SweetAlert.swal({
- title: "请选择配置项分类",
- // text: "请先删除选中的分类的子级",
- type: "error"
- });
- return;
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/wt_preview.html',
- controller: function ($scope, $modalInstance, api_bpm_data, scope) {
- console.log(content, wt_title);
- $scope.contents = [];
- $scope.contents = content
- $scope.wt_title = wt_title;
- }, size: 'lg',
- resolve: {
- // datas: function () {
- // return $scope.subdata;
- // },
- // tree_data: function () {
- // return $scope.tree_data;
- // },
- // parent: function () {
- // return $scope.parent
- // },
- scope: function () {
- return $scope
- }
- }
- });
- }
- }
- //提交
- $scope.yes = function (content) {
- console.log(content)
- console.log($scope.cData)
- var upDate = {
- FormDefinition: $scope.cData
- }
- upDate.FormDefinition.modelUIDTOList = content;
- console.log(upDate.FormDefinition)
- // alert(2222)
- for (var i = 0; i < upDate.FormDefinition.modelUIDTOList.length; i++) {
- console.log(upDate.FormDefinition.modelUIDTOList[i])
-
- if(upDate.FormDefinition.modelUIDTOList[i].type=='input'&&upDate.FormDefinition.modelUIDTOList[i].readonly){
- upDate.FormDefinition.modelUIDTOList[i].uiWidget.id='20';
- }
- if(upDate.FormDefinition.modelUIDTOList[i].type=='input'&&!upDate.FormDefinition.modelUIDTOList[i].readonly){
- upDate.FormDefinition.modelUIDTOList[i].uiWidget.id='2';
- }
- if (upDate.FormDefinition.modelUIDTOList[i].label == '' || upDate.FormDefinition.modelUIDTOList[i].label == null) {
- SweetAlert.swal({
- title: "提交失败!",
- text: '提交组件标题为空',
- type: "error"
- })
- return;
- }
- delete (upDate.FormDefinition.modelUIDTOList[i].type);
- delete (upDate.FormDefinition.modelUIDTOList[i].$$hashKey);
- }
- console.log(upDate)
- api_report_data.updateForm('FormDefinition', upDate).then(function (data) {
- console.log(data)
- if (data) {
- if (data.status == 200) {
- $scope.typeModel = 'kj';
- $scope.controlsType = true;
- $scope.fieldType = false;
- // $scope.typeModel2 = '';
- // $scope.item = {}
- SweetAlert.swal({
- title: "提交成功!",
- type: "success"
- });
- console.log($scope.output)
- $scope.my_tree_handler($scope.output)
- console.log($scope.typeModel)
- }
- }
- // $scope.try_async_load()
- })
- console.log($scope.content)
- }
- function convertListToTree(data, treeMap) {
- console.log(data)
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var parentNode = null;
- var root = null; //Initially set our loop to null
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- // console.log("datum="+JSON.stringify(datum))
- if (typeof datum.parent === "undefined") {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- // delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- console.log(list)
- return list;
- }
- // $scope.onFilterCallback = function(item){
- // $scope.addcategory.parent=item.label;
- // }
- $scope.parentdata = {};
- //获取类型数据
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.doing_async = true;
- var data = { "idx": 0, "sum": 1000, "ciclassify": { id: 0 } };
- api_report_data.fetchDataList1('ciclassify', data).then(function (response) {
- console.log(response.list)
- var data = response.list;
- var objects = [];
- $scope.parentdata = data;
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- if (angular.isDefined(data[i].parent)) {
- object.parent = data[i].parent;
- }
- if (angular.isDefined(data[i].hasArea)) {
- object.hasArea = data[i].hasArea;
- }
- if (angular.isDefined(data[i].hasSimple)) {
- object.hasSimple = data[i].hasSimple;
- }
- if (angular.isDefined(data[i].group)) {
- object.group = data[i].group;
- }
- if (angular.isDefined(data[i].priority)) {
- object.priority = data[i].priority;
- }
- if (angular.isDefined(data[i].prefix)) {
- object.prefix = data[i].prefix;
- }
- if (angular.isDefined(data[i].sign)) {
- object.sign = data[i].sign;
- }
- object.label = data[i].label;
- // object.actions = data[i][3]; //权限部分
- // object.group = "1";
- // object.user = "2";
- object.state = {
- "opened": true
- };
- object.typeName = "type";
- // if()
- // if (object.actions.indexOf("2") >= 0) { //知识库类型 具有增加权限--系统管理员
- $scope.showAddSolutionType = true;
- // }
- // if (object.actions.indexOf("5") >= 0) { //知识库类型 具有授权权限--系统管理员
- $scope.showReviewKnowledgeType = true;
- // }
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.tree_data = angular.copy($scope.my_data);
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- console.log($scope.tree_data)
- });
- };
- $scope.closethis = function (formdata) {
- formdata.category = "";
- formdata.parent.category = "";
- };
- /* -----start submit incidet category----- */
- $scope.submitchange = function (formdata) {
- if (formdata.hasArea) {
- formdata.hasArea = 1;
- formdata.hasPlace = 1;
- } else {
- formdata.hasArea = 0;
- formdata.hasPlace = 0;
- }
- // }
- if (formdata.hasSimple == true) {
- formdata.hasSimple = 1;
- } else {
- formdata.hasSimple = 0;
- }
- if (formdata.parent) {
- formdata.parent = { "id": formdata.parent.id };
- }
- var filedata = { "incidentcategory": formdata }
- api_bpm_data.updData('incidentcategory', filedata).then(function (response) {
- if (response) {
- if (response.status == 200) {
- $scope.try_async_load()
- SweetAlert.swal({
- title: "修改成功!",
- type: "success"
- }, function () {
- $scope.$apply($scope.my_data);
- })
- } else {
- SweetAlert.swal({
- title: "修改失败!",
- type: "error"
- })
- }
- }
- });
- };
- $scope.adddata = {};
- $scope.addparent = false;
- $scope.submitadd = function (formdata) {
- // var paret = {};
- // var filedata = {};
- // filedata = angular.copy(formdata);
- // delete filedata.addp
- // if (angular.isDefined(formdata.parent) && addparent) {
- // angular.forEach($scope.parentdata, function(data) {
- // if (formdata.parent.category.id == data.id) {
- // filedata = { "incidentcategory": { "category": formdata.category, "parent": { "id": data.id } } }
- // }
- // })
- // } else {
- // filedata = { "incidentcategory": { "category": formdata.category } }
- // }
- // filedata = { "incidentcategory": { "category": formdata.category, "parent": { "id": formdata.parentNode.id } } }
- // if (formdata.hasArea && formdata.hasArea == true) {
- if (formdata.hasArea) {
- formdata.hasArea = 1;
- formdata.hasPlace = 1;
- } else {
- formdata.hasArea = 0;
- formdata.hasPlace = 0;
- }
- if (formdata.hasSimple == true) {
- formdata.hasSimple = 1;
- } else {
- formdata.hasSimple = 0;
- }
- if (formdata.parent) {
- formdata.parent = { "id": formdata.parent.id };
- }
- var filedata = { "incidentcategory": formdata }
- api_bpm_data.addData('incidentcategory', filedata).then(function (response) {
- if (response) {
- if (response.status == 200) {
- $scope.userdata = [];
- $scope.outdata = [];
- $scope.try_async_load();
- SweetAlert.swal({
- title: "增加成功!",
- type: "success"
- })
- } else if (response.status == 408) {
- SweetAlert.swal({
- title: "增加失败!",
- text: response.error,
- type: "error"
- })
- } else {
- SweetAlert.swal({
- title: "增加失败!",
- type: "error"
- })
- }
- }
- });
- };
- /* -----end submit incidet category----- */
- $scope.try_async_load();
- // $scope.ldloading={};
- var filterData = {
- key: 'null',
- status: 0,
- pageIndex: 0,
- pageSum: 10,
- //treeIds:'[]',
- userId: loginUser.id
- }
- }])
|