|
@@ -30,7 +30,7 @@
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
- import { ref, reactive, onMounted, computed } from 'vue';
|
|
|
|
|
|
|
+ import { ref, reactive, onMounted } from 'vue';
|
|
|
import { storeToRefs } from 'pinia';
|
|
import { storeToRefs } from 'pinia';
|
|
|
import { ElMessage } from 'element-plus';
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
import { useUserStore } from '@/store/modules/user';
|
|
@@ -40,7 +40,7 @@
|
|
|
updateSystemMessage,
|
|
updateSystemMessage,
|
|
|
viewSystemMessage,
|
|
viewSystemMessage,
|
|
|
} from '@/api/message/sysnotion-config';
|
|
} from '@/api/message/sysnotion-config';
|
|
|
- import { RuleFormView, MessageTypeEnum, ContentTypeEnum, RuleFormAdd } from './type';
|
|
|
|
|
|
|
+ import { RuleFormView, MessageTypeEnum, ContentTypeEnum, RuleFormAdd, SysMessageStatus } 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';
|
|
@@ -64,6 +64,7 @@
|
|
|
content: '',
|
|
content: '',
|
|
|
contentUrl: '',
|
|
contentUrl: '',
|
|
|
operator: info.value.nickname,
|
|
operator: info.value.nickname,
|
|
|
|
|
+ status: SysMessageStatus.DRAFT
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 原始数据副本
|
|
// 原始数据副本
|
|
@@ -76,32 +77,27 @@
|
|
|
router.back();
|
|
router.back();
|
|
|
};
|
|
};
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
- const sysId = route.query.id;
|
|
|
|
|
- onMounted(() => {
|
|
|
|
|
- if (sysId) {
|
|
|
|
|
|
|
+ const sysId = Number(route.query.id as string);
|
|
|
|
|
+
|
|
|
|
|
+ const fetchSystemMessage = async () => {
|
|
|
|
|
+ const messageId = sysId || ruleForm.id
|
|
|
|
|
+
|
|
|
|
|
+ // 查看 或 编辑状态
|
|
|
|
|
+ if (messageId) {
|
|
|
isDisabled.value = true;
|
|
isDisabled.value = true;
|
|
|
- viewSystemMessage(Number(sysId)).then((res) => {
|
|
|
|
|
- if (!res?.status) {
|
|
|
|
|
- isDisabled.value = false;
|
|
|
|
|
- }
|
|
|
|
|
- ruleForm.id = Number(sysId);
|
|
|
|
|
- ruleForm.title = res.title;
|
|
|
|
|
- ruleForm.introduction = res.introduction ? res.introduction : '';
|
|
|
|
|
- ruleForm.messageType = res.messageType;
|
|
|
|
|
- ruleForm.content = res.content ? res.content : ' ';
|
|
|
|
|
- ruleForm.pushChannel = res.pushChannel;
|
|
|
|
|
- ruleForm.recipientType = res.recipientType;
|
|
|
|
|
|
|
+ const res = await viewSystemMessage(messageId);
|
|
|
|
|
+ if (res.status === SysMessageStatus.DRAFT) {
|
|
|
|
|
+ isDisabled.value = false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (res.recipientType === 2) {
|
|
|
|
|
- // 若选择分组
|
|
|
|
|
- ruleForm.userGroupList = res.userGroupList;
|
|
|
|
|
- } else if (res.recipientType === 3) {
|
|
|
|
|
- // 若选择自定义
|
|
|
|
|
- ruleForm.customUserList = res.customUserList;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ruleForm.id = messageId;
|
|
|
|
|
+ Object.entries(res).forEach(([key, value]) => {
|
|
|
|
|
+ ruleForm[key] = value;
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// 取消
|
|
// 取消
|
|
|
const onCancel = () => {
|
|
const onCancel = () => {
|
|
@@ -132,38 +128,31 @@
|
|
|
// })
|
|
// })
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// 暂存
|
|
// 暂存
|
|
|
const onSave = async () => {
|
|
const onSave = async () => {
|
|
|
// 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('baseInfoData', baseInfoData);
|
|
|
|
|
- console.log('contentConfigData', contentConfigData);
|
|
|
|
|
|
|
|
|
|
const params: RuleFormAdd = {
|
|
const params: RuleFormAdd = {
|
|
|
...baseInfoData!,
|
|
...baseInfoData!,
|
|
|
...contentConfigData,
|
|
...contentConfigData,
|
|
|
};
|
|
};
|
|
|
delete params.operator;
|
|
delete params.operator;
|
|
|
|
|
+ delete params.status;
|
|
|
|
|
|
|
|
|
|
+ const messageId = sysId || ruleForm.id;
|
|
|
|
|
+
|
|
|
|
|
+ if (!messageId) {
|
|
|
|
|
+ ruleForm.id = await addSystemMessage(params);
|
|
|
|
|
+ ElMessage.success('暂存成功!');
|
|
|
|
|
+ await router.replace(`/message/sysnotion-config?id=${ruleForm.id}`)
|
|
|
|
|
+ fetchSystemMessage();
|
|
|
|
|
|
|
|
- if (!sysId) {
|
|
|
|
|
- addSystemMessage(params).then((res) => {
|
|
|
|
|
- if (res) {
|
|
|
|
|
- ruleForm.id = res;
|
|
|
|
|
- ElMessage({
|
|
|
|
|
- message: '暂存成功!',
|
|
|
|
|
- type: 'success',
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
} else {
|
|
} else {
|
|
|
- updateSystemMessage(params).then(() => {
|
|
|
|
|
- ElMessage({
|
|
|
|
|
- message: '编辑成功!',
|
|
|
|
|
- type: 'success',
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ await updateSystemMessage(params)
|
|
|
|
|
+ ElMessage.success('编辑成功!');
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -180,7 +169,7 @@
|
|
|
message: '下发成功!',
|
|
message: '下发成功!',
|
|
|
type: 'success',
|
|
type: 'success',
|
|
|
});
|
|
});
|
|
|
- router.back();
|
|
|
|
|
|
|
+ router.push('/message/systemNotifications');
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -194,6 +183,11 @@
|
|
|
}
|
|
}
|
|
|
return diff;
|
|
return diff;
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ onMounted(() => {
|
|
|
|
|
+ fetchSystemMessage();
|
|
|
|
|
+ });
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|