优化待办、回复抽屉

This commit is contained in:
kuaifan 2022-07-08 07:43:34 +08:00
parent 5bbbbb0b02
commit 488259d442
3 changed files with 170 additions and 112 deletions

View File

@ -56,18 +56,6 @@ export default {
return {} return {}
} }
}, },
hidePercentage: {
type: Boolean,
default: false
},
hideReply: {
type: Boolean,
default: false
},
isReply: {
type: Boolean, //
default: false
},
operateVisible: { operateVisible: {
type: Boolean, type: Boolean,
default: false default: false
@ -78,6 +66,18 @@ export default {
return {} return {}
} }
}, },
simpleView: {
type: Boolean,
default: false
},
isMyDialog: {
type: Boolean,
default: false
},
msgId: {
type: Number,
default: 0
},
}, },
data() { data() {
@ -90,15 +90,28 @@ export default {
...mapState(['userId']), ...mapState(['userId']),
isRightMsg() { isRightMsg() {
return !this.isReply && this.source.userid == this.userId return this.source.userid == this.userId
},
isReply() {
return this.simpleView || this.msgId === this.source.id
},
hidePercentage() {
return this.simpleView || this.isMyDialog || this.isReply
},
hideReply() {
return this.simpleView || this.msgId > 0
}, },
classArray() { classArray() {
return { return {
'dialog-item': true, 'dialog-item': true,
'reply-item': this.isReply,
'self': this.isRightMsg, 'self': this.isRightMsg,
} }
} },
}, },
watch: { watch: {

View File

@ -88,7 +88,7 @@
:data-component="msgItem" :data-component="msgItem"
:item-class-add="itemClassAdd" :item-class-add="itemClassAdd"
:extra-props="{dialogData, operateVisible, operateItem, hidePercentage: isMyDialog, hideReply: msgId > 0}" :extra-props="{dialogData, operateVisible, operateItem, isMyDialog, msgId}"
:estimate-size="78" :estimate-size="78"
:keeps="50" :keeps="50"
:disabled="scrollDisabled" :disabled="scrollDisabled"
@ -124,9 +124,8 @@
<div v-if="todoShow" class="chat-todo"> <div v-if="todoShow" class="chat-todo">
<div class="todo-label">{{$L('待办')}}:</div> <div class="todo-label">{{$L('待办')}}:</div>
<ul class="scrollbar-hidden"> <ul class="scrollbar-hidden">
<li v-for="item in todoList" @click.stop="onClickTodo(item, $event)"> <li v-for="item in todoList" @click.stop="onViewTodo(item)">
<div class="todo-desc">{{$A.getMsgSimpleDesc(item.msg_data)}}</div> <div class="todo-desc">{{$A.getMsgSimpleDesc(item.msg_data)}}</div>
<div v-if="item.click" class="todo-done">{{$L('完成')}}</div>
</li> </li>
</ul> </ul>
</div> </div>
@ -293,24 +292,41 @@
<DrawerOverlay <DrawerOverlay
v-model="replyListShow" v-model="replyListShow"
placement="right" placement="right"
class-name="dialog-wrapper-reply-list" class-name="dialog-wrapper-drawer-list"
:size="500"> :size="500">
<DialogWrapper <DialogWrapper
v-if="replyListShow && replyListItem" v-if="replyListShow"
:dialogId="dialogId" :dialogId="dialogId"
:msgId="replyListId" :msgId="replyListId"
class="reply-list"> class="drawer-list">
<div slot="head" class="dialog-scroller"> <div slot="head" class="drawer-title">{{$L('回复消息')}}</div>
</DialogWrapper>
</DrawerOverlay>
<!--待办完成-->
<DrawerOverlay
v-model="todoViewShow"
placement="right"
class-name="dialog-wrapper-drawer-list"
:size="500">
<div class="dialog-wrapper drawer-list">
<div class="dialog-nav">
<div class="drawer-title">{{$L('待办消息')}}</div>
</div>
<div class="dialog-scroller scrollbar-overlay">
<DialogItem <DialogItem
:source="replyListItem" v-if="todoViewMsg"
:source="todoViewMsg"
@on-view-text="onViewText" @on-view-text="onViewText"
@on-view-file="onViewFile" @on-view-file="onViewFile"
@on-emoji="onEmoji" @on-emoji="onEmoji"
hidePercentage simpleView/>
hideReply <Button class="original-button" icon="md-exit" type="text" @click="onPosTodo">{{ $L("回到原文") }}</Button>
isReply/> </div>
<div class="todo-button">
<Button type="primary" size="large" icon="md-checkbox-outline" @click="onDoneTodo" :loading="todoViewLoad" long>{{ $L("完成") }}</Button>
</div>
</div> </div>
</DialogWrapper>
</DrawerOverlay> </DrawerOverlay>
</div> </div>
</template> </template>
@ -405,6 +421,11 @@ export default {
replyListShow: false, replyListShow: false,
replyListId: 0, replyListId: 0,
todoViewLoad: false,
todoViewShow: false,
todoViewMid: 0,
todoViewId: 0,
scrollDisabled: false, scrollDisabled: false,
scrollDirection: null, scrollDirection: null,
scrollAction: 0, scrollAction: 0,
@ -454,22 +475,24 @@ export default {
}, },
allMsgList() { allMsgList() {
const dialogMsgList = this.dialogMsgList.filter(item => this.msgFilter(item)) const array = [];
array.push(...this.dialogMsgList.filter(item => this.msgFilter(item)));
if (this.msgId > 0) {
const msgItem = this.dialogMsgs.find(item => item.id == this.msgId)
if (msgItem) {
array.unshift(msgItem)
}
}
if (this.tempMsgList.length > 0) { if (this.tempMsgList.length > 0) {
const ids = dialogMsgList.map(({id}) => id) const ids = array.map(({id}) => id)
const tempMsgList = this.tempMsgList.filter(item => !ids.includes(item.id) && this.msgFilter(item)) const tempMsgList = this.tempMsgList.filter(item => !ids.includes(item.id) && this.msgFilter(item))
if (tempMsgList.length > 0) { if (tempMsgList.length > 0) {
const array = [];
array.push(...dialogMsgList);
array.push(...tempMsgList) array.push(...tempMsgList)
}
}
return array.sort((a, b) => { return array.sort((a, b) => {
return a.id - b.id; return a.id - b.id;
}); })
}
}
return dialogMsgList.sort((a, b) => {
return a.id - b.id;
});
}, },
loadMsg() { loadMsg() {
@ -609,8 +632,8 @@ export default {
return this.replyId ? this.dialogMsgs.find(({id}) => id === this.replyId) : null return this.replyId ? this.dialogMsgs.find(({id}) => id === this.replyId) : null
}, },
replyListItem() { todoViewMsg() {
return this.replyListId ? this.dialogMsgs.find(item => item.id == this.replyListId) : null return this.todoViewMid ? this.dialogMsgs.find(item => item.id == this.todoViewMid) : null
} }
}, },
@ -964,43 +987,57 @@ export default {
}) })
}, },
onClickTodo(item, event) { onViewTodo(item) {
if (event && event.target.classList.contains('todo-done')) { if (this.operateVisible) {
// return
this.$store.dispatch("setLoad", { }
key: `msg-${item.msg_id}`, this.todoViewId = item.id
delay: 600 this.todoViewMid = item.msg_id
}) this.todoViewShow = true
},
onCloseTodo() {
this.todoViewLoad = false
this.todoViewShow = false
this.todoViewMid = 0
this.todoViewId = 0
},
onPosTodo() {
if (!this.todoViewMid) {
return
}
this.onPositionId(this.todoViewMid).then(this.onCloseTodo)
},
onDoneTodo() {
if (!this.todoViewId || this.todoViewLoad) {
return
}
this.todoViewLoad = true
//
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'dialog/msg/done', url: 'dialog/msg/done',
data: { data: {
id: item.id, id: this.todoViewId,
}, },
}).then(({data}) => { }).then(({data}) => {
this.$store.dispatch("saveDialogTodo", { this.$store.dispatch("saveDialogTodo", {
id: item.id, id: this.todoViewId,
done_at: $A.formatDate("Y-m-d H:i:s") done_at: $A.formatDate("Y-m-d H:i:s")
}) })
if (data.add) { if (data.add) {
this.sendSuccess(data.add) this.sendSuccess(data.add)
} }
if (this.todoList.length === 0) { if (this.todoList.length === 0) {
this.$store.dispatch("getDialogTodo", item.dialog_id) this.$store.dispatch("getDialogTodo", this.dialogId)
} }
this.onCloseTodo()
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg) $A.modalError(msg)
}).finally(_ => { }).finally(_ => {
this.$store.dispatch("cancelLoad", `msg-${item.msg_id}`) this.todoViewLoad = false
}); });
} else {
//
this.onPositionId(item.msg_id).then(_ => {
this.$store.dispatch("saveDialogTodo", {
id: item.id,
click: true
})
})
}
}, },
itemClassAdd(index) { itemClassAdd(index) {
@ -1452,6 +1489,7 @@ export default {
onReply() { onReply() {
const {tail} = this.scrollInfo() const {tail} = this.scrollInfo()
this.replyActiveId = this.operateItem.id this.replyActiveId = this.operateItem.id
this.replyActiveUpdate = false
this.inputFocus() this.inputFocus()
if (tail <= 10) { if (tail <= 10) {
requestAnimationFrame(this.onToBottom) requestAnimationFrame(this.onToBottom)

View File

@ -13,28 +13,46 @@
overflow: hidden; overflow: hidden;
} }
&.reply-list { &.drawer-list {
border-radius: 18px 0 0 18px; border-radius: 18px 0 0 18px;
overflow: hidden; overflow: hidden;
.dialog-nav { .dialog-nav {
position: relative; .drawer-title {
text-align: center;
&:before { height: 56px;
content: ""; line-height: 56px;
position: absolute; border-bottom: 1px solid #eeeeee;
left: 0; font-size: 16px;
bottom: 0; font-weight: 500;
width: 100%; }
height: 1px;
z-index: 1;
background-color: #f4f5f5;
} }
.dialog-scroller { .dialog-scroller {
padding-right: 16px; padding: 16px 20px 0;
.reply-item {
border-bottom: 1px solid #eeeeee;
margin-bottom: 16px;
} }
.original-button {
display: block;
margin: 0 auto;
box-shadow: none;
}
}
.todo-button {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
margin: 18px 24px;
cursor: pointer;
> button {
margin: 0 8px;
}
} }
} }
@ -791,9 +809,6 @@
.common-loading { .common-loading {
margin: 0 3px 0 0; margin: 0 3px 0 0;
} }
> i {
color: $primary-color;
}
} }
.reply { .reply {
@ -1041,30 +1056,13 @@
cursor: pointer; cursor: pointer;
display: flex; display: flex;
align-items: center; align-items: center;
.todo-desc { .todo-desc {
max-width: 150px; max-width: 150px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.todo-done {
flex-shrink: 1;
font-weight: 500;
color: $primary-color;
position: relative;
margin-left: 7px;
padding-left: 8px;
&:before {
content: "";
position: absolute;
top: 50%;
left: 0;
height: 10px;
width: 1px;
transform: translateY(-50%) scaleX(0.5);
background-color: #cccccc;
}
}
} }
} }
} }
@ -1312,7 +1310,7 @@
} }
} }
.dialog-wrapper-reply-list { .dialog-wrapper-drawer-list {
position: absolute !important; position: absolute !important;
overflow: hidden !important; overflow: hidden !important;
} }
@ -1320,6 +1318,15 @@
@media (max-width: 768px) { @media (max-width: 768px) {
.dialog-wrapper { .dialog-wrapper {
background-color: #f8f8f8; background-color: #f8f8f8;
&.drawer-list {
.dialog-nav {
.drawer-title {
height: 52px;
line-height: 52px;
border-bottom: 0;
}
}
}
.dialog-nav { .dialog-nav {
.nav-wrapper { .nav-wrapper {
height: 52px; height: 52px;