溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

django報(bào)障系統(tǒng)之解決工單和報(bào)表

發(fā)布時(shí)間:2020-07-13 20:25:30 來源:網(wǎng)絡(luò) 閱讀:2236 作者:kesungang 欄目:開發(fā)技術(shù)

前面實(shí)現(xiàn)了用戶的角色管理、權(quán)限管理、故障管理。下面學(xué)習(xí)下解決故障

  • 當(dāng)有權(quán)限的用戶登錄后,可以看到自己創(chuàng)建的單子,或者自己已經(jīng)接了單子和解決完成的單子
    django報(bào)障系統(tǒng)之解決工單和報(bào)表
  • 創(chuàng)建好對(duì)應(yīng)的url
  • 當(dāng)用戶處理的時(shí)候,跳轉(zhuǎn)到處理的頁面
    django報(bào)障系統(tǒng)之解決工單和報(bào)表
  • 處理完成后把狀態(tài) 改成“已處理”,沒有完成的把狀態(tài)改成“處理中”

    下面是報(bào)表管理

    報(bào)表只有總監(jiān)能看到,這里用的報(bào)表使用了hichart,插件來實(shí)現(xiàn)的

    
    {% extends 'layout.html' %}

{% block content %}
<div id="container" style="min-width:300px;height:300px"></div>
<div id="container2" style="min-width:500px;height:500px"></div>
{% endblock %}

{% block js %}
<script src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
<script src="https://img.hcharts.cn/highcharts/modules/exporting.js"></script>
<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>

<script>
    $(function () {
        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });
        $.ajax({
            url: '/report.html',
            type: "POST",
            data: {'csrfmiddlewaretoken': '{{ csrf_token }}'},
            dataType: 'JSON',
            success: function (arg) {
                console.log(arg);

                $('#container').highcharts({
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },
                    title: {
                        text: '運(yùn)維人員處理報(bào)障占比'
                    },
                    tooltip: {
                        headerFormat: '{series.name}<br>',
                        pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                                style: {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                }
                            }
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: '運(yùn)維人員處理報(bào)障占比',
                        data: arg.pie
                    }]
                });

                Highcharts.chart('container2', {
                    title: {
                        text: '每日處理訂單詳細(xì)',
                        x: -20 //center
                    },
                    subtitle: {
                        text: '...',
                        x: -20
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom',
                        borderWidth: 1
                    },
                    xAxis:{
                        labels:{
                            formatter:function(){
                                return Highcharts.dateFormat("%Y-%m-%d",this.value);
                                //return this.value;
                            }
                        },
                        minTickInterval:24
                    },
                    series: arg.zhexian
                });
            }
        });

    })
</script>

{% endblock %}


后端的數(shù)據(jù)提供是:

def report(request):
if request.permission_code == "LOOK":
if request.method == "GET":
return render(request,'report.html')
else:
from django.db.models import Count
#餅圖
result = models.Order.objects.filter(status=3).values_list('processor__nickname').annotate(ct=Count('id'))
response = {}
result_dic ={}

for bin in result:

        #     key = bin['processor_id']
        #     if key in result_dic:
        #         result_dic[key]['data'].append([bin['processor__nickname'],bin['ct']])
        #     else:
        #         result_dic[key]={'data':[[bin['processor__nickname'],bin['ct']],]}
        response['pie']=list(result)
        ymd_list = models.Order.objects.filter(status=3).extra(select={'ymd':"strftime('%%s',strftime('%%Y-%%m-%%d',ptime))"}).values('processor_id','processor__nickname','ymd').annotate(ct=Count('id'))
        ymd_dict = {}
        for row in ymd_list:
            key = row['processor_id']
            if key in ymd_dict:
                ymd_dict[key]['data'].append([float(row['ymd'])*1000, row['ct']])
            else:
                ymd_dict[key] = {'name':row['processor__nickname'],'data':[ [float(row['ymd'])*1000, row['ct']],  ]}
        response['zhexian']=list(ymd_dict.values())
        return HttpResponse(json.dumps(response))


結(jié)果:
![](https://s1.51cto.com/images/blog/201805/22/f5728870af697d0d7f23052846fb8791.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI