|
@@ -30,16 +30,17 @@
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
- import { ref, reactive, onMounted } from 'vue';
|
|
|
|
|
|
|
+ import { ref, reactive, onMounted, computed } from 'vue';
|
|
|
import { storeToRefs } from 'pinia';
|
|
import { storeToRefs } from 'pinia';
|
|
|
- import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
|
|
|
|
+ import { ElMessage } from 'element-plus';
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
import { useUserStore } from '@/store/modules/user';
|
|
|
import {
|
|
import {
|
|
|
addSystemMessage,
|
|
addSystemMessage,
|
|
|
confirmReportConfig,
|
|
confirmReportConfig,
|
|
|
|
|
+ updateSystemMessage,
|
|
|
viewSystemMessage,
|
|
viewSystemMessage,
|
|
|
} from '@/api/message/sysnotion-config';
|
|
} from '@/api/message/sysnotion-config';
|
|
|
- import { RuleFormProps, MessageTypeEnum } from './type';
|
|
|
|
|
|
|
+ import { RuleFormView, MessageTypeEnum, ContentTypeEnum, RuleFormAdd } from './type';
|
|
|
import BasicInfo from './compontents/BasicInfo.vue';
|
|
import BasicInfo from './compontents/BasicInfo.vue';
|
|
|
import ContentConfig from './compontents/ContentConfig.vue';
|
|
import ContentConfig from './compontents/ContentConfig.vue';
|
|
|
import RightCard from './compontents/RightCard.vue';
|
|
import RightCard from './compontents/RightCard.vue';
|
|
@@ -49,21 +50,24 @@
|
|
|
const { info } = storeToRefs(useUser);
|
|
const { info } = storeToRefs(useUser);
|
|
|
const basicInfoRef = ref<InstanceType<typeof BasicInfo>>();
|
|
const basicInfoRef = ref<InstanceType<typeof BasicInfo>>();
|
|
|
const contentConfigRef = ref<InstanceType<typeof ContentConfig>>();
|
|
const contentConfigRef = ref<InstanceType<typeof ContentConfig>>();
|
|
|
- const ruleForm = reactive<RuleFormProps>({
|
|
|
|
|
|
|
+ const ruleForm = reactive<RuleFormView>({
|
|
|
messageType: MessageTypeEnum.BANNER,
|
|
messageType: MessageTypeEnum.BANNER,
|
|
|
- bannerUrl: '',
|
|
|
|
|
title: '',
|
|
title: '',
|
|
|
|
|
+ bannerUrl: '',
|
|
|
pushChannel: [],
|
|
pushChannel: [],
|
|
|
- recipientType: {},
|
|
|
|
|
expirationTime: '',
|
|
expirationTime: '',
|
|
|
|
|
+ recipientType: 1, // 全员
|
|
|
|
|
+ userGroupList: [],
|
|
|
|
|
+ customUserList: [],
|
|
|
introduction: '',
|
|
introduction: '',
|
|
|
- contentType: 1,
|
|
|
|
|
|
|
+ contentType: ContentTypeEnum.RICHTEXT,
|
|
|
content: '',
|
|
content: '',
|
|
|
|
|
+ contentUrl: '',
|
|
|
operator: info.value.nickname,
|
|
operator: info.value.nickname,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 原始数据副本
|
|
// 原始数据副本
|
|
|
- let originalData: RuleFormProps = {
|
|
|
|
|
|
|
+ let originalData: RuleFormView = {
|
|
|
...ruleForm,
|
|
...ruleForm,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -86,12 +90,14 @@
|
|
|
ruleForm.messageType = res.messageType;
|
|
ruleForm.messageType = res.messageType;
|
|
|
ruleForm.content = res.content ? res.content : ' ';
|
|
ruleForm.content = res.content ? res.content : ' ';
|
|
|
ruleForm.pushChannel = res.pushChannel;
|
|
ruleForm.pushChannel = res.pushChannel;
|
|
|
- ruleForm.recipientType.recipientType = res.recipientType;
|
|
|
|
|
|
|
+ ruleForm.recipientType = res.recipientType;
|
|
|
|
|
+
|
|
|
if (res.recipientType === 2) {
|
|
if (res.recipientType === 2) {
|
|
|
- ruleForm.recipientType.userGroupList = res.userGroupList;
|
|
|
|
|
- }
|
|
|
|
|
- if (res.recipientType === 3) {
|
|
|
|
|
- ruleForm.recipientType.customUserList = res.customUserList;
|
|
|
|
|
|
|
+ // 若选择分组
|
|
|
|
|
+ ruleForm.userGroupList = res.userGroupList;
|
|
|
|
|
+ } else if (res.recipientType === 3) {
|
|
|
|
|
+ // 若选择自定义
|
|
|
|
|
+ ruleForm.customUserList = res.customUserList;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -131,33 +137,34 @@
|
|
|
// to save dada
|
|
// to save dada
|
|
|
const baseInfoData = await basicInfoRef.value?.validate();
|
|
const baseInfoData = await basicInfoRef.value?.validate();
|
|
|
const contentConfigData = contentConfigRef.value?.buildFormdata();
|
|
const contentConfigData = contentConfigRef.value?.buildFormdata();
|
|
|
- console.log('contentConfigData: ', contentConfigData);
|
|
|
|
|
- console.log('baseInfoDara: ', baseInfoData);
|
|
|
|
|
|
|
+ console.log('baseInfoData', baseInfoData);
|
|
|
|
|
+ console.log('contentConfigData', contentConfigData);
|
|
|
|
|
|
|
|
- const { messageType, title, pushChannel, expirationTime, bannerUrl, recipientType } =
|
|
|
|
|
- baseInfoData;
|
|
|
|
|
- const params = {
|
|
|
|
|
|
|
+ const params: RuleFormAdd = {
|
|
|
|
|
+ ...baseInfoData!,
|
|
|
...contentConfigData,
|
|
...contentConfigData,
|
|
|
- messageType,
|
|
|
|
|
- title,
|
|
|
|
|
- pushChannel,
|
|
|
|
|
- expirationTime,
|
|
|
|
|
- bannerUrl,
|
|
|
|
|
- recipientType: recipientType.recipientType,
|
|
|
|
|
- customUserList: recipientType.customUserList,
|
|
|
|
|
- userGroupList: recipientType.userGroupList,
|
|
|
|
|
- contentUrl: '',
|
|
|
|
|
};
|
|
};
|
|
|
delete params.operator;
|
|
delete params.operator;
|
|
|
- addSystemMessage(params).then((res) => {
|
|
|
|
|
- if (res) {
|
|
|
|
|
- ruleForm.id = res;
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (!sysId) {
|
|
|
|
|
+ addSystemMessage(params).then((res) => {
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ ruleForm.id = res;
|
|
|
|
|
+ ElMessage({
|
|
|
|
|
+ message: '暂存成功!',
|
|
|
|
|
+ type: 'success',
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ updateSystemMessage(params).then(() => {
|
|
|
ElMessage({
|
|
ElMessage({
|
|
|
- message: '暂存成功!',
|
|
|
|
|
- type: 'success',
|
|
|
|
|
|
|
+ message: '编辑成功!',
|
|
|
|
|
+ type: 'success',
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const submitForm = () => {
|
|
const submitForm = () => {
|
|
@@ -178,11 +185,11 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 比对方法
|
|
// 比对方法
|
|
|
- const compareData = (newData: RuleFormProps, oldData: RuleFormProps) => {
|
|
|
|
|
- const diff: Partial<Omit<RuleFormProps, 'content'>> = {};
|
|
|
|
|
|
|
+ const compareData = (newData: RuleFormView, oldData: RuleFormView) => {
|
|
|
|
|
+ const diff: Partial<Omit<RuleFormView, 'content'>> = {};
|
|
|
for (const key in newData) {
|
|
for (const key in newData) {
|
|
|
- if (newData[key as keyof RuleFormProps] !== oldData[key as keyof RuleFormProps]) {
|
|
|
|
|
- diff[key as keyof RuleFormProps] = newData[key as keyof RuleFormProps];
|
|
|
|
|
|
|
+ if (newData[key as keyof RuleFormView] !== oldData[key as keyof RuleFormView]) {
|
|
|
|
|
+ diff[key as keyof RuleFormView] = newData[key as keyof RuleFormView];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return diff;
|
|
return diff;
|