莳松crm管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ss-crm-manage-web/src/views/Basic/Role/Comp/ReportDaily.vue

150 lines
3.6 KiB

8 months ago
<template>
8 months ago
<div class="pl-20px pr-20px">
<el-form :model="form" ref="formRef" :rules="rules" label-width="auto" v-loading="formLoading">
8 months ago
<el-form-item label="开启通知">
8 months ago
<el-radio-group v-model="form.status">
8 months ago
<el-radio :label="1"> 开启 </el-radio>
<el-radio :label="0"> 关闭 </el-radio>
</el-radio-group>
</el-form-item>
8 months ago
<el-form-item label="发送途径">
8 months ago
<el-checkbox-group v-model="form.sendType">
<el-checkbox v-for="(item, index) in sendTypeOptions" :key="index" :label="item.value">
{{ item.label }}
</el-checkbox>
8 months ago
</el-checkbox-group>
</el-form-item>
<el-form-item label="发送时间">
<el-time-picker
v-model="form.sendTime"
placeholder="任意时间点"
8 months ago
format="HH:mm"
value-format="HH:mm"
8 months ago
/>
</el-form-item>
<el-form-item label="发送内容">
<el-tree
ref="treeRef"
:data="contentOptions"
8 months ago
:props="defaultProps"
8 months ago
empty-text="加载中,请稍候"
8 months ago
node-key="id"
8 months ago
show-checkbox
default-expand-all
style="width: 100%"
/>
</el-form-item>
<el-form-item>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
</el-form-item>
</el-form>
</div>
8 months ago
</template>
8 months ago
<script setup name="ReportDaily">
8 months ago
import * as DaliyReportApi from '@/api/system/role/daliyReport'
import { defaultProps, handleTree } from '@/utils/tree'
import { getGeneralSysDictData } from '@/api/system/dict/dict.data'
8 months ago
const message = useMessage() // 消息弹窗
const props = defineProps({
roleId: {
type: Number
}
})
const formLoading = ref(false)
const form = ref({
8 months ago
sendItem: []
8 months ago
})
8 months ago
watch(
() => props.roleId,
() => {
getReportInfo()
}
)
8 months ago
onMounted(() => {
init()
})
const formRef = ref()
const rules = {}
const contentOptions = ref([])
async function init() {
getOptions()
getReportInfo()
}
8 months ago
const sendTypeOptions = ref([])
8 months ago
const treeRef = ref()
function getOptions() {
8 months ago
getGeneralSysDictData('message_send_type').then((data) => {
sendTypeOptions.value = data
})
DaliyReportApi.getDaliyReportContent().then((data) => {
contentOptions.value = handleTree(data)
})
8 months ago
}
async function getReportInfo() {
try {
formLoading.value = true
8 months ago
const data = await DaliyReportApi.getRoleDaliyReport(props.roleId)
form.value = { ...data }
if (!form.value.sendType) {
form.value.sendType = []
}
if (!form.value.sendTime) {
form.value.sendTime = '22:00'
8 months ago
}
8 months ago
if (!form.value.sendItem) {
form.value.sendItem = []
}
treeRef.value.setCheckedKeys([], false)
// 设置选中
form.value.sendItem.forEach((menuId) => {
treeRef.value.setChecked(menuId, true, false)
})
8 months ago
formLoading.value = false
} catch (error) {
console.log(error)
formLoading.value = false
}
}
/** 提交表单 */
const submitForm = async () => {
// 提交请求
formLoading.value = true
try {
const data = {
8 months ago
id: form.value.id,
8 months ago
roleId: props.roleId,
8 months ago
sendType: form.value.sendType,
sendTime: form.value.sendTime,
status: form.value.status,
sendItem: [
8 months ago
...treeRef.value.getCheckedKeys(false), // 获得当前选中节点
...treeRef.value.getHalfCheckedKeys() // 获得半选中的父节点
]
}
8 months ago
await DaliyReportApi.updateRoleDaliyReport(data)
8 months ago
message.success('保存成功')
8 months ago
getReportInfo()
8 months ago
} finally {
formLoading.value = false
}
}
</script>
8 months ago
<style lang="scss" scoped></style>