feat: 添加投票功能 30%

This commit is contained in:
weifashi 2023-12-08 01:42:59 +08:00
parent bab82dc290
commit 5dfc66fc21
16 changed files with 355 additions and 74 deletions

View File

@ -521,6 +521,7 @@ class WebSocketDialogMsg extends AbstractModel
}
switch ($data['type']) {
case 'text':
case 'word-chain':
return $this->previewTextMsg($data['msg']['text'], $preserveHtml);
case 'record':
return "[语音]";

View File

@ -1434,6 +1434,7 @@ APP推送
发起接龙
发起接龙,参与接龙目前共(*)人
请输入接龙内容
可填写接龙格式
重复内容将不再计入接龙结果
返回编辑

View File

@ -818,6 +818,7 @@
if ($A.isJson(data)) {
switch (data.type) {
case 'text':
case 'word-chain':
return $A.getMsgTextPreview(data.msg.text, imgClassName)
case 'record':
return `[${$A.L('语音')}]`

View File

@ -264,9 +264,6 @@
<MobileBack :showTabbar="showMobileTabbar"/>
<MobileNotification ref="mobileNotification"/>
<!--接龙-->
<WordChain/>
<!-- okr明细 -->
<MicroApps v-show="false" v-if="$route.name != 'manage-apps'" name="okr-details" :url="okrUrl" :datas="okrWindow"/>
</div>
@ -292,8 +289,7 @@ import TaskExport from "./manage/components/TaskExport";
import ApproveExport from "./manage/components/ApproveExport";
import notificationKoro from "notification-koro1";
import {Store} from "le5le-store";
import MicroApps from "../components/MicroApps.vue";
import WordChain from "../components/WordChain.vue";
import MicroApps from "../components/MicroApps";
export default {
components: {
@ -312,8 +308,7 @@ export default {
ProjectManagement,
TeamManagement,
ProjectArchived,
MicroApps,
WordChain
MicroApps
},
directives: {longpress},
data() {

View File

@ -191,7 +191,7 @@
<!-- 发起接龙 -->
<UserSelect
ref="wordChain"
ref="wordChainRef"
v-model="sendData"
:multiple-max="50"
:title="$L('选择群组发起接龙')"
@ -327,6 +327,7 @@ export default {
{ value: "meeting", label: "会议" },
{ value: "calendar", label: "日历" },
{ value: "word-chain", label: "接龙" },
{ value: "vote", label: "投票" },
];
// wap
let appApplyList = this.windowOrientation != 'portrait' ? (
@ -418,7 +419,11 @@ export default {
return;
case 'word-chain':
this.sendData = [];
this.$refs.wordChain.onSelection()
this.$refs.wordChainRef.onSelection()
return;
case 'vote':
this.sendData = [];
this.$refs.wordChainRef.onSelection()
return;
}
this.$emit("on-click", item.value)
@ -549,12 +554,12 @@ export default {
},
});
},
//
//
onWordChain(){
const dialog_id = Number(this.sendData[0].replace('d:', ''))
if(this.windowPortrait){
this.$store.dispatch("openDialog", dialog_id ).then(() => {
this.$store.state.wordChain = {
this.$store.state.dialogDroupWordChain = {
type: 'create',
dialog_id: dialog_id
}
@ -562,13 +567,12 @@ export default {
}else{
this.goForward({ name: 'manage-messenger', params: { dialog_id: dialog_id}});
setTimeout(()=>{
this.$store.state.wordChain = {
this.$store.state.dialogDroupWordChain = {
type: 'create',
dialog_id: dialog_id
}
},100)
}
}
}
}

View File

@ -102,14 +102,18 @@
<i class="taskfont">&#xe690;</i>
{{$L('匿名消息')}}
</div>
<div v-if="dialogData.type == 'group'" class="chat-input-popover-item" @click="onToolbar('word-chain')">
<i class="taskfont">&#xe807;</i>
{{$L('接龙')}}
</div>
<div v-if="dialogData.type == 'group'" class="chat-input-popover-item" @click="onToolbar('vote')">
<i class="taskfont">&#xe806;</i>
{{$L('投票')}}
</div>
<div class="chat-input-popover-item" @click="onToolbar('full')">
<i class="taskfont">&#xe6a7;</i>
{{$L('全屏输入')}}
</div>
<div v-if="dialogData.type == 'group'" class="chat-input-popover-item" @click="onToolbar('chain-reaction')">
<i class="taskfont">&#xe807;</i>
{{$L('接龙')}}
</div>
</EPopover>
</li>
@ -1233,12 +1237,20 @@ export default {
this.$emit('on-more', action)
break;
case 'chain-reaction':
this.$store.state.wordChain = {
case 'word-chain':
this.$store.state.dialogDroupWordChain = {
type: 'create',
dialog_id: this.dialogId
}
break;
case 'vote':
this.$store.state.dialogGroupVote = {
type: 'create',
dialog_id: this.dialogId
}
break;
}
},

View File

@ -0,0 +1,238 @@
<template>
<Modal class-name="dialog-droup-word-chain"
v-model="show"
:mask-closable="false"
:title="dialogGroupVote.type == 'create' ? $L('发起投票') : $L('投票结果')"
:closable="!isFullscreen"
:fullscreen="isFullscreen"
:footer-hide="isFullscreen">
<!-- 顶部 -->
<template #header>
<div v-if="isFullscreen" class="chain-modal-header">
<div class="chain-modal-close" @click="show = false">
{{ $L('取消') }}
</div>
<div class="chain-modal-title">
{{ dialogGroupVote.type == 'create' ? $L('发起接龙') : $L('接龙结果') }}
</div>
<div class="chain-modal-submit" :class="{'disabled': !isEdit}" @click="onSend" >
<div v-if="loadIng > 0" class="submit-loading"><Loading /></div>
{{$L('发送')}}
</div>
</div>
</template>
<template #close>
<i class="ivu-icon ivu-icon-ios-close"></i>
</template>
<div ref="wordChainBodyRef" class="word-chain-body">
<div class="source" v-if="dialogGroupVote.type == 'create'">
{{$L('来自')}}
<span>{{ dialog.name }}</span>
</div>
<div class="initiate">
<span>{{ $L('由') }}</span>
<UserAvatar :userid="createId" :size="22" :showName="true" tooltipDisabled/>
<span> {{ $L('发起') }}</span>
</div>
<div class="textarea">
<Input ref="wordChainTextareaRef"
v-model="value"
type="textarea"
:placeholder="$L('请输入投票主题')"
:autosize="{minRows: 3,maxRows: 5}"
:disabled="dialogGroupVote.type != 'create'" />
</div>
<ul ref="wordChainListRef">
<li v-for="(item,index) in list">
<span>
<i class="taskfont" @click="del">&#xe680;</i>
</span>
<Input v-model="item.text" :disabled="item.userid != userId" :placeholder="$L('请输入选项内容')"/>
</li>
<li class="add">
<i class="taskfont" @click="add">&#xe78c;</i>
</li>
</ul>
</div>
<div slot="footer">
<Button type="default" @click="show=false">{{$L('取消')}}</Button>
<Button type="primary" :loading="loadIng > 0" @click="onSend" :disabled="!isEdit">{{$L('发送')}}</Button>
</div>
</Modal>
</template>
<script>
import {mapState} from "vuex";
export default {
name: 'DialogGroupVote',
data() {
return {
show: false,
createId: 0,
value: "",
list: [],
oldData: '',
loadIng: 0,
}
},
computed: {
...mapState(['dialogGroupVote', 'userInfo', 'dialogMsgs', 'cacheDialogs']),
isFullscreen({ windowWidth }) {
return windowWidth < 576;
},
allList(){
const msg = this.dialogGroupVote.msgData?.msg || {};
let list = JSON.parse(JSON.stringify(msg.list || []));
this.dialogMsgs.filter(h=>{
return h.type == "word-chain" && h.msg?.uuid == msg.uuid
}).forEach((h)=>{
(h.msg.list || []).forEach(k=>{
if(list.map(j=>j.id).indexOf(k.id) == -1){
list.push(k)
}
})
});
return list;
},
isEdit(){
return this.oldData != JSON.stringify(this.list);
},
dialog(){
return this.cacheDialogs.find(h=>h.id == this.dialogGroupVote.dialog_id) || {}
},
},
watch: {
show(val){
if(!val){
this.value = "";
this.list = [];
}else{
if(this.dialogGroupVote.type == 'create'){
this.$nextTick(()=>{
this.$refs.wordChainTextareaRef.focus()
})
}
this.scrollTo();
}
},
dialogGroupVote(data) {
if(data.type == 'create' && data.dialog_id){
this.show = true;
this.createId = this.userId;
this.list.push({
id: Date.now(),
userid: this.userId,
text: ""
});
this.list.push({
id: Date.now() + 1,
userid: this.userId,
text: ""
});
}
if(data.type == 'participate' && data.dialog_id && data.msgData){
this.show = true;
this.createId = data.msgData.msg.userid;
this.value = data.msgData.msg.text;
this.list = this.allList;
this.oldData = JSON.stringify(this.list);
}
}
},
methods: {
add(){
this.list.push({
id: Date.now(),
type: 'text',
userid: this.userId,
text: this.userInfo.nickname,
});
this.scrollTo();
},
del(){
this.list.push({
id: Date.now(),
type: 'text',
userid: this.userId,
text: this.userInfo.nickname,
});
},
scrollTo(){
this.$nextTick(()=>{
this.$refs.wordChainListRef.scrollTo(0, 99999);
});
},
onSend() {
if( !this.isEdit ){
return;
}
const texts = this.list.map(h=> h.text);
if( texts.length != [...new Set(texts)].length ){
$A.modalConfirm({
content: '重复内容将不再计入接龙结果',
cancelText: '返回编辑',
okText: '继续发送',
onOk: () => {
this.send()
}
})
return;
}
this.send();
},
/**
* 发送消息
*/
send() {
const list = [];
this.list.forEach(h=>{
if( list.map(h=> h.text).indexOf(h.text) == -1){
list.push(h);
}
});
//
this.loadIng++;
this.$store.dispatch("call", {
url: 'dialog/msg/wordchain',
method: 'post',
data: {
dialog_id: this.dialogGroupVote.dialog_id,
text: this.value,
list: list,
uuid: this.dialogGroupVote.msgData?.msg?.uuid || ''
}
}).then(({data}) => {
this.show = false;
this.$store.dispatch("saveDialogMsg", data);
}).catch(({msg}) => {
if( msg.indexOf("System error") !== -1){
$A.modalInfo({
language: false,
title: '版本过低',
content: '服务器版本过低,请升级服务器。',
})
return;
}
$A.modalError(msg);
}).finally(_ => {
this.loadIng--;
});
}
}
}
</script>

View File

@ -1,8 +1,8 @@
<template>
<Modal class-name="word-chain-wrapper"
<Modal class-name="dialog-droup-word-chain"
v-model="show"
:mask-closable="false"
:title="wordChain.type == 'create' ? $L('发起接龙') : $L('接龙结果')"
:title="dialogDroupWordChain.type == 'create' ? $L('发起接龙') : $L('接龙结果')"
:closable="!isFullscreen"
:fullscreen="isFullscreen"
:footer-hide="isFullscreen">
@ -13,7 +13,7 @@
{{ $L('取消') }}
</div>
<div class="chain-modal-title">
{{ wordChain.type == 'create' ? $L('发起接龙') : $L('接龙结果') }}
{{ dialogDroupWordChain.type == 'create' ? $L('发起接龙') : $L('接龙结果') }}
</div>
<div class="chain-modal-submit" :class="{'disabled': !isEdit}" @click="onSend" >
<div v-if="loadIng > 0" class="submit-loading"><Loading /></div>
@ -25,7 +25,7 @@
<i class="ivu-icon ivu-icon-ios-close"></i>
</template>
<div ref="wordChainBodyRef" class="word-chain-body">
<div class="source" v-if="wordChain.type == 'create'">
<div class="source" v-if="dialogDroupWordChain.type == 'create'">
{{$L('来自')}}
<span>{{ dialog.name }}</span>
</div>
@ -35,16 +35,16 @@
<span> {{ $L('发起,参与接龙目前共'+num+'人') }}</span>
</div>
<div class="textarea">
<Input ref="wordChainTextareaRef" v-model="value" type="textarea" :autosize="{minRows: 3,maxRows: 5}" :disabled="wordChain.type != 'create'" />
<Input ref="wordChainTextareaRef" v-model="value" type="textarea" :autosize="{minRows: 3,maxRows: 5}" :disabled="dialogDroupWordChain.type != 'create'" />
</div>
<ul ref="wordChainListRef">
<li v-for="(item,index) in list" :key="index" v-if="item.type == 'case' && (wordChain.type == 'create' || item.text)">
<li v-for="(item,index) in list" v-if="item.type == 'case' && (dialogDroupWordChain.type == 'create' || item.text)">
<span>{{ $L('例') }}</span>
<Input v-model="item.text" :placeholder="$L('可填写接龙格式')" :disabled="wordChain.type != 'create'" />
<Input v-model="item.text" :placeholder="$L('可填写接龙格式')" :disabled="dialogDroupWordChain.type != 'create'" />
</li>
<li v-for="(item,index) in list" :key="index" v-if="item.type != 'case'">
<span>{{index}}</span>
<Input v-model="item.text" :disabled="item.userid != userId"/>
<li v-for="(item,index) in list.filter(h=>h.type != 'case')">
<span>{{index + 1}}</span>
<Input v-model="item.text" :disabled="item.userid != userId" :placeholder="$L('请输入接龙内容')"/>
</li>
<li class="add">
<i class="taskfont" @click="add">&#xe78c;</i>
@ -61,7 +61,7 @@
<script>
import {mapState} from "vuex";
export default {
name: 'WordChain',
name: 'DialogDroupWordChain',
data() {
return {
@ -77,7 +77,7 @@ export default {
},
computed: {
...mapState(['wordChain', 'userInfo', 'dialogMsgs', 'cacheDialogs']),
...mapState(['dialogDroupWordChain', 'userInfo', 'dialogMsgs', 'cacheDialogs']),
isFullscreen({ windowWidth }) {
return windowWidth < 576;
@ -88,9 +88,10 @@ export default {
},
allList(){
let list = JSON.parse(JSON.stringify(this.wordChain.msgData?.msg?.list)) || [];
const msg = this.dialogDroupWordChain.msgData?.msg || {};
let list = JSON.parse(JSON.stringify(msg.list || []));
this.dialogMsgs.filter(h=>{
return h.type == "word-chain" && h.msg?.uuid == this.wordChain.msgData?.msg?.uuid
return h.type == "word-chain" && h.msg?.uuid == msg.uuid
}).forEach((h)=>{
(h.msg.list || []).forEach(k=>{
if( k.type != 'case' && list.map(j=>j.id).indexOf(k.id) == -1 ){
@ -102,11 +103,11 @@ export default {
},
isEdit(){
return this.oldData != JSON.stringify(this.list)
return this.oldData != JSON.stringify(this.list);
},
dialog(){
return this.cacheDialogs.find(h=>h.id == this.wordChain.dialog_id) || {}
return this.cacheDialogs.find(h=>h.id == this.dialogDroupWordChain.dialog_id) || {}
},
},
@ -116,37 +117,38 @@ export default {
this.value = "#接龙 \n";
this.list = [];
}else{
if(this.wordChain.type == 'create'){
if(this.dialogDroupWordChain.type == 'create'){
this.$nextTick(()=>{
this.$refs.wordChainTextareaRef.focus()
})
}
this.scrollTo();
}
},
wordChain(data) {
dialogDroupWordChain(data) {
if(data.type == 'create' && data.dialog_id){
this.show = true;
this.createId = this.userId
this.createId = this.userId;
this.list.push({
id: Date.now(),
type: 'case',
type: "case",
userid: this.userId,
text: '',
})
text: ""
});
this.list.push({
id: Date.now() + 1,
type: 'text',
type: "text",
userid: this.userId,
text: this.userInfo.nickname,
})
text: this.userInfo.nickname
});
}
if(data.type == 'participate' && data.dialog_id && data.msgData){
this.show = true;
this.createId = data.msgData.msg.userid
this.value = data.msgData.msg.text
this.list = this.allList
this.oldData = JSON.stringify(this.list)
this.createId = data.msgData.msg.userid;
this.value = data.msgData.msg.text;
this.list = this.allList;
this.oldData = JSON.stringify(this.list);
}
}
},
@ -158,10 +160,14 @@ export default {
type: 'text',
userid: this.userId,
text: this.userInfo.nickname,
})
});
this.scrollTo();
},
scrollTo(){
this.$nextTick(()=>{
this.$refs.wordChainListRef.scrollTo(0, 99999);
})
});
},
onSend() {
@ -180,7 +186,7 @@ export default {
})
return;
}
this.send()
this.send();
},
/**
@ -188,21 +194,30 @@ export default {
*/
send() {
const list = [];
let isEmpty = false;
this.list.forEach(h=>{
if( list.map(h=> h.text).indexOf(h.text) == -1){
if(!h.text && h.type != "case"){
isEmpty = true;
return;
}
if( h.text && list.map(h=> h.text).indexOf(h.text) == -1){
list.push(h);
}
});
if(isEmpty){
$A.messageError("请输入接龙内容");
return;
}
//
this.loadIng++;
this.$store.dispatch("call", {
url: 'dialog/msg/wordchain',
method: 'post',
data: {
dialog_id: this.wordChain.dialog_id,
dialog_id: this.dialogDroupWordChain.dialog_id,
text: this.value,
list: list,
uuid: this.wordChain.msgData?.msg?.uuid || ''
uuid: this.dialogDroupWordChain.msgData?.msg?.uuid || ''
}
}).then(({data}) => {
this.show = false;

View File

@ -70,13 +70,15 @@
<div v-else-if="msgData.type === 'word-chain'" class="content-text content-word-chain no-dark-content">
<pre v-html="$A.formatTextMsg(msgData.msg.text, userId)"></pre>
<ul>
<li v-for="(item,index) in (msgData.msg.list || [])" :key="index">
<span class="expand" v-if="index == 2 && index != msgData.msg.list.length - 1 && msgData.msg.list.length > 4" @click="unfoldWordChain">
<li v-for="(item) in (msgData.msg.list || []).filter(h=>h.type == 'case')">
{{ $L('例') }} {{ item.text }}
</li>
<li v-for="(item,index) in (msgData.msg.list || []).filter(h=>h.type != 'case')">
<span class="expand" v-if="index == 2 && msgData.msg.list.length > 4" @click="unfoldWordChain">
...{{$L('展开')}}...
</span>
<span :class="{'shrink': index >= 2 && index != msgData.msg.list.length - 1 && msgData.msg.list.length > 4 } ">
<span v-if="item.type == 'case' && item.text">{{ $L('') }} {{ item.text }}</span>
<span v-else-if="item.type != 'case'">{{index}}. {{item.text}}</span>
<span :class="{'shrink': index >= 2 && msgData.msg.list.length > 4 } ">
{{index + 1}}. {{item.text}}
</span>
</li>
<li @click="onWordChain" class="participate">{{ $L('参与接龙') }}<span>></span></li>
@ -522,7 +524,7 @@ export default {
},
onWordChain(){
this.$store.state.wordChain = {
this.$store.state.dialogDroupWordChain = {
type: 'participate',
dialog_id: this.msgData.dialog_id,
msgData: this.msgData,

View File

@ -535,6 +535,13 @@
<DrawerOverlay v-model="approveDetailsShow" placement="right" :size="600">
<ApproveDetails v-if="approveDetailsShow" :data="approveDetails" style="height: 100%;border-radius: 10px;"></ApproveDetails>
</DrawerOverlay>
<!-- 群接龙 -->
<DialogGroupWordChain/>
<!-- 群投票 -->
<DialogGroupVote/>
</div>
</template>
@ -554,6 +561,9 @@ import {choiceEmojiOne} from "./ChatInput/one";
import ApproveDetails from "../../../pages/manage/approve/details.vue";
import UserSelect from "../../../components/UserSelect.vue";
import DialogGroupWordChain from "./DialogGroupWordChain";
import DialogGroupVote from "./DialogGroupVote";
export default {
name: "DialogWrapper",
@ -567,7 +577,9 @@ export default {
DialogGroupInfo,
DrawerOverlay,
DialogUpload,
ApproveDetails
ApproveDetails,
DialogGroupWordChain,
DialogGroupVote,
},
props: {

View File

@ -50,7 +50,7 @@
</EDropdownItem>
<EDropdownItem command="move">
<div class="item">
<Icon type="md-move" />{{$L('移动')}}
<i class="taskfont movefont">&#xe7fc;</i>{{$L('移动')}}
</div>
</EDropdownItem>
<EDropdownItem command="remove">

View File

@ -112,6 +112,8 @@ export default {
dialogDraftTimer: {},
dialogMsgTransfer: {time: 0},
dialogSseList: [],
dialogDroupWordChain: {},
dialogGroupVote: {},
// 搜索关键词(主要用于移动端判断滑动返回)
messengerSearchKey: {dialog: '', contacts: ''},
@ -209,9 +211,6 @@ export default {
meetingid: 0
},
// 接龙
wordChain: {},
// okr窗口
okrWindow: {
type: 'open',

View File

@ -29,4 +29,4 @@
@import "project-menu";
@import "calendar";
@import "home-calendar";
@import "word-chain";
@import "dialog-droup-word-chain";

View File

@ -1,4 +1,4 @@
.word-chain-wrapper {
.dialog-droup-word-chain {
.ivu-modal-body{
max-height: calc(100vh - 365px);
overflow: auto;
@ -57,6 +57,7 @@
height: 100%;
max-height: calc(100vh - 370px);
.source{
padding-top: 10px;
margin-right: 32px;
span{
color: #84C56A;
@ -120,7 +121,7 @@
}
body.window-portrait {
.word-chain-wrapper {
.dialog-droup-word-chain {
.ivu-modal-body{
padding-top: 10px !important;
max-height: 100%;
@ -129,9 +130,4 @@ body.window-portrait {
max-height: 100%;
}
}
@media (max-width: 640px) {
.word-chain-wrapper {
}
}
}

View File

@ -980,7 +980,7 @@
margin-left: 2px;
}
}
&.expand{
&.expand,li:nth-last-child(2){
.expand{
display: none;
}

View File

@ -49,6 +49,11 @@
&.ivu-icon {
font-size: 16px;
}
&.movefont{
font-size: 14px;
text-align: center;
}
}
}