|
|
@@ -90,196 +90,201 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
- import { onMounted, ref, reactive, watch, watchEffect } from 'vue';
|
|
|
- import SelectTree from '../persongroup/components/SelectTree.vue';
|
|
|
- import Group from './Group.vue';
|
|
|
- import { recipientTypeName } from '../constant';
|
|
|
- import { ToPushObjectqueryUserGroupList, queryUserGroupDetail } from '../api/index';
|
|
|
- import type { FormInstance } from 'element-plus';
|
|
|
- import { GroupData } from '../persongroup/type';
|
|
|
- const ruleFormRef = ref<FormInstance>();
|
|
|
- const groupInfo = ref<boolean>(false);
|
|
|
- const userInfo = ref<boolean>(false);
|
|
|
- const disabled = ref<boolean>(false);
|
|
|
- export interface customUserList {
|
|
|
- userId: number;
|
|
|
- userLoginName: string;
|
|
|
- userNickname: string;
|
|
|
- userNumber: string;
|
|
|
- }
|
|
|
- export interface userGroupVOList {
|
|
|
- userGroupId: number;
|
|
|
- total: number;
|
|
|
- operatorName: string;
|
|
|
- operationTime: string;
|
|
|
- name: string;
|
|
|
- description: string;
|
|
|
- }
|
|
|
- interface UserList {
|
|
|
- id: string;
|
|
|
- name: string;
|
|
|
- userId: number;
|
|
|
- }
|
|
|
- const selectedUser = ref<UserList[]>([]);
|
|
|
- interface RuleForm {
|
|
|
- recipientType?: number;
|
|
|
- userGroupList: number[];
|
|
|
- customUserList: UserList[];
|
|
|
- }
|
|
|
- const ruleForm = reactive<RuleForm>({
|
|
|
- userGroupList: [],
|
|
|
- customUserList: [],
|
|
|
- });
|
|
|
- const props = defineProps<{
|
|
|
- recipientType?: number;
|
|
|
- userGroupList?: userGroupVOList[];
|
|
|
- customUserList?: customUserList[];
|
|
|
- disabled?: boolean;
|
|
|
- }>();
|
|
|
- const emit = defineEmits(['submitWithForm']);
|
|
|
- interface Options {
|
|
|
- userGroupId?: number;
|
|
|
- name?: string;
|
|
|
- description: string;
|
|
|
- total: number;
|
|
|
- operatorName: string;
|
|
|
- operationTime: string;
|
|
|
- }
|
|
|
- const options = ref<Options[]>([]);
|
|
|
- const userGroupInfo = ref<GroupData[]>();
|
|
|
- const queryGroupInfo = (groupList) => {
|
|
|
- groupInfo.value = true;
|
|
|
- queryUserGroupDetail(groupList).then((res) => {
|
|
|
- userGroupInfo.value = res.map((group) => ({
|
|
|
- ...group,
|
|
|
- isExpand: false,
|
|
|
- isHidden: false,
|
|
|
- }));
|
|
|
- });
|
|
|
- };
|
|
|
- const submitForm = () => {
|
|
|
- return ruleFormRef.value!.validate(() => {});
|
|
|
- };
|
|
|
- const validateForm = () => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- ruleFormRef
|
|
|
- .value!.validate(() => {})
|
|
|
- .then((valid) => {
|
|
|
- if (valid) {
|
|
|
- const res = getChildValue();
|
|
|
- emit('submitWithForm', res);
|
|
|
- resolve(() => {});
|
|
|
- } else {
|
|
|
- reject(new Error('error submit!'));
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- };
|
|
|
- const getChildValue = () => {
|
|
|
- return {
|
|
|
- recipientType: ruleForm.recipientType,
|
|
|
- userGroupList:
|
|
|
- ruleForm.recipientType === 3
|
|
|
- ? []
|
|
|
- : ruleForm.recipientType === 1
|
|
|
- ? []
|
|
|
- : ruleForm.userGroupList.map((item) => item),
|
|
|
- customUserList:
|
|
|
- ruleForm.recipientType === 2
|
|
|
- ? []
|
|
|
- : ruleForm.recipientType === 1
|
|
|
- ? []
|
|
|
- : ruleForm.customUserList.map((item) => item.userId),
|
|
|
- };
|
|
|
- };
|
|
|
- const handleCancle = () => {
|
|
|
- userInfo.value = false;
|
|
|
- };
|
|
|
- const handleSubmit = (selectedData: UserList[]) => {
|
|
|
- selectedUser.value = selectedData;
|
|
|
- ruleForm.customUserList = selectedUser.value;
|
|
|
- userInfo.value = false;
|
|
|
- };
|
|
|
- const formatCustomUserList = (customList: customUserList[]): UserList[] => {
|
|
|
- return customList.map((item) => ({
|
|
|
- id: `u${item.userId}`,
|
|
|
- userId: item.userId,
|
|
|
- name: `${item.userLoginName}-${item.userNickname}`,
|
|
|
+import { onMounted, ref, reactive, watch, watchEffect } from 'vue';
|
|
|
+import SelectTree from '../persongroup/components/SelectTree.vue';
|
|
|
+import Group from './Group.vue';
|
|
|
+import { recipientTypeName } from '../constant';
|
|
|
+import { ToPushObjectqueryUserGroupList, queryUserGroupDetail } from '../api/index';
|
|
|
+import type { FormInstance } from 'element-plus';
|
|
|
+import { GroupData } from '../persongroup/type';
|
|
|
+const ruleFormRef = ref<FormInstance>();
|
|
|
+const groupInfo = ref<boolean>(false);
|
|
|
+const userInfo = ref<boolean>(false);
|
|
|
+const disabled = ref<boolean>(false);
|
|
|
+export interface customUserList {
|
|
|
+ userId: number;
|
|
|
+ userLoginName: string;
|
|
|
+ userNickname: string;
|
|
|
+ userNumber: string;
|
|
|
+}
|
|
|
+export interface userGroupVOList {
|
|
|
+ userGroupId: number;
|
|
|
+ total: number;
|
|
|
+ operatorName: string;
|
|
|
+ operationTime: string;
|
|
|
+ name: string;
|
|
|
+ description: string;
|
|
|
+}
|
|
|
+interface UserList {
|
|
|
+ id: string;
|
|
|
+ name: string;
|
|
|
+ userId: number;
|
|
|
+}
|
|
|
+const selectedUser = ref<UserList[]>([]);
|
|
|
+interface RuleForm {
|
|
|
+ recipientType?: number;
|
|
|
+ userGroupList: number[];
|
|
|
+ customUserList: UserList[];
|
|
|
+}
|
|
|
+const ruleForm = reactive<RuleForm>({
|
|
|
+ userGroupList: [],
|
|
|
+ customUserList: [],
|
|
|
+});
|
|
|
+const props = defineProps<{
|
|
|
+ recipientType?: number;
|
|
|
+ userGroupList?: userGroupVOList[];
|
|
|
+ customUserList?: customUserList[];
|
|
|
+ disabled?: boolean;
|
|
|
+}>();
|
|
|
+const emit = defineEmits(['submitWithForm']);
|
|
|
+interface Options {
|
|
|
+ userGroupId?: number;
|
|
|
+ name?: string;
|
|
|
+ description: string;
|
|
|
+ total: number;
|
|
|
+ operatorName: string;
|
|
|
+ operationTime: string;
|
|
|
+}
|
|
|
+const options = ref<Options[]>([]);
|
|
|
+const userGroupInfo = ref<GroupData[]>();
|
|
|
+const queryGroupInfo = (groupList) => {
|
|
|
+ groupInfo.value = true;
|
|
|
+ queryUserGroupDetail(groupList).then((res) => {
|
|
|
+ userGroupInfo.value = res.map((group) => ({
|
|
|
+ ...group,
|
|
|
+ isExpand: false,
|
|
|
+ isHidden: false,
|
|
|
}));
|
|
|
- };
|
|
|
- defineExpose({
|
|
|
- submitForm,
|
|
|
- validateForm,
|
|
|
- getChildValue,
|
|
|
});
|
|
|
- onMounted(() => {
|
|
|
- ToPushObjectqueryUserGroupList().then((res) => {
|
|
|
- options.value = res.groupVOList;
|
|
|
- });
|
|
|
+};
|
|
|
+const submitForm = () => {
|
|
|
+ return ruleFormRef.value!.validate(() => {});
|
|
|
+};
|
|
|
+const refreshForm = () => {
|
|
|
+ if (!ruleFormRef.value) return;
|
|
|
+ ruleFormRef.value!.resetFields();
|
|
|
+};
|
|
|
+const validateForm = () => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ ruleFormRef
|
|
|
+ .value!.validate(() => {})
|
|
|
+ .then((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const res = getChildValue();
|
|
|
+ emit('submitWithForm', res);
|
|
|
+ resolve(() => {});
|
|
|
+ } else {
|
|
|
+ reject(new Error('error submit!'));
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
- watchEffect(() => {
|
|
|
- if (props.recipientType) {
|
|
|
- ruleForm.recipientType = props.recipientType;
|
|
|
- }
|
|
|
- if (props.userGroupList) {
|
|
|
- ruleForm.userGroupList = props.userGroupList.map((item) => item.userGroupId);
|
|
|
- }
|
|
|
- if (props.customUserList) {
|
|
|
- ruleForm.customUserList = formatCustomUserList(props.customUserList);
|
|
|
- selectedUser.value = formatCustomUserList(props.customUserList);
|
|
|
- }
|
|
|
- if (props.disabled) {
|
|
|
- disabled.value = props.disabled;
|
|
|
- }
|
|
|
+};
|
|
|
+const getChildValue = () => {
|
|
|
+ return {
|
|
|
+ recipientType: ruleForm.recipientType,
|
|
|
+ userGroupList:
|
|
|
+ ruleForm.recipientType === 3
|
|
|
+ ? []
|
|
|
+ : ruleForm.recipientType === 1
|
|
|
+ ? []
|
|
|
+ : ruleForm.userGroupList.map((item) => item),
|
|
|
+ customUserList:
|
|
|
+ ruleForm.recipientType === 2
|
|
|
+ ? []
|
|
|
+ : ruleForm.recipientType === 1
|
|
|
+ ? []
|
|
|
+ : ruleForm.customUserList.map((item) => item.userId),
|
|
|
+ };
|
|
|
+};
|
|
|
+const handleCancle = () => {
|
|
|
+ userInfo.value = false;
|
|
|
+};
|
|
|
+const handleSubmit = (selectedData: UserList[]) => {
|
|
|
+ selectedUser.value = selectedData;
|
|
|
+ ruleForm.customUserList = selectedUser.value;
|
|
|
+ userInfo.value = false;
|
|
|
+};
|
|
|
+const formatCustomUserList = (customList: customUserList[]): UserList[] => {
|
|
|
+ return customList.map((item) => ({
|
|
|
+ id: `u${item.userId}`,
|
|
|
+ userId: item.userId,
|
|
|
+ name: `${item.userLoginName}-${item.userNickname}`,
|
|
|
+ }));
|
|
|
+};
|
|
|
+defineExpose({
|
|
|
+ submitForm,
|
|
|
+ refreshForm,
|
|
|
+ validateForm,
|
|
|
+ getChildValue,
|
|
|
+});
|
|
|
+onMounted(() => {
|
|
|
+ ToPushObjectqueryUserGroupList().then((res) => {
|
|
|
+ options.value = res.groupVOList;
|
|
|
});
|
|
|
- watch(
|
|
|
- () => ruleForm.customUserList,
|
|
|
- (newSelected) => {
|
|
|
- selectedUser.value = newSelected;
|
|
|
- },
|
|
|
- { immediate: true },
|
|
|
- );
|
|
|
+});
|
|
|
+watchEffect(() => {
|
|
|
+ if (props.recipientType) {
|
|
|
+ ruleForm.recipientType = props.recipientType;
|
|
|
+ }
|
|
|
+ if (props.userGroupList) {
|
|
|
+ ruleForm.userGroupList = props.userGroupList.map((item) => item.userGroupId);
|
|
|
+ }
|
|
|
+ if (props.customUserList) {
|
|
|
+ ruleForm.customUserList = formatCustomUserList(props.customUserList);
|
|
|
+ selectedUser.value = formatCustomUserList(props.customUserList);
|
|
|
+ }
|
|
|
+ if (props.disabled) {
|
|
|
+ disabled.value = props.disabled;
|
|
|
+ }
|
|
|
+});
|
|
|
+watch(
|
|
|
+ () => ruleForm.customUserList,
|
|
|
+ (newSelected) => {
|
|
|
+ selectedUser.value = newSelected;
|
|
|
+ },
|
|
|
+ { immediate: true },
|
|
|
+);
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
- .userGroupList {
|
|
|
- margin-left: 12%;
|
|
|
- width: 88%;
|
|
|
- max-height: 120px;
|
|
|
- padding: 12px 17px 12px 12px;
|
|
|
- background: #fafafa;
|
|
|
- border-radius: 4px;
|
|
|
- :deep(.el-form-item) {
|
|
|
- margin-bottom: 12px !important;
|
|
|
- }
|
|
|
- ::v-deep .el-select__selection {
|
|
|
- min-height: 25px;
|
|
|
- max-height: 60px;
|
|
|
- overflow-y: auto;
|
|
|
- }
|
|
|
- span {
|
|
|
- cursor: pointer;
|
|
|
- margin-left: 80px;
|
|
|
- font-weight: 400;
|
|
|
- font-size: 10px;
|
|
|
- color: #1777ff;
|
|
|
- line-height: 14px;
|
|
|
- }
|
|
|
+.userGroupList {
|
|
|
+ margin-left: 12%;
|
|
|
+ width: 88%;
|
|
|
+ max-height: 120px;
|
|
|
+ padding: 12px 17px 12px 12px;
|
|
|
+ background: #fafafa;
|
|
|
+ border-radius: 4px;
|
|
|
+ :deep(.el-form-item) {
|
|
|
+ margin-bottom: 12px !important;
|
|
|
+ }
|
|
|
+ ::v-deep .el-select__selection {
|
|
|
+ min-height: 25px;
|
|
|
+ max-height: 60px;
|
|
|
+ overflow-y: auto;
|
|
|
+ }
|
|
|
+ span {
|
|
|
+ cursor: pointer;
|
|
|
+ margin-left: 80px;
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 10px;
|
|
|
+ color: #1777ff;
|
|
|
+ line-height: 14px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.customUserList {
|
|
|
+ margin-left: 12%;
|
|
|
+ width: 88%;
|
|
|
+ max-height: 120px;
|
|
|
+ padding: 12px 17px 12px 12px;
|
|
|
+ background: #fafafa;
|
|
|
+ border-radius: 4px;
|
|
|
+ :deep(.el-form-item) {
|
|
|
+ margin-bottom: 12px !important;
|
|
|
}
|
|
|
- .customUserList {
|
|
|
- margin-left: 12%;
|
|
|
- width: 88%;
|
|
|
- max-height: 120px;
|
|
|
- padding: 12px 17px 12px 12px;
|
|
|
- background: #fafafa;
|
|
|
- border-radius: 4px;
|
|
|
- :deep(.el-form-item) {
|
|
|
- margin-bottom: 12px !important;
|
|
|
- }
|
|
|
- ::v-deep .el-select__selection {
|
|
|
- min-height: 25px;
|
|
|
- max-height: 60px;
|
|
|
- overflow-y: auto;
|
|
|
- }
|
|
|
+ ::v-deep .el-select__selection {
|
|
|
+ min-height: 25px;
|
|
|
+ max-height: 60px;
|
|
|
+ overflow-y: auto;
|
|
|
}
|
|
|
+}
|
|
|
</style>
|