12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064 |
- '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
- }
- }
- }
- // 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) {
- 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
- }
- }])
|