|
@@ -0,0 +1,324 @@
|
|
|
+<template>
|
|
|
+ <div class="tenant">
|
|
|
+ <div class="content">
|
|
|
+ <byTable
|
|
|
+ :source="sourceList.data"
|
|
|
+ :pagination="sourceList.pagination"
|
|
|
+ :config="config"
|
|
|
+ :loading="loading"
|
|
|
+ highlight-current-row
|
|
|
+ :selectConfig="selectConfig"
|
|
|
+ :action-list="[
|
|
|
+ {
|
|
|
+ text: '添加签名',
|
|
|
+ action: () => openModal(),
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ @moreSearch="moreSearch"
|
|
|
+ @get-list="getList"
|
|
|
+ >
|
|
|
+ <template #content="{ item }">
|
|
|
+ <div v-if="item.content">
|
|
|
+ <div v-html="getHtml(item.content)"></div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </byTable>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ :title="submitType == 'add' ? '添加模板' : '编辑模板'"
|
|
|
+ v-if="addDialog"
|
|
|
+ v-model="addDialog"
|
|
|
+ width="60%"
|
|
|
+ >
|
|
|
+ <byForm
|
|
|
+ :formConfig="formConfig"
|
|
|
+ :formOption="formOption"
|
|
|
+ v-model="formData.data"
|
|
|
+ :rules="rules"
|
|
|
+ ref="byform"
|
|
|
+ >
|
|
|
+ <template #content>
|
|
|
+ <div style="width: 100%">
|
|
|
+ <Editor
|
|
|
+ :value="formData.data.content"
|
|
|
+ @updateValue="updateHandover"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </byForm>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="addDialog = false" size="large">取 消</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="submitForm()"
|
|
|
+ size="large"
|
|
|
+ :loading="submitLoading"
|
|
|
+ >确 定</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="预览"
|
|
|
+ v-if="previewDialog"
|
|
|
+ v-model="previewDialog"
|
|
|
+ width="60%"
|
|
|
+ >
|
|
|
+ <div style="width: 100%" class="main">
|
|
|
+ <img src="@/assets/images/mail-preview.png" alt="" class="img" />
|
|
|
+ <div class="body">
|
|
|
+ <div v-html="getHtml(selectRowData.content)"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="display: flex; align-items: center; margin-top: 20px">
|
|
|
+ <div style="margin-right: 5px">选择签名</div>
|
|
|
+ <el-select disabled v-model="selectRowData.templateName"> </el-select>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="previewDialog = false" size="large">取 消</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
+import byTable from "@/components/byTable/index";
|
|
|
+import byForm from "@/components/byForm/index";
|
|
|
+import Editor from "@/components/Editor/index.vue";
|
|
|
+
|
|
|
+const loading = ref(false);
|
|
|
+const sourceList = ref({
|
|
|
+ data: [],
|
|
|
+ pagination: {
|
|
|
+ total: 0,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ type: "",
|
|
|
+ keyword: "",
|
|
|
+ },
|
|
|
+});
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+const selectConfig = computed(() => {
|
|
|
+ return [];
|
|
|
+});
|
|
|
+const config = computed(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "模板名称",
|
|
|
+ prop: "templateName",
|
|
|
+ width: 180,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "签名内容",
|
|
|
+ prop: "content",
|
|
|
+ slot: "content",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "创建时间",
|
|
|
+ prop: "createTime",
|
|
|
+ width: 155,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "操作",
|
|
|
+ width: "160",
|
|
|
+ align: "center",
|
|
|
+ fixed: "right",
|
|
|
+ },
|
|
|
+ renderHTML(row) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "预览",
|
|
|
+ type: "primary",
|
|
|
+ text: true,
|
|
|
+ },
|
|
|
+ el: "button",
|
|
|
+ click() {
|
|
|
+ openModalOne(row);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "修改",
|
|
|
+ type: "primary",
|
|
|
+ text: true,
|
|
|
+ },
|
|
|
+ el: "button",
|
|
|
+ click() {
|
|
|
+ getDtl(row);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "删除",
|
|
|
+ type: "primary",
|
|
|
+ text: true,
|
|
|
+ },
|
|
|
+ el: "button",
|
|
|
+ click() {
|
|
|
+ // 弹窗提示是否删除
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ "此操作将永久删除该数据, 是否继续?",
|
|
|
+ "提示",
|
|
|
+ {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ // 删除
|
|
|
+ proxy
|
|
|
+ .post("/mailSignature/delete", {
|
|
|
+ id: row.id,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: "删除成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+});
|
|
|
+const getList = async (req) => {
|
|
|
+ sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
|
|
|
+ loading.value = true;
|
|
|
+ proxy
|
|
|
+ .post("/mailSignature/page", sourceList.value.pagination)
|
|
|
+ .then((message) => {
|
|
|
+ sourceList.value.data = message.rows;
|
|
|
+ sourceList.value.pagination.total = message.total;
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false;
|
|
|
+ }, 200);
|
|
|
+ });
|
|
|
+};
|
|
|
+getList();
|
|
|
+const formData = reactive({
|
|
|
+ data: {},
|
|
|
+});
|
|
|
+const formOption = reactive({
|
|
|
+ inline: true,
|
|
|
+ labelWidth: 100,
|
|
|
+ itemWidth: 100,
|
|
|
+ rules: [],
|
|
|
+});
|
|
|
+const formConfig = computed(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "templateName",
|
|
|
+ label: "模板名称",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "slot",
|
|
|
+ prop: "content",
|
|
|
+ label: "签名内容",
|
|
|
+ slotName: "content",
|
|
|
+ },
|
|
|
+ ];
|
|
|
+});
|
|
|
+const rules = ref({
|
|
|
+ templateName: [
|
|
|
+ { required: true, message: "请输入模板名称", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ content: [{ required: true, message: "请输入签名内容", trigger: "blur" }],
|
|
|
+});
|
|
|
+const submitType = ref("add");
|
|
|
+const addDialog = ref(false);
|
|
|
+const submitLoading = ref(false);
|
|
|
+const byform = ref(null);
|
|
|
+const openModal = () => {
|
|
|
+ submitType.value = "add";
|
|
|
+ formData.data = {
|
|
|
+ content: "",
|
|
|
+ };
|
|
|
+ addDialog.value = true;
|
|
|
+};
|
|
|
+const updateHandover = (val) => {
|
|
|
+ formData.data.content = val;
|
|
|
+};
|
|
|
+const submitForm = () => {
|
|
|
+ byform.value.handleSubmit(() => {
|
|
|
+ submitLoading.value = true;
|
|
|
+ proxy.post("/mailSignature/" + submitType.value, formData.data).then(
|
|
|
+ () => {
|
|
|
+ ElMessage({
|
|
|
+ message: "操作成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ addDialog.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ getList();
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
+};
|
|
|
+const getDtl = (row) => {
|
|
|
+ submitType.value = "edit";
|
|
|
+ proxy.post("/mailSignature/detail", { id: row.id }).then((res) => {
|
|
|
+ addDialog.value = true;
|
|
|
+ formData.data = res;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const getHtml = (str) => {
|
|
|
+ if (str) {
|
|
|
+ let newStr = str.replace(/<p\b/gi, "<div"); // 使用正则表达式替换<p>为<div
|
|
|
+ return newStr.replace(/<\/p>/gi, "</div>"); // 使用正则表达式替换</p>为</div>
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const selectRowData = ref({});
|
|
|
+const previewDialog = ref(false);
|
|
|
+const openModalOne = (row) => {
|
|
|
+ selectRowData.value = row;
|
|
|
+ previewDialog.value = true;
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.tenant {
|
|
|
+ padding: 20px;
|
|
|
+}
|
|
|
+.ql-editor {
|
|
|
+ padding: 0px;
|
|
|
+}
|
|
|
+.main {
|
|
|
+ position: relative;
|
|
|
+ .img {
|
|
|
+ width: 100%;
|
|
|
+ // height: 500px;
|
|
|
+ object-fit: contain;
|
|
|
+ vertical-align: middle;
|
|
|
+ }
|
|
|
+ .body {
|
|
|
+ padding: 10px;
|
|
|
+ position: absolute;
|
|
|
+ background: #fff;
|
|
|
+ min-height: 20%;
|
|
|
+ left: 6%;
|
|
|
+ bottom: 16px;
|
|
|
+ min-width: 50%;
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|