Skip to content

Commit

Permalink
feat: 发起投票功能添加缓存记录选中效果
Browse files Browse the repository at this point in the history
  • Loading branch information
weifashi committed Mar 5, 2024
1 parent ae147c7 commit 0968c43
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
27 changes: 22 additions & 5 deletions resources/assets/js/pages/manage/components/DialogView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@
</div>
<pre v-html="$A.formatTextMsg(msgData.msg.text, userId)"></pre>
<template v-if="(msgData.msg.votes || []).filter(h=>h.userid == userId).length == 0">
<RadioGroup v-if="msgData.msg.multiple == 0" v-model="msgData.msg._vote" vertical>
<RadioGroup v-if="msgData.msg.multiple == 0" v-model="voteData[msgData.msg.uuid]" vertical>
<Radio v-for="(item,index) in (msgData.msg.list || [])" :label="item.id" :key="index">
{{item.text}}
</Radio>
</RadioGroup>
<CheckboxGroup v-else v-model="msgData.msg._vote">
<CheckboxGroup v-else v-model="voteData[msgData.msg.uuid]">
<Checkbox v-for="(item,index) in (msgData.msg.list || [])" :label="item.id" :key="index">
{{item.text}}
</Checkbox>
</CheckboxGroup>
<div class="btn-row">
<Button v-if="(msgData.msg._vote || []).length == 0" disabled>{{$L("请选择后投票")}}</Button>
<Button v-if="(voteData[msgData.msg.uuid] || []).length == 0" disabled>{{$L("请选择后投票")}}</Button>
<Button v-else type="warning" :loading="msgData.msg._loadIng > 0" @click="onVote('vote',msgData)">{{$L("立即投票")}}</Button>
</div>
</template>
Expand Down Expand Up @@ -316,12 +316,17 @@ export default {
todoShow: false,
todoList: [],
emojiUsersNum: 5
emojiUsersNum: 5,
voteData: {}
}
},
mounted() {
this.emojiUsersNum = Math.min(6, Math.max(2, Math.floor((this.windowWidth - 180) / 52)))
if (Object.keys(this.voteData).length === 0) {
this.voteData = JSON.parse(window.localStorage.getItem(`__cache:vote__`)) || {};
}
},
beforeDestroy() {
Expand Down Expand Up @@ -411,6 +416,18 @@ export default {
if (val) {
setTimeout(_ => this.operateEnter = true, 500)
}
},
voteData: {
handler(val) {
const voteData = JSON.parse(window.localStorage.getItem('__cache:vote__')) || {}
for (const key in val) {
voteData[key] = val[key];
}
if (Object.keys(voteData).length > 0) {
window.localStorage.setItem('__cache:vote__', JSON.stringify(voteData))
}
},
deep: true
}
},
Expand Down Expand Up @@ -614,7 +631,7 @@ export default {
data: {
dialog_id: msgData.dialog_id,
uuid: msgData.msg.uuid,
vote: msgData.msg._vote || [],
vote: this.voteData[msgData.msg.uuid] || [],
type: type
}
}).then(({ data }) => {
Expand Down
3 changes: 3 additions & 0 deletions resources/assets/js/pages/manage/components/DialogWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,9 @@ export default {
dialogId: {
handler(dialog_id, old_id) {
if (dialog_id) {
//
window.localStorage.removeItem('__cache:vote__')
//
this.msgNew = 0
this.msgType = ''
this.unreadOne = 0
Expand Down

0 comments on commit 0968c43

Please sign in to comment.