From 5b5c6374749159db03a14ee645760327930bbb28 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: 星期一, 13 十月 2025 14:46:41 +0800
Subject: [PATCH] 修改
---
src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue | 210 ++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 168 insertions(+), 42 deletions(-)
diff --git a/src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue b/src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue
index a521f1e..96be64d 100644
--- a/src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue
+++ b/src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue
@@ -7,16 +7,47 @@
:before-close="handleClose"
>
<el-form :model="state.noticeForm" size="default" ref="noticeRef" :rules="title === '新增' || title === '编辑' ? state.formRules : {}" label-width="110px" >
+ <el-form-item v-if="state.isAdmin" label="企业:" prop="companyId">
+ <el-select v-model="state.noticeForm.companyId" placeholder="请选择" clearable filterable style="width: 100%" :disabled="title == '查看' || title == '编辑' || !state.isAdmin">
+ <el-option
+
+ v-for="item in state.companyList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
<el-form-item label="企业概括:" v-if="showEditor" required>
- <t-editor style="width: 800px" ref="myEditor" :value="state.noticeForm.noticeContent" ></t-editor>
+ <t-editor style="width: 800px" ref="myEditor" :toolbar="toolbar" :value="state.noticeForm.companySummary" ></t-editor>
</el-form-item>
- <el-form-item label="公告内容:" v-else>
+ <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 class="reviewTable" v-html="state.noticeForm.companySummary" @click="showFile($event)"></div>
</div>
</div>
</el-form-item>
+ <el-form-item label="营业执照:" prop="filePath" v-if="showEditor">
+ <el-upload accept=".jpg,.jpeg,.png,.pdf" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile)" :on-exceed="showTip" :limit='state.fileLimit' v-model:file-list="state.fileList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles)" >
+ <el-button type="primary">点击上传</el-button>
+ <template #tip>
+ <div class="el-upload__tip">尺寸小于5M,最多可上传1张</div>
+ </template>
+ </el-upload>
+ </el-form-item>
+ <el-form-item label="营业执照:" prop="filePath" v-else>
+ <div v-if="state.fileType === 'pdf'" class="pdf-preview">
+ <iframe
+ :src="state.fileUrl"
+ width="650px"
+ height="800px"
+ ></iframe>
+ </div>
+ <div v-else class="image-preview">
+ <img :src="state.fileUrl" style="width:650px" alt="预览图片" class="preview-image" />
+ </div>
+ </el-form-item>
</el-form>
<template #footer v-if="!isReview">
<span class="dialog-footer">
@@ -28,7 +59,7 @@
</div>
</template>
<script setup>
-import {nextTick, reactive, ref, toRefs, watch} from 'vue'
+import {nextTick, onMounted, 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";
@@ -37,12 +68,17 @@
import {getToken} from "@/utils/auth";
import {handleThemeStyle} from "@/utils/theme";
import useSettingsStore from "@/store/modules/settings";
+import {addCom, editCom} from "@/api/companyInfo/overview";
+import Cookies from "js-cookie";
+import {getCompany} from "@/api/onlineEducation/company";
+import {delPic} from "@/api/onlineEducation/banner";
const emit = defineEmits(["getList"]);
const dialogVisible = ref(false);
const title = ref("");
+const toolbar = ref('fontsizeselect | undo redo')
const noticeRef = ref();
const fileList = ref([]);
const myEditor = ref();
@@ -51,34 +87,64 @@
const state = reactive({
noticeForm: {
id: '',
- noticeTitle: '',
- noticeContent: '',
+ companySummary: '',
+ companyId:null,
+ companyName: '',
+ filePath: '',
+ fileName: ''
},
formRules:{
- // noticeContent: [{ required: true, message: '请输入公告内容', trigger: 'blur' }],
+ companyId: [{ required: true, message: '请选择企业', trigger: 'blur' }],
+ companySummary: [{ required: true, message: '企业概况', trigger: 'blur' }],
+ filePath: [{ required: true, message: '请上传营业执照', trigger: 'blur' }],
},
+ isAdmin: false,
+ companyList: [],
+ uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile',
+ header: {
+ Authorization: getToken()
+ },
+ fileLimit: 1,
+ fileList: [],
+ fileType: '',
+ fileUrl: ''
})
-const openDialog = async (type, value) => {
- dialogVisible.value = true;
- // state.noticeForm.noticeContent = ""
+onMounted(() => {
+});
+const openDialog = async (type, value,companyList) => {
+
+ const userInfo = JSON.parse(Cookies.get('userInfo'))
+ state.isAdmin = userInfo.userType === 0;
+ if(state.isAdmin){
+ state.companyList = companyList
+ }
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)
- // }
+ Object.keys(state.noticeForm).forEach(key => {
+ if (key in value) {
+ state.noticeForm[key] = value[key]
+ }
+ })
+ state.noticeForm.companySummary = value.companySummary
+ state.noticeForm.id = value.id
+ if(state.isAdmin){
+ state.noticeForm.companyId = value.companyId
+ state.noticeForm.companyName = value.companyName
+ }
+ if(value.filePath) {
+ const obj = {
+ url: value.filePath,
+ name: value.fileName
+ }
+ state.fileType = value.fileName.split('.')[1]
+ state.fileUrl = import.meta.env.VITE_APP_BASE_API + '/' + value.filePath
+ state.fileList = [obj]
+ }
}
if(type === 'review') {
showEditor.value = false
@@ -91,11 +157,10 @@
if(type === 'add'){
reset()
}
-
-
+ dialogVisible.value = true;
}
const getEditorData = (val) =>{
- state.noticeForm.noticeContent = val;
+ state.noticeForm.companySummary = val;
}
const showFile = (e) => {
@@ -132,26 +197,27 @@
}
}
+
const onSubmit = async () => {
- state.noticeForm.noticeContent = tinyMCE.activeEditor.getContent();
- console.log("点击提交")
- console.log('data',state.noticeForm.noticeContent)
+ state.noticeForm.companySummary = tinyMCE.activeEditor.getContent();
+ if(!state.isAdmin){
+ const userInfo = JSON.parse(Cookies.get('userInfo'))
+ state.noticeForm.companyId = userInfo.companyId
+ state.noticeForm.companyName = userInfo.companyName
+ }
// // myEditor.value.submit();
const valid = await noticeRef.value.validate();
if(valid){
-
- if(state.noticeForm.noticeContent == "") {
+ if(state.noticeForm.companySummary == "") {
ElMessage({
type: 'warning',
- message: '请输入公司概况'
+ message: '请输入企业概况'
});
return;
}
if(title.value === '新增'){
- const param = {
- content: state.noticeForm.noticeContent,
- }
- const res = await addNotice(param)
+ const {id,...data} = JSON.parse(JSON.stringify(state.noticeForm))
+ const res = await addCom(data)
if(res.code === 200){
ElMessage({
type: 'success',
@@ -167,11 +233,8 @@
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)
+ const {...data} = JSON.parse(JSON.stringify(state.noticeForm))
+ const res = await editCom(data)
if(res.code === 200){
ElMessage({
type: 'success',
@@ -190,6 +253,13 @@
}
}
+const selectValue = (val) => {
+ state.companyList.forEach(item => {
+ if(item.name === val){
+ state.noticeForm.companyId = item.id
+ }
+ })
+}
const handleClose = () => {
if(title.value ==="新增"|| title.value ==='编辑'){
myEditor.value.clear();
@@ -197,16 +267,72 @@
}
// reset()
+ state.fileList = []
+ state.companyList = []
noticeRef.value.clearValidate();
dialogVisible.value = false;
}
const reset = () => {
state.noticeForm = {
- id: '',
- noticeTitle: '',
- noticeContent: ''
+ id: '',
+ companySummary: '',
+ companyId:null,
+ companyName: '',
+ filePath: '',
+ fileName: ''
}
+ state.fileList = []
}
+const handleAvatarSuccess = (res, uploadFile) => {
+ if(res.code == 200){
+ state.noticeForm.fileName = res.data.originName
+ state.noticeForm.filePath = res.data.path
+ }else{
+ state.fileList = []
+ ElMessage({
+ type: 'warning',
+ message: '文件上传失败'
+ })
+ }
+}
+
+const showTip =()=>{
+ ElMessage({
+ type: 'warning',
+ message: '超出文件上传数量'
+ });
+}
+const picSize = async (rawFile) => {
+ if(rawFile.size / 1024 / 1024 > 5){
+ ElMessage({
+ type: 'warning',
+ message: '文件大小不能超过5M'
+ });
+ return false
+ }
+};
+const handleRemove = async (file, uploadFiles) => {
+
+ let path = state.noticeForm.filePath;
+ await delPic({path: path}).then(res => {
+ if(res.code == 200){
+ // ElMessage({
+ // type: 'success',
+ // message: '文件已删除'
+ // })
+ state.noticeForm.filePath = ''
+ state.noticeForm.fileName = ''
+ }else{
+ ElMessage({
+ type: 'warning',
+ message: res.message
+ })
+ }
+ }).catch(() => {
+ state.noticeForm.filePath = ''
+ });
+}
+
defineExpose({
openDialog
--
Gitblit v1.9.2