|
@@ -2,18 +2,31 @@
|
|
|
<div class="push-object-container">
|
|
<div class="push-object-container">
|
|
|
<el-form :model="ruleForm" ref="ruleFormRef">
|
|
<el-form :model="ruleForm" ref="ruleFormRef">
|
|
|
<el-form-item>
|
|
<el-form-item>
|
|
|
- <el-radio-group v-model="ruleForm.recipientType">
|
|
|
|
|
|
|
+ <el-radio-group v-model="ruleForm.recipientType" @change="emits('recipientTypeChange', ruleForm.recipientType)">
|
|
|
<el-radio :value="1">分组</el-radio>
|
|
<el-radio :value="1">分组</el-radio>
|
|
|
<el-radio :value="2">自定义</el-radio>
|
|
<el-radio :value="2">自定义</el-radio>
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<div class="userList" v-if="ruleForm.recipientType === 1">
|
|
<div class="userList" v-if="ruleForm.recipientType === 1">
|
|
|
- <el-form-item label="选择分组" prop="userGroupList" :rules="[{ required: true, message: '请选择分组' }]">
|
|
|
|
|
- <el-select v-model="ruleForm.userGroupList" multiple placeholder="请选择分组" filterable>
|
|
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ label="选择分组"
|
|
|
|
|
+ prop="userGroupList"
|
|
|
|
|
+ :rules="[{ required: true, message: '请选择分组' }]"
|
|
|
|
|
+ class="user-group-list"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="ruleForm.userGroupList"
|
|
|
|
|
+ multiple
|
|
|
|
|
+ placeholder="请选择分组"
|
|
|
|
|
+ filterable
|
|
|
|
|
+ @change="emits('userGroupListChange', ruleForm.userGroupList)"
|
|
|
|
|
+ >
|
|
|
<el-option v-for="item in groupOptions" :key="item.id" :value="item.id" :label="item.name" />
|
|
<el-option v-for="item in groupOptions" :key="item.id" :value="item.id" :label="item.name" />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
|
|
+ <span @click="showGroupInfo" v-if="ruleForm.userGroupList.length > 0" class="group-info-span">
|
|
|
|
|
+ 人员详情
|
|
|
|
|
+ </span>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <span @click="showGroupInfo"> 人员详情 </span>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
<div class="userList" v-else-if="ruleForm.recipientType === 2">
|
|
<div class="userList" v-else-if="ruleForm.recipientType === 2">
|
|
|
<el-form-item label="选择人员" prop="customUserList" :rules="[{ required: true, message: '请选择人员' }]">
|
|
<el-form-item label="选择人员" prop="customUserList" :rules="[{ required: true, message: '请选择人员' }]">
|
|
@@ -64,16 +77,23 @@
|
|
|
import type { GroupOptionType, TreeNodeData } from '../types';
|
|
import type { GroupOptionType, TreeNodeData } from '../types';
|
|
|
import type { UserInfo, UserGroupInfo } from '@/types/push-object';
|
|
import type { UserInfo, UserGroupInfo } from '@/types/push-object';
|
|
|
import { queryUserGroupDetailByIds } from '@/api/push-object';
|
|
import { queryUserGroupDetailByIds } from '@/api/push-object';
|
|
|
|
|
+ import type { FormInstance } from 'element-plus';
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
recipientType: number | null;
|
|
recipientType: number | null;
|
|
|
userGroupList: number[];
|
|
userGroupList: number[];
|
|
|
customUserList: UserInfo[];
|
|
customUserList: UserInfo[];
|
|
|
}>();
|
|
}>();
|
|
|
|
|
+ const emits = defineEmits<{
|
|
|
|
|
+ (e: 'recipientTypeChange', recipientType: number | null): void;
|
|
|
|
|
+ (e: 'userGroupListChange', userGroupList: number[]): void;
|
|
|
|
|
+ (e: 'customUserListChange', customUserList: UserInfo[]): void;
|
|
|
|
|
+ }>();
|
|
|
interface RuleForm {
|
|
interface RuleForm {
|
|
|
- recipientType: number;
|
|
|
|
|
|
|
+ recipientType: number | null;
|
|
|
userGroupList: number[];
|
|
userGroupList: number[];
|
|
|
customUserList: UserInfo[];
|
|
customUserList: UserInfo[];
|
|
|
}
|
|
}
|
|
|
|
|
+ const ruleFormRef = ref<FormInstance>();
|
|
|
const groupOptions = ref<GroupOptionType[]>([
|
|
const groupOptions = ref<GroupOptionType[]>([
|
|
|
{
|
|
{
|
|
|
id: 1,
|
|
id: 1,
|
|
@@ -114,11 +134,22 @@
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
userOptions.value = ruleForm.customUserList;
|
|
userOptions.value = ruleForm.customUserList;
|
|
|
|
|
+ emits('customUserListChange', ruleForm.customUserList);
|
|
|
};
|
|
};
|
|
|
|
|
+ const validateForm = () => {
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
|
|
|
+ ruleFormRef.value?.validate((valid) => {
|
|
|
|
|
+ resolve(valid);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ defineExpose({
|
|
|
|
|
+ validateForm,
|
|
|
|
|
+ });
|
|
|
watch(
|
|
watch(
|
|
|
[() => props.recipientType, () => props.userGroupList, () => props.customUserList],
|
|
[() => props.recipientType, () => props.userGroupList, () => props.customUserList],
|
|
|
([newRecipientType, newUserGroupList, newCustomUserList]) => {
|
|
([newRecipientType, newUserGroupList, newCustomUserList]) => {
|
|
|
- ruleForm.recipientType = newRecipientType ?? 1;
|
|
|
|
|
|
|
+ ruleForm.recipientType = newRecipientType ?? null;
|
|
|
ruleForm.userGroupList = newUserGroupList ?? [];
|
|
ruleForm.userGroupList = newUserGroupList ?? [];
|
|
|
ruleForm.customUserList = newCustomUserList ?? [];
|
|
ruleForm.customUserList = newCustomUserList ?? [];
|
|
|
userOptions.value = ruleForm.customUserList;
|
|
userOptions.value = ruleForm.customUserList;
|
|
@@ -139,11 +170,16 @@
|
|
|
.userList {
|
|
.userList {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
padding: 12cpx 0 0 12cpx;
|
|
padding: 12cpx 0 0 12cpx;
|
|
|
- span {
|
|
|
|
|
- cursor: pointer;
|
|
|
|
|
- font-size: 10cpx;
|
|
|
|
|
- color: $primary-color;
|
|
|
|
|
- margin-left: 80px;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ .user-group-list {
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ }
|
|
|
|
|
+ .group-info-span {
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ bottom: -30px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ font-size: 10cpx;
|
|
|
|
|
+ color: $primary-color;
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|