4 changed files with 217 additions and 12 deletions
@ -0,0 +1,16 @@
|
||||
import request from '@/utils/request' |
||||
|
||||
// 标签列表
|
||||
export function labelLists(params?: any) { |
||||
return request.get({ url: '/system/label/list', params }) |
||||
} |
||||
|
||||
// 标签新增
|
||||
export function labelAdd(params?: any) { |
||||
return request.post({ url: '/system/label/add', params }) |
||||
} |
||||
|
||||
// 标签插入
|
||||
export function labelInsert(params?: any) { |
||||
return request.post({ url: '/system/label/insert', params }) |
||||
} |
||||
@ -0,0 +1,158 @@
|
||||
<template> |
||||
<el-dialog v-model="visible" width="50vw" top="4vh" class="dialog-header-nopadding" align-center |
||||
style="--el-dialog-padding-primary: 10px"> |
||||
<template #header="" style="display: flex;align-items: center;justify-content: space-between;"> |
||||
<div class="dialog-header"> |
||||
<span class="dialog-title">信件标签</span> |
||||
</div> |
||||
</template> |
||||
<div class="dialog-body"> |
||||
<el-form ref="formRef" :model="form"> |
||||
<span class="main-label">请选择标签</span> |
||||
<el-form-item class="mt-20"> |
||||
<el-checkbox-group v-model="form.mainLabels" style="width: 100%;"> |
||||
<el-row> |
||||
<el-col :span="6" v-for="(mailLabel, index) in allLabels" :key="index"> |
||||
<el-checkbox :label="mailLabel.id">{{ mailLabel.labelName }}</el-checkbox> |
||||
</el-col> |
||||
</el-row> |
||||
</el-checkbox-group> |
||||
</el-form-item> |
||||
<el-row :gutter="20"> |
||||
<el-col :span="6"> |
||||
<el-input v-model="form.newLabel" placeholder="请输入标签"></el-input> |
||||
</el-col> |
||||
<el-col :span="6"> |
||||
<el-button type="primary" @click="handleLabelAdd" plain>添加标签</el-button> |
||||
</el-col> |
||||
</el-row> |
||||
<div style="width: 100%;display: flex;justify-content: flex-end; margin-top: 20px;"> |
||||
<el-button type="primary" @click="handleSubmit" style="height: 40px;">确认标签</el-button> |
||||
</div> |
||||
</el-form> |
||||
</div> |
||||
</el-dialog> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { ref, defineProps } from 'vue' |
||||
import { watch } from 'vue' |
||||
import { labelLists } from '@/api/org/label' |
||||
import { labelAdd } from '@/api/org/label' |
||||
import { labelInsert } from '@/api/org/label' |
||||
import { ElMessage } from 'element-plus' |
||||
const emit = defineEmits(['update']) |
||||
const props = defineProps({ |
||||
show: { |
||||
type: Boolean, |
||||
default: false |
||||
}, |
||||
mailId: { |
||||
type: String, |
||||
default: '' |
||||
} |
||||
}) |
||||
const visible = ref(props.show) |
||||
watch( |
||||
() => props.show, |
||||
(val) => { |
||||
visible.value = val; |
||||
if (val) { |
||||
} |
||||
} |
||||
); |
||||
|
||||
interface MailLabel { |
||||
id: number, |
||||
labelName: string |
||||
} |
||||
const form = ref({ |
||||
mainLabels: [] as MailLabel[], |
||||
newLabel: null, |
||||
}) |
||||
const allLabels = ref([] as MailLabel[]) |
||||
getMainLabels() |
||||
function getMainLabels() { |
||||
labelLists().then((res: any) => { |
||||
allLabels.value = res |
||||
}) |
||||
} |
||||
|
||||
const handleLabelAdd = () => { |
||||
let newLabel = JSON.stringify({ labelName: form.value.newLabel, }) |
||||
labelAdd(JSON.parse(newLabel)).then((res: any) => { |
||||
console.log(res) |
||||
getMainLabels() |
||||
}) |
||||
} |
||||
const handleSubmit = () => { |
||||
let strLabels = '' |
||||
for (let i = 0; i < form.value.mainLabels.length; i++) { |
||||
if (i === form.value.mainLabels.length - 1) |
||||
strLabels += form.value.mainLabels[i] |
||||
else |
||||
strLabels += form.value.mainLabels[i] + ',' |
||||
} |
||||
let labelInfo = JSON.stringify({ mailId: props.mailId, labelName: strLabels }) |
||||
console.log(labelInfo) |
||||
console.log(JSON.parse(labelInfo)) |
||||
labelInsert(JSON.parse(labelInfo)).then((res: any) => { |
||||
console.log(res) |
||||
ElMessage.success('标签设置成功') |
||||
visible.value = false |
||||
emit('update') |
||||
}).catch((err: any) => { |
||||
console.log(err) |
||||
ElMessage.error('标签设置失败') |
||||
}) |
||||
console.log(form.value.mainLabels) |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
.dialog-header { |
||||
height: 60px; |
||||
display: flex; |
||||
align-items: center; |
||||
justify-self: center; |
||||
} |
||||
|
||||
.dialog-title { |
||||
margin-left: 20px; |
||||
width: 64px; |
||||
height: 22px; |
||||
font-size: 16px; |
||||
font-family: PingFangSC, PingFang SC; |
||||
font-weight: 400; |
||||
color: #FFFFFF; |
||||
line-height: 22px; |
||||
} |
||||
|
||||
.dialog-body { |
||||
margin-left: 20px; |
||||
margin-right: 20px; |
||||
} |
||||
|
||||
.main-label { |
||||
width: 80px; |
||||
height: 22px; |
||||
font-size: 20px; |
||||
font-family: PingFang-SC, PingFang-SC; |
||||
font-weight: bold; |
||||
color: #333333; |
||||
line-height: 22px; |
||||
} |
||||
|
||||
.title-label { |
||||
margin-bottom: 20px; |
||||
} |
||||
|
||||
.info-input { |
||||
width: 100%; |
||||
} |
||||
|
||||
.el-upload__inner { |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
} |
||||
</style> |
||||
Loading…
Reference in new issue