123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- "use strict";
- app.controller("servicePerformanceCtrl", [
- "$scope",
- "$rootScope",
- "$state",
- "$timeout",
- "$interval",
- "$http",
- "$cookieStore",
- "moment",
- "SweetAlert",
- "Restangular",
- "api_report",
- "api_statistic",
- "api_bpm_data",
- "api_user_data",
- "$modal",
- function (
- $scope,
- $rootScope,
- $state,
- $timeout,
- $interval,
- $http,
- $cookieStore,
- moment,
- SweetAlert,
- Restangular,
- api_report,
- api_statistic,
- api_bpm_data,
- api_user_data,
- $modal
- ) {
- $scope.parameters = {};
- $scope.category = {};
- $scope.reportName = "计费";
- $scope.allheight = 100;
- $scope.isMaskground = false;
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- $scope.starttimes = moment(
- new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
- ).format("YYYY-MM-DD HH:mm:ss");
- $scope.endtimes = moment(
- new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
- ).format("YYYY-MM-DD HH:mm:ss");
- $scope.parameters.paramDateFrom = $scope.starttimes;
- $scope.parameters.paramDateTo = $scope.endtimes;
- $scope.reshdata = function() {
- api_bpm_data
- .serviceCount({
- type: 'serviceCountList',
- startTime: $scope.starttimes,
- finishTime: $scope.endtimes,
- })
- .then(function (response) {
- if (response) {
- if ((response.status = 200)) {
- $scope.isMaskground = false;
- $scope.charginrow = response.data.sort((a, b) => b.total - a.total);
- // 图表
- barechart6(response.data);
- barechart7(response.data);
- var totalScore = $scope.charginrow.reduce((pre,cur)=>{
- return pre + cur.score;
- },0)
- angular.forEach($scope.charginrow, function(item) {
- if(totalScore){
- item.percent = (item.score * 100 / totalScore).toFixed(2) + '%';
- }else{
- item.percent = '0%';
- }
- })
- if (response.list && response.list.length == 0) {
- $scope.shows = true;
- $scope.empty = "数据为空!";
- }
- }
- }
- });
- }
- $scope.reshdata();
- $scope.reset = function () {
- $scope.parameters = {};
- $scope.starttimes = moment(
- new Date(moment().startOf("month")).setMonth(new Date().getMonth() - 1)
- ).format("YYYY-MM-DD HH:mm:ss");
- $scope.endtimes = moment(
- new Date(moment().startOf("month")).setMonth(new Date().getMonth()) - 1
- ).format("YYYY-MM-DD HH:mm:ss");
- $scope.parameters.paramDateFrom = $scope.starttimes;
- $scope.parameters.paramDateTo = $scope.endtimes;
- $scope.mdxquerym();
- };
- $scope.mdxquerym = function () {
- $scope.starttimes = moment($scope.parameters.paramDateFrom).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- $scope.endtimes = moment($scope.parameters.paramDateTo).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- $scope.isMaskground = true;
- $scope.shows = false;
- $scope.reshdata();
- };
- // 弹窗1
- $scope.servicePerformanceDetail = function(data){
- if(!data.incidentId){
- return;
- }
- $modal.open({
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- size: "lg",
- templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail1.html',
- controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
- $scope.title = "提示";
- $scope.reshdata = function() {
- $scope.isMaskground = true;
- api_bpm_data
- .serviceCount({
- type: 'serviceDaysList',
- userId: data.userId,
- startTime: scope.starttimes,
- finishTime: scope.endtimes,
- })
- .then(function (response) {
- if (response) {
- if ((response.status = 200)) {
- $scope.isMaskground = false;
- $scope.charginrow = response.data;
- if (response.list && response.list.length == 0) {
- $scope.shows = true;
- $scope.empty = "数据为空!";
- }
- }
- }
- });
- }
- $scope.reshdata();
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- // 弹窗2
- $scope.servicePerformanceDetail = function(data){
- $scope.cancel();
- $modal.open({
- resolve: {
- scope: function () {
- return scope;
- },
- },
- size: "lg",
- templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail2.html',
- controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
- $scope.title = "提示";
- $scope.reshdata = function() {
- $scope.isMaskground = true;
- api_bpm_data
- .serviceCount({
- type: 'serviceIncidentList',
- userId: data.userId,
- startTime: data.acceptdate,
- finishTime: data.acceptdate,
- })
- .then(function (response) {
- if (response) {
- if ((response.status = 200)) {
- $scope.isMaskground = false;
- $scope.charginrow = response.data;
- if (response.list && response.list.length == 0) {
- $scope.shows = true;
- $scope.empty = "数据为空!";
- }
- }
- }
- });
- }
- $scope.reshdata();
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- // 弹窗3
- $scope.servicePerformanceDetail = function(data){
- $scope.cancel();
- $modal.open({
- resolve: {
- scope: function () {
- return scope;
- },
- },
- size: "lg",
- templateUrl: 'assets/views/customform/tpl/servicePerformanceDetail3.html',
- controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
- $scope.title = data.category + "-" + data.score;
- $scope.reshdata = function() {
- $scope.isMaskground = true;
- api_bpm_data
- .serviceCount({
- type: 'serviceDetailsList',
- categoryId: data.categoryId,
- userId: data.userId,
- startTime: moment(data.acceptdate).format('YYYY-MM-DD'),
- finishTime: moment(data.acceptdate).format('YYYY-MM-DD'),
- })
- .then(function (response) {
- if (response) {
- if ((response.status = 200)) {
- $scope.isMaskground = false;
- $scope.charginrow = response.data;
- if (response.list && response.list.length == 0) {
- $scope.shows = true;
- $scope.empty = "数据为空!";
- }
- }
- }
- });
- }
- $scope.reshdata();
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- });
- }
- },
- });
- }
- },
- });
- }
- // 饼图
- function barechart6(datas) {
- var dom = document.getElementById("XYSJ");
- var option = null;
- var myChart = echarts.init(dom);
- var data = datas.map(v=>({name: v.userName, value: v.score}));
- option = {
- color: ["#91c7ae", "#61a0a8", "#2f4554", "#c23531", "#d48265"],
- title: {
- text: "积分占比",
- // subtext: datas.pieChartSum,
- // textAlign: "center",
- textStyle: {
- color: "#333",
- fontSize: 16,
- align: 'center',
- },
- // subtextStyle: {
- // fontSize: 14,
- // color: ["#005395"],
- // fontWeight: "bolder",
- // // align: 'center'
- // },
- // x: "34.5%",
- // y: "50%",
- },
- tooltip: {
- trigger: "item",
- formatter: function (a) {
- return a["data"]["name"] + ":" + a["data"]["value"];
- },
- position: ["50%", "30%"],
- },
- grid: {
- bottom: 150,
- left: 100,
- right: "10%",
- },
- legend: {
- orient: "vertical",
- top: "middle",
- right: "5%",
- textStyle: {
- color: "#333",
- fontSize: 12,
- },
- itemWidth: 8,
- itemHeight: 8,
- icon: "roundRect",
- data: data,
- },
- series: [
- // 主要展示层的
- {
- radius: ["50%", "65%"],
- center: ["35%", "60%"],
- type: "pie",
- label: {
- normal: {
- show: true,
- formatter: "{d}%",
- textStyle: {
- fontSize: 14,
- },
- position: "outside",
- },
- emphasis: {
- show: true,
- },
- },
- labelLine: {
- normal: {
- show: true,
- length: 5,
- length2: 25,
- },
- emphasis: {
- show: true,
- },
- },
- name: "",
- data: data,
- },
- ],
- };
- if (option && typeof option === "object") {
- myChart.setOption(option);
- myChart.hideLoading();
- }
- }
- // 柱形图
- function barechart7(datas) {
- console.log(datas);
- var datas_obj = {name:[], '处理工单总数':[]};
- // 处理数据 start
- datas.forEach(v=>{
- datas_obj.name.push(v.userName);
- datas_obj['处理工单总数'].push(v.total);
- })
- datas = datas_obj;
- console.log(datas);
- // 处理数据 end
- var name = [];
- var series = [];
- for (var key in datas) {
- if (key !== "name") {
- name.push(key);
- series.push({
- name: key,
- type: "bar",
- stack: "1",
- // barWidth: 40,
- itemStyle: {
- normal: {},
- },
- data: datas[key],
- });
- }
- }
- var dom = document.getElementById("jjmyd");
- var myChart = echarts.init(dom);
- var option = null;
- myChart.showLoading({
- text: "数据加载中...",
- color: "#c23531",
- textColor: "#fff",
- maskColor: "rgba(255,255,255,0)",
- zlevel: 0,
- });
- myChart.hideLoading();
- option = {
- title: {
- text: "处理工单总数",
- // subtext: datas.pieChartSum,
- // textAlign: "center",
- textStyle: {
- color: "#333",
- fontSize: 16,
- align: 'center',
- },
- // subtextStyle: {
- // fontSize: 14,
- // color: ["#005395"],
- // fontWeight: "bolder",
- // // align: 'center'
- // },
- // x: "34.5%",
- // y: "50%",
- },
- tooltip: {
- trigger: "axis",
- axisPointer: {
- // 坐标轴指示器,坐标轴触发有效
- type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
- },
- },
- // legend: {
- // data: name,
- // align: "left",
- // // itemWidth:10,
- // // itemHeight:10,
- // bottom: 0,
- // },
- grid: {
- top: "15%",
- left: "2%",
- right: "1.5%",
- bottom: "5%",
- containLabel: true,
- },
- xAxis: [
- {
- type: "category",
- axisTick: {
- alignWithLabel: true
- },
- axisLabel: {
- interval: 0,
- textStyle: {
- color: "#7B7B7B",
- // fontSize: '14',
- },
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: "#7B7B7B",
- // type: 'dotted'
- },
- },
- data: datas.name,
- },
- ],
- yAxis: [
- {
- type: "value",
- scale: true,
- name: "处理工单总数",
- min: 0,
- boundaryGap: [0.2, 0.2],
- axisLabel: {
- formatter: "{value}",
- textStyle: {
- color: "#7B7B7B",
- // fontSize: '14',
- },
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: "#7B7B7B",
- // type: 'dotted'
- },
- },
- },
- ],
- series: series,
- };
- if (option && typeof option === "object") {
- myChart.setOption(option);
- myChart.hideLoading();
- }
- }
- },
- ]);
|