cz vor 1 Jahr
Ursprung
Commit
02b452d3fe

+ 7 - 1
src/views/connect/E-mail/mail/com/mailDetail.vue

@@ -112,7 +112,12 @@
         <div class="value">
           <div
             v-for="(item, index) in fileList"
-            style="margin-right: 20px; display: flex; align-items: center"
+            style="
+              margin-right: 20px;
+              display: flex;
+              align-items: center;
+              margin-bottom: 5px;
+            "
             :key="index"
           >
             <span style="cursor: pointer" @click="handleClickFile(item)">{{
@@ -591,6 +596,7 @@ defineExpose({
         font-weight: 700;
         margin-right: 10px;
         display: flex;
+        flex-wrap: wrap;
       }
     }
   }

+ 2 - 2
src/views/connect/E-mail/mail/com/mailList.vue

@@ -343,9 +343,9 @@ const handleRowClick = (row, index) => {
 };
 
 const init = () => {
-  getList();
+  // getList();
 };
-
+getList();
 const handleCurrentChange = (val) => {
   tableData.pagination.pageNum = val;
   getList();

+ 59 - 16
src/views/connect/E-mail/mail/com/mailWrite.vue

@@ -215,22 +215,45 @@
             style="width: 50%"
           />
         </el-form-item> -->
-        <el-form-item label="发件人" prop="replyTo">
-          <el-select
-            v-model="formData.data.replyTo"
-            filterable
-            placeholder="请选择"
-            style="width: 50%"
-            @change="handleChangeReply"
-          >
-            <el-option
-              v-for="item in userMailList"
-              :key="item.mailUser"
-              :label="item.mailUser"
-              :value="item.mailUser"
-            />
-          </el-select>
-        </el-form-item>
+
+        <el-row>
+          <el-col :span="6">
+            <el-form-item label="发件人" prop="replyTo">
+              <el-select
+                v-model="formData.data.replyTo"
+                filterable
+                placeholder="请选择"
+                style="width: 100%"
+                @change="handleChangeReply"
+              >
+                <el-option
+                  v-for="item in userMailList"
+                  :key="item.mailUser"
+                  :label="item.mailUser"
+                  :value="item.mailUser"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="签  名:">
+              <el-select
+                v-model="formData.data.templateId"
+                filterable
+                placeholder="请选择"
+                style="width: 100%"
+                @change="handleChangeTemplate"
+              >
+                <el-option
+                  v-for="item in templateList"
+                  :key="item.id"
+                  :label="item.templateName"
+                  :value="item.id"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
         <el-form-item>
           <el-button type="primary" @click="handleSend()"> 发 送 </el-button>
         </el-form-item>
@@ -639,6 +662,26 @@ watch(
     }
   }
 );
+const templateList = ref([]);
+const getTemplateList = () => {
+  proxy
+    .post("/mailSignature/page", {
+      pageNum: 1,
+      pageSize: 9999,
+    })
+    .then((res) => {
+      templateList.value = res.rows;
+    });
+};
+getTemplateList();
+const handleChangeTemplate = (val) => {
+  if (val) {
+    const current = templateList.value.find((x) => x.id === val);
+    contentEditor.value.changeHtml(
+      `${formData.data.content}<br><div style="width: 50%;padding: 15px;overflow: auto;box-shadow: 0px 0px 12px rgba(0, 0, 0, .12);">${current.content}</div>`
+    );
+  }
+};
 
 onMounted(() => {});
 

+ 324 - 0
src/views/connect/E-mail/signature/index.vue

@@ -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>