可信代码库-订阅操作添加预警手机号和预警邮件地址
This commit is contained in:
@@ -6,6 +6,16 @@
|
||||
<d-form-item field="subscribeType" label="通知方式">
|
||||
<d-checkbox-group name="subscribeType" v-model="formData.subscribeType" :options="subscribeTypeOptions" direction="row"></d-checkbox-group>
|
||||
</d-form-item>
|
||||
|
||||
<!-- 预警手机号 - 当选择短信时显示 -->
|
||||
<d-form-item field="warningMobile" label="预警手机号" v-if="showWarningMobile">
|
||||
<d-input v-model="formData.warningMobile" placeholder="请输入接收短信的手机号" />
|
||||
</d-form-item>
|
||||
|
||||
<!-- 预警邮箱 - 当选择邮件时显示 -->
|
||||
<d-form-item field="warningEmail" label="预警邮箱" v-if="showWarningEmail">
|
||||
<d-input v-model="formData.warningEmail" placeholder="请输入接收邮件的邮箱" />
|
||||
</d-form-item>
|
||||
</d-form>
|
||||
</div>
|
||||
<div class="subscribe-operation mt-5">
|
||||
@@ -19,6 +29,7 @@
|
||||
import { subscribeSoftware } from '@/api/jyh';
|
||||
import { computed, ref } from 'vue';
|
||||
import { Message } from 'vue-devui';
|
||||
import { useAccountStore } from '@/stores/user';
|
||||
const subscribeTypeOptions = [
|
||||
{ name: '短信', value: 'mobileSwitch', id: 1 },
|
||||
{ name: '邮件', value: 'emailSwitch', id: 2 },
|
||||
@@ -26,13 +37,40 @@ const subscribeTypeOptions = [
|
||||
];
|
||||
const props = defineProps(['softwareData']);
|
||||
const emit = defineEmits(['close','closeSub']);
|
||||
|
||||
const userInfo = useAccountStore();
|
||||
const {accountInfo} = userInfo;
|
||||
debugger
|
||||
|
||||
const formRef = ref(null);
|
||||
const formData = ref({
|
||||
subscribeType: [],
|
||||
warningMobile: accountInfo.warningMobile||'',
|
||||
warningEmail: accountInfo.warningEmail||'',
|
||||
});
|
||||
|
||||
const rules = {
|
||||
subscribeType: [{ type: 'array', required: true, message: '请至少选择一种通知方式', trigger: 'change' }],
|
||||
warningMobile: [
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的11位手机号码', trigger: 'blur' },
|
||||
{ required: true, message: '请输入预警手机号', trigger: 'blur' }
|
||||
],
|
||||
warningEmail: [
|
||||
{ type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' },
|
||||
{ required: true, message: '请输入预警邮箱', trigger: 'blur' }
|
||||
]
|
||||
};
|
||||
|
||||
// 计算属性 - 控制输入框显示
|
||||
const showWarningMobile = computed(() => {
|
||||
return formData.value.subscribeType.some(item => item.value === 'mobileSwitch');
|
||||
});
|
||||
|
||||
const showWarningEmail = computed(() => {
|
||||
return formData.value.subscribeType.some(item => item.value === 'emailSwitch');
|
||||
});
|
||||
|
||||
|
||||
const sendSubscribe = async () => {
|
||||
let alertType = {};
|
||||
formData.value.subscribeType.forEach(item => {
|
||||
@@ -42,6 +80,8 @@ const sendSubscribe = async () => {
|
||||
softwareId: props.softwareData.id,
|
||||
status: '1',
|
||||
alertType,
|
||||
warningMobile: formData.value.warningMobile,
|
||||
warningEmail: formData.value.warningEmail
|
||||
}).catch(err => {
|
||||
Message({
|
||||
message: err.error,
|
||||
|
||||
Reference in New Issue
Block a user