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-17 20:17:49 +08:00
|
|
|
|
<d-radio-group direction="row" v-model="formData.subscribeType">
|
2025-03-15 18:02:45 +08:00
|
|
|
|
<d-radio value="0">短信</d-radio>
|
|
|
|
|
|
<d-radio value="1">邮件</d-radio>
|
|
|
|
|
|
<d-radio value="2">站内通知</d-radio>
|
|
|
|
|
|
</d-radio-group>
|
|
|
|
|
|
</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-15 17:17:31 +08:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps(['softwareData']);
|
|
|
|
|
|
const emit = defineEmits(['close']);
|
2025-03-15 18:02:45 +08:00
|
|
|
|
const formRef = ref(null);
|
|
|
|
|
|
const formData = ref({
|
|
|
|
|
|
subscribeType: '',
|
|
|
|
|
|
});
|
|
|
|
|
|
const rules = {
|
|
|
|
|
|
subscribeType: [{ required: true, message: '请选择', trigger: 'change' }],
|
|
|
|
|
|
};
|
2025-03-18 19:51:01 +08:00
|
|
|
|
const sendSubscribe = async () => {
|
|
|
|
|
|
const data = await subscribeSoftware({
|
|
|
|
|
|
softwareId: props.softwareData.id,
|
|
|
|
|
|
status: '1',
|
|
|
|
|
|
alertType: {
|
|
|
|
|
|
mobileSwitch: formData.value.subscribeType === '0',
|
|
|
|
|
|
emailSwitch: formData.value.subscribeType === '1',
|
|
|
|
|
|
webSwitch: formData.value.subscribeType === '2',
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
Message({
|
|
|
|
|
|
message: err.error,
|
|
|
|
|
|
type: 'error'
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!data?.data?.data?.data) {
|
|
|
|
|
|
Message({
|
|
|
|
|
|
message: data?.data?.data?.msg,
|
|
|
|
|
|
type: 'error'
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
emit('close');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
.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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|