Commit 1142582d by keith

update code

parent a68140bb
......@@ -604,7 +604,7 @@ func (c *PublicController) CreateWorkOrder() {
// type is exist?
workOrderTypeRepository := services.GetWorkOrderTypeRepositoryInstance()
if _, err := workOrderTypeRepository.GetWorkOrderType(workOrder.CID); err != nil {
if _, err := workOrderTypeRepository.GetWorkOrderType(workOrder.TID); err != nil {
c.JSON(configs.ResponseFail, "创建失败,工单类型不存在~", err.Error())
}
......@@ -692,6 +692,9 @@ func (c *PublicController) ReplyWorkOrder() {
}
}
if workOrder.Status == 0 {
status = 0
}
params["Status"] = status
if _, err := workOrderRepository.Update(workOrderComment.WID, params); err != nil {
c.JSON(configs.ResponseFail, "发送失败!", nil)
......@@ -818,3 +821,28 @@ func (c *PublicController) DeleteWorkOrder() {
c.JSON(configs.ResponseSucess, "删除成功!", nil)
}
// CloseWorkOrder user close word order
func (c *PublicController) CloseWorkOrder() {
// get user
user := c.GetUserInfo()
if user == nil {
c.JSON(configs.ResponseFail, "fail!", nil)
}
// wid
wid, _ := strconv.ParseInt(c.Ctx.Input.Param(":wid"), 10, 64)
workOrderRepository := services.GetWorkOrderRepositoryInstance()
workOrder, err := workOrderRepository.GetWorkOrder(wid)
if err != nil {
c.JSON(configs.ResponseFail, "查询失败,工单不存在!", nil)
}
if user != nil && user.ID != workOrder.UID {
c.JSON(configs.ResponseFail, "关闭失败,工单不存在!", nil)
}
if _, err := workOrderRepository.Update(wid, orm.Params{"Status": 3}); err != nil {
c.JSON(configs.ResponseFail, "关闭失败,工单不存在!", nil)
}
c.JSON(configs.ResponseSucess, "关闭成功!", nil)
}
......@@ -55,6 +55,7 @@ func init() {
beego.NSRouter("/workorder/comments/:wid", &controllers.PublicController{}, "get:GetWorkOrderComments"),
beego.NSRouter("/workorder/:wid", &controllers.PublicController{}, "get:GetWorkOrder"),
beego.NSRouter("/workorder/:wid", &controllers.PublicController{}, "delete:DeleteWorkOrder"),
beego.NSRouter("/workorder/close/:wid", &controllers.PublicController{}, "put:CloseWorkOrder"),
),
// knowledge_base
......
......@@ -29,7 +29,7 @@ func GetWorkOrderCommentRepositoryInstance() *WorkOrderCommentRepository {
// GetWorkOrderComments get 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)
_, err := r.o.Raw("SELECT id,wid,aid,avatar,content,create_at,nickname FROM (SELECT w.*,w.a_i_d AS `aid`,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 ASC) b WHERE wid = ?", wid, wid).Values(&workOrderComments)
if err != nil {
logs.Warn("GetWorkOrderComments get WorkOrderComments-----------", err)
}
......
......@@ -55,7 +55,7 @@ func (r *WorkOrderTypeRepository) GetWorkOrderType(id int64) (models.WorkOrderTy
var workOrderType models.WorkOrderType
err := r.q.Filter("id", id).One(&workOrderType)
if err != nil {
logs.Warn(" GetWorkOrderType get------------", err)
logs.Warn(" GetWorkOrderType get------------", id, err)
}
return workOrderType, err
}
......
......@@ -47,8 +47,8 @@ Helps.install = function (Vue, options) {
.then(res => {
if (success) success(res.data.data);
})
.catch(() => {
if (fail) fail();
.catch((e) => {
if (fail) fail(e);
});
}
// 七牛云
......@@ -85,8 +85,8 @@ Helps.install = function (Vue, options) {
.then(() => {
if (success) success(fileName);
})
.catch(() => {
if (fail) fail();
.catch((e) => {
if (fail) fail(e);
});
},
complete: function (res) {
......
......@@ -32,9 +32,15 @@
fieldset, img { border:0; }
button, input, select, textarea { font-size:100%; outline: none;}
table { border-collapse:collapse; border-spacing:0; }
*{
-webkit-overflow-scrolling: touch!important;
-webkit-appearance: none!important;
-webkit-tap-highlight-color:rgba(0,0,0,0)!important;
outline:none!important;
}
input{
border:0;
outline: none;
outline: none !important;
}
html{
overflow: hidden;
......
......@@ -24,7 +24,8 @@
</div>
<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>
<i v-if="item.status == 0" style="color:#FF9800">待处理</i>
<i v-if="item.status == 2" style="color:#FF9800">待回复</i>
</li>
</template>
</ul>
......@@ -96,24 +97,24 @@ export default {
position relative
height 40px
.title{
font-size 14px
font-size 15px
color #333
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.type{
font-size 12px
font-size 13px
color #666
}
.date{
margin-left 10px
font-size 12px
font-size 13px
color #999
}
i{
font-style normal
font-size 11px
font-size 13px
position absolute
right 10px
top 0
......
......@@ -4,8 +4,8 @@
<div slot="left">
<mt-button @click="$router.go(-1)" icon="back"></mt-button>
</div>
<mt-button v-if="workorder.status == 3" slot="right">
<span>删除</span>
<mt-button @click="close()" v-if="workorder.status != 3" slot="right">
<span>关闭工单</span>
</mt-button>
</mt-header>
<div class="content" :class="{'hide-header': !isShowHeader}">
......@@ -35,30 +35,78 @@
<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>
<i v-if="workorder.status == 0" style="color:#FF9800">待处理</i>
<i v-if="workorder.status == 2" style="color:#FF9800">待回复</i>
</span>
</div>
</div>
<div class="comments">
<div class="no-data" v-if="comments.length <= 0">暂无回复内容,请您耐心等待~</div>
<template v-else v-for="(item,index) in comments">
<div :key="index" class="item">
<div class="avatar">
<img v-if="item.aid == '0'" :src="userInfo.avatar || 'http://qiniu.cmp520.com/avatar_degault_3.png'" alt="">
<img v-else :src="item.avatar || 'http://qiniu.cmp520.com/avatar_degault_3.png'" alt="">
</div>
<div class="right">
<div class="nickname" v-if="item.aid == '0'"></div>
<div class="nickname" v-else>{{item.nickname}}</div>
<div class="detail" v-html="commentView(item.content)"></div>
<div class="date">{{$formatDate(item.create_at)}}</div>
</div>
</div>
</template>
<div class="workorder-close" v-if="workorder.status == 3">
工单已结束~
</div>
</div>
<div class="file-view" v-if="request.file != '' || isShowUploadLoading">
<span v-if="isShowUploadLoading">
<img src="./../assets/loading.gif" alt="">
<i>上传中~</i>
</span>
<span v-else>
<img src="./../assets/fujian1.png" alt="">
<i>你已成功添加附件,重新上传可替换~</i>
</span>
</div>
<div class="input-form" v-if="workorder.status != 3">
<textarea v-model="request.content" @blur="inputBlur()" placeholder="请输入内容~"></textarea>
<span class="icon-btn">
<input type="file" @change="uploadFile" onclick="this.value = null" />
</span>
<span class="sub-btn" @click="reply()">提交</span>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import { Toast,MessageBox } from 'mint-ui';
import axios from "axios";
export default {
name: "workorder_detail",
components: {},
data() {
return {
isShowUploadLoading: false,
isSubmit: false,
workorder: {},
comments:[]
comments:[],
fileType: "",
request:{
file: "",
content: "",
}
};
},
computed: {
...mapGetters([
'isShowHeader',
'workorders',
'userInfo',
'workorderTypes',
"uploadToken"
])
},
created() {
......@@ -71,28 +119,125 @@ export default {
}));
},
methods: {
commentView(comment){
var res = comment.match(/\[file=(.*)\]/)
if(res == null) return comment
var fileType = res[1].substr(res[1].lastIndexOf('.')+1)
if("jpg,jpeg,png,JPG,JPEG,PNG".indexOf(fileType) != -1){
comment = comment.replace(res[0], "<br><img style='max-width:60%' preview='1' src='"+res[1]+"' />")
this.$previewRefresh();
}
return comment
},
getWorkOrder(id){
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 => {
if(response.data.data == null) return;
this.comments = response.data.data
console.log(this.comments)
}).catch(error => {
console.log(error)
});
},
reply(){
const content = this.request.content + this.request.file
if(content.trim() == ''){
Toast({
message: "请输入内容~"
})
return
}
if(this.isSubmit) return
this.isSubmit = true
const wid = this.workorder.id
axios.post("/public/workorder/reply", {wid, content}).then(response => {
this.getComments(wid)
this.request = {
file: "",
content: "",
}
}).catch(error => {
Toast({
message: "提交失败~"
})
});
},
inputBlur(){
  setTimeout(() => { 
  document.body.scrollTo = 0;
window.scrollTo(0, 0);  
}, 100);
},
uploadFile(e){
var fileDom = e.target;
var file = fileDom.files[0];
this.isShowUploadLoading = true
const self = this
this.$uploadFile({
file,
mode: this.uploadToken.mode,
// 七牛才会执行
percent(res) {},
success(src) {
self.request.file = '[file=' + self.uploadToken.host + '/' + src + ']'
self.isShowUploadLoading = false
},
fail(e) {
self.isShowUploadLoading = false
if(e.response && e.response.data){
Toast({
message: e.response.data.message
})
return
}
}
});
},
close(){
var wid = this.workorder.id
MessageBox.confirm('您确定关闭该工单吗?').then(action => {
axios.put("/public/workorder/close/"+wid).then(response => {
Toast({
message: "工单已关闭~"
})
this.getWorkOrder(wid)
}).catch(error => {
Toast({
message: "工单关闭失败~"
})
console.log(error)
});
});
}
}
};
</script>
<style lang="stylus" scoped>
.container{
height 100vh
overflow hidden
overflow-y auto
}
.content{
padding-top 50px
padding-bottom: 90px;
.no-data{
color #666
font-size 14px
}
.workorder-close{
text-align center
color #666
font-size 14px
padding 10px
}
&.hide-header{
padding-top 0
}
......@@ -119,6 +264,126 @@ export default {
}
}
.comments{
padding 10px
.item{
display flex
.avatar{
padding-top 10px
img{
width 35px
height 35px
border-radius 100px
display block
}
border-bottom 1px solid rgba(158, 158, 158, 0.13);
}
.right{
padding 10px 5px
flex-grow 1
border-bottom 1px solid rgba(158, 158, 158, 0.13);
.nickname{
font-size 15px
color #333
}
.detail{
font-size 15px
color #333
margin-top 5px
}
.date{
color #999
font-size 14px
margin-top 5px
}
}
&:last-child{
.right,.avatar{
border-bottom 0
}
}
}
}
.file-view{
position fixed
bottom 80px
left 0
right 0
padding 5px 10px
margin 0 auto
font-size 13px
color #8bc34a;
span {
display flex
align-content center
align-items center
img{
width 20px
height 20px
}
i{
font-style normal
margin-left 5px
}
}
}
.input-form{
position fixed
bottom 0
left 0
right 0
margin 0 auto
width 100%
height 80px
background-color #fff
border-top 1px solid rgba(158, 158, 158, 0.13);
display flex
justify-content space-between
padding 0 10px
box-sizing border-box
align-content center
align-items center
textarea{
height 45px
flex-grow 1
border-radius 0
border 0
color #333
font-size 14px
resize none
}
.icon-btn{
background url(./../assets/upload.png) center center no-repeat
background-size 30px
width: 55px;
height 55px
overflow hidden
input{
display block
width 100%
height 100%
font-size 100px
opacity 0
}
}
.sub-btn {
display block
width: 55px;
height: 30px;
color: #fff;
line-height: 30px;
text-align: center;
border-radius: 3px;
border: none;
font-size: 14px;
background: linear-gradient(to right, #26a2ff, #736cde);
flex-shrink: 0;
&:active {
opacity: 0.8;
}
}
}
}
</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