Commit 3378309c by chenxianqi

update code

parent db2b66d4
......@@ -44,6 +44,9 @@ func (c *BaseController) JSON(status configs.ResponseStatusType, message string,
// GetAdminAuthInfo get current anth admin that AuthInfo
func (c *BaseController) GetAdminAuthInfo() *models.Auths {
token := c.Ctx.Input.Header("Authorization")
if token == "" {
c.JSON(configs.ResponseFail, "用户效验失败!", nil)
}
var authsRepository = services.GetAuthsRepositoryInstance()
auth := authsRepository.GetAdminAuthInfo(token)
if auth == nil {
......@@ -56,8 +59,12 @@ func (c *BaseController) GetAdminAuthInfo() *models.Auths {
// GetUserInfo get current user info
func (c *BaseController) GetUserInfo() *models.User {
token := c.Ctx.Input.Header("Token")
if token == "" {
return nil
}
var userRepository = services.GetUserRepositoryInstance()
user := userRepository.GetUserWithToken(token)
print("user==", user)
if user == nil {
logs.Warn("GetUserInfo get current user info error------------用户效验失败!")
}
......
......@@ -770,6 +770,7 @@ func (c *PublicController) GetWorkOrder() {
// get user
user := c.GetUserInfo()
print(&user)
if user == nil {
// GetAdminAuthInfo
auth := c.GetAdminAuthInfo()
......@@ -784,10 +785,10 @@ func (c *PublicController) GetWorkOrder() {
workOrderRepository := services.GetWorkOrderRepositoryInstance()
workOrder, err := workOrderRepository.GetWorkOrder(wid)
if err != nil {
c.JSON(configs.ResponseFail, "查询失败,工单不存在!", nil)
c.JSON(configs.ResponseFail, "查询失败,工单不存在1!", nil)
}
if user != nil && user.ID != workOrder.UID {
c.JSON(configs.ResponseFail, "查询失败,工单不存在!", nil)
c.JSON(configs.ResponseFail, "查询失败,工单不存在2!", nil)
}
c.JSON(configs.ResponseSucess, "查询成功!", &workOrder)
......
......@@ -89,13 +89,15 @@ func (r *WorkOrderRepository) GetWorkOrders(request models.WorkOrderPaginationDt
request.PageOn = 1
}
var maps []orm.Params
SQL := "SELECT *,t_i_d AS tid,c_i_d AS cid FROM (SELECT w.*,u.nickname FROM work_order w LEFT JOIN (SELECT id, nickname FROM `user`) u ON w.uid = u.id) w WHERE `delete` = 0 " + statusSQL + tidSQL + " ORDER BY id,create_at,update_at DESC"
_, err := r.o.Raw(SQL+" LIMIT ? OFFSET ?", request.PageSize, (request.PageOn-1)*request.PageSize).Values(&maps)
SQLSUB := "SELECT w.*,u.nickname AS u_nickname,a.nickname AS a_nickname FROM work_order w LEFT JOIN (SELECT id, nickname FROM `user`) u ON w.uid = u.id LEFT JOIN (SELECT id, nickname FROM `admin`) a ON w.last_reply = a.id"
SQL := "SELECT *,t_i_d AS tid,c_i_d AS cid FROM (" + SQLSUB + ") w WHERE `delete` = 0 " + statusSQL + tidSQL + " ORDER BY status ASC, create_at DESC"
_, err := r.o.Raw(SQL+" LIMIT ? OFFSET ?", request.PageSize, (request.PageOn-1)*request.PageSize).Values(&maps)
if err != nil {
logs.Warn("GetWorkOrders get WorkOrders------------", err)
request.List = []int{}
}
total, _ := r.o.Raw(SQL).Values(&maps)
var _maps []orm.Params
total, _ := r.o.Raw(SQL).Values(&_maps)
request.List = maps
request.Total = total
return request, err
......
......@@ -28,7 +28,7 @@
<el-badge :hidden="$store.getters.readCount == 0" :value="$store.getters.readCount" :max="99" style="width: 100%;">
<div>
<i class="el-icon-tickets"></i>
<span slot="title">工单系统</span>
<span slot="title">工单管理</span>
</div>
</el-badge>
</el-menu-item>
......
<template>
<div>
<div class="me-head">
<span>
<i class="el-icon-tickets"></i>
<span slot="title">工单系统</span>
</span>
<el-button size="mini">设置</el-button>
</div>
<el-divider />
<el-table :data="tableData.list" style="width: 100%" v-loading="loading">
<div>
<div class="me-head">
<span>
<i class="el-icon-tickets"></i>
<span slot="title">工单管理</span>
</span>
<el-button size="mini">设置</el-button>
</div>
<el-divider />
<el-table :data="tableData.list" style="width: 100%" v-loading="loading">
<el-table-column type="index" :index="indexMethod" width="60"></el-table-column>
<el-table-column prop="nickname" label="用户"></el-table-column>
<el-table-column prop="title" label="工单标题"></el-table-column>
<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 == 1">待回复</el-tag>
<el-tag type="success" v-if="scope.row.status == 2">已回复</el-tag>
<el-tag type="info" v-if="scope.row.status == 3">已结束</el-tag>
</template>
</el-table-column>
<el-table-column prop="u_nickname" label="用户(发布者)"></el-table-column>
<el-table-column prop="a_nickname" label="最后回复者(客服)">
<template slot-scope="scope">
{{scope.row.a_nickname || '-----'}}
</template>
</el-table-column>
<el-table-column prop="create_at" label="创建时间">
<template slot-scope="scope">{{$formatUnixDate(scope.row.create_at, "YYYY/MM/DD")}}</template>
</el-table-column>
<el-table-column prop="operating" align="center" width="150" label="操作">
<template>
<el-button size="mini">查 看</el-button>
<template slot-scope="scope">
<el-button @click="onShow(scope.row)" size="mini">查 看</el-button>
</template>
</el-table-column>
</el-table>
<el-row type="flex" style="margin-top: 20px;" justify="space-between">
<el-row type="flex" style="margin-top: 20px;" justify="space-between">
<span style="color:#666;font-size: 14px;">共找到{{tableData.total}}条数据</span>
<el-pagination
background
......@@ -42,24 +47,31 @@
:total="tableData.total"
></el-pagination>
</el-row>
</div>
<WorkOrderView :prop="showWorkOrder" v-model="isShowWorkOrderView" />
</div>
</template>
<script>
import axios from "axios";
import WorkOrderView from "./workorder-view"
export default {
name: 'workorder-index',
data(){
name: "workorder-index",
components: {
WorkOrderView
},
data() {
return {
loading: true,
isShowWorkOrderView: false,
showWorkOrder: {},
tableData: {
list: [],
page_on: 1,
page_size: 10,
total: 0,
status: -1,
tid: 0,
},
}
tid: 0
}
};
},
created() {
setTimeout(() => {
......@@ -67,6 +79,10 @@ export default {
}, 500);
},
methods: {
onShow(item){
this.showWorkOrder = item
this.isShowWorkOrderView = true
},
// 行号
indexMethod(index) {
return (
......@@ -91,28 +107,28 @@ export default {
// 改变每页条数
handleSizeChange(val) {
this.tableData.page_size = val;
this.getKnowledgeList();
this.getWorkorderList();
},
// 分页
handleCurrentChange(val) {
this.tableData.page_on = val;
this.getKnowledgeList();
},
this.getWorkorderList();
}
}
}
};
</script>
<style scoped lang="stylus">
.me-head {
height: 30px;
display: flex;
align-items: center;
font-size: 20px;
justify-content: space-between;
color: #666;
.me-head {
height: 30px;
display: flex;
align-items: center;
font-size: 20px;
justify-content: space-between;
color: #666;
i {
margin-right: 5px;
}
i {
margin-right: 5px;
}
}
</style>
<template>
<div class="workorder-view" :class="{'is-show-aside': !isShowAside}" v-show="value">
<div class="mask" @dblclick="close"></div>
<transition name="el-zoom-in-bottom">
<div class="content" v-show="value">
<div class="title">
<i class="el-icon-tickets"></i> 工单详细
</div>
<span class="close" @click="close"><i class="el-icon-close"></i></span>
<div class="form-line">
<span class="lable"> 标题:</span>
<div class="con">{{showData.title}}</div>
</div>
<div class="form-line">
<span class="lable"> 手机:</span>
<div class="con">{{showData.phone}}</div>
</div>
<div class="form-line">
<span class="lable"> 邮箱:</span>
<div class="con">{{showData.email || '未预留邮箱'}}</div>
</div>
<div class="form-line">
<span class="lable"> 状态:</span>
<div class="con">
<span style="color:#e6a23c;" v-if="showData.status == 0">待处理</span>
<span style="color:#e6a23c;" v-if="showData.status == 1">待回复</span>
<span style="color:#67c23a;" v-if="showData.status == 2">已回复</span>
<span style="color:#909399;" v-if="showData.status == 3">已结束</span>
</div>
</div>
<div class="form-line">
<span class="lable"> 内容:</span>
<div class="con" v-html="showData.content"></div>
</div>
</div>
</transition>
</div>
</template>
<script>
import axios from "axios";
export default {
name: "workorder-view",
data() {
return {
workorder: null,
};
},
props: {
value: {
default: false,
type: Boolean
},
prop: Object
},
computed: {
showData(){
return this.workorder || this.prop
},
isShowAside(){
return this.$store.state.isShowAside;
}
},
methods: {
// 按钮操作
close() {
this.$emit("input", false);
},
getWorkOrder(){
axios
.get("/public/workorder/" + this.prop.id)
.then(response => {
this.workorder = response.data.data;
setTimeout(()=> this.$previewRefresh(), 500)
})
}
},
watch: {
prop(){
this.getWorkOrder()
setTimeout(()=> this.$previewRefresh(), 500)
}
},
};
</script>
<style scoped lang="stylus">
.workorder-view {
width: 100vw;
height: 100vh;
position: fixed;
right: 0;
top: 0px;
left: 0px;
background-color: rgba(0, 0, 0, 0.8);
z-index: 9;
.mask{
width: 100%;
height: 100%;
}
.content {
width: 550px;
height: 100%;
background-color: #fff;
position: fixed;
right: 0px;
left 260px
margin 0 auto
top: 30px;
padding 10px
overflow hidden
overflow-y auto
border-radius 5px 5px 0 0
padding-top 50px
.title{
width 100%
height 40px
border-bottom 1px solid #ddd
position absolute
top 0
left 0
background-color #fff
padding 10px 0 0 10px
box-sizing border-box
}
.close{
position absolute
top 5px
right 5px
font-size 25px
color #ccc
cursor pointer
}
.form-line{
margin-bottom 5px
font-size 14px
color #333
display flex
.lable{
width: 50px
flex-shrink 0
}
.con{
flex-grow 1
}
img{
width 30% ;
}
}
}
&.is-show-aside{
left: 0;
.content{
left 0px
}
}
}
</style>
......@@ -130,10 +130,10 @@ export default {
var fullPath = self.uploadToken.host + "/" + src;
var fileType = src.substr(src.lastIndexOf(".") + 1);
if ("jpg,jpeg,png,JPG,JPEG,PNG".indexOf(fileType) != -1) {
html = "<br><img style='max-width:60%' preview='1' src='" + fullPath + "' />"
html = "<br><img style='max-width:45%' preview='1' src='" + fullPath + "' />"
}else{
html = "<br><img style='width:20px;height:30px;top:3px; right:3px;position: relative;' preview='1' src='http://qiniu.cmp520.com/fj.png' />"
html += "<a target='_blank' href='"+fullPath+"'>下载附件</a>"
html += "<a target='_blank' style='color: #2e9dfc;' href='"+fullPath+"'>下载附件</a>"
}
self.source = html
Toast({
......
......@@ -202,10 +202,10 @@ export default {
var fullPath = self.uploadToken.host + "/" + src;
var fileType = src.substr(src.lastIndexOf(".") + 1);
if ("jpg,jpeg,png,JPG,JPEG,PNG".indexOf(fileType) != -1) {
html = "<br><img style='max-width:60%' preview='1' src='" + fullPath + "' />"
html = "<br><img style='max-width:45%' preview='1' src='" + fullPath + "' />"
}else{
html = "<br><img style='width:20px;height:30px;top:3px; right:3px;position: relative;' preview='1' src='http://qiniu.cmp520.com/fj.png' />"
html += "<a target='_blank' href='"+fullPath+"'>下载附件</a>"
html += "<a target='_blank' style='color: #2e9dfc;' href='"+fullPath+"'>下载附件</a>"
}
self.request.source = html
Toast({
......
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