Files
UNION_NSI/target/classes/static/components/plugins/SendMsgByGroupId.vue
T
2026-09-08 19:49:21 +08:00

159 lines
4.6 KiB
Vue

<template>
<div>
<el-dialog :visible.sync="sendDialogVisible" title="发送通知" width="45%"
:close-on-click-modal="false"
@closed="sendDialogClose">
<el-form ref="sendForm" :model="formData" label-width="80px">
<el-form-item label="发送对象" prop="activityGroupId"
:rules="[{required: true, message: '请选择发送对象', trigger: ['blur', 'change']}]">
<el-select @change="groupChange" :disabled="group_id" placeholder="请选择活动组别" clearable
style="width: 100%"
v-model="formData.activityGroupId">
<el-option :label="item.groupName"
:value="item.groupId"
v-for="item in activityGroupList"></el-option>
</el-select>
</el-form-item>
<el-form-item label="发送方式" prop="sendTypes"
:rules="[{required: true, message: '请选择发送方式', trigger: ['blur', 'change']}]">
<el-checkbox-group v-model="formData.sendTypes" size="medium">
<el-checkbox border label="1">短信发送</el-checkbox>
<el-checkbox border label="4">微信发送</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="发送内容" prop="content"
:rules="[{required: true, message: '请选择发送内容', trigger: ['blur', 'change']}]">
<el-input
v-model="formData.content"
:rows="6"
placeholder="请输入内容"
type="textarea">
</el-input>
</el-form-item>
<el-alert
show-icon
:title="url"
description="如果您发送的内容需要含有链接,请把上述内容复制到发送内容里面,不要随意修改!"
type="warning">
</el-alert>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="sendDialogVisible = false"> </el-button>
<el-button :disabled="!this.formData.activityGroupId" type="primary"
@click="doSend()"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
module.exports = {
props: {
group_id: {
type: String, default: ''
},
url: {
required: false,
type: String
}
},
model: {},
data() {
return {
sendDialogVisible: false,
activityGroupList: [],
formData: {
sendTypes: [],
activityGroupId: '',
content: '',
},
}
},
watch: {
},
methods: {
sendDialogClose() {
if (this.$refs['sendForm']) {
this.$refs['sendForm'].resetFields()
}
},
openDialog(groupId) {
if (!groupId) {
this.$notify.warning({title: '警告', message: '您选择的活动没有发送对象!'})
return
}
this.group_id = groupId
if (groupId) {
this.formData.activityGroupId = Number(groupId)
}
this.sendDialogVisible = true
},
groupChange(val) {
},
async doSend() {
const valid = await this.$refs['sendForm'].validate()
if (!valid) return
const group = this.activityGroupList.find(o => o.groupId === this.formData.activityGroupId)
const groupName = group !== undefined ? group.groupName : ''
const confirm = await this.$confirm('您确定要给【' + groupName + '】发送通知吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
if (confirm) {
const loading = this.$loading({
lock: true,
text: '正在发送...',
spinner: 'el-icon-loading',
background: COVER_LAYER_COLOR
});
this.formData.activityGroupId = this.group_id
this.formData.flag = this.group_id
const resp = await $.post('/platform/msgNotify/send/sendMsgByGroupId', {
msgNotify: JSON.stringify(this.formData),
})
if (resp.code === 0) {
this.$notify.success({title: '成功', message: resp.msg})
this.sendDialogVisible = false
} else {
this.$notify.warning({title: '警告', message: resp.msg})
}
loading.close()
}
},
async getActivityGroup() {
const resp = await $.get('/platform/activity/basic/scope/getActivityUserScopeGroup')
this.activityGroupList = resp.data
},
async initData() {
await this.getActivityGroup()
},
},
computed: {},
created() {
this.initData()
}
}
</script>
<style scoped>
</style>