Commit 5e3f6d21 by keith

update code

parent b6252c89
...@@ -59,8 +59,8 @@ func (c *HomeController) Statistical() { ...@@ -59,8 +59,8 @@ func (c *HomeController) Statistical() {
} }
// TodayActionStatistical today Statistical // GetFlowStatistical flow Statistical
func (c *HomeController) TodayActionStatistical() { func (c *HomeController) GetFlowStatistical() {
// request body // request body
statisticalRequest := StatisticalRequest{} statisticalRequest := StatisticalRequest{}
...@@ -78,7 +78,7 @@ func (c *HomeController) TodayActionStatistical() { ...@@ -78,7 +78,7 @@ func (c *HomeController) TodayActionStatistical() {
} }
} }
statisticalData, err := c.StatisticalRepository.GetTodayActionStatistical(statisticalRequest.DateStart, statisticalRequest.DateEnd) statisticalData, err := c.StatisticalRepository.GetFlowStatistical(statisticalRequest.DateStart, statisticalRequest.DateEnd)
if err != nil { if err != nil {
c.JSON(configs.ResponseFail, err.Error(), err.Error()) c.JSON(configs.ResponseFail, err.Error(), err.Error())
} }
......
...@@ -771,7 +771,6 @@ func (c *PublicController) GetWorkOrder() { ...@@ -771,7 +771,6 @@ func (c *PublicController) GetWorkOrder() {
// get user // get user
user := c.GetUserInfo() user := c.GetUserInfo()
print(&user)
if user == nil { if user == nil {
// GetAdminAuthInfo // GetAdminAuthInfo
auth := c.GetAdminAuthInfo() auth := c.GetAdminAuthInfo()
...@@ -806,6 +805,10 @@ func (c *PublicController) DeleteWorkOrder() { ...@@ -806,6 +805,10 @@ func (c *PublicController) DeleteWorkOrder() {
if auth == nil { if auth == nil {
c.JSON(configs.ResponseFail, "fail!", nil) c.JSON(configs.ResponseFail, "fail!", nil)
} }
admin := services.GetAdminRepositoryInstance().GetAdmin(auth.UID)
if admin.Root == 0 {
c.JSON(configs.ResponseFail, "无权限删除!", nil)
}
} }
// wid // wid
......
...@@ -136,7 +136,7 @@ func (c *WorkOrderController) GetWorkType() { ...@@ -136,7 +136,7 @@ func (c *WorkOrderController) GetWorkType() {
// GetWorkTypes get work order types // GetWorkTypes get work order types
func (c *WorkOrderController) GetWorkTypes() { func (c *WorkOrderController) GetWorkTypes() {
workOrderTypes := c.WorkOrderTypeRepository.GetWorkOrderTypes() workOrderTypes := c.WorkOrderTypeRepository.GetWorkOrderTypesAndCountWorkorder()
c.JSON(configs.ResponseSucess, "查询成功!", workOrderTypes) c.JSON(configs.ResponseSucess, "查询成功!", workOrderTypes)
} }
......
package models
// WorkOrderTypeDto model
type WorkOrderTypeDto struct {
ID int64 `orm:"auto;pk;type(bigint);column(id)" json:"id"` // ID
Title string `orm:"unique;type(varchar);null;column(title)" json:"title"` // 类型名称
Count int64 `orm:"type(bigint);column(count)" json:"count"` // 类型名称
CreateAt int64 `orm:"type(bigint);column(create_at)" json:"create_at"` // 提交时间
}
...@@ -61,7 +61,7 @@ func routers(prefix string) *beego.Namespace { ...@@ -61,7 +61,7 @@ func routers(prefix string) *beego.Namespace {
beego.NSNamespace("/home", beego.NSNamespace("/home",
beego.NSBefore(filters.FilterToken), beego.NSBefore(filters.FilterToken),
beego.NSRouter("/statistical", &controllers.HomeController{}, "post:Statistical"), beego.NSRouter("/statistical", &controllers.HomeController{}, "post:Statistical"),
beego.NSRouter("/today_statistical", &controllers.HomeController{}, "post:TodayActionStatistical"), beego.NSRouter("/flow_statistical", &controllers.HomeController{}, "post:GetFlowStatistical"),
), ),
// message // message
......
...@@ -176,7 +176,7 @@ func (r *KnowledgeBaseRepository) Delete(id int64) (int64, error) { ...@@ -176,7 +176,7 @@ func (r *KnowledgeBaseRepository) Delete(id int64) (int64, error) {
// GetKnowledgeBasePlatformsTotal get Group count // GetKnowledgeBasePlatformsTotal get Group count
func (r *KnowledgeBaseRepository) GetKnowledgeBasePlatformsTotal() []orm.Params { func (r *KnowledgeBaseRepository) GetKnowledgeBasePlatformsTotal() []orm.Params {
var maps []orm.Params var maps []orm.Params
_, err := r.o.Raw("select P.id,p.title,IFNULL(k.count,0) as count FROM platform p LEFT JOIN (SELECT platform,COUNT(*) AS count FROM `knowledge_base` GROUP BY platform) k ON k.platform = p.id").Values(&maps) _, err := r.o.Raw("SELECT P.id,p.title,IFNULL(k.count,0) as count FROM platform p LEFT JOIN (SELECT platform,COUNT(*) AS count FROM `knowledge_base` GROUP BY platform) k ON k.platform = p.id").Values(&maps)
if err != nil { if err != nil {
logs.Warn("GetKnowledgeBasePlatformsTotal get Group count------------", err) logs.Warn("GetKnowledgeBasePlatformsTotal get Group count------------", err)
return []orm.Params{} return []orm.Params{}
......
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
type StatisticalRepositoryInterface interface { type StatisticalRepositoryInterface interface {
Add(servicesStatistical *models.ServicesStatistical) (int64, error) Add(servicesStatistical *models.ServicesStatistical) (int64, error)
GetStatisticals(startDate string, endDate string) (map[string]interface{}, error) GetStatisticals(startDate string, endDate string) (map[string]interface{}, error)
GetTodayActionStatistical(startDate string, endDate string) ([]orm.Params, error) GetFlowStatistical(startDate string, endDate string) ([]orm.Params, error)
GetCustomerServiceList(request models.ServicesStatisticalPaginationDto) models.ServicesStatisticalPaginationDto GetCustomerServiceList(request models.ServicesStatisticalPaginationDto) models.ServicesStatisticalPaginationDto
CheckIsReplyAndSetReply(uid int64, aid int64, platform int64) CheckIsReplyAndSetReply(uid int64, aid int64, platform int64)
} }
...@@ -70,7 +70,7 @@ func (r *StatisticalRepository) GetCustomerServiceList(request models.ServicesSt ...@@ -70,7 +70,7 @@ func (r *StatisticalRepository) GetCustomerServiceList(request models.ServicesSt
addSQL1 = " GROUP BY `user_account` " addSQL1 = " GROUP BY `user_account` "
} }
if counter, err := r.o.Raw("SELECT s.id, s.user_account, s.service_account,s.create_at,s.is_reception, s.transfer_account,s.platform,u.nickname FROM services_statistical AS s INNER JOIN (SELECT * FROM `user` ) AS u ON s.user_account = u.id AND s.service_account = ? AND s.create_at > ? AND s.create_at < ? AND is_reception IN("+ INReception +") "+addSQL1+" ORDER BY s.create_at DESC LIMIT ?,?", request.Cid, startDate.Unix(), endDate.Unix(), (request.PageOn-1)*request.PageSize, request.PageSize).Values(&params); counter <= 0 { if counter, err := r.o.Raw("SELECT s.id, s.user_account, s.service_account,s.create_at,s.is_reception, s.transfer_account,s.platform,u.nickname FROM services_statistical AS s INNER JOIN (SELECT * FROM `user` ) AS u ON s.user_account = u.id AND s.service_account = ? AND s.create_at > ? AND s.create_at < ? AND is_reception IN("+INReception+") "+addSQL1+" ORDER BY s.create_at DESC LIMIT ?,?", request.Cid, startDate.Unix(), endDate.Unix(), (request.PageOn-1)*request.PageSize, request.PageSize).Values(&params); counter <= 0 {
logs.Warn("GetCustomerServiceList get Customer Service List2------------", err) logs.Warn("GetCustomerServiceList get Customer Service List2------------", err)
request.List = []string{} request.List = []string{}
return request return request
...@@ -144,8 +144,8 @@ func (r *StatisticalRepository) GetStatisticals(startDate string, endDate string ...@@ -144,8 +144,8 @@ func (r *StatisticalRepository) GetStatisticals(startDate string, endDate string
return countsArr, nil return countsArr, nil
} }
// GetTodayActionStatistical get Today Action Statistical // GetFlowStatistical get Today Action Statistical
func (r *StatisticalRepository) GetTodayActionStatistical(startDate string, endDate string) ([]orm.Params, error) { func (r *StatisticalRepository) GetFlowStatistical(startDate string, endDate string) ([]orm.Params, error) {
// transform date // transform date
layoutDate := "2006-01-02 15:04:05" layoutDate := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Local") loc, _ := time.LoadLocation("Local")
...@@ -157,7 +157,7 @@ func (r *StatisticalRepository) GetTodayActionStatistical(startDate string, endD ...@@ -157,7 +157,7 @@ func (r *StatisticalRepository) GetTodayActionStatistical(startDate string, endD
var statisticalData []orm.Params var statisticalData []orm.Params
_, err := r.o.Raw("SELECT p.id platform,p.title, IFNULL(u.count,0) AS `count` FROM platform as p LEFT JOIN (SELECT platform,COUNT(*) AS count FROM `user` WHERE last_activity BETWEEN ? AND ? GROUP BY platform) u ON p.id = u.platform", dateStart.Unix(), dateEnd.Unix()).Values(&statisticalData) _, err := r.o.Raw("SELECT p.id platform,p.title, IFNULL(u.count,0) AS `count` FROM platform as p LEFT JOIN (SELECT platform,COUNT(*) AS count FROM `user` WHERE last_activity BETWEEN ? AND ? GROUP BY platform) u ON p.id = u.platform", dateStart.Unix(), dateEnd.Unix()).Values(&statisticalData)
if err != nil { if err != nil {
logs.Warn("GetTodayActionStatistical get Today Action Statistical------------", err) logs.Warn("GetFlowStatistical get Today Action Statistical------------", err)
return nil, err return nil, err
} }
return statisticalData, nil return statisticalData, nil
......
...@@ -80,7 +80,7 @@ func (r *WorkOrderRepository) GetWorkOrders(request models.WorkOrderPaginationDt ...@@ -80,7 +80,7 @@ func (r *WorkOrderRepository) GetWorkOrders(request models.WorkOrderPaginationDt
} }
tidSQL := "" tidSQL := ""
if request.Tid != 0 { if request.Tid != 0 {
tidSQL = " ADN `t_i_d` = " + strconv.FormatInt(request.Tid, 10) + " " tidSQL = " AND `t_i_d` = " + strconv.FormatInt(request.Tid, 10) + " "
} }
if request.PageSize == 0 { if request.PageSize == 0 {
request.PageSize = 10 request.PageSize = 10
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
type WorkOrderTypeRepositoryInterface interface { type WorkOrderTypeRepositoryInterface interface {
GetWorkOrderType(id int64) (models.WorkOrderType, error) GetWorkOrderType(id int64) (models.WorkOrderType, error)
GetWorkOrderTypes() []models.WorkOrderType GetWorkOrderTypes() []models.WorkOrderType
GetWorkOrderTypesAndCountWorkorder() []models.WorkOrderTypeDto
Update(id int64, params orm.Params) (int64, error) Update(id int64, params orm.Params) (int64, error)
Delete(id int64) (int64, error) Delete(id int64) (int64, error)
Add(data models.WorkOrderType) (bool, int64, error) Add(data models.WorkOrderType) (bool, int64, error)
...@@ -71,6 +72,17 @@ func (r *WorkOrderTypeRepository) GetWorkOrderTypes() []models.WorkOrderType { ...@@ -71,6 +72,17 @@ func (r *WorkOrderTypeRepository) GetWorkOrderTypes() []models.WorkOrderType {
return workOrderTypes return workOrderTypes
} }
// GetWorkOrderTypesAndCountWorkorder get all
func (r *WorkOrderTypeRepository) GetWorkOrderTypesAndCountWorkorder() []models.WorkOrderTypeDto {
var workOrderTypes []models.WorkOrderTypeDto
_, err := r.o.Raw("SELECT t.*,IFNULL(w.count,0) as `count` FROM work_order_type t LEFT JOIN (SELECT t_i_d,COUNT(*) AS `count` FROM `work_order` WHERE `delete` = 0 GROUP BY `t_i_d`) w ON t.id = w.t_i_d").QueryRows(&workOrderTypes)
if err != nil {
logs.Warn("GetWorkOrderTypes get all------------", err)
return []models.WorkOrderTypeDto{}
}
return workOrderTypes
}
// Update WorkOrderType Info // Update WorkOrderType Info
func (r *WorkOrderTypeRepository) Update(id int64, params orm.Params) (int64, error) { func (r *WorkOrderTypeRepository) Update(id int64, params orm.Params) (int64, error) {
var res models.WorkOrderType var res models.WorkOrderType
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</el-col> </el-col>
</el-row> </el-row>
<div> <div>
<div class="mini-im-home-title" style="padding-bottom: 10px;">各渠道<span style="color: #f44336;">当天独立用户</span>访问量</div> <div class="mini-im-home-title" style="padding-bottom: 10px; text-align: left;">各渠道<span style="color: #f44336">{{optionsDate[selectDateValue].label}}独立用户</span>访问量</div>
<el-table <el-table
:data="todayStatisticalTableData" :data="todayStatisticalTableData"
style="width: 100%"> style="width: 100%">
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
prop="count" prop="count"
align="center" align="center"
width="180" width="180"
label="当天访问人次"> label="访问人次">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label=""> label="">
...@@ -129,7 +129,7 @@ export default { ...@@ -129,7 +129,7 @@ export default {
created(){ created(){
this.selectDate = this.getDate(2) this.selectDate = this.getDate(2)
this.getStatistical() this.getStatistical()
this.getTodayStatistical() this.getFlowStatistical()
this.getOnlines() this.getOnlines()
}, },
computed:{ computed:{
...@@ -186,11 +186,11 @@ export default { ...@@ -186,11 +186,11 @@ export default {
this.$message.error(error.response.data.message) this.$message.error(error.response.data.message)
}); });
}, },
// 获取今天访问数据 // 获取访问数据
getTodayStatistical(){ getFlowStatistical(){
axios.post('/home/today_statistical', { axios.post('/home/flow_statistical', {
"date_start": moment(new Date()).format("YYYY-MM-DD"), "date_start": moment(this.selectDate[0]).format("YYYY-MM-DD"),
"date_end": moment(new Date()).format("YYYY-MM-DD") "date_end": moment(this.selectDate[1]).format("YYYY-MM-DD")
}) })
.then(response => { .then(response => {
this.todayStatisticalTableData = response.data.data this.todayStatisticalTableData = response.data.data
...@@ -239,6 +239,7 @@ export default { ...@@ -239,6 +239,7 @@ export default {
// 时间变更 // 时间变更
changeDate(){ changeDate(){
this.getStatistical() this.getStatistical()
this.getFlowStatistical()
}, },
// 获取在线用户数 // 获取在线用户数
getOnlines(){ getOnlines(){
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
:class="{'el-button--primary': item.id + '' == tableData.platform + ''}" :class="{'el-button--primary': item.id + '' == tableData.platform + ''}"
@click="onTogglePlatform(item.id)" @click="onTogglePlatform(item.id)"
:key="item.id" :key="item.id"
size="mini" size="small"
>{{item.title}} ({{item.count}})</el-button> >{{item.title}} ( {{item.count}} )</el-button>
</template> </template>
</el-button-group> </el-button-group>
<el-col :span="5"> <el-col :span="5">
......
...@@ -5,19 +5,44 @@ ...@@ -5,19 +5,44 @@
<span> <span>
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span slot="title">工单管理</span> <span slot="title">工单管理</span>
<span style="font-size:15px;margin-left: 30px;color:#e7a646">当前有
<strong style="color: #f56c6c">5</strong>
条待处理, 和<strong style="color: #f56c6c"> 8</strong>
条待回复工单</span>
</span> </span>
<el-button size="mini">设置</el-button> <div>
<el-button-group>
<el-radio size="small" v-model="workStatus" label="-1" border>全部</el-radio>
<el-radio size="small" v-model="workStatus" label="0" border>待处理</el-radio>
<el-radio size="small" v-model="workStatus" label="2" border>待回复</el-radio>
<el-radio size="small" v-model="workStatus" label="1" border>已回复</el-radio>
<el-radio size="small" v-model="workStatus" label="3" border>已关闭</el-radio>
</el-button-group>
</div>
<div>
<el-button size="mini">回收站 ( 52654 )</el-button>
<el-button size="mini">分类设置</el-button>
</div>
</div> </div>
<el-divider /> <el-divider />
<div class="container-box">
<div class="menu">
<el-tabs @tab-click="tabsChange" tab-position="left" style="width:200px;height: 80vh;">
<template size="small" v-for="item in workorderTypes" border>
<el-tab-pane :key="item.id" :label="item.title + '('+item.count+')'"></el-tab-pane>
</template>
</el-tabs>
</div>
<div class="table-content">
<el-table :data="tableData.list" style="width: 100%" v-loading="loading"> <el-table :data="tableData.list" style="width: 100%" v-loading="loading">
<el-table-column type="index" :index="indexMethod" width="60" label="#序号"></el-table-column> <el-table-column type="index" :index="indexMethod" width="60" label="#序号"></el-table-column>
<el-table-column prop="title" label="工单标题"></el-table-column> <el-table-column prop="title" label="工单标题"></el-table-column>
<el-table-column prop="status" label="当前状态"> <el-table-column prop="status" label="当前状态">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="warning" v-if="scope.row.status == 0">处理</el-tag> <el-tag type="warning" v-if="scope.row.status == 0">等待客服处理</el-tag>
<el-tag type="warning" v-if="scope.row.status == 1">回复</el-tag> <el-tag type="warning" v-if="scope.row.status == 2">等待客服回复</el-tag>
<el-tag type="success" v-if="scope.row.status == 2">回复</el-tag> <el-tag type="success" v-if="scope.row.status == 1">已有客服回复</el-tag>
<el-tag type="info" v-if="scope.row.status == 3">已结束</el-tag> <el-tag type="info" v-if="scope.row.status == 3"> 工单已结束 </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="u_nickname" label="用户(发布者)"></el-table-column> <el-table-column prop="u_nickname" label="用户(发布者)"></el-table-column>
...@@ -47,6 +72,8 @@ ...@@ -47,6 +72,8 @@
:total="tableData.total" :total="tableData.total"
></el-pagination> ></el-pagination>
</el-row> </el-row>
</div>
</div>
<WorkOrderView :prop="showWorkOrder" v-model="isShowWorkOrderView" /> <WorkOrderView :prop="showWorkOrder" v-model="isShowWorkOrderView" />
</div> </div>
</template> </template>
...@@ -63,6 +90,7 @@ export default { ...@@ -63,6 +90,7 @@ export default {
loading: true, loading: true,
isShowWorkOrderView: false, isShowWorkOrderView: false,
showWorkOrder: {}, showWorkOrder: {},
workStatus: "-1",
tableData: { tableData: {
list: [], list: [],
page_on: 1, page_on: 1,
...@@ -70,25 +98,38 @@ export default { ...@@ -70,25 +98,38 @@ export default {
total: 0, total: 0,
status: -1, status: -1,
tid: 0 tid: 0
},
workorderTypes:[
{
"id": 0,
"count": 0,
"title": "全部工单"
} }
],
}; };
}, },
created() { created() {
setTimeout(() => {
this.getWorkorderList(); this.getWorkorderList();
}, 500); this.getWorkorderTypes()
}, },
methods: { methods: {
onShow(item){ onShow(item){
this.showWorkOrder = item this.showWorkOrder = item
this.isShowWorkOrderView = true this.isShowWorkOrderView = true
}, },
tabsChange(tab){
this.changeType(this.workorderTypes[parseInt(tab.index)].id)
},
// 行号 // 行号
indexMethod(index) { indexMethod(index) {
return ( return (
(this.tableData.page_on - 1) * this.tableData.page_size + index + 1 (this.tableData.page_on - 1) * this.tableData.page_size + index + 1
); );
}, },
changeType(tid){
this.tableData.tid = tid;
this.getWorkorderList(1);
},
// 获取数据 // 获取数据
getWorkorderList(index) { getWorkorderList(index) {
if (index) this.tableData.page_on = index; if (index) this.tableData.page_on = index;
...@@ -104,6 +145,20 @@ export default { ...@@ -104,6 +145,20 @@ export default {
this.$message.error(error.response.data.message); this.$message.error(error.response.data.message);
}); });
}, },
// 获取类型数据
getWorkorderTypes() {
axios
.get("/workorder/types")
.then(response => {
this.workorderTypes = this.workorderTypes.concat(response.data.data);
for(var i=0; i<response.data.data.length; i++){
this.workorderTypes[0].count += response.data.data[i].count
}
})
.catch(error => {
this.$message.error(error.response.data.message);
});
},
// 改变每页条数 // 改变每页条数
handleSizeChange(val) { handleSizeChange(val) {
this.tableData.page_size = val; this.tableData.page_size = val;
...@@ -114,6 +169,17 @@ export default { ...@@ -114,6 +169,17 @@ export default {
this.tableData.page_on = val; this.tableData.page_on = val;
this.getWorkorderList(); this.getWorkorderList();
} }
},
watch: {
isShowWorkOrderView(show){
if(!show){
this.getWorkorderList();
}
},
workStatus(status){
this.tableData.status = parseInt(status)
this.getWorkorderList();
}
} }
}; };
</script> </script>
...@@ -130,5 +196,15 @@ export default { ...@@ -130,5 +196,15 @@ export default {
margin-right: 5px; margin-right: 5px;
} }
} }
.container-box{
display flex
.menu{
flex-shrink: 0;
width 180px;
}
.table-content{
flex-grow 1
}
}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment