From ee0224fcd3a0d5edc876013a6307310ee07d3b32 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: 星期五, 12 十二月 2025 16:21:50 +0800
Subject: [PATCH] 修改新增
---
src/views/build/conpanyFunctionConsult/infoPlatform/components/editDialog.vue | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 111 insertions(+), 6 deletions(-)
diff --git a/src/views/build/conpanyFunctionConsult/infoPlatform/components/editDialog.vue b/src/views/build/conpanyFunctionConsult/infoPlatform/components/editDialog.vue
index 6c3bbc5..6af0748 100644
--- a/src/views/build/conpanyFunctionConsult/infoPlatform/components/editDialog.vue
+++ b/src/views/build/conpanyFunctionConsult/infoPlatform/components/editDialog.vue
@@ -9,6 +9,16 @@
:close-on-click-modal="false"
>
<el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" >
+ <el-form-item v-if="state.isAdmin" label="单位:" prop="companyId">
+ <el-select v-model="state.form.companyId" placeholder="请选择" clearable>
+ <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="信息平台名称:" prop="platformName">
<el-input v-model.trim="state.form.platformName" :disabled="state.title =='查看'" placeholder="信息平台名称"></el-input>
</el-form-item>
@@ -20,6 +30,17 @@
value-format="YYYY-MM-DD"
placeholder="请选择创建时间"
/>
+ </el-form-item>
+ <el-form-item label="平台链接:" prop="platformAddress">
+ <el-input v-model.trim="state.form.platformAddress" :disabled="state.title =='查看'" placeholder="平台链接"></el-input>
+ </el-form-item>
+ <el-form-item label="系统图标" prop="platformPic">
+ <el-upload accept="image/*" :action="state.uploadUrl" :disabled="state.title =='查看'" list-type="picture-card" :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-icon><Plus /></el-icon>
+ <template #tip>
+ <div class="el-upload__tip">支持上传图片格式,尺寸小于5M,最多可上传1份</div>
+ </template>
+ </el-upload>
</el-form-item>
</el-form>
<template #footer v-if="state.title !='查看'">
@@ -38,28 +59,54 @@
import {Base64} from "js-base64"
import {getCompany} from "@/api/onlineEducation/company";
import {updateInfoPlatforms} from "@/api/staffManage/staff";
+import {delPic} from "@/api/onlineEducation/banner";
+import {getToken} from "@/utils/auth";
const emit = defineEmits(["getList"]);
const dialogVisible = ref(false)
const superRef = ref()
+const checkFiles = (rule, value, callback) => {
+ if (state.fileList.length == 0) {
+ callback(new Error('请上传系统图标'))
+ } else {
+ callback()
+ }
+}
const state = reactive({
title: '',
form: {
id: null,
platformName: '',
buildDate: '',
- companyId: null
+ companyId: null,
+ platformAddress: '',
+ platformPic: ''
},
formRules:{
+ companyId: [{ required: true, message: '请选择企业', trigger: 'blur' }],
platformName: [{ required: true, message: '请输入信息平台名称', trigger: 'blur' }],
- buildDate: [{ required: true, message: '请选择平台创建时间', trigger: 'blur' }]
- }
+ buildDate: [{ required: true, message: '请选择平台创建时间', trigger: 'blur' }],
+ platformAddress: [{ required: true, message: '请填写平台链接', trigger: 'blur' }],
+ platformPic: [{ required: true, validator: checkFiles, trigger: 'blur' }]
+ },
+ isAdmin: false,
+ companyList: [],
+ uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile',
+ header: {
+ Authorization: getToken()
+ },
+ fileLimit: 1,
+ fileList: []
})
onMounted(() => {
});
-const openDialog = async (type, value,companyId) => {
+const openDialog = async (type, value,companyId, isAdmin, companyList) => {
+ state.isAdmin = isAdmin
+ if(isAdmin){
+ state.companyList = companyList
+ }
state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看'
state.form.companyId = companyId
if(state.title == '编辑'||state.title == '查看'){
@@ -68,10 +115,63 @@
state.form[key] = value[key]
}
})
+ if(value.platformPic) {
+ const obj = {
+ url: import.meta.env.VITE_APP_BASE_API + '/' + value.platformPic,
+ name: value.platformName
+ }
+ state.fileList = [obj]
+ }
}
dialogVisible.value = true
}
+const handleAvatarSuccess = (res, uploadFile) => {
+ if(res.code == 200){
+ state.form.platformPic = 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.form.platformPic
+ await delPic({path: path}).then(res => {
+ if(res.code == 200){
+ // ElMessage({
+ // type: 'success',
+ // message: '文件已删除'
+ // })
+ state.form.platformPic = ''
+ }else{
+ ElMessage({
+ type: 'warning',
+ message: res.message
+ })
+ }
+ }).catch(() => {
+ state.form.platformPic = ''
+ });
+}
const onSubmit = async () => {
const valid = await superRef.value.validate();
@@ -81,7 +181,9 @@
data = {
platformName: state.form.platformName,
buildDate: state.form.buildDate,
- companyId: state.form.companyId
+ companyId: state.form.companyId,
+ platformAddress: state.form.platformAddress,
+ platformPic: state.form.platformPic
}
}else{
data = state.form
@@ -104,8 +206,11 @@
id: null,
platformName: '',
buildDate: '',
- companyId: null
+ companyId: null,
+ platformAddress: '',
+ platformPic: ''
}
+ state.fileList = []
superRef.value.clearValidate();
superRef.value.resetFields()
dialogVisible.value = false;
--
Gitblit v1.9.2