Commit a68140bb by chenxianqi

update code

parent e3a7f5bd
......@@ -5,11 +5,12 @@ import (
"time"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
)
// WorkOrderCommentRepositoryInterface interface
type WorkOrderCommentRepositoryInterface interface {
GetWorkOrderComments(wid int64) ([]models.WorkOrderComment, error)
GetWorkOrderComments(wid int64) ([]orm.Params, error)
Add(workOrderComment models.WorkOrderComment) (int64, error)
}
......@@ -26,9 +27,9 @@ func GetWorkOrderCommentRepositoryInstance() *WorkOrderCommentRepository {
}
// GetWorkOrderComments get WorkOrderComments
func (r *WorkOrderCommentRepository) GetWorkOrderComments(wid int64) ([]models.WorkOrderComment, error) {
var workOrderComments []models.WorkOrderComment
_, err := r.q.Filter("wid", wid).OrderBy("id").All(&workOrderComments)
func (r *WorkOrderCommentRepository) GetWorkOrderComments(wid int64) ([]orm.Params, error) {
var workOrderComments []orm.Params
_, err := r.o.Raw("SELECT * FROM (SELECT w.*,a.nickname,a.avatar FROM work_order_comment w LEFT JOIN (SELECT * FROM admin) a ON w.a_i_d = a.id AND w.wid = ? ORDER BY w.id DESC) b WHERE wid = ?", wid, wid).Values(&workOrderComments)
if err != nil {
logs.Warn("GetWorkOrderComments get WorkOrderComments-----------", err)
}
......
......@@ -53,7 +53,7 @@ func (r *WorkOrderRepository) Close(id int64, cid int64, remark string) (int64,
// GetUserWorkOrders get user WorkOrders
func (r *WorkOrderRepository) GetUserWorkOrders(uid int64) ([]models.WorkOrder, error) {
var workOrders []models.WorkOrder
_, err := r.q.Filter("uid", uid).Filter("delete", 0).OrderBy("-id").All(&workOrders)
_, err := r.q.Filter("uid", uid).Filter("delete", 0).OrderBy("-id").OrderBy("status").All(&workOrders)
if err != nil {
logs.Warn("GetUserWorkOrders get user WorkOrders------------", err)
}
......@@ -89,13 +89,6 @@ func (r *WorkOrderRepository) Add(workOrder models.WorkOrder) (int64, error) {
if err != nil {
logs.Warn("Add add WorkOrder------------", err)
}
if wid > 0 {
r.WorkOrderCommentRepository.Add(models.WorkOrderComment{
WID: wid,
Content: workOrder.Content,
CreateAt: createAt,
})
}
return wid, err
}
......
......@@ -22,9 +22,9 @@
<span class="type">{{getTypeName(item.tid)}}</span>
<span class="date">{{$formatDate(item.create_at)}}</span>
</div>
<i v-if="item.status == 1" style="color:#FF9800;">客服已回复</i>
<i v-if="item.status == 3" style="color:#ccc">工单已结束</i>
<i v-if="item.status == 0 || item.status == 2" style="color:green">待回复</i>
<i v-if="item.status == 1" style="color:#8bc34a;">已回复</i>
<i v-if="item.status == 3" style="color:#ccc">已结束</i>
<i v-if="item.status == 0 || item.status == 2" style="color:#FF9800">待处理</i>
</li>
</template>
</ul>
......
<template>
<div class="container">
<mt-header v-if="isShowHeader" fixed :title="workorder.title || '工单详情'">
<mt-header v-if="isShowHeader" fixed title="工单详细">
<div slot="left">
<mt-button @click="$router.go(-1)" icon="back"></mt-button>
</div>
<mt-button slot="right">
<mt-button v-if="workorder.status == 3" slot="right">
<span>删除</span>
</mt-button>
</mt-header>
<div class="content" :class="{'hide-header': !isShowHeader}">
<div class="head">
<div class="con">
<span>标题:</span>
<span>{{workorder.title}}</span>
</div>
<div class="con">
<span>内容:</span>
<span v-html="workorder.content"></span>
</div>
<div class="con">
<span>电话:</span>
<span>{{workorder.phone || '未预留电话号码'}}</span>
</div>
<div class="con">
<span>邮箱:</span>
<span>{{workorder.email || '未预留邮箱'}}</span>
</div>
<div class="con">
<span>时间:</span>
<span>{{$formatDate(workorder.create_at)}}</span>
</div>
<div class="con">
<span>状态:</span>
<span>
<i v-if="workorder.status == 1" style="color:#8bc34a;">已回复</i>
<i v-if="workorder.status == 3" style="color:#ccc">已结束</i>
<i v-if="workorder.status == 0 || workorder.status == 2" style="color:#FF9800">待处理</i>
</span>
</div>
</div>
</div>
</div>
</template>
<script>
......@@ -19,6 +51,7 @@ export default {
data() {
return {
workorder: {},
comments:[]
};
},
computed: {
......@@ -29,23 +62,63 @@ export default {
])
},
created() {
document.title = "工单详"
document.title = "工单详"
const id = this.$route.params.id
this.getWorkOrder(id)
this.$store.commit("updateState", {isShowPageLoading: true});
axios.all([this.getWorkOrder(id), this.getComments(id)])
.then(axios.spread(() => {
this.$store.commit("updateState", {isShowPageLoading: false});
}));
},
methods: {
getWorkOrder(id){
axios.get("/public/workorder/"+id).then(response => {
return axios.get("/public/workorder/"+id).then(response => {
this.workorder = response.data.data
console.log(this.workorder)
}).catch(error => {
console.log(error)
});
},
getComments(id){
return axios.get("/public/workorder/comments/"+id).then(response => {
this.comments = response.data.data
console.log(this.comments)
}).catch(error => {
console.log(error)
});
}
}
};
</script>
<style lang="stylus" scoped>
.content{
padding-top 50px
&.hide-header{
padding-top 0
}
.head{
margin 0 10px
padding 10px 0
border-bottom 1px solid rgba(158, 158, 158, 0.13);
.con{
font-size 15px
color #333
display flex
margin-bottom 8px
span{
flex-flow 1
}
span:first-child{
flex-flow 0
flex-shrink 0
width 45px
}
i{
font-style normal
}
}
}
}
</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