123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868 |
- 'use strict';
- app.controller('selfDefinedReportCtrl', ["$scope", "$http", "i18nService", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_text", "api_bpm_data", "api_user_data", "api_configure_data", '$parse', "$injector", "$aside", 'toaster', "api_configure_form", "api_cmdb", 'api_bpm', 'api_report_data', function ($scope, $http, i18nService, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_text, api_bpm_data, api_user_data, api_configure_data, $parse, $injector, $aside, toaster, api_configure_form, api_cmdb, api_bpm, api_report_data) {
- console.log(echarts);
- var loginUser = $rootScope.user;
- $scope.pageData = {};
- $scope.haveSave = false;
- // $scope.pageData.chartType = {
- // status: 0,
- // value: "饼状图"
- // }
- $scope.my_tree_handler = function (branch) {
- if (!branch.children.length) {
- api_report_data.fetchDataList('reportCustom', { idx: 0, sum: 1000, reportCustom: { reportType: { id: branch.id } } }).then(function (data) {
- if (data.list.length) {
- $scope.pageData.sqlContent = data.list[0].fetchSql;
- console.log(data.list[0].fetchSql)
- if (data.list[0].status == 0) {
- $scope.pageData.chartType = {
- status: 0,
- value: "饼状图"
- }
- } else if (data.list[0].status == 1) {
- $scope.pageData.chartType = {
- status: 1,
- value: "柱状图"
- }
- }
- }else {
- $scope.pageData.sqlContent = '';
- }
- })
- } else {
- $scope.pageData.sqlContent = '';
- }
- $scope.changecate = true;
- $scope.addcate = false;
- filterData.treeIds = branch.id;
- $scope.selectedTreeNode = branch;
- $scope.output = branch;
- convertchildToTree(branch);
- // console.log($scope.subdata)
- // var eqflag = false;
- // 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
- // });
- // 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;
- // // });
- // }
- };
- function convertchildToTree(datum) {
- $scope.subdata = {};
- // console.log($scope.parentdata)
- if (datum.parent) {
- // angular.forEach($scope.parentdata, function(item, index) {
- // if (datum.id == item.id) return $scope.subdata = item;
- // });
- $scope.subdata = { 'id': datum.id, 'name': datum.label, 'parent': datum.parent, 'hasArea': datum.hasArea, 'hasSimple': datum.hasSimple, 'group': datum.group }
- } else {
- $scope.subdata = { 'id': datum.id, 'name': datum.label, 'group': datum.group, 'hasSimple': datum.hasSimple, 'hasArea': datum.hasArea }
- }
- // 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}}
- }
- function convertListToTree(data, treeMap) {
- // console.log(data);
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = 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 = {};
- // ddd定制数据结构
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.doing_async = true;
- var data = { "idx": 0, "sum": 1000 };
- api_report_data.fetchDataList('reportType', data).then(function (response) {
- console.log(response.list)
- var data = response.list;
- // data.unshift({ id: 0, name: "all" })
- // console.log(data);
- 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) && data[i].id != 0) {
- // object.parent = data[i].parent;
- // } else if (data[i].id != 0) {
- // object.parent = data[i].parent = { id: 0, name: "all" }
- // }
- 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;
- }
- object.label = data[i].name;
- // 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);
- }
- console.log(objects)
- $scope.my_data = convertParentToChildList(objects);
- // console.log($scope.my_data);
- $scope.tree_data = angular.copy($scope.my_data);
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- });
- };
- $scope.try_async_load();
- // $scope.ldloading={};
- var filterData = {
- key: 'null',
- status: 0,
- pageIndex: 0,
- pageSum: 10,
- //treeIds:'[]',
- userId: loginUser.id
- }
- // 增删改弹窗
- console.log($scope.inpContent)
- $scope.redact = function (type, model) {
- console.log(model)
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/system/selfDefinedReport/tpl/dialog.tpl.html',
- controller: function ($scope, $modalInstance, api_bpm, modelData, currentUserId, Alert, api_report_data, selectedTreeNode, scope) {
- console.log(selectedTreeNode);
- $scope.inp = {};
- // console.log($scope.inpContent.a)
- if (type == 0) {
- $scope.title = '新增报表类型';
- $scope.placeholder = '请输入报表名称';
- $scope.inp.content = '';
- } else if (type == 1) {
- $scope.title = '修改报表类型';
- $scope.placeholder = '知识增加数量';
- $scope.delContent = $scope.inp.content = selectedTreeNode.label;
- } else if (type == 2) {
- $scope.title = '删除报表类型';
- $scope.type = 2;
- $scope.delContent = $scope.inp.content = selectedTreeNode.label;
- }
- $scope.ok = function () {
- console.log($scope.inp.content)
- if ($scope.inp.content == '') { return }
- var parentId = selectedTreeNode.parent ? selectedTreeNode.parent.id : 1;
- if (type == 0) {
- var iid = parentId == 1 ? selectedTreeNode.id : parentId;
- // var postData={reportType: { name: $scope.inp.content, id: parentId }};
- api_report_data.addModel('reportType', { reportType: { name: $scope.inp.content, parent: { id: iid } } }).then(function (data) {
- console.log(data);
- if (data && data.status == 200) {
- SweetAlert.swal("添加成功!", "添加成功", "success")
- $modalInstance.dismiss('cancel');
- scope.try_async_load()
- } else {
- SweetAlert.swal("添加失败!", "请稍候重试", "error");
- }
- })
- } else if (type == 1) {
- api_report_data.updateModel('reportType', { reportType: { name: $scope.inp.content, parent: { id: parentId }, id: selectedTreeNode.id } }).then(function (data) {
- console.log(data);
- if (data && data.status == 200) {
- SweetAlert.swal("修改成功!", "修改成功", "success")
- $modalInstance.dismiss('cancel');
- scope.try_async_load()
- } else {
- SweetAlert.swal("修改失败!", "请稍候重试", "error");
- }
- })
- } else if (type == 2) {
- if (selectedTreeNode.children.length) {
- alert('存在子集,无法删除!');
- } else {
- api_report_data.rmModels('reportType', selectedTreeNode.id).then(function (data) {
- console.log(data);
- if (data && data.status == 200) {
- SweetAlert.swal("删除成功!", "删除成功", "success")
- $modalInstance.dismiss('cancel');
- scope.try_async_load();
- } else {
- SweetAlert.swal("删除失败!", "请稍候重试", "error");
- }
- })
- }
- }
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_report_data: function () {
- return api_report_data;
- },
- selectedTreeNode: function () {
- return $scope.selectedTreeNode;
- },
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 预览图形
- $scope.designType = [
- { value: '饼状图', status: 0 },
- { value: '柱状图', status: 1 },
- ]
- $scope.onChange = function (item) {
- console.log(item);
- console.log($scope.pageData.sqlContent)
- // $scope.pageData.chartType = item.status;
- }
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.showGridFooter = false;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = false;
- $scope.gridOptions.paginationPageSizes = [100];
- $scope.gridOptions.paginationPageSize = 100;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [
- { name: 'category', displayName: '事件类型', width: '33.4%', enableFiltering: false },
- { name: 'COUNT', displayName: '事件数量', width: '33.3%', enableFiltering: false },
- { name: 'percent', displayName: '事件占比', width: '33.3%', enableFiltering: false },
- ];
- // 展示表格
- $scope.showTable = function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.length;
- myData.data.forEach(function (v, i) {
- v.percent = v.percent + '%';
- v.id = i;
- })
- $scope.myData = myData.data;
- }
- // 展示echarts
- $scope.initEchart = function (data) {
- // console.log(data);
- if ($scope.pageData.chartType.status == 0) {
- initChartsConfig(data);
- } else if ($scope.pageData.chartType.status == 1) {
- initConfigChart(data)
- } else {
- initChartsConfig(data);
- }
- }
- //饼图
- function initChartsConfig(data) {
- var nameArr = [], dataArr = [];
- data.forEach(function (v, i) {
- nameArr.push(v.category);
- dataArr.push({ value: v.COUNT, name: v.category })
- })
- // nameArr=nameArr.slice(0,10)
- console.log(nameArr);
- var parkaccountChart = echarts.init(document.getElementById('main'));//p 标签id
- var option = {
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b}: {c} ({d}%)"
- },
- legend: {
- orient: 'vertical',
- x: 'left',
- data: nameArr
- },
- series: [
- {
- name: '',
- type: 'pie',
- radius: ['50%', '70%'],
- avoidLabelOverlap: false,
- label: {
- normal: {
- show: false,
- position: 'center'
- },
- emphasis: {
- show: true,
- textStyle: {
- fontSize: '30',
- fontWeight: 'bold'
- }
- }
- },
- labelLine: {
- normal: {
- show: false
- }
- },
- data: dataArr
- }
- ]
- };
- parkaccountChart.setOption(option, true);
- }
- //柱状图数据
- function initConfigChart(data) {
- console.log(data);
- var nameArr = [], countArr = [];
- data.forEach(function (v, i) {
- nameArr.push(v.category);
- countArr.push(v.COUNT);
- })
- console.log(nameArr, countArr);
- var parkaccountChart = echarts.init(document.getElementById('main'));//p 标签id
- var option = {
- color: ['#3398DB'],
- tooltip: {
- trigger: 'axis',
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: [
- {
- type: 'category',
- data: nameArr,
- axisTick: {
- alignWithLabel: true
- }
- }
- ],
- yAxis: [
- {
- type: 'value'
- }
- ],
- series: [
- {
- name: '直接访问',
- type: 'bar',
- barWidth: '60%',
- data: countArr
- }
- ]
- };
- parkaccountChart.setOption(option, true);
- }
- // }
- // 保存
- $scope.save = function () {
- // console.log($scope.pageData);
- // console.log($scope.selectedTreeNode);
- $scope.haveSave = true;
- var postData = {
- reportCustom: {
- reportType: {
- id: $scope.selectedTreeNode.id,
- name: $scope.selectedTreeNode.label
- },
- fetchSql: $scope.pageData.sqlContent,
- status: $scope.pageData.chartType.status
- }
- }
- console.log(postData)
- // console.log($scope.selectedTreeNode.id, $scope.selectedTreeNode.label)
- api_report_data.addModel('reportCustom', postData).then(function (data) {
- // console.log(data);
- if (data && data.status == 200) {
- SweetAlert.swal("保存成功!", "保存成功", "success")
- $scope.haveSave = true;
- api_report_data.report('executeSQL', { sql: $scope.pageData.sqlContent }).then(function (data) {
- // api_report_data.report('executeSQL', { sql: 'SELECT iic.category,COUNT(*) AS COUNT FROM itsm_incident ii INNER JOIN itsm_incident_category iic ON ii.categoryid = iic.id GROUP BY iic.category' }).then(function (data) {
- // console.log(data.data);
- $scope.showTable(data);
- $scope.echartsLength=data.data.length;
- // if (data.data.length <= 15) {
- // $scope.initEchart(data.data);
- // }
- if (data.data.length <= 15) {
- $scope.initEchart(data.data);
- $scope.myStyle={
- 'height':'1000px'
- }
- }else{
- $scope.myStyle={
- 'height':'620px'
- }
- }
- })
- } else {
- SweetAlert.swal("保存失败!", "请稍候重试", "error");
- }
- })
- }
- $scope.preview = function (data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/system/selfDefinedReport/tpl/preview.tpl.html',
- controller: function ($scope, $modalInstance, i18nService, $timeout, api_bpm_domain, api_user_data, pageData, scope) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.showGridFooter = false;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = false;
- $scope.gridOptions.paginationPageSizes = [1000];
- $scope.gridOptions.paginationPageSize = 1000;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [
- { name: 'category', displayName: '事件类型', width: '33.4%', enableFiltering: false },
- { name: 'COUNT', displayName: '事件数量', width: '33.3%', enableFiltering: false },
- { name: 'percent', displayName: '事件占比', width: '33.3%', enableFiltering: false },
- ];
- $scope.showTable = function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.length;
- myData.data.forEach(function (v, i) {
- v.percent = v.percent + '%';
- v.id = i;
- })
- $scope.myData = myData.data;
- }
- //饼图
- function initChartsConfig(data) {
- var nameArr = [], dataArr = [];
- data.forEach(function (v, i) {
- nameArr.push(v.category);
- dataArr.push({ value: v.COUNT, name: v.category })
- })
- // nameArr=nameArr.slice(0,10)
- console.log(nameArr);
- var parkaccountChart = echarts.init(document.getElementById('previewmain'));//p 标签id
- var option = {
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b}: {c} ({d}%)"
- },
- legend: {
- orient: 'vertical',
- x: 'left',
- data: nameArr
- },
- series: [
- {
- name: '',
- type: 'pie',
- radius: ['50%', '70%'],
- avoidLabelOverlap: false,
- label: {
- normal: {
- show: false,
- position: 'center'
- },
- emphasis: {
- show: true,
- textStyle: {
- fontSize: '30',
- fontWeight: 'bold'
- }
- }
- },
- labelLine: {
- normal: {
- show: false
- }
- },
- data: dataArr
- }
- ]
- };
- parkaccountChart.setOption(option, true);
- }
- //柱状图数据
- function initConfigChart(data) {
- console.log(data);
- var nameArr = [], countArr = [];
- data.forEach(function (v, i) {
- nameArr.push(v.category);
- countArr.push(v.COUNT);
- })
- console.log(nameArr, countArr);
- var parkaccountChart = echarts.init(document.getElementById('previewmain'));//p 标签id
- var option = {
- color: ['#3398DB'],
- tooltip: {
- trigger: 'axis',
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: [
- {
- type: 'category',
- data: nameArr,
- axisTick: {
- alignWithLabel: true
- }
- }
- ],
- yAxis: [
- {
- type: 'value'
- }
- ],
- series: [
- {
- name: '直接访问',
- type: 'bar',
- barWidth: '60%',
- data: countArr
- }
- ]
- };
- parkaccountChart.setOption(option, true);
- }
- $scope.initEchart = function (data) {
- if (pageData.chartType.status == 0) {
- initChartsConfig(data);
- } else if (pageData.chartType.status == 1) {
- initConfigChart(data)
- } else {
- initChartsConfig(data);
- }
- }
- api_report_data.report('executeSQL', { sql: pageData.sqlContent }).then(function (data) {
- // api_report_data.report('executeSQL', { sql: 'SELECT iic.category,COUNT(*) AS COUNT FROM itsm_incident ii INNER JOIN itsm_incident_category iic ON ii.categoryid = iic.id GROUP BY iic.category' }).then(function (data) {
- $scope.showTable(data);
- // console.log(data.data.length);
- $scope.echartsLength=data.data.length;
- if (data.data.length <= 15) {
- $scope.initEchart(data.data);
- $scope.myStyle={
- 'height':'1000px'
- }
- }else{
- $scope.myStyle={
- 'height':'620px'
- }
- }
- })
- $scope.ok = function () {
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg',
- resolve: {
- pageData: function () {
- return $scope.pageData
- },
- scope: function () {
- return $scope
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- // if (selectedItem) {
- // var filterData = {
- // "assginee": selectedItem[0].id
- // }
- // api_bpm_domain.delegateTask(data.taskId, filterData).then(function (data) {
- // if (data && data.status == 200) {
- // SweetAlert.swal("添加成功!", "添加协同人成功", "success")
- // $scope.refreshData('expand-right', $scope.memoryfilterData);
- // } else {
- // SweetAlert.swal("添加失败!", "请稍候重试", "error");
- // }
- // // var myData = Restangular.stripRestangular(data);
- // // $scope.gridOptions.totalItems = myData.totalNum;
- // // $scope.myData = myData.list;
- // });
- // }
- });
- }
- // 日期组件
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function ($event) {
- console.log($scope.startOpened)
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- // console.log(document.getElementById('input1').nextSibling.setAttribute('height', '100px'))
- // document.getElementById('input2').nextSibling.setAttribute('style', 'displsy: block !important')
- // document.getElementById('input1').nextSibling.setAttribute('style', 'displsy: block !important')
- // console.log(document.getElementById('input1').nextSibling)
- // console.log(document.getElementById('input2').nextSibling)
- };
- $scope.startOpen = function ($event) {
- console.log($scope.startOpened)
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- // document.getElementById('input1').nextSibling.setAttribute('style', 'displsy: block !important')
- // document.getElementById('input2').nextSibling.setAttribute('style', 'displsy: block !important')
- // console.log(document.getElementById('input1').nextSibling)
- // console.log(document.getElementById('input2').nextSibling)
- $scope.startOpened = !$scope.startOpened;
- };
- // 搜索
- $scope.chiceIncident = function (item) {
- console.log(item);
- // var fildata = {};
- // // $scope.memoryfilterData = fildata;
- // if (!fildata.incident) {
- // fildata['incident'] = {};
- // }
- // // $scope.gridOptions.paginationCurrentPage = 1;
- // if (item.acceptDateFrom) {
- // item.acceptDateFrom = moment(item.acceptDateFrom).format('YYYY-MM-DD HH:mm:ss');
- // }
- // if (item.acceptDateEnd) {
- // // item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD HH:mm:ss');
- // item.acceptDateEnd = moment(new Date(item.acceptDateEnd).getTime() + 86399999).format('YYYY-MM-DD HH:mm:ss');
- // }
- // var transitiondata = angular.copy(item);
- // angular.extend(fildata.incident, transitiondata)
- // $scope.memoryfilterData = fildata;
- // $scope.refreshData('expand-right', fildata);
- }
- //导出
- $scope.export = function () {
- var filadata = angular.copy($scope.memoryfilterData);
- filadata.sum = 10000;
- $http({
- url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
- method: 'POST',
- data: JSON.stringify(filadata),
- headers: {
- // 'Content-type': 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- var file = new Blob([data], {
- type: 'application/vnd.ms-excel'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = '工单列表.xls';
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- console.log(data);
- });
- }
- }]);
|