2025-03-15 17:17:31 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="subscribe-container">
|
|
|
|
|
|
<div class="subscribe-tip mb-3">当您订阅的软件有漏洞预警通知时,将以应用号的方式通知。可在首页查看或取消订阅!</div>
|
|
|
|
|
|
<div class="subscribe-form">
|
2025-03-15 18:02:45 +08:00
|
|
|
|
<d-form ref="formRef" :data="formData" :rules="rules">
|
|
|
|
|
|
<d-form-item field="subscribeType" label="通知方式">
|
2025-03-20 21:16:36 +08:00
|
|
|
|
<d-checkbox-group name="subscribeType" v-model="formData.subscribeType" :options="subscribeTypeOptions" direction="row"></d-checkbox-group>
|
2025-03-15 18:02:45 +08:00
|
|
|
|
</d-form-item>
|
|
|
|
|
|
</d-form>
|
2025-03-15 17:17:31 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="subscribe-operation mt-5">
|
2025-03-15 18:02:45 +08:00
|
|
|
|
<d-button @click="confirm" variant="solid" class="mr-2">确定</d-button>
|
2025-03-15 17:17:31 +08:00
|
|
|
|
<d-button @click="$emit('close')">取消</d-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2025-03-18 19:51:01 +08:00
|
|
|
|
import { subscribeSoftware } from '@/api/jyh';
|
2025-03-15 17:17:31 +08:00
|
|
|
|
import { computed, ref } from 'vue';
|
2025-03-18 19:51:01 +08:00
|
|
|
|
import { Message } from 'vue-devui';
|
2025-03-20 21:16:36 +08:00
|
|
|
|
const subscribeTypeOptions = [
|
|
|
|
|
|
{ name: '短信', value: 'mobileSwitch', id: 1 },
|
|
|
|
|
|
{ name: '邮件', value: 'emailSwitch', id: 2 },
|
|
|
|
|
|
{ name: '站内通知', value: 'webSwitch', id: 3 },
|
2025-03-21 12:07:27 +08:00
|
|
|
|
];
|
2025-03-15 17:17:31 +08:00
|
|
|
|
const props = defineProps(['softwareData']);
|
2025-03-21 12:07:27 +08:00
|
|
|
|
const emit = defineEmits(['close','closeSub']);
|
2025-03-15 18:02:45 +08:00
|
|
|
|
const formRef = ref(null);
|
|
|
|
|
|
const formData = ref({
|
2025-03-20 21:16:36 +08:00
|
|
|
|
subscribeType: [],
|
2025-03-15 18:02:45 +08:00
|
|
|
|
});
|
|
|
|
|
|
const rules = {
|
2025-03-21 09:23:36 +08:00
|
|
|
|
subscribeType: [{ type: 'array', required: true, message: '请至少选择一种通知方式', trigger: 'change' }],
|
2025-03-15 18:02:45 +08:00
|
|
|
|
};
|
2025-03-18 19:51:01 +08:00
|
|
|
|
const sendSubscribe = async () => {
|
2025-03-20 21:16:36 +08:00
|
|
|
|
let alertType = {};
|
|
|
|
|
|
formData.value.subscribeType.forEach(item => {
|
|
|
|
|
|
alertType[item.value] = true;
|
|
|
|
|
|
})
|
2025-03-18 19:51:01 +08:00
|
|
|
|
const data = await subscribeSoftware({
|
|
|
|
|
|
softwareId: props.softwareData.id,
|
|
|
|
|
|
status: '1',
|
2025-03-20 21:16:36 +08:00
|
|
|
|
alertType,
|
2025-03-18 19:51:01 +08:00
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
Message({
|
|
|
|
|
|
message: err.error,
|
|
|
|
|
|
type: 'error'
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!data?.data?.data?.data) {
|
|
|
|
|
|
Message({
|
|
|
|
|
|
message: data?.data?.data?.msg,
|
|
|
|
|
|
type: 'error'
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2025-03-18 22:06:02 +08:00
|
|
|
|
Message({
|
|
|
|
|
|
message: '订阅成功!',
|
|
|
|
|
|
type: 'success'
|
|
|
|
|
|
})
|
2025-03-18 19:51:01 +08:00
|
|
|
|
emit('close');
|
2025-03-21 12:07:27 +08:00
|
|
|
|
emit('closeSub');
|
2025-03-18 19:51:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-15 17:17:31 +08:00
|
|
|
|
const confirm = () => {
|
2025-03-15 18:02:45 +08:00
|
|
|
|
(formRef?.value as any)?.validate((isValid: boolean, invalidFields: any) => {
|
|
|
|
|
|
if (!isValid) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-03-18 19:51:01 +08:00
|
|
|
|
sendSubscribe();
|
2025-03-15 18:02:45 +08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
2025-03-15 17:17:31 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
.subscribe-container {
|
|
|
|
|
|
width: 600px;
|
2025-03-21 12:07:27 +08:00
|
|
|
|
|
2025-03-15 17:17:31 +08:00
|
|
|
|
.subscribe-tip {
|
|
|
|
|
|
color: #191919;
|
|
|
|
|
|
font-family: HarmonyOS Sans SC;
|
|
|
|
|
|
font-weight: regular;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.subscribe-form {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
background: #F2F5FC;
|
2025-03-15 18:02:45 +08:00
|
|
|
|
padding: 20px 32px 0;
|
2025-03-15 17:17:31 +08:00
|
|
|
|
|
2025-03-15 18:02:45 +08:00
|
|
|
|
form {
|
|
|
|
|
|
width: 100%;
|
2025-03-15 17:17:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.subscribe-operation {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-21 12:07:27 +08:00
|
|
|
|
</style>
|