From 21b86f6d81e2153d100587cadc16aaaf470cab33 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: 星期二, 10 六月 2025 17:12:15 +0800
Subject: [PATCH] 修改

---
 src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue |  244 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 244 insertions(+), 0 deletions(-)

diff --git a/src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue b/src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue
new file mode 100644
index 0000000..a521f1e
--- /dev/null
+++ b/src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue
@@ -0,0 +1,244 @@
+<template>
+    <div class="notice">
+        <el-dialog
+            v-model="dialogVisible"
+            :title="title"
+            width="800px"
+            :before-close="handleClose"
+        >
+            <el-form :model="state.noticeForm" size="default" ref="noticeRef" :rules="title === '新增' || title === '编辑' ? state.formRules : {}" label-width="110px" >
+                <el-form-item label="企业概括:" v-if="showEditor"  required>
+                    <t-editor style="width: 800px" ref="myEditor" :value="state.noticeForm.noticeContent" ></t-editor>
+                </el-form-item>
+                <el-form-item label="公告内容:" v-else>
+                    <div class="ql-container ql-snow" style="height: 500px;width: 100%;margin-top: 10px;" >
+                        <div class="ql-editor">
+                            <div class="reviewTable" v-html="state.noticeForm.noticeContent"  @click="showFile($event)"></div>
+                        </div>
+                    </div>
+                </el-form-item>
+            </el-form>
+            <template #footer v-if="!isReview">
+                    <span class="dialog-footer">
+                        <el-button @click="handleClose" size="default">取 消</el-button>
+                        <el-button type="primary"  @click="onSubmit" size="default" v-preReClick>确认</el-button>
+                    </span>
+            </template>
+        </el-dialog>
+    </div>
+</template>
+<script setup>
+import {nextTick, reactive, ref, toRefs, watch} from 'vue'
+import WeEditor from "@/components/WeEditor/index.vue";
+import TEditor from "@/components/Tinymce/Tinymce.vue"
+import {ElMessage} from "element-plus";
+import {addNotice, editNotice, getNoticeDetail} from "@/api/backManage/notice";
+import axios from "axios";
+import {getToken} from "@/utils/auth";
+import {handleThemeStyle} from "@/utils/theme";
+import useSettingsStore from "@/store/modules/settings";
+
+
+const emit = defineEmits(["getList"]);
+
+const dialogVisible = ref(false);
+const title = ref("");
+const noticeRef = ref();
+const fileList = ref([]);
+const myEditor = ref();
+const isReview = ref(false);
+const showEditor = ref(true);
+const state = reactive({
+    noticeForm: {
+        id: '',
+        noticeTitle: '',
+        noticeContent: '',
+    },
+    formRules:{
+        // noticeContent: [{ required: true, message: '请输入公告内容', trigger: 'blur' }],
+    },
+
+})
+
+const openDialog = async (type, value) => {
+    dialogVisible.value = true;
+    // state.noticeForm.noticeContent = ""
+    isReview.value = false;
+    showEditor.value = false
+    title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ;
+    if(type === 'edit' || type === 'review') {
+        // const param = {
+        //     noticeId: value.id
+        // }
+        // const res = await getNoticeDetail(param);
+        // if(res.code === 200){
+        //     state.noticeForm.id = res.data.id
+        //     state.noticeForm.noticeTitle = res.data.title
+        //     state.noticeForm.noticeContent = res.data.content
+        // }else{
+        //     ElMessage.warning(res.message)
+        // }
+
+    }
+    if(type === 'review') {
+        showEditor.value = false
+        isReview.value = true;
+    }
+    if(type === 'edit' || type === 'add') {
+        showEditor.value = true;
+        isReview.value = false;
+    }
+    if(type === 'add'){
+        reset()
+    }
+
+
+}
+const getEditorData = (val) =>{
+    state.noticeForm.noticeContent = val;
+}
+
+const showFile = (e) => {
+    if(e.target.nodeName === 'A'){
+        console.log("e",e)
+        e.preventDefault();
+        const file = {
+            fileUrl: e.target.href,
+            fileName: e.target.innerHTML
+        }
+        axios.get( file.fileUrl,{
+                headers:
+                    {
+                        'Content-Type': 'application/json',
+                        'Authorization':getToken(),
+                    },
+                responseType: 'blob'
+            }
+        ).then(res=>{
+            if (res) {
+                const link = document.createElement('a')
+                let blob = new Blob([res.data],{type: res.data.type})
+                link.style.display = "none";
+                link.href = URL.createObjectURL(blob); // 创建URL
+                link.setAttribute("download", file.fileName);
+                document.body.appendChild(link);
+                link.click();
+                document.body.removeChild(link);
+            } else {
+                this.$message.error('获取文件失败')
+            }
+            // handleClose();
+        })
+    }
+}
+
+const onSubmit = async () => {
+    state.noticeForm.noticeContent = tinyMCE.activeEditor.getContent();
+    console.log("点击提交")
+    console.log('data',state.noticeForm.noticeContent)
+    // // myEditor.value.submit();
+    const valid = await noticeRef.value.validate();
+    if(valid){
+
+        if(state.noticeForm.noticeContent == "") {
+            ElMessage({
+                type: 'warning',
+                message: '请输入公司概况'
+            });
+            return;
+        }
+        if(title.value === '新增'){
+            const param = {
+                content: state.noticeForm.noticeContent,
+            }
+            const res = await addNotice(param)
+            if(res.code === 200){
+                ElMessage({
+                    type: 'success',
+                    message: '新增成功'
+                });
+            }else{
+                ElMessage.warning(res.message)
+            }
+            emit("getList")
+            reset();
+            showEditor.value=false
+            myEditor.value.clear();
+            noticeRef.value.clearValidate();
+            dialogVisible.value = false;
+        }else if(title.value === '编辑') {
+            const param = {
+                id: state.noticeForm.id,
+                content: state.noticeForm.noticeContent,
+            }
+            const res = await editNotice(param)
+            if(res.code === 200){
+                ElMessage({
+                    type: 'success',
+                    message: '编辑成功'
+                });
+            }else{
+                ElMessage.warning(res.message)
+            }
+            emit("getList")
+            reset();
+            showEditor.value=false
+            myEditor.value.clear();
+            noticeRef.value.clearValidate();
+            dialogVisible.value = false;
+        }
+    }
+}
+
+const handleClose = () => {
+    if(title.value ==="新增"|| title.value ==='编辑'){
+        myEditor.value.clear();
+        showEditor.value=false
+    }
+
+    // reset()
+    noticeRef.value.clearValidate();
+    dialogVisible.value = false;
+}
+const reset = () => {
+    state.noticeForm = {
+        id: '',
+        noticeTitle: '',
+        noticeContent: ''
+    }
+}
+
+defineExpose({
+    openDialog
+});
+
+</script>
+
+<style scoped lang="scss">
+.notice{
+    :deep(.el-form .el-form-item__label) {
+        font-size: 15px;
+    }
+    .file {
+        display: flex;
+        flex-direction: column;
+        align-items: flex-start;
+    }
+}
+.reviewTable {
+    :deep(table){
+        border: 1px solid #ccc;
+        text-align: center;
+    }
+    :deep(table td){
+        border: 1px solid #ccc;
+        text-align: center;
+        padding: 0 5px;
+    }
+    :deep(table th){
+        border: 1px solid #ccc;
+    }
+}
+
+
+</style>

--
Gitblit v1.9.2