123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546 |
- 'use strict';
- app.controller('event_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", "api_event_form", "api_user_data", "api_bpm", function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_event_form, api_user_data, api_bpm) {
- //默认显示事件总数
- $scope.tap = 'SJZS';
- //默认无选中,选择日期
- $scope.searchstate = 'none';
- //默认按日统计
- $scope.dateItem = 'day';
- //按日
- $scope.dayByClick = function () {
- $scope.datepickerPopuptime = 'yyyy-MM-dd';//日期格式化
- $scope.day(7);//近7天
- };
- //按月
- $scope.monthByClick = function () {
- $scope.datepickerPopuptime = 'yyyy-MM';
- $scope.month(1);
- };
- //按年
- $scope.yearByClick = function () {
- $scope.datepickerPopuptime = 'yyyy';
- $scope.year(1);
- };
- //日期显示格式
- $scope.datepickerPopuptime = 'yyyy-MM-dd';
- //按日/月/年统计
- $scope.dateItemClick = function (str) {
- $scope.dateItem = str;
- switch (str) {
- case 'day':
- $scope.dayByClick();
- break;
- case 'month':
- $scope.monthByClick();
- break;
- case 'year':
- $scope.yearByClick();
- break;
- }
- };
- //切换开始/结束日期
- $scope.timesChange = function (str) {
- //切换结束日期的时候为年底或月底,方便传参
- switch (str) {
- case 'month':
- $scope.endtimesModel = moment($scope.endtimesModel).endOf('month').toDate();
- break;
- case 'year':
- $scope.endtimesModel = moment($scope.endtimesModel).endOf('year').toDate();
- break;
- }
- $scope.datepickerUpdate(str);
- };
- //配置项更新
- $scope.datepickerUpdate = function (str) {
- //开始的datepickerOptions
- $scope.datepickerOptionsStart = {
- maxDate: moment($scope.endtimesModel).format('YYYY/MM/DD'),
- minMode: str,
- datepickerMode: str
- };
- //结束的datepickerOptions
- $scope.datepickerOptionsEnd = {
- minDate: moment($scope.starttimesModel).format('YYYY/MM/DD'),
- maxDate: moment().format('YYYY/MM/DD'),
- minMode: str,
- datepickerMode: str
- };
- };
- //日期选择
- //近N周
- $scope.week = function (num) {
- num = num > 1 ? num : 1;
- $scope.searchstate = "week" + num;
- var weeks = new Date().getDay();
- $scope.starttimesModel = moment(new Date().getTime() - num * 86400000 * (weeks + 6)).toDate();
- $scope.endtimesModel = moment(new Date().getTime() - 86400000 * (weeks)).toDate();
- $scope.datepickerUpdate('day');
- }
- //近N月
- $scope.month = function (num) {
- num = num > 1 ? num : 1;
- $scope.searchstate = "month" + num;
- $scope.starttimesModel = moment().startOf('month').add(-num, 'M').toDate();
- $scope.endtimesModel = moment().endOf('month').add(-1, 'M').toDate();
- $scope.datepickerUpdate('month');
- }
- //近N年
- $scope.year = function (num) {
- num = num > 1 ? num : 1;
- $scope.searchstate = "year" + num;
- $scope.starttimesModel = moment().startOf('year').add(-num, 'y').toDate();
- $scope.endtimesModel = moment().endOf('year').add(-1, 'y').toDate();
- $scope.datepickerUpdate('year');
- }
- //近N日
- $scope.day = function (num) {
- num = num > 1 ? num : 1;
- $scope.searchstate = "none";
- $scope.starttimesModel = moment().subtract(num, "days").toDate();
- $scope.endtimesModel = moment().subtract(1, "days").toDate();
- $scope.datepickerUpdate('day');
- }
- //选择上一周,上个月,去年等等快捷方式
- $scope.chooseDate = function (date) {
- switch (date) {
- case 'week1'://上周
- $scope.week(1);
- break;
- case 'month1'://上个月
- $scope.month(1);
- break;
- case 'month3'://近三月
- $scope.month(3);
- break;
- case 'month6'://近六月
- $scope.month(6);
- break;
- case 'year1'://去年
- $scope.year(1);
- break;
- case 'year3'://近三年
- $scope.year(3);
- break;
- case 'year5'://近五年
- $scope.year(5);
- break;
- }
- };
- // 事件分类级别
- $scope.sjSelected = [{
- name: '一级分类',
- id: 1
- }, {
- name: '二级分类',
- id: 2
- }, {
- name: '三级分类',
- id: 3
- }];
- $scope.sjSelectedOne = {
- value: $scope.sjSelected[0]//选中
- };
- // 处理人/组
- $scope.groupSelected = [{
- id: -2,
- groupName: '按组选择'
- }, {
- id: -1,
- groupName: '按人选择'
- }];
- $scope.groupSelectedOne = {
- value: $scope.groupSelected[0]//选中
- };
- $scope.tableGroupSelectedOne = '';//处理组或人
- // 区域地点
- $scope.areaSelected = [{
- name: '区域',
- id: 1
- }, {
- name: '地点',
- id: 2
- }];
- $scope.areaSelectedOne = {
- value: $scope.areaSelected[0]//选中
- };
- /**
- *日历
- */
- //打开开始日期选择框
- $scope.startOpen = function ($event) {
- console.log(1)
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- //打开结束日期选择框
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- //重置
- $scope.reload = function () {
- $scope.dateItemClick('day');
- $scope.type = 'desc';//表格排序,排序方式desc,asc
- $scope.direction = 'top';//箭头方向 top,bottom
- switch ($scope.tap) {
- case 'SJZS'://事件总数
- $scope.sortActive = 'accdatetop';
- $scope.name = 'accdate';//表格排序,字段名称
- $scope.mdxquery('accdate', 'desc');
- break;
- case 'SJLX'://事件类型
- $scope.sortActive = 'sumtop';
- $scope.name = 'sum';//表格排序,字段名称
- $scope.mdxquery('sum', 'desc');
- $scope.sjSelectedOne.value = $scope.sjSelected[0];//事件分类级别
- break;
- case 'CLRZ'://处理人/组
- $scope.sortActive = 'sumtop';
- $scope.name = 'sum';//表格排序,字段名称
- $scope.mdxquery('sum', 'desc');
- $scope.groupSelectedOne.value = $scope.groupSelected[0];//选择处理人/组
- break;
- case 'QYDD'://区域地点
- $scope.sortActive = 'sumtop';
- $scope.name = 'sum';//表格排序,字段名称
- $scope.mdxquery('sum', 'desc');
- $scope.areaSelectedOne.value = $scope.areaSelected[0];//区域/地点
- break;
- case 'SJLY'://事件来源
- $scope.sortActive = 'sumtop';
- $scope.name = 'sum';//表格排序,字段名称
- $scope.mdxquery('sum', 'desc');
- break;
- }
- };
- //选择类型,事件总数,事件类型,处理人/组,区域地点
- $scope.active = function (name) {
- $scope.tap = name;
- $scope.reload();
- };
- //事件总数,无限滚动加载
- $scope.topEndComplete = function () {
- console.log('滚动');
- };
- //表格排序------------------------------------------------
- $scope.sortActive = '';//表格排序,箭头高亮选中状态
- $scope.type = '';//表格排序,排序方式desc,asc
- $scope.name = '';//表格排序,字段名称
- $scope.direction = '';//箭头方向 top,bottom
- /**
- * 表格排序
- *
- * @param {string} name 字段名称
- * @param {string} type 排序方式desc,asc
- * @param {string} direction 箭头方向 top,bottom
- */
- $scope.tableSort = function (name, type, direction) {
- if ($scope.name == name) {
- $scope.type = $scope.type == 'desc' ? 'asc' : 'desc';
- $scope.direction = $scope.direction == 'top' ? 'bottom' : 'top';
- } else {
- $scope.type = 'desc';
- $scope.direction = 'top';
- }
- $scope.name = name;
- $scope.sortActive = name + $scope.direction;
- $scope.mdxquery(name, $scope.type);
- };
- //搜索----------------------------------------------------
- //loading
- $scope.isArrays = function (arr) {
- return Array.isArray(arr);
- };
- //事件总数
- $scope.sjzs_list = null;//表格列表
- $scope.sjzs_num = 0;//事件总数数量
- $scope.sjzs_responseTime = '0分';//平均响应时间
- $scope.sjzs_resolvedTime = '0分';//平均解决时间
- $scope.sjzs_satisfactionRatio = 0;//满意度
- //事件类型
- $scope.sjlx_list = null;//表格列表
- $scope.sjlx_num = 0;//事件总数数量
- //处理人/组
- $scope.clrz_list = null;//表格列表
- $scope.clrz_num = 0;//事件总数数量
- $scope.clrz_responseTime = '0分';//平均响应时间
- $scope.clrz_resolvedTime = '0分';//平均解决时间
- $scope.clrz_satisfactionRatio = 0;//满意度
- //区域地点
- $scope.qydd_list = null;//表格列表
- $scope.qydd_num = 0;//事件总数数量
- //事件来源
- $scope.sjly_list = null;//表格列表
- $scope.sjly_num = 0;//事件总数数量
- /**
- *
- *
- * @param {string} name 排序字段
- * @param {string} type 排序方式 desc,asc
- */
- $scope.mdxquery = function (name, type) {
- if (!name) {
- name = $scope.tap == 'SJZS' ? 'accdate' : 'sum';
- }
- type = type || 'desc';
- switch ($scope.tap) {
- case 'SJZS'://事件总数
- $scope.sjzs_list = null;
- // 请求列表
- api_event_form.fetchSjzsList({
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "type": $scope.dateItem,
- "sortData": name,
- "sortType": type
- }).then(function (res) {
- if (res.stats == 200) {
- $scope.sjzs_list = res.dataList;//表格列表
- $scope.sjzs_num = res.sum;//事件总数数量
- $scope.sjzs_responseTime = res.responseTime;//平均响应时间
- $scope.sjzs_resolvedTime = res.resolvedTime;//平均解决时间
- $scope.sjzs_satisfactionRatio = res.satisfactionRatio;//满意度
- }
- })
- break;
- case 'SJLX'://事件类型
- $scope.sjlx_list = null;
- // 请求列表
- api_event_form.fetchSjlxList({
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "hierarchy": $scope.sjSelectedOne.value.id,
- "sortData": name,
- "sortType": type
- }).then(function (res) {
- if (res.stats == 200) {
- $scope.sjlx_list = res.typedataList;//表格列表
- }
- })
- // 请求事件总数数量
- api_event_form.getSjNum({
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- }).then(function (res) {
- if (res.stats == 200) {
- $scope.sjlx_num = res.data[0].sum;//事件总数数量
- }
- })
- break;
- case 'CLRZ'://处理人/组
- $scope.clrz_list = null;
- //获取组
- api_user_data.fetchDataList('group', {
- idx: 0,
- sum: 1000,
- group: {
- selectType: "nouser"
- }
- }).then(res => {
- if (res.status == 200) {
- var groupList = [{
- id: -2,
- groupName: '按组选择'
- }, {
- id: -1,
- groupName: '按人选择'
- }];
- groupList.push(...res.list);
- $scope.groupSelected = groupList;//下拉框数据
- // 请求列表
- if ($scope.groupSelectedOne.value.id == -2) {//按组
- var params = {
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "type": 1,
- "sortData": name,
- "sortType": type
- };
- } else if ($scope.groupSelectedOne.value.id == -1) {//按人
- var params = {
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "type": 2,
- "sortData": name,
- "sortType": type
- };
- } else {
- var params = {
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "type": 3,
- "groupid": $scope.groupSelectedOne.value.id,
- "sortData": name,
- "sortType": type
- };
- }
- api_event_form.fetchClrzList(params).then(function (res) {
- if (res.stats == 200) {
- $scope.tableGroupSelectedOne = params.type;//处理人或组
- $scope.clrz_list = res.listData;//表格列表
- $scope.clrz_num = res.sum;//事件总数量
- $scope.clrz_responseTime = res.responseTime;//平均响应时间
- $scope.clrz_resolvedTime = res.resolvedTime;//平均解决时间
- $scope.clrz_satisfactionRatio = res.satisfactionRatio;//满意度
- }
- })
- }
- })
- break;
- case 'QYDD'://区域地点
- $scope.qydd_list = null;
- // 请求列表
- api_event_form.fetchQyddList({
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "type": $scope.areaSelectedOne.value.id,
- "sortData": name,
- "sortType": type
- }).then(function (res) {
- if (res.stats == 200) {
- $scope.qydd_list = res.listData;//表格列表
- }
- })
- // 请求事件总数数量
- api_event_form.getSjNum({
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD')
- }).then(function (res) {
- if (res.stats == 200) {
- $scope.qydd_num = res.data[0].sum;//事件总数数量
- }
- })
- break;
- case 'SJLY'://事件来源
- $scope.sjly_list = null;
- // 请求列表
- api_event_form.fetchSjlyList({
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "sortData": name,
- "sortType": type
- }).then(function (res) {
- if (res.stats == 200) {
- $scope.sjly_list = res.listData;//表格列表
- }
- })
- // 请求事件总数数量
- api_event_form.getSjNum({
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD')
- }).then(function (res) {
- if (res.stats == 200) {
- $scope.sjly_num = res.data[0].sum;//事件总数数量
- }
- })
- break;
- }
- };
- // 请求人
- // api_user_data.fetchDataList('requester', {
- // "idx": 0,
- // "sum": 10
- // }).then(function (response) {
- // if (response) {
- // if (response.status = 200) {
- // $scope.requester = response.list;
- // }
- // }
- // })
- //导出
- $scope.export = function () {
- var postData = {
- "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
- "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
- "sortData": $scope.name,
- "sortType": $scope.type,
- report: {}
- }
- switch ($scope.tap) {
- case 'SJZS'://事件总数
- postData.type = $scope.dateItem;
- postData.key = 'mdv2_incident_repot_sum';
- postData.titles = ['时间', '事件数量', '平均响应时间', '平均解决时间', '完全解决', '部分解决', '其他', '满意度(%)'];
- break;
- case 'SJLX'://事件类型
- postData.hierarchy = $scope.sjSelectedOne.value.id;
- postData.key = 'mdv2_incident_repot_type';
- postData.titles = ['事件类型', '类型数量', '类型占比', '平均响应时间', '平均解决时间', '完全解决', '部分解决', '其他'];
- break;
- case 'CLRZ'://处理人/组
- if ($scope.groupSelectedOne.value.id == -2) {//按组
- postData.type = 1;
- } else if ($scope.groupSelectedOne.value.id == -1) {//按人
- postData.type = 2;
- } else {
- postData.type = 3;
- }
- postData.key = 'mdv2_incident_repot_handle';
- postData.titles = ['处理组', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)'];
- break;
- case 'QYDD'://区域地点
- postData.type = $scope.areaSelectedOne.value.id;
- postData.key = 'mdv2_incident_repot_area_place';
- postData.titles = ['区域/地点', '事件数量', '事件占比'];
- break;
- case 'SJLY'://事件来源
- postData.key = 'mdv2_incident_repot_source';
- postData.titles = ['事件来源', '事件数量', '事件来源占比'];
- break;
- }
- var wt_url = api_bpm.downDataModel('report', 1).getRequestedUrl()
- $http({
- url: wt_url,
- method: 'POST',
- data: JSON.stringify(postData),
- headers: {
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var fileName = '';
- switch ($scope.tap) {
- case 'SJZS'://事件总数
- fileName = '事件总数';
- break;
- case 'SJLX'://事件类型
- fileName = '事件类型';
- break;
- case 'CLRZ'://处理人/组
- fileName = '处理人/组';
- break;
- case 'QYDD'://区域地点
- fileName = '区域地点';
- break;
- case 'SJLY'://事件来源
- fileName = '事件来源';
- break;
- }
- // var fileName = headers("Content-Disposition").split(";")[1].split("filename=")[1];
- var file = new Blob([data], {
- type: 'application/vnd.ms-excel'
- });
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = fileName + '.xls';
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- });
- };
- //初始化
- $scope.dateItemClick('day');
- $scope.mdxquery('accdate', 'desc');
- $scope.sortActive = 'accdatetop';
- $scope.name = 'accdate';//表格排序,字段名称
- $scope.type = 'desc';//表格排序,排序方式desc,asc
- $scope.direction = 'top';//箭头方向 top,bottom
- }])
|