perf: 优化快捷创建群组

This commit is contained in:
kuaifan 2024-06-02 10:41:33 +08:00
parent 78ad3468ae
commit 617fe902a4
2 changed files with 83 additions and 52 deletions

View File

@ -186,7 +186,9 @@
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="project">{{$L('新建项目')}} ({{mateName}}+B)</DropdownItem>
<DropdownItem name="task">{{$L('新建任务')}} ({{mateName}}+K)</DropdownItem>
<DropdownItem name="group">{{$L('创建群组')}} ({{mateName}}+U)</DropdownItem>
<DropdownItem name="createMeeting">{{$L('新会议')}} ({{mateName}}+J)</DropdownItem>
<DropdownItem name="joinMeeting">{{$L('加入会议')}}</DropdownItem>
</DropdownMenu>
@ -242,6 +244,28 @@
<TaskAdd ref="addTask" v-model="addTaskShow"/>
</Modal>
<!--创建群组-->
<Modal
v-model="createGroupShow"
:title="$L('创建群组')"
:mask-closable="false">
<Form :model="createGroupData" label-width="auto" @submit.native.prevent>
<FormItem prop="avatar" :label="$L('群头像')">
<ImgUpload v-model="createGroupData.avatar" :num="1" :width="512" :height="512" :whcut="1"/>
</FormItem>
<FormItem prop="userids" :label="$L('群成员')">
<UserSelect v-model="createGroupData.userids" :uncancelable="createGroupData.uncancelable" :multiple-max="100" show-bot :title="$L('选择项目成员')"/>
</FormItem>
<FormItem prop="chat_name" :label="$L('群名称')">
<Input v-model="createGroupData.chat_name" :placeholder="$L('输入群名称(选填)')"/>
</FormItem>
</Form>
<div slot="footer" class="adaption">
<Button type="default" @click="createGroupShow=false">{{$L('取消')}}</Button>
<Button type="primary" :loading="createGroupLoad > 0" @click="submitCreateGroup">{{$L('创建')}}</Button>
</div>
</Modal>
<!--导出任务统计-->
<TaskExport v-model="exportTaskShow"/>
@ -335,9 +359,12 @@ import MicroApps from "../components/MicroApps.vue";
import notificationKoro from "notification-koro1";
import {Store} from "le5le-store";
import {MarkdownPreview} from "../store/markdown";
import UserSelect from "../components/UserSelect.vue";
import ImgUpload from "../components/ImgUpload.vue";
export default {
components: {
ImgUpload, UserSelect,
TaskExport,
CheckinExport,
ApproveExport,
@ -379,6 +406,11 @@ export default {
addTaskShow: false,
addTaskSubscribe: null,
createGroupShow: false,
createGroupData: {},
createGroupLoad: 0,
createGroupSubscribe: null,
exportTaskShow: false,
exportCheckinShow: false,
exportApproveShow: false,
@ -418,6 +450,7 @@ export default {
this.notificationInit();
//
this.addTaskSubscribe = Store.subscribe('addTask', this.onAddTask);
this.createGroupSubscribe = Store.subscribe('createGroup', this.onCreateGroup);
this.dialogMsgSubscribe = Store.subscribe('dialogMsgPush', this.addDialogMsg);
//
document.addEventListener('keydown', this.shortcutEvent);
@ -441,6 +474,10 @@ export default {
this.addTaskSubscribe.unsubscribe();
this.addTaskSubscribe = null;
}
if (this.createGroupSubscribe) {
this.createGroupSubscribe.unsubscribe();
this.createGroupSubscribe = null;
}
if (this.dialogMsgSubscribe) {
this.dialogMsgSubscribe.unsubscribe();
this.dialogMsgSubscribe = null;
@ -846,10 +883,18 @@ export default {
onAddMenu(name) {
switch (name) {
case 'project':
this.onAddShow()
break;
case 'task':
this.onAddTask(0)
break;
case 'group':
this.onCreateGroup([this.userId])
break;
case 'createMeeting':
Store.set('addMeeting', {
type: 'create',
@ -922,17 +967,21 @@ export default {
this.onAddShow()
break;
case 75:
case 78: // K/N -
e.preventDefault();
this.onAddMenu('task')
break;
case 85: // U -
this.onCreateGroup([this.userId])
break;
case 74: // J -
e.preventDefault();
this.onAddMenu('createMeeting')
break;
case 75:
case 78: // K/N -
e.preventDefault();
this.onAddMenu('task')
break;
case 83: // S -
if (this.$refs.taskModal.checkUpdate()) {
e.preventDefault();
@ -966,6 +1015,33 @@ export default {
this.$store.dispatch("openTask", task)
},
onCreateGroup(userids) {
if (!$A.isArray(userids)) {
userids = []
}
this.createGroupData = {userids, uncancelable: [this.userId]}
this.createGroupShow = true
},
submitCreateGroup() {
this.createGroupLoad++;
this.$store.dispatch("call", {
url: 'dialog/group/add',
data: this.createGroupData
}).then(({data, msg}) => {
$A.messageSuccess(msg);
this.createGroupShow = false;
this.createGroupData = {};
this.$store.dispatch("saveDialog", data);
this.$store.dispatch('openDialog', data.id)
this.toggleRoute('messenger', {dialogAction: 'dialog'})
}).catch(({msg}) => {
$A.modalError(msg);
}).finally(_ => {
this.createGroupLoad--;
});
},
addDialogMsg(data) {
if (!this.natificationReady && !this.$isEEUiApp) {
return; //

View File

@ -395,28 +395,6 @@
</ul>
</Modal>
<!--创建群组-->
<Modal
v-model="createGroupShow"
:title="$L('创建群组')"
:mask-closable="false">
<Form :model="createGroupData" label-width="auto" @submit.native.prevent>
<FormItem prop="avatar" :label="$L('群头像')">
<ImgUpload v-model="createGroupData.avatar" :num="1" :width="512" :height="512" :whcut="1"/>
</FormItem>
<FormItem prop="userids" :label="$L('群成员')">
<UserSelect v-model="createGroupData.userids" :uncancelable="createGroupData.uncancelable" :multiple-max="100" show-bot :title="$L('选择项目成员')"/>
</FormItem>
<FormItem prop="chat_name" :label="$L('群名称')">
<Input v-model="createGroupData.chat_name" :placeholder="$L('输入群名称(选填)')"/>
</FormItem>
</Form>
<div slot="footer" class="adaption">
<Button type="default" @click="createGroupShow=false">{{$L('取消')}}</Button>
<Button type="primary" :loading="createGroupLoad > 0" @click="onCreateGroup">{{$L('创建')}}</Button>
</div>
</Modal>
<!--修改资料-->
<Modal
v-model="modifyShow"
@ -772,10 +750,6 @@ export default {
searchLocation: 1,
searchResult: [],
createGroupShow: false,
createGroupData: {},
createGroupLoad: 0,
modifyShow: false,
modifyData: {},
modifyLoad: 0,
@ -2460,8 +2434,7 @@ export default {
if (this.dialogData.dialog_user && this.userId != this.dialogData.dialog_user.userid) {
userids.push(this.dialogData.dialog_user.userid)
}
this.createGroupData = {userids, uncancelable: [this.userId]}
this.createGroupShow = true
Store.set('createGroup', userids);
break;
case "modifyNormal":
@ -2606,24 +2579,6 @@ export default {
});
},
onCreateGroup() {
this.createGroupLoad++;
this.$store.dispatch("call", {
url: 'dialog/group/add',
data: this.createGroupData
}).then(({data, msg}) => {
$A.messageSuccess(msg);
this.createGroupShow = false;
this.createGroupData = {};
this.$store.dispatch("saveDialog", data);
this.$store.dispatch('openDialog', data.id)
}).catch(({msg}) => {
$A.modalError(msg);
}).finally(_ => {
this.createGroupLoad--;
});
},
onModify() {
if (this.modifyData.userid) {
//