# Conflicts:
#	src/router/routes/basic.ts
This commit is contained in:
2025-12-05 10:05:50 +08:00
32 changed files with 902 additions and 333 deletions

View File

@ -10,9 +10,10 @@ VITE_PUBLIC_PATH = /
# 如果接口地址匹配到则会转发到http://localhost:3000防止本地出现跨域问题 # 如果接口地址匹配到则会转发到http://localhost:3000防止本地出现跨域问题
# 可以有多个,注意多个不能换行,否则代理将会失效 # 可以有多个,注意多个不能换行,否则代理将会失效
#VITE_PROXY = [["/api","http://localhost:3000"],["/upload","http://localhost:3300/upload"]] #VITE_PROXY = [["/api","http://localhost:3000"],["/upload","http://localhost:3300/upload"]]
VITE_PROXY=[["/api","http://10.10.2.102:9500"]] #VITE_PROXY=[["/api","http://10.10.2.102:9500"]]
#VITE_PROXY=[["/api/system/generator/","http://127.0.0.1:8091/system/generator/"],["/api/system/file/","http://127.0.0.1:8091/system/file/"],["/api/system/oss/","http://127.0.0.1:8091/system/oss/"],["/api/sales/","http://127.0.0.1:8096","/sales/"],["/api/mdm/","http://127.0.0.1:8096","/mdm/"],["/api","http://10.10.2.102:9500"]] #VITE_PROXY=[["/api/system/generator/","http://127.0.0.1:8091/system/generator/"],["/api/system/file/","http://127.0.0.1:8091/system/file/"],["/api/system/oss/","http://127.0.0.1:8091/system/oss/"],["/api/sales/","http://127.0.0.1:8096","/sales/"],["/api/mdm/","http://127.0.0.1:8096","/mdm/"],["/api","http://10.10.2.102:9500"]]
#VITE_PROXY=[["/api/sales/","http://127.0.0.1:8096","/sales/"],["/api/mdm/","http://127.0.0.1:8096","/mdm/"],["/api","http://10.10.2.102:9500"]] #VITE_PROXY=[["/api/sales/","http://127.0.0.1:8096","/sales/"],["/api/mdm/","http://127.0.0.1:8096","/mdm/"],["/api","http://10.10.2.102:9500"]]
VITE_PROXY=[["/api/system/file/","http://127.0.0.1:8091/system/file/"],["/api","http://10.10.2.102:9500"]]
# 是否删除Console.log # 是否删除Console.log
VITE_DROP_CONSOLE = false VITE_DROP_CONSOLE = false
@ -29,10 +30,10 @@ VITE_GLOB_API_URL=/api
VITE_GLOB_REPORT_URL=http://localhost:8090/api VITE_GLOB_REPORT_URL=http://localhost:8090/api
# 文件上传接口 可选 # 文件上传接口 可选
VITE_GLOB_UPLOAD_URL = /system/oss/upload VITE_GLOB_UPLOAD_URL = /system/file/upload
# 文件预览接口 可选 # 文件预览接口 可选
VITE_GLOB_UPLOAD_PREVIEW = http://10.10.2.101:8012/onlinePreview?url= VITE_GLOB_UPLOAD_PREVIEW = http://10.10.2.101:8012/preview/onlinePreview?url=
#外部url地址 #外部url地址
VITE_GLOB_OUT_LINK_URL = ['http://localhost:4100'] VITE_GLOB_OUT_LINK_URL = ['http://localhost:4100']

View File

@ -19,16 +19,16 @@ export function uploadApi(params: UploadFileParams) {
/** /**
* @description: Upload interface * @description: Upload interface
*/ */
export function uploadMultiApi(params: UploadFileParams, folderid) { export function uploadMultiApi(params: UploadFileParams,tableId:any,tableName?:any,columnName?:any) {
return defHttp.uploadFile<UploadApiResult>( return defHttp.uploadFile<UploadApiResult>(
{ {
url: '/system/oss/multi-upload?folderId=' + folderid, url: '/system/file/multi-upload?tableName=' + tableName + '&columnName=' + columnName + '&tableId=' + tableId,
}, },
params, params,
); );
} }
export const uploadSrc = '/system/oss/upload'; export const uploadSrc = '/system/file/upload';
// 上传二进制文件生成图片 // 上传二进制文件生成图片
export async function uploadBlobApi(blob, filename) { export async function uploadBlobApi(blob, filename) {

View File

@ -2,28 +2,38 @@ import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios'; import { ErrorMessageMode } from '/#/axios';
import { FilePageListParams, FilePageListSearchModel, FilePageListResultModel, ZipFilesModel, FileModel } from './model'; import { FilePageListParams, FilePageListSearchModel, FilePageListResultModel, ZipFilesModel, FileModel } from './model';
import { useGlobSetting } from '/@/hooks/setting';
const globSetting = useGlobSetting();
const urlPrefix = globSetting.apiUrl;
enum Api { enum Api {
File = '/system/file', File = '/system/file',
Info = '/system/file/info', Info = '/system/file/info',
InfoByDownloadUrl = '/system/file/info-byDownloadUrl', List = '/system/file/list',
List = '/system/file',
Page = '/system/file/page', Page = '/system/file/page',
DeleteFile = '/system/file/delete-single', DeleteFile = '/system/file/delete',
ZipFiles = '/system/file/package-files', ZipFiles = '/system/file/package-files',
} }
export async function getInfoByDownloadUrl(params: {id: string}, mode: ErrorMessageMode = 'modal') { export function parseDownloadUrl(url:string,th?:boolean,full?:boolean) {
return defHttp.get<FileModel>( // 空值防护如果url为空直接返回空字符串避免拼接出错
{ if (!url) return '';
url: Api.InfoByDownloadUrl,
params, // 判断url是否以/api开头忽略首尾空格兼容可能的空格场景
}, const trimmedUrl = url.trim();
{ if(urlPrefix!=undefined && trimmedUrl.startsWith(urlPrefix)){
errorMessageMode: mode, return trimmedUrl + (th ? '&th=true' : '');
}, }
); let resultUrl = urlPrefix + trimmedUrl + (th ? '&th=true' : '');
if(full){
return location.origin + resultUrl;
}
return resultUrl;
} }
/** /**
* @description: 查询文件分页 * @description: 查询文件分页
*/ */
@ -48,7 +58,7 @@ export async function getFilePage(
export async function deleteFile(ids: string[], mode: ErrorMessageMode = 'modal') { export async function deleteFile(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<number>( return defHttp.delete<number>(
{ {
url: Api.File, url: Api.DeleteFile,
data: ids, data: ids,
}, },
{ {
@ -64,7 +74,7 @@ export async function deleteSingleFile(id: string, mode: ErrorMessageMode = 'mod
return defHttp.delete<string>( return defHttp.delete<string>(
{ {
url: Api.DeleteFile, url: Api.DeleteFile,
data: id, data: [id],
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode,

View File

@ -2,7 +2,9 @@ import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
export interface FilePageListParams { export interface FilePageListParams {
fileName?: string; //文件名 fileName?: string; //文件名
folderId?: string; //文件夹Id tableName?: string; //表名称
columnName?: string; //属性名
tableId?: string; //表主键
processId?: string; //流程Id processId?: string; //流程Id
} }
@ -11,14 +13,17 @@ export interface FilePageListParams {
*/ */
export interface FilePageListModel { export interface FilePageListModel {
id: number; id: number;
folderId: number; tableName: string;
fileName: string; columnName: string;
tableId: number;
fileOrg: string;
fileUrl: string; fileUrl: string;
fileSize: number; fileSize: number;
fileSuffiex: any;
fileType: string; fileType: string;
downloadCount: number; filePath: string;
remark: string; downloadCnt: number;
docDesc: string;
} }
/** /**
@ -26,15 +31,18 @@ export interface FilePageListModel {
*/ */
export interface FileModel { export interface FileModel {
id: number; id: number;
folderId: number; tableName: string;
fileName: string; columnName: string;
tableId: number;
fileOrg: string;
fileUrl: string; fileUrl: string;
fileSize: number; fileSize: number;
fileSuffiex: any;
fileType: string; fileType: string;
downloadCount: number; filePath: string;
remark: string; downloadCnt: number;
fileUrlFixed: string; //加签后的url docDesc: string;
} }
/** /**

View File

@ -1326,25 +1326,25 @@
// console.log(t('上传超时')); // console.log(t('上传超时'));
// }; // };
// xhr.send(formData); // xhr.send(formData);
let folderId = data.value.options.defaultValue; let tableId = data.value.options.defaultValue;
uploadMultiApi( uploadMultiApi(
{ {
name: 'file', name: 'file',
file: [file] file: [file]
}, },
folderId tableId
).then((res) => { ).then((res) => {
data.value.options.defaultValue = res[0].folderId; data.value.options.defaultValue = res[0].tableId;
getImage(); getImage();
}); });
}; };
async function getImage() { async function getImage() {
if (data.value.options.defaultValue) { if (data.value.options.defaultValue) {
let fileList = await getFileList({ folderId: data.value.options.defaultValue }); let fileList = await getFileList({ tableId: data.value.options.defaultValue });
if (fileList.length) { if (fileList.length) {
imageUrl.value = fileList[0].fileUrl; imageUrl.value = fileList[0].fileUrl;
data.value.options.defaultValue = fileList[0].folderId; data.value.options.defaultValue = fileList[0].tableId;
} }
} else { } else {
imageUrl.value = ''; imageUrl.value = '';

View File

@ -38,6 +38,8 @@
const props = defineProps({ const props = defineProps({
value: String, value: String,
tableName: String,
columnName: String,
maxNumber: Number, maxNumber: Number,
accpet: String, accpet: String,
name: String, name: String,
@ -67,9 +69,24 @@
const fileList = ref<any[]>([]); const fileList = ref<any[]>([]);
const list = ref<any[]>([]); const list = ref<any[]>([]);
const { notification } = useMessage(); const { notification } = useMessage();
const folderId = ref<string>(''); const tableId = ref<string>('');
const tableName = ref<string>('');
const columnName = ref<string>('');
const bindValues = (data:any)=>{
if(data){
tableId.value = data.tableId;
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
}
}
const deleteFlag = ref(false); const deleteFlag = ref(false);
const emit = defineEmits(['update:value', 'change', 'click']); const emit = defineEmits(['update:value', 'change', 'click', 'update:tableName', 'update:columnName']);
const loading = ref(false); const loading = ref(false);
const previewVisible = ref(false); const previewVisible = ref(false);
@ -80,18 +97,19 @@
() => props.value, () => props.value,
async (val) => { async (val) => {
if (val) { if (val) {
fileList.value = await getFileList({ folderId: props.value }); fileList.value = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value });
if (fileList.value.length) { if (fileList.value.length) {
fileList.value.forEach((x) => { fileList.value.forEach((x) => {
x.name = x.fileName; x.name = x.fileOrg;
x.thumbUrl = x.fileUrl; x.thumbUrl = x.fileUrl;
x.status = 'done'; //没有则不会展示下载按钮 x.status = 'done'; //没有则不会展示下载按钮
}); });
folderId.value = fileList.value[0].folderId; bindValues(fileList.value[0]);
} }
} }
if (!val) { if (!val) {
fileList.value = []; fileList.value = [];
bindValues(undefined);
} }
}, },
{ {
@ -113,14 +131,16 @@
name: 'file', name: 'file',
file: arr file: arr
}, },
folderId.value tableId.value, tableName.value, columnName.value
); );
folderId.value = res[0].folderId; bindValues(res[0]);
fileList.value.forEach((x) => { fileList.value.forEach((x) => {
x.status = 'done'; //没有则不会展示下载按钮 x.status = 'done'; //没有则不会展示下载按钮
x.thumbUrl = x.fileUrl; x.thumbUrl = x.fileUrl;
}); });
emit('update:value', folderId.value); emit('update:value', tableId.value);
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change'); emit('change');
loading.value = false; loading.value = false;
} catch (error) { } catch (error) {
@ -155,26 +175,21 @@
} }
const handleRemove = async (info) => { const handleRemove = async (info) => {
const id = info.response ? info.response.data.id : info.id; const id = info.response ? info.response.data.id : info.id;
const status = await deleteSingleFile(id);
const newFolderId = await deleteSingleFile(id); if (status) {
folderId.value = newFolderId;
deleteFlag.value = true; deleteFlag.value = true;
const index = fileList.value.findIndex((x) => x.id === id); const index = fileList.value.findIndex((x) => x.id === id);
fileList.value.splice(index, 1); fileList.value.splice(index, 1);
fileList.value.forEach((x) => {
x.folderId = newFolderId;
});
emit('update:value', folderId.value);
emit('change');
notification.success({ notification.success({
message: 'Tip', message: 'Tip',
description: '删除成功!' description: '删除成功!'
}); });
}else{
notification.error({
message: 'Tip',
description: '删除失败!'
});
}
}; };
const handleDownload = (info) => { const handleDownload = (info) => {

View File

@ -29,13 +29,21 @@
import { Upload } from 'ant-design-vue'; import { Upload } from 'ant-design-vue';
import { PlusOutlined } from '@ant-design/icons-vue'; import { PlusOutlined } from '@ant-design/icons-vue';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { getFileList } from '/@/api/system/file'; import { getFileList,parseDownloadUrl } from '/@/api/system/file';
import { uploadMultiApi } from '/@/api/sys/upload'; import { uploadMultiApi } from '/@/api/sys/upload';
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
const props = defineProps({ const props = defineProps({
value: String, value: String,
tableName: {
type: String,
default: ''
},
columnName: {
type: String,
default: ''
},
name: String, name: String,
disabled: Boolean, disabled: Boolean,
isUpload: Boolean isUpload: Boolean
@ -44,9 +52,23 @@
const fileList = ref(''); const fileList = ref('');
const list = ref<any[]>([]); const list = ref<any[]>([]);
const { notification } = useMessage(); const { notification } = useMessage();
const folderId = ref<string>(''); const tableId = ref<string>('');
const tableName = ref<string>('');
const columnName = ref<string>('');
const bindValues = (data:any)=>{
if(data){
tableId.value = data.tableId;
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
}
}
const deleteFlag = ref(false); const deleteFlag = ref(false);
const emit = defineEmits(['update:value', 'change', 'click']); const emit = defineEmits(['update:value', 'change', 'click', 'update:tableName', 'update:columnName']);
const loading = ref(false); const loading = ref(false);
const visible = ref<boolean>(false); const visible = ref<boolean>(false);
const setVisible = (value): void => { const setVisible = (value): void => {
@ -57,14 +79,14 @@
() => props.value, () => props.value,
async (val) => { async (val) => {
if (val) { if (val) {
let result = await getFileList({ folderId: props.value }); let result = await getFileList({tableName: props.tableName, columnName: props.columnName,tableId: props.value});
if (result.length) { if (result.length) {
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
let x = result[i]; let x = result[i];
if (i > 0) break; if (i > 0) break;
fileList.value = x.fileUrl; fileList.value = parseDownloadUrl(x.fileUrl,false,true);
} }
folderId.value = result[0].folderId; bindValues(result[0]);
console.log(fileList.value, val, 'fileList.value'); console.log(fileList.value, val, 'fileList.value');
} }
} }
@ -91,21 +113,22 @@
name: 'file', name: 'file',
file: arr file: arr
}, },
folderId.value tableId.value, tableName.value, columnName.value
); );
folderId.value = res[0].folderId; bindValues(res[0]);
if (res.length) { if (res.length) {
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
let x = res[i]; let x = res[i];
if (i > 0) break; if (i > 0) break;
fileList.value = x.fileUrl; fileList.value = parseDownloadUrl(x.fileUrl,false,true);
} }
folderId.value = res[0].folderId; bindValues(res[0]);
console.log(fileList.value, 'fileList.value1111111'); console.log(fileList.value, 'fileList.value1111111');
} }
emit('update:value', folderId.value); emit('update:value', tableId.value);
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change'); emit('change');
loading.value = false; loading.value = false;
} catch (error) { } catch (error) {

View File

@ -42,7 +42,7 @@
import { Upload } from 'ant-design-vue'; import { Upload } from 'ant-design-vue';
import { QuestionCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue'; import { QuestionCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { deleteSingleFile, getFileList } from '/@/api/system/file'; import { deleteSingleFile, getFileList, parseDownloadUrl } from '/@/api/system/file';
import { downloadByUrl } from '/@/utils/file/download'; import { downloadByUrl } from '/@/utils/file/download';
import { uploadMultiApi } from '/@/api/sys/upload'; import { uploadMultiApi } from '/@/api/sys/upload';
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
@ -51,6 +51,14 @@
const { VITE_GLOB_UPLOAD_ALERT_TIP } = getAppEnvConfig(); const { VITE_GLOB_UPLOAD_ALERT_TIP } = getAppEnvConfig();
const props = defineProps({ const props = defineProps({
value: String, value: String,
tableName: {
type: String,
default: ''
},
columnName: {
type: String,
default: ''
},
showTip: { type: Boolean, default: true }, showTip: { type: Boolean, default: true },
placeholder: String, placeholder: String,
tipType: String, tipType: String,
@ -61,9 +69,24 @@
const fileList = ref<any[]>([]); const fileList = ref<any[]>([]);
const list = ref<any[]>([]); const list = ref<any[]>([]);
const { notification } = useMessage(); const { notification } = useMessage();
const folderId = ref<string>(''); const tableId = ref<string>('');
const tableName = ref<string>('');
const columnName = ref<string>('');
const bindValues = (data:any)=>{
if(data){
tableId.value = data.tableId;
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
}
}
const deleteFlag = ref(false); const deleteFlag = ref(false);
const emit = defineEmits(['update:value', 'change', 'click']); const emit = defineEmits(['update:value', 'change', 'click', 'update:tableName', 'update:columnName']);
const loading = ref(false); const loading = ref(false);
const name = ref(); const name = ref();
const previewVisible = ref(false); const previewVisible = ref(false);
@ -74,16 +97,16 @@
() => props.value, () => props.value,
async (val) => { async (val) => {
if (val) { if (val) {
fileList.value = await getFileList({ folderId: props.value }); fileList.value = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value});
if (fileList.value.length) { if (fileList.value.length) {
fileList.value.forEach((x) => { fileList.value.forEach((x) => {
x.name = x.fileName; x.name = x.fileOrg;
x.url = x.fileUrl; x.url = x.fileUrl;
x.thumbUrl = x.thUrl; x.thumbUrl = x.thUrl;
x.status = 'done'; //没有则不会展示下载按钮 x.status = 'done'; //没有则不会展示下载按钮
}); });
folderId.value = fileList.value[0].folderId; bindValues(fileList.value[0]);
name.value = fileList.value[0].name + fileList.value[0].fileType; name.value = fileList.value[0].fileOrg;
} }
} }
if (!val) { if (!val) {
@ -110,16 +133,18 @@
name: 'file', name: 'file',
file: arr file: arr
}, },
folderId.value tableId.value, tableName.value, columnName.value
); );
folderId.value = res[0].folderId; bindValues(res[0]);
fileList.value.forEach((x) => { fileList.value.forEach((x) => {
x.status = 'done'; //没有则不会展示下载按钮 x.status = 'done'; //没有则不会展示下载按钮
x.url = x.fileUrl; x.url = x.fileUrl;
x.thumbUrl = x.thUrl; x.thumbUrl = x.thUrl;
}); });
name.value = res[0].fileName + res[0].fileType; name.value = res[0].fileOrg;
emit('update:value', folderId.value); emit('update:value', tableId.value);
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change'); emit('change');
loading.value = false; loading.value = false;
} catch (error) { } catch (error) {
@ -152,40 +177,40 @@
const handleRemove = async (info) => { const handleRemove = async (info) => {
const id = info.response ? info.response.data.id : info.id; const id = info.response ? info.response.data.id : info.id;
const newFolderId = await deleteSingleFile(id); const status = await deleteSingleFile(id);
folderId.value = newFolderId;
if (status) {
deleteFlag.value = true; deleteFlag.value = true;
const index = fileList.value.findIndex((x) => x.id === id); const index = fileList.value.findIndex((x) => x.id === id);
fileList.value.splice(index, 1); fileList.value.splice(index, 1);
fileList.value.forEach((x) => {
x.folderId = newFolderId;
});
emit('update:value', folderId.value);
emit('change');
notification.success({ notification.success({
message: 'Tip', message: 'Tip',
description: '删除成功!' description: '删除成功!'
}); });
}else{
notification.error({
message: 'Tip',
description: '删除失败!'
});
}
}; };
const handleDownload = (info) => { const handleDownload = (info) => {
const url = info.response ? info.response.data.fileUrl : info.fileUrl; const url = parseDownloadUrl(info.response ? info.response.data.fileUrl : info.fileUrl);
const fileName = info.response ? info.response.data.fileName : info.fileName; const fileName = info.response ? info.response.data.fileOrg : info.fileOrg;
downloadByUrl({ url, fileName }); downloadByUrl({ url, fileName });
}; };
const handlePreview = async (file) => { const handlePreview = async (file) => {
const fileUrl = file.response?.data?.fileUrl || file.fileUrl; const fileUrl = file.response?.data?.fileUrl || file.fileUrl;
previewFile.value = getAppEnvConfig().VITE_GLOB_UPLOAD_PREVIEW + encodeURIComponent(Base64.encode(fileUrl.includes('http://') || fileUrl.includes('https://') ? fileUrl : getAppEnvConfig().VITE_GLOB_API_URL + fileUrl)); const fileFullUrl = fileUrl.includes('http://') || fileUrl.includes('https://') ? fileUrl : location.origin + getAppEnvConfig().VITE_GLOB_API_URL + fileUrl;
previewFile.value = getAppEnvConfig().VITE_GLOB_UPLOAD_PREVIEW + encodeURIComponent(Base64.encode(fileFullUrl));
previewVisible.value = true; previewVisible.value = true;
previewTitle.value = file.name || file.fileName; previewTitle.value = file.name || file.fileOrg;
console.log(fileFullUrl);
}; };
const handleCancel = () => { const handleCancel = () => {
@ -195,8 +220,8 @@
function handleClear() { function handleClear() {
name.value = ''; name.value = '';
folderId.value = ''; tableId.value = '';
emit('update:value', folderId.value); emit('update:value', tableId.value);
emit('change'); emit('change');
} }
</script> </script>

View File

@ -69,9 +69,9 @@
<upload-outlined /> <upload-outlined />
点击上传 点击上传
</a-button> </a-button>
<!-- <div v-if="VITE_GLOB_UPLOAD_ALERT_TIP?.trim()" style="color: red; margin-top: 8px"> <div v-if="VITE_GLOB_UPLOAD_ALERT_TIP?.trim()" style="color: red; margin-top: 8px">
{{ VITE_GLOB_UPLOAD_ALERT_TIP }} {{ VITE_GLOB_UPLOAD_ALERT_TIP }}
</div> --> </div>
</div> </div>
<template #itemRender="{ file, actions }"> <template #itemRender="{ file, actions }">
@ -110,7 +110,7 @@
import { Upload } from 'ant-design-vue'; import { Upload } from 'ant-design-vue';
import { UploadOutlined, PlusOutlined, DownloadOutlined, DeleteOutlined, EditOutlined, PaperClipOutlined } from '@ant-design/icons-vue'; import { UploadOutlined, PlusOutlined, DownloadOutlined, DeleteOutlined, EditOutlined, PaperClipOutlined } from '@ant-design/icons-vue';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { deleteSingleFile, getAppToken, getFileList, getOnlineEditUrl, getZipFiles } from '/@/api/system/file'; import { deleteFile, getAppToken, getFileList, getZipFiles,parseDownloadUrl } from '/@/api/system/file';
import { downloadByUrl } from '/@/utils/file/download'; import { downloadByUrl } from '/@/utils/file/download';
import { uploadMultiApi } from '/@/api/sys/upload'; import { uploadMultiApi } from '/@/api/sys/upload';
import Icon from '/@/components/Icon/index'; import Icon from '/@/components/Icon/index';
@ -124,8 +124,18 @@
const { createSuccessModal } = useMessage(); const { createSuccessModal } = useMessage();
const props = defineProps({ const props = defineProps({
value: String, value: String,
tableName: {
type: String,
default: ''
},
columnName: {
type: String,
default: ''
},
maxNumber: Number, maxNumber: Number,
accept: String, accept: String,
name: String, name: String,
@ -156,9 +166,24 @@
const fileList = ref<any[]>([]); const fileList = ref<any[]>([]);
const list = ref<any[]>([]); const list = ref<any[]>([]);
const { notification } = useMessage(); const { notification } = useMessage();
const folderId = ref<string>(''); const tableId = ref<string>('');
const tableName = ref<string>('');
const columnName = ref<string>('');
const bindValues = (data:any)=>{
if(data){
tableId.value = data.tableId;
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
}
}
const deleteFlag = ref(false); const deleteFlag = ref(false);
const emit = defineEmits(['update:value', 'change', 'click']); const emit = defineEmits(['update:value', 'change', 'click', 'update:tableName', 'update:columnName']);
const loading = ref(false); const loading = ref(false);
const previewVisible = ref(false); const previewVisible = ref(false);
@ -170,18 +195,18 @@
() => props.value, () => props.value,
async (val) => { async (val) => {
if (val) { if (val) {
fileList.value = await getFileList({ folderId: props.value }); fileList.value = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value });
if (fileList.value.length) { if (fileList.value.length) {
fileList.value.forEach((x) => { fileList.value.forEach((x) => {
x.name = x.fileName; x.name = x.fileOrg;
x.url = x.fileUrl; x.url = x.fileUrl;
x.thumbUrl = x.thUrl; x.thumbUrl = x.thUrl;
x.status = 'done'; //没有则不会展示下载按钮 x.status = 'done'; //没有则不会展示下载按钮
}); });
folderId.value = fileList.value[0].folderId; bindValues(fileList.value[0]);
} }
} else { } else {
folderId.value = ''; bindValues(undefined);
} }
if (!val) { if (!val) {
fileList.value = []; fileList.value = [];
@ -206,9 +231,9 @@
name: 'file', name: 'file',
file: arr file: arr
}, },
folderId.value tableId.value, tableName.value, columnName.value
); );
folderId.value = res[0].folderId; bindValues(res[0]);
fileList.value.forEach((x) => { fileList.value.forEach((x) => {
x.status = 'done'; //没有则不会展示下载按钮 x.status = 'done'; //没有则不会展示下载按钮
x.url = x.fileUrl; x.url = x.fileUrl;
@ -216,8 +241,10 @@
x.fileSize = x.fileSize x.fileSize = x.fileSize
}); });
emit('update:value', folderId.value); emit('update:value', tableId.value);
emit('change', fileList.value); emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change');
loading.value = false; loading.value = false;
} catch (error) { } catch (error) {
console.error(error); console.error(error);
@ -255,34 +282,27 @@
} }
const handleRemove = async (info) => { const handleRemove = async (info) => {
const id = info.response ? info.response.data.id : info.id; const id = info.response ? info.response.data.id : info.id;
const status = await deleteFile([id]);
const newFolderId = await deleteSingleFile(id); if (status) {
folderId.value = newFolderId;
deleteFlag.value = true; deleteFlag.value = true;
const index = fileList.value.findIndex((x) => x.id === id); const index = fileList.value.findIndex((x) => x.id === id);
fileList.value.splice(index, 1); fileList.value.splice(index, 1);
fileList.value.forEach((x) => {
x.folderId = newFolderId;
});
emit('update:value', folderId.value);
emit('change');
notification.success({ notification.success({
message: 'Tip', message: 'Tip',
description: '删除成功!' description: '删除成功!'
}); });
}else{
notification.error({
message: 'Tip',
description: '删除失败!'
});
}
}; };
const handleDownload = (info) => { const handleDownload = (info) => {
const url = info.response ? info.response.data.fileUrl : info.fileUrl; const url = parseDownloadUrl(info.response ? info.response.data.fileUrl : info.fileUrl);
const fileName = info.response ? info.response.data.fileName : info.fileName; const fileName = info.response ? info.response.data.fileOrg : info.fileOrg;
const fileType = info.response ? info.response.data.fileType : info.fileType; downloadByUrl({ url, fileName: fileName});
downloadByUrl({ url, fileName: fileName + fileType });
}; };
const handleCancelWps = () => { const handleCancelWps = () => {
@ -322,12 +342,13 @@
const handlePreview = async (file) => { const handlePreview = async (file) => {
const fileUrl = file.response?.data?.fileUrl || file.fileUrl; const fileUrl = file.response?.data?.fileUrl || file.fileUrl;
previewFile.value = getAppEnvConfig().VITE_GLOB_UPLOAD_PREVIEW + encodeURIComponent(Base64.encode(fileUrl.includes('http://') || fileUrl.includes('https://') ? fileUrl : getAppEnvConfig().VITE_GLOB_API_URL + fileUrl)); const fileFullUrl = fileUrl.includes('http://') || fileUrl.includes('https://') ? fileUrl : location.origin + getAppEnvConfig().VITE_GLOB_API_URL + fileUrl;
previewFile.value = getAppEnvConfig().VITE_GLOB_UPLOAD_PREVIEW + encodeURIComponent(Base64.encode(fileFullUrl));
previewVisible.value = true; previewVisible.value = true;
previewTitle.value = file.name || file.fileName; previewTitle.value = file.name || file.fileOrg;
console.log(fileUrl.includes('http://') || fileUrl.includes('https://') ? fileUrl : getAppEnvConfig().VITE_GLOB_API_URL + fileUrl); console.log(fileFullUrl);
}; };
const handleCancel = () => { const handleCancel = () => {
@ -377,15 +398,9 @@
createSuccessModal({ title: 'Tip', content: res.msg }); createSuccessModal({ title: 'Tip', content: res.msg });
return; return;
} else if (res.type === 'synced') { } else if (res.type === 'synced') {
downloadByUrl({ url: res.url, fileName: res.name || 'files.zip' }); downloadByUrl({ url: parseDownloadUrl(res.url), fileName: res.name || 'files.zip' });
} }
} }
function getValue () {
return fileList.value
}
defineExpose({
getValue
});
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.list-upload { .list-upload {

View File

@ -0,0 +1,511 @@
<template>
<div>
<div v-if="listType === 'dragger'">
<a-upload-dragger
:file-list="fileList"
:maxCount="maxNumber"
:accept="accept"
:name="name"
:disabled="disabled"
:multiple="multiple"
:beforeUpload="beforeUpload"
listType="picture"
:show-upload-list="{ showDownloadIcon, showPreviewIcon, showRemoveIcon }"
@remove="handleRemove"
@download="handleDownload"
@preview="handlePreview"
@drop="handleClick"
@click="handleClick"
class="list-upload dragger-upload"
:style="style"
>
<div class="dragger-text">
<Icon icon="ep:upload-filled" color="#5e95ff" :size="24" />
<div class="mt-2 text-xs">点击或将文件拖拽到这里上传</div>
</div>
<div class="dragger-tip">{{ tip }}</div>
</a-upload-dragger>
</div>
<div v-else-if="listType === 'picture'">
<a-upload
:file-list="fileList"
:maxCount="maxNumber"
:accept="accept"
:name="name"
:disabled="disabled"
:multiple="multiple"
:beforeUpload="beforeUpload"
:listType="listType"
:show-upload-list="{ showDownloadIcon, showPreviewIcon, showRemoveIcon }"
@remove="handleRemove"
@download="handleDownload"
@preview="handlePreview"
@click="handleClick"
class="list-upload"
:style="style"
>
<plus-outlined />
</a-upload>
</div>
<a-upload
:file-list="fileListWithHeader"
:maxCount="maxNumber"
:accept="accept"
:name="name"
:disabled="disabled"
:multiple="multiple"
:beforeUpload="beforeUpload"
:listType="listType"
:show-upload-list="showUploadList"
@remove="handleRemove"
@download="handleDownload"
@preview="handlePreview"
@click="handleClick"
v-else
>
<plus-outlined v-if="listType == 'picture-card'" />
<div :style="style" v-else>
<a-button :loading="loading" :disabled="loading" v-if="!disabled">
<upload-outlined />
{{ btnTip || '点击上传' }}
</a-button>
<!-- <div v-if="VITE_GLOB_UPLOAD_ALERT_TIP?.trim()" style="color: red; margin-top: 8px">
{{ VITE_GLOB_UPLOAD_ALERT_TIP }}
</div> -->
</div>
<template #itemRender="{ file, actions }">
<template v-if="file.__header && showDownloadIcon">
<!-- <div class="file-list-header" style="display: flex; align-items: center; padding: 4px 0">
<input type="checkbox" :checked="isAllSelected" @change="toggleSelectAll" style="margin-right: 8px" />全选
<a-button type="primary" size="small" :disabled="!selectedIds.length" @click="handleBatchDownload" style="margin-left: 8px">批量打包下载</a-button>
</div> -->
</template>
<template v-else>
<a-space class="file-space">
<!-- <input v-if="showDownloadIcon" type="checkbox" :checked="selectedIds.includes(file.id)" @change="(e) => toggleSelectOne(file.id, e)" style="margin-right: 8px" /> -->
<PaperClipOutlined />
<span class="file-name-span" @click="actions.preview">{{ file.name }}</span>
<a-tooltip v-if="showDownloadIcon" title="下载">
<span @click="actions.download" class="file-outlined-span"><DownloadOutlined /></span>
</a-tooltip>
<a-tooltip v-if="!disabled && showRemoveIcon" title="删除">
<span @click="actions.remove" class="file-outlined-span"><DeleteOutlined /></span>
</a-tooltip>
<!-- <a-tooltip v-if="'.doc,.docx,.xls,.xlsx,.pdf'.includes(file.fileType)" title="编辑文档">
<span @click="editFile(file)" class="file-outlined-span"><EditOutlined /></span>
</a-tooltip> -->
</a-space>
</template>
</template>
</a-upload>
<a-modal :bodyStyle="bodyStyle" :width="800" :visible="previewVisible" :title="previewTitle" :footer="null" @cancel="handleCancel"> <iframe v-if="previewVisible" :src="previewFile" class="iframe-box"></iframe>; </a-modal>
<a-modal wrap-class-name="full-modal" width="100%" :visible="wpsPreviewVisible" :title="previewTitle" :footer="null" @cancel="handleCancelWps">
<div v-if="wpsPreviewVisible" id="office-container"></div>
</a-modal>
</div>
</template>
<script lang="ts" setup>
import { nextTick, ref, watch, computed } from 'vue';
import { Upload } from 'ant-design-vue';
import { UploadOutlined, PlusOutlined, DownloadOutlined, DeleteOutlined, EditOutlined, PaperClipOutlined } from '@ant-design/icons-vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { deleteSingleFile, getAppToken, getFileList, parseDownloadUrl, getZipFiles } from '/@/api/system/file';
import { downloadByUrl } from '/@/utils/file/download';
import { uploadMultiApi } from '/@/api/sys/upload';
import Icon from '/@/components/Icon/index';
import { Base64 } from 'js-base64';
import { getAppEnvConfig } from '/@/utils/env';
import WebOfficeSDK from '/@/assets/libs/open-jssdk-v0.1.3.es.js';
import { getToken } from '/@/utils/auth';
import { useRoute } from 'vue-router';
const route = useRoute();
const { VITE_GLOB_UPLOAD_ALERT_TIP } = getAppEnvConfig();
const { createSuccessModal } = useMessage();
const props = defineProps({
value: String,
tableName: String,
columnName: String,
maxNumber: Number,
accept: String,
name: String,
disabled: Boolean,
multiple: Boolean,
maxSize: Number,
api: Function,
style: Object,
listType: {
type: String,
default: 'text'
},
tip: String,
showPreviewIcon: {
type: Boolean,
default: true
},
showRemoveIcon: {
type: Boolean,
default: true
},
showDownloadIcon: {
type: Boolean,
default: true
},
showUploadList: {
type: Boolean,
default: true
},
fileList: Array,
btnTip: String
});
const fileList = ref<any[]>([]);
const list = ref<any[]>([]);
const { notification } = useMessage();
const tableId = ref<string>('');
const tableName = ref<string>('');
const columnName = ref<string>('');
const bindValues = (data:any)=>{
if(data){
tableId.value = data.tableId;
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
}
}
const deleteFlag = ref(false);
const emit = defineEmits(['update:value', 'change', 'click','update:tableName', 'update:columnName']);
const loading = ref(false);
const previewVisible = ref(false);
const wpsPreviewVisible = ref(false);
const previewFile = ref('');
const previewTitle = ref('');
watch(
() => props.fileList,
async (val) => {
console.log(val, 43)
if (val) {
fileList.value = props.fileList
if (fileList.value.length) {
fileList.value.forEach((x) => {
x.name = x.fileName || x.fileOrg;
x.url = x.fileUrl || x.filePath;
x.thumbUrl = x.thUrl || x.filePath;
x.status = 'done'; //没有则不会展示下载按钮
x.fileType =x.fileType || ('.' + x.filePath.split('?')[0]?.split('.')?.pop())
});
}
bindValues(fileList.value[0]);
} else {
bindValues(undefined);
}
if (!val) {
fileList.value = [];
}
},
{
immediate: true
}
);
watch(
() => props.value,
async (val) => {
if (val) {
fileList.value = await getFileList({tableName: props.tableName, columnName: props.columnName,tableId: props.value});
if (fileList.value.length) {
fileList.value.forEach((x) => {
x.name = x.fileName;
x.url = x.fileUrl;
x.thumbUrl = x.thUrl;
x.status = 'done'; //没有则不会展示下载按钮
});
}
bindValues(fileList.value[0]);
} else {
bindValues(undefined);
}
if (!val) {
fileList.value = [];
}
},
{
immediate: true
}
);
watch(
() => list.value,
async (val) => {
if (deleteFlag.value) return;
if (val.length) {
let arr: any[] = val.filter((o) => {
return !o.status;
});
if (arr.length <= 0) return;
try {
let res = await uploadMultiApi(
{
name: 'file',
file: arr
},
tableId.value, tableName.value, columnName.value
);
let fileArr = res||[]
fileArr.forEach((x) => {
x.status = 'done'; //没有则不会展示下载按钮
x.url = x.fileUrl;
x.thumbUrl = x.thUrl;
x.fileSize = x.fileSize
});
bindValues(res[0]);
fileList.value = [...fileList.value, ...fileArr]
emit('update:value', tableId.value);
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change');
loading.value = false;
} catch (error) {
console.error(error);
loading.value = false;
}
}
}
);
const bodyStyle = { height: '500px' };
const beforeUpload = (file) => {
if (props.maxSize && file.size / 1024 / 1024 > props.maxSize) {
notification.error({
message: 'Tip',
description: `文件大小不能超过${props.maxSize}MB`
});
return false || Upload.LIST_IGNORE;
}
if (props.maxNumber && fileList.value.length + list.value.length === props.maxNumber!) {
notification.error({
message: 'Tip',
description: `文件数量不能超过${props.maxNumber}个!`
});
return false;
}
list.value = [...list.value, file];
deleteFlag.value = false;
loading.value = true;
return Upload.LIST_IGNORE;
};
function handleClick() {
list.value = [];
}
const handleRemove = async (info) => {
const id = info.response ? info.response.data.id : info.id;
const index = fileList.value.findIndex((x) => x.id === id);
fileList.value.splice(index, 1);
emit('update:value', tableId.value);
emit('change', fileList.value);
notification.success({
message: 'Tip',
description: '删除成功!'
});
};
const handleDownload = (info) => {
console.log(info, 434)
const url = parseDownloadUrl(info.response ? info.response.data.fileUrl : (info.presignedUrl || info.fileUrl));
const fileName = info.response ? info.response.data.fileOrg : info.fileOrg;
downloadByUrl({ url, fileName: fileName });
};
const handleCancelWps = () => {
wpsPreviewVisible.value = false;
previewTitle.value = '';
};
const refreshToken = async () => {
return getToken();
};
const editFile = async (file) => {
wpsPreviewVisible.value = true;
previewTitle.value = file.name || file.fileName;
let appToken = await getAppToken({ _w_fileid: file.id });
let containerNode = document.getElementById('office-container');
containerNode.style.height = 'calc(100vh - 50px)';
containerNode.style.width = '100%';
let webOfficeSdk = WebOfficeSDK.config({
mount: containerNode,
url: appToken.wpsUrl + '&_w_tokentype=1',
refreshToken: refreshToken
});
webOfficeSdk.setToken({
token: appToken.token,
timeout: 10 * 60 * 1000
});
/*await webOfficeSdk.ready();
const app = webOfficeSdk.Application;
// 获取总页数
const totalPages = await app.ActiveDocument.Range.Information(
app.Enum.WdInformation.wdNumberOfPagesInDocument
);
console.log("总页数为:", totalPages);*/
};
const handlePreview = async (file) => {
const fileUrl = file.presignedUrl|| file.response?.data?.fileUrl || file.fileUrl;
console.log(fileUrl, 'fileUrl', file)
window.open(fileUrl)
// previewFile.value = getAppEnvConfig().VITE_GLOB_UPLOAD_PREVIEW + encodeURIComponent(Base64.encode(fileUrl.includes('http://') || fileUrl.includes('https://') ? fileUrl : getAppEnvConfig().VITE_GLOB_API_URL + fileUrl));
// previewVisible.value = true;
// previewTitle.value = file.name || file.fileName;
// console.log(previewFile.value, 99)
// console.log(fileUrl.includes('http://') || fileUrl.includes('https://') ? fileUrl : getAppEnvConfig().VITE_GLOB_API_URL + fileUrl);
};
const handleCancel = () => {
previewVisible.value = false;
previewTitle.value = '';
};
const selectedIds = ref<string[]>([]);
const isAllSelected = computed(() => fileList.value.length > 0 && selectedIds.value.length === fileList.value.length);
const fileListWithHeader = computed(() => {
// 只在有文件时插入头部
if (fileList.value.length) {
return [{ __header: true, uid: '__header__' }, ...fileList.value];
}
return fileList.value;
});
function toggleSelectAll(e: Event) {
const checked = (e.target as HTMLInputElement).checked;
selectedIds.value = checked ? fileList.value.map((f) => f.id) : [];
}
function toggleSelectOne(id: string, e: Event) {
const checked = (e.target as HTMLInputElement).checked;
if (checked) {
selectedIds.value = [...selectedIds.value, id];
} else {
selectedIds.value = selectedIds.value.filter((item) => item !== id);
}
}
async function handleBatchDownload() {
if (!selectedIds.value.length) return;
// getZipFiles 返回下载url
let formName = '';
try {
formName = (route.query.formName as string) || '';
// 获取当前页面得form name
} catch (error) {
console.warn(error);
}
const res = await getZipFiles({ fileIds: selectedIds.value.join(','), insertionFileName: formName });
if (!res) {
notification.error({
message: 'Tip',
description: '批量下载失败,请稍后重试!'
});
return;
} else if (res.type === 'async') {
createSuccessModal({ title: 'Tip', content: res.msg });
return;
} else if (res.type === 'synced') {
downloadByUrl({ url: res.url, fileName: res.name || 'files.zip' });
}
}
</script>
<style lang="less" scoped>
.list-upload {
:deep(.ant-upload) {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 128px;
height: 128px;
background: #fafafa;
border: 1px dashed #d9d9d9;
}
:deep(.anticon-plus) {
font-size: 20px;
color: #999;
}
.dragger-tip {
background: rgb(0 0 0 / 60%);
color: #fff;
height: 100%;
border-radius: 2px;
display: none;
padding: 8px 5px;
width: 100%;
}
.dragger-text {
padding: 16px 0;
}
&:hover .dragger-tip {
display: block;
}
&:hover .dragger-text {
display: none;
}
}
:deep(.ant-upload) {
padding: 0 !important;
}
.iframe-box {
width: 100%;
height: 100%;
}
.file-name-span {
margin-right: 16px;
color: #1890ff;
cursor: pointer;
}
.file-outlined-span {
cursor: pointer;
}
.file-space:hover {
background-color: #f5f5f5;
}
.file-space {
display: flex;
align-items: center;
padding: 5px 0;
}
.full-modal {
.ant-modal {
max-width: 100%;
top: 0;
padding-bottom: 0;
margin: 0;
}
.ant-modal-content {
display: flex;
flex-direction: column;
height: calc(100vh);
}
.ant-modal-body {
flex: 1;
}
}
</style>

View File

@ -20,7 +20,7 @@
</a-button> </a-button>
</Tooltip> </Tooltip>
</Space> </Space>
<UploadModal v-bind="bindValue" :previewFileList="fileList" :folderId="folderId" @register="registerUploadModal" @change="handleChange" @delete="handleDelete" /> <UploadModal v-bind="bindValue" :previewFileList="fileList" :folderId="tableId" @register="registerUploadModal" @change="handleChange" @delete="handleDelete" />
<UploadPreviewModal :value="fileList" :file-names="fileNameList" @register="registerPreviewModal" @list-change="handlePreviewChange" @delete="handlePreviewDelete" /> <UploadPreviewModal :value="fileList" :file-names="fileNameList" @register="registerPreviewModal" @list-change="handlePreviewChange" @delete="handlePreviewDelete" />
</div> </div>
@ -56,7 +56,7 @@
const fileList = ref<string[]>([]); const fileList = ref<string[]>([]);
const fileNameList = ref<string[]>([]); const fileNameList = ref<string[]>([]);
const folderId = computed(() => props.value); const tableId = computed(() => props.value);
const showPreview = computed(() => { const showPreview = computed(() => {
const { emptyHidePreview } = props; const { emptyHidePreview } = props;
if (!emptyHidePreview) return true; if (!emptyHidePreview) return true;
@ -73,9 +73,9 @@
async (value) => { async (value) => {
//如果没有传入参数 默认不再请求文件列表 //如果没有传入参数 默认不再请求文件列表
if (value && value.length > 0) { if (value && value.length > 0) {
const list = await getFileList({ folderId: value }); const list = await getFileList({ tableId: value });
fileList.value = list.map((item) => item.fileUrl); fileList.value = list.map((item) => item.fileUrl);
fileNameList.value = list.map((item) => item.fileName); fileNameList.value = list.map((item) => item.fileOName);
} else { } else {
fileList.value = []; fileList.value = [];
} }
@ -122,7 +122,7 @@
bindValue, bindValue,
handleDelete, handleDelete,
handlePreviewDelete, handlePreviewDelete,
folderId, tableId,
t t
}; };
} }

View File

@ -173,7 +173,7 @@
{ {
data: { data: {
...(props.uploadParams || {}), ...(props.uploadParams || {}),
folderId tableId: props.folderId,
}, },
file: item.file, file: item.file,
name: props.name, name: props.name,

View File

@ -224,14 +224,6 @@ export const FLOW_ROUTE: AppRouteRecordRaw[] = [{
title: (route) => '查看'+(route.query.formName||'表单') title: (route) => '查看'+(route.query.formName||'表单')
} }
}, },
// {
// path: 'createFormCustomer',
// name: 'createFormCustomer',
// component: () => import('/@/views/sales/Customer/formCreatePage.vue'),
// meta: {
// title: (route) => '新建'+(route.query.formName||'表单')
// }
// }
] ]
}]; }];
export const PROCESS_MONITORING: AppRouteRecordRaw[] = [{ export const PROCESS_MONITORING: AppRouteRecordRaw[] = [{

View File

@ -1,5 +1,6 @@
import { openWindow } from '..'; import { openWindow } from '..';
import { dataURLtoBlob, urlToBase64 } from './base64Conver'; import { dataURLtoBlob, urlToBase64 } from './base64Conver';
import { defHttp } from '/@/utils/http/axios';
/** /**
* Download online pictures * Download online pictures
@ -71,7 +72,6 @@ export function downloadByUrl({
let fileUrl = window.URL.createObjectURL(x.response); let fileUrl = window.URL.createObjectURL(x.response);
const isChrome = window.navigator.userAgent.toLowerCase().indexOf('chrome') > -1; const isChrome = window.navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
const isSafari = window.navigator.userAgent.toLowerCase().indexOf('safari') > -1; const isSafari = window.navigator.userAgent.toLowerCase().indexOf('safari') > -1;
if (/(iP)/g.test(window.navigator.userAgent)) { if (/(iP)/g.test(window.navigator.userAgent)) {
console.error('Your browser does not support download!'); console.error('Your browser does not support download!');
return false; return false;

View File

@ -26,7 +26,6 @@ import useGlobalFlag from '/@/hooks/core/useGlobalFlag';
import { useLockStore } from '/@/store/modules/lock'; import { useLockStore } from '/@/store/modules/lock';
const globSetting = useGlobSetting(); const globSetting = useGlobSetting();
const urlPrefix = globSetting.urlPrefix; const urlPrefix = globSetting.urlPrefix;
const { createMessage, createErrorModal } = useMessage(); const { createMessage, createErrorModal } = useMessage();

View File

@ -25,7 +25,7 @@
height: '300px' height: '300px'
} }
}); });
imgList.value = await getFileList({ folderId: data.filePath }); imgList.value = await getFileList({ tableId: data.filePath });
}); });
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -302,7 +302,7 @@
}; };
}); });
if (baseInfo.value.filePath) { if (baseInfo.value.filePath) {
imgList.value = await getFileList({ folderId: baseInfo.value.filePath }); imgList.value = await getFileList({ tableId: baseInfo.value.filePath });
} }
}; };

View File

@ -46,7 +46,7 @@
alarmtInfo.value = await getDeviceAlarmCheck(data.id); alarmtInfo.value = await getDeviceAlarmCheck(data.id);
imgSrc.value = alarmtInfo.value?.state === 0 ? 'check_tip_no1' : 'check_tip_pass1'; imgSrc.value = alarmtInfo.value?.state === 0 ? 'check_tip_no1' : 'check_tip_pass1';
if (alarmtInfo.value.filePath) { if (alarmtInfo.value.filePath) {
imgList.value = await getFileList({ folderId: alarmtInfo.value.filePath }); imgList.value = await getFileList({ tableId: alarmtInfo.value.filePath });
} }
}); });
</script> </script>

View File

@ -49,7 +49,7 @@
inspectInfo.value = await getDeviceInspectInfo(data.id); inspectInfo.value = await getDeviceInspectInfo(data.id);
imgSrc.value = inspectInfo.value?.state === 0 ? 'check_tip_no' : 'check_tip_pass'; imgSrc.value = inspectInfo.value?.state === 0 ? 'check_tip_no' : 'check_tip_pass';
if (inspectInfo.value.filePath) { if (inspectInfo.value.filePath) {
imgList.value = await getFileList({ folderId: inspectInfo.value.filePath }); imgList.value = await getFileList({ tableId: inspectInfo.value.filePath });
} }
}); });
</script> </script>

View File

@ -257,7 +257,7 @@
} }
]; ];
if (baseInfo.value.fileId) { if (baseInfo.value.fileId) {
imgList.value = await getFileList({ folderId: baseInfo.value.fileId }); imgList.value = await getFileList({ tableId: baseInfo.value.fileId });
} }
}); });

View File

@ -528,7 +528,7 @@
isReady.value = true; isReady.value = true;
if (baseInfo.value.filePath) { if (baseInfo.value.filePath) {
imgList.value = await getFileList({ folderId: baseInfo.value.filePath }); imgList.value = await getFileList({ tableId: baseInfo.value.filePath });
} }
}; };

View File

@ -612,7 +612,7 @@
}; };
}); });
if (baseInfo.value.filePath) { if (baseInfo.value.filePath) {
imgList.value = await getFileList({ folderId: baseInfo.value.filePath }); imgList.value = await getFileList({ tableId: baseInfo.value.filePath });
} }
}; };

View File

@ -103,10 +103,10 @@
} }
}); });
if (ele1.fieldCode.indexOf('file') > 0 || ele1.fieldCode.indexOf('File') > 0) { if (ele1.fieldCode.indexOf('file') > 0 || ele1.fieldCode.indexOf('File') > 0) {
const newlist = await getFileList({ folderId: ele1.newValue }); const newlist = await getFileList({ tableId: ele1.newValue });
fileList.value.push({ id: ele1.newValue, name: newlist.map((item) => item.fileName).join('、') }); fileList.value.push({ id: ele1.newValue, name: newlist.map((item) => item.fileName).join('、') });
const oldlist = await getFileList({ folderId: ele1.oldValue }); const oldlist = await getFileList({ tableId: ele1.oldValue });
fileList.value.push({ id: ele1.oldValue, name: oldlist.map((item) => item.fileName).join('、') }); fileList.value.push({ id: ele1.oldValue, name: oldlist.map((item) => item.fileName).join('、') });
} }
}); });

View File

@ -45,7 +45,7 @@
); );
async function getImage() { async function getImage() {
if (props.config.folderId) { if (props.config.folderId) {
let fileList = await getFileList({ folderId: props.config.folderId }); let fileList = await getFileList({ tableId: props.config.folderId });
if (fileList.length) { if (fileList.length) {
imageUrl.value = fileList[0].fileUrl; imageUrl.value = fileList[0].fileUrl;
} }

View File

@ -70,24 +70,24 @@
data.show = true; data.show = true;
}); });
const submitUpload = (file) => { const submitUpload = (file) => {
let folderId = data.info.config.folderId; let tableId = data.info.config.folderId;
uploadMultiApi( uploadMultiApi(
{ {
name: 'file', name: 'file',
file: [file] file: [file]
}, },
folderId tableId
).then((res) => { ).then((res) => {
data.info.config.folderId = res[0].folderId; data.info.config.folderId = res[0].tableId;
getImage(); getImage();
}); });
}; };
async function getImage() { async function getImage() {
if (data.info.config.folderId) { if (data.info.config.folderId) {
let fileList = await getFileList({ folderId: data.info.config.folderId }); let fileList = await getFileList({ tableId: data.info.config.folderId });
if (fileList.length) { if (fileList.length) {
imageUrl.value = fileList[0].fileUrl; imageUrl.value = fileList[0].fileUrl;
data.info.config.folderId = fileList[0].folderId; data.info.config.folderId = fileList[0].tableId;
} }
} else { } else {
imageUrl.value = ''; imageUrl.value = '';

View File

@ -1178,15 +1178,15 @@
}; };
const submitUpload = (file) => { const submitUpload = (file) => {
let folderId = data.value.options.defaultValue; let tableId = data.value.options.defaultValue;
uploadMultiApi( uploadMultiApi(
{ {
name: 'file', name: 'file',
file: [file] file: [file]
}, },
folderId tableId
).then((res) => { ).then((res) => {
data.value.options.defaultValue = res[0].folderId; data.value.options.defaultValue = res[0].tableId;
getImage(); getImage();
}); });
}; };
@ -1350,10 +1350,10 @@
} }
async function getImage() { async function getImage() {
if (data.value.options.defaultValue) { if (data.value.options.defaultValue) {
let fileList = await getFileList({ folderId: data.value.options.defaultValue }); let fileList = await getFileList({ tableId: data.value.options.defaultValue });
if (fileList.length) { if (fileList.length) {
imageUrl.value = fileList[0].fileUrl; imageUrl.value = fileList[0].fileUrl;
data.value.options.defaultValue = fileList[0].folderId; data.value.options.defaultValue = fileList[0].tableId;
} }
} else { } else {
imageUrl.value = ''; imageUrl.value = '';

View File

@ -157,43 +157,6 @@
} }
closeModal(); closeModal();
emit('success', selectedValues.value); emit('success', selectedValues.value);
// try {
// const values = await validate();
// let data = getDataSource();
// data.sort((a, b) => {
// return a.sortNum - b.sortNum;
// });
// values.formatJson = JSON.stringify(data);
// setModalProps({ confirmLoading: true });
// if (values.formatJson === '[]') {
// notification.warning({
// message: t('提示'),
// description: t('编码规则不能为空')
// });
// return;
// }
// // TODO custom api
// if (!unref(isUpdate)) {
// //false 新增
// await addCodeRule(values);
// notification.success({
// message: t('提示'),
// description: t('新增成功')
// }); //提示消息
// } else {
// values.id = rowId.value;
// await editCodeRule(values);
// notification.success({
// message: t('提示'),
// description: t('修改成功!')
// }); //提示消息
// }
// closeModal();
// emit('success');
// } finally {
// setModalProps({ confirmLoading: false });
// }
} }

View File

@ -28,7 +28,7 @@
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item label="上传附件" name="fileList" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }"> <a-form-item label="上传附件" name="fileList" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<Upload v-model:value="formState.filePath" @change="changeUplod" ref="uploadRef" :multiple="true" :maxSize="200" :accept="accept"></Upload> <UploadNew :file-list="formState.fileList" @change="changeUplod" :multiple="true" :maxSize="200" :accept="accept" />
<div style="color: #ccc; font-size: 12px">{{ fileTip }}</div> <div style="color: #ccc; font-size: 12px">{{ fileTip }}</div>
</a-form-item> </a-form-item>
@ -41,11 +41,11 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, computed, unref,reactive } from 'vue'; import { ref, onMounted, computed, unref,reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal'; import { BasicModal, useModalInner } from '/@/components/Modal';
import { Form } from 'ant-design-vue'; import { Form, message } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import type { Rule } from 'ant-design-vue/es/form'; import type { Rule } from 'ant-design-vue/es/form';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import Upload from '/@/components/Form/src/components/Upload.vue'; import UploadNew from '/@/components/Form/src/components/UploadNew.vue';
import { getDocCpList } from '/@/api/sales/Customer'; import { getDocCpList } from '/@/api/sales/Customer';
import type { FormInstance } from 'ant-design-vue'; import type { FormInstance } from 'ant-design-vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
@ -65,6 +65,7 @@ let formState = reactive({
docTypeCode: '', docTypeCode: '',
fileList: [] fileList: []
}); });
const list = ref()
const rules = { const rules = {
docTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }], docTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
}; };
@ -74,10 +75,12 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
setModalProps({ confirmLoading: false }); setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate; isUpdate.value = !!data?.isUpdate;
isDisable.value = data?.btnType == 'view' ? true : false isDisable.value = data?.btnType == 'view' ? true : false
list.value = data.list
if (unref(isUpdate)) { if (unref(isUpdate)) {
let dateFrom = data.record?.dateFrom ? dayjs(data.record?.dateFrom) : null let dateFrom = data.record?.dateFrom ? dayjs(data.record?.dateFrom) : null
let dateTo = data.record?.dateTo ? dayjs(data.record?.dateTo) : null let dateTo = data.record?.dateTo ? dayjs(data.record?.dateTo) : null
Object.assign(formState, {...data.record,dateFrom, dateTo}) Object.assign(formState, {...data.record,dateFrom, dateTo})
formState.filePath = formState.fileList[0]?.xjrFileId
} }
}); });
@ -112,21 +115,26 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
try { try {
await formRef.value.validate(); await formRef.value.validate();
// 验证通过,提交表单 // 验证通过,提交表单
let arr = uploadRef.value.getValue() || []
let obj = { let obj = {
...formState, ...formState,
dateFrom: formState.dateFrom ? dayjs(formState.dateFrom).format('YYYY-MM-DD') : '', dateFrom: formState.dateFrom ? dayjs(formState.dateFrom).format('YYYY-MM-DD') : '',
dateTo: formState.dateTo ? dayjs(formState.dateTo).format('YYYY-MM-DD') : '', dateTo: formState.dateTo ? dayjs(formState.dateTo).format('YYYY-MM-DD') : '',
fileList: arr.map(v => { fileList: formState.fileList.map(v => {
return { return {
fileOrg: v.name, fileOrg: v.name,
filePath: v.url, filePath: v.url,
filesize: v.fileSize fileSize: v.fileSize,
xjrFileId: v.tableId
} }
}) })
} }
console.log(obj,543, uploadRef.value.getValue()) let idx =list.value.findIndex(v => v.docTypeCode == obj.docTypeCode)
formState.filePath = '' if (idx > -1) {
message.warn('证书已存在')
formRef.value.resetFields();
closeModal();
return
}
emit('success', obj); emit('success', obj);
notification.success({ notification.success({
message: t('操作'), message: t('操作'),

View File

@ -219,6 +219,12 @@
<a-button v-if="!isDisable" type="primary" style="margin-bottom: 10px;" @click="handleAdd('certificate')">新增证书</a-button> <a-button v-if="!isDisable" type="primary" style="margin-bottom: 10px;" @click="handleAdd('certificate')">新增证书</a-button>
<a-table :columns="columnsCertificate" :data-source="dataCertificate" > <a-table :columns="columnsCertificate" :data-source="dataCertificate" >
<template #bodyCell="{ column, record, index }"> <template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'dateFrom'">
{{ record.dateFrom ? dayjs(record.dateFrom).format('YYYY-MM-DD') : ''}}
</template>
<template v-if="column.dataIndex === 'dateTo'">
{{ record.dateTo ? dayjs(record.dateTo).format('YYYY-MM-DD') : ''}}
</template>
<template v-if="column.dataIndex === 'docTypeCode'"> <template v-if="column.dataIndex === 'docTypeCode'">
{{ (optionSelect.docCpList.find(v=>v.code == record.docTypeCode) || {}).fullName }} {{ (optionSelect.docCpList.find(v=>v.code == record.docTypeCode) || {}).fullName }}
</template> </template>
@ -278,20 +284,7 @@
<span style="font-size: 12px;font-weight: normal;">上传公司财报等附件</span> <span style="font-size: 12px;font-weight: normal;">上传公司财报等附件</span>
</div> </div>
</template> </template>
<a-upload <UploadNew v-if="!isDisable" style="margin-bottom: 10px;" :file-list="dataFile" :showUploadList="false" :btnTip="btnTip" @change="changeUplod" :multiple="true"/>
v-if="!isDisable"
:multiple="true"
:showUploadList="false"
name="file"
:action="data.action"
:headers="data.headers"
@change="handleChangeFile"
>
<a-button>
<upload-outlined></upload-outlined>
上传
</a-button>
</a-upload>
<a-table :columns="columnsFile" :data-source="dataFile" > <a-table :columns="columnsFile" :data-source="dataFile" >
<template #bodyCell="{ column,record,index, text }"> <template #bodyCell="{ column,record,index, text }">
<template v-if="column.dataIndex === 'fileOrg'"> <template v-if="column.dataIndex === 'fileOrg'">
@ -334,10 +327,8 @@
import { addLngCustomer,updateLngCustomer,getLngCustomer } from '/@/api/sales/Customer'; import { addLngCustomer,updateLngCustomer,getLngCustomer } from '/@/api/sales/Customer';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { getAppEnvConfig } from '/@/utils/env'; import { getAppEnvConfig } from '/@/utils/env';
import { getToken } from '/@/utils/auth';
import { uploadSrc, uploadBlobApi } from '/@/api/sys/upload';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import UploadNew from '/@/components/Form/src/components/UploadNew.vue';
const formType = ref('2'); // 0 新建 1 修改 2 查看 const formType = ref('2'); // 0 新建 1 修改 2 查看
const formRef = ref(); const formRef = ref();
@ -364,12 +355,6 @@
const curIdx = ref(null) const curIdx = ref(null)
const { notification } = useMessage(); const { notification } = useMessage();
const { t } = useI18n(); const { t } = useI18n();
const data = reactive({
info: {},
action: '',
headers: { Authorization: '' },
photoUrl: '',
});
const formState = reactive({ const formState = reactive({
valid: 'Y', valid: 'Y',
approCode: 'WTJ', approCode: 'WTJ',
@ -381,6 +366,7 @@
} }
] ]
}); });
const btnTip = '上传'
const [registerCertificate, { openModal:openModalCertificate }] = useModal(); const [registerCertificate, { openModal:openModalCertificate }] = useModal();
const [registerContact, { openModal:openModalContact }] = useModal(); const [registerContact, { openModal:openModalContact }] = useModal();
@ -440,7 +426,7 @@
]); ]);
const dataCertificate= reactive([]); const dataCertificate= reactive([]);
const dataBank= reactive([]); const dataBank= reactive([]);
const dataFile = reactive([]); const dataFile = ref([]);
const dataContact= reactive([]); const dataContact= reactive([]);
let optionSelect= reactive({ let optionSelect= reactive({
natureCodeList: [], natureCodeList: [],
@ -486,12 +472,11 @@
if (pageId.value) { if (pageId.value) {
getList(pageId.value) getList(pageId.value)
} }
data.action = getAppEnvConfig().VITE_GLOB_API_URL + uploadSrc;
data.headers.Authorization = `Bearer ${getToken()}`;
}); });
async function getList(id) { async function getList(id) {
spinning.value = true spinning.value = true
try {
let data = await getLngCustomer(id) let data = await getLngCustomer(id)
spinning.value = false spinning.value = false
Object.assign(formState, {...data}) Object.assign(formState, {...data})
@ -499,7 +484,12 @@
Object.assign(dataBank, formState.lngCustomerBankList || []) Object.assign(dataBank, formState.lngCustomerBankList || [])
Object.assign(dataCertificate, formState.lngCustomerDocList || []) Object.assign(dataCertificate, formState.lngCustomerDocList || [])
Object.assign(dataContact, formState.lngCustomerContactList || []) Object.assign(dataContact, formState.lngCustomerContactList || [])
Object.assign(dataFile, formState.lngFileUploadList || []) Object.assign(dataFile.value, formState.lngFileUploadList || [])
formState.dateEntry = formState.dateEntry ? dayjs(formState.dateEntry) : null
formState.dateEstab = formState.dateEstab ? dayjs(formState.dateEstab) : null
} catch (error) {
spinning.value = false
}
} }
async function getOption() { async function getOption() {
optionSelect.natureCodeList = await getDictionary('LNG_ENT_PR') optionSelect.natureCodeList = await getDictionary('LNG_ENT_PR')
@ -527,7 +517,7 @@
const handleAdd = (val)=> { const handleAdd = (val)=> {
curIdx.value = null curIdx.value = null
if (val ==='certificate') { if (val ==='certificate') {
openModalCertificate(true,{isUpdate: false}); openModalCertificate(true,{isUpdate: false, list: dataCertificate});
} }
if (val ==='contact'){ if (val ==='contact'){
openModalContact(true, {}); openModalContact(true, {});
@ -544,7 +534,7 @@
// 证书 // 证书
if (type == 'certificate') { if (type == 'certificate') {
if (btn == 'edit' || btn == 'view') { if (btn == 'edit' || btn == 'view') {
openModalCertificate(true, {record: record,isUpdate: true, btnType: btn}); openModalCertificate(true, {record: record,isUpdate: true, btnType: btn, list: dataCertificate});
} }
if (btn == 'delete') { if (btn == 'delete') {
dataCertificate.splice(index, 1) dataCertificate.splice(index, 1)
@ -586,19 +576,19 @@
// 附件 // 附件
if (type == 'file') { if (type == 'file') {
if (btn == 'delete') { if (btn == 'delete') {
dataFile.splice(index, 1) dataFile.value.splice(index, 1)
} }
if (btn == 'up') { if (btn == 'up') {
if (index === 0) { if (index === 0) {
return return
} }
dataFile[index] = dataFile.splice(index-1, 1, dataFile[index])[0]; dataFile.value[index] = dataFile.value.splice(index-1, 1, dataFile.value[index])[0];
} }
if (btn == 'down') { if (btn == 'down') {
if (index === dataFile.length - 1) { if (index === dataFile.value.length - 1) {
return return
} }
dataFile[index] = dataFile.splice(index+1, 1, dataFile[index])[0]; dataFile.value[index] = dataFile.value.splice(index+1, 1, dataFile.value[index])[0];
} }
} }
} }
@ -627,36 +617,16 @@
} }
dataBank.push(val) dataBank.push(val)
} }
function handleChangeFile(info) { function changeUplod (val) {
console.log(info, 'info', info.file.status) dataFile.value = []
if (info.file.status !== 'uploading') { val.forEach(v => {
v.fileOrg = v.fileOrg || v.fileName,
v.filePath = v.filePath || v.fileUrl,
v.fileSize = v.fileSize
dataFile.value.push(v)
})
console.log(val, 532, dataFile.value)
} }
if (info.file.status === 'done') {
if (info.file && info.file.response && info.file.response.code == 0) {
message.success(t(`{name}上传成功!`, { name: info.file.name }));
// 存储原始URL到info.fileUrl用于提交改了
data.info.fileUrl = info.file.response.data.fileUrl;
data.fileName = info.file.response.data.fileName;
// 显示使用fileUrlFixed如果有否则使用fileUrl (改了)
data.photoUrl = info.file.response.data.fileUrlFixed || info.file.response.data.fileUrl;
let obj = {
fileOrg: data.fileName,
filePath: data.photoUrl,
filesize: info?.file?.response?.data?.fileSize
}
dataFile.push(obj)
} else {
message.error(t('上传照片失败'));
}
} else if (info.file.status === 'error') {
message.error(t(`{name}上传失败.`, { name: info.file.name }));
}
}
function close() { function close() {
tabStore.closeTab(currentRoute.value, router); tabStore.closeTab(currentRoute.value, router);
} }
@ -698,7 +668,7 @@
} }
}), }),
lngCustomerContactList: dataContact, lngCustomerContactList: dataContact,
lngFileUploadList: dataFile lngFileUploadList: dataFile.value
} }
spinning.value = true; spinning.value = true;
@ -709,13 +679,15 @@
if (type) { if (type) {
data?.id && (formState.id = data.id) data?.id && (formState.id = data.id)
data?.cuCode && (formState.cuCode = data.cuCode) data?.cuCode && (formState.cuCode = data.cuCode)
if (!type) {
notification.success({ notification.success({
message: 'Tip', message: 'Tip',
description: !data?.id ? t('新增成功!') : t('修改成功!') description: data?.id ? t('新增成功!') : t('修改成功!')
}); //提示消息 }); //提示消息
} }
}
// formRef.value.resetFields(); // formRef.value.resetFields();
return data return data?.id ? data : formState
// setTimeout(() => { // setTimeout(() => {
// bus.emit(FORM_LIST_MODIFIED, { path: formPath }); // bus.emit(FORM_LIST_MODIFIED, { path: formPath });
// close(); // close();

View File

@ -179,15 +179,28 @@
} }
}); });
} else { } else {
if (schemaIdComputedRef.value) {
router.push({ router.push({
path: '/form/Customer/' + record.id + '/viewForm', path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: { query: {
formPath: 'sales/Customer', formPath: 'sales/Customer',
formName: formName, formName: formName,
formId:currentRoute.value.meta.formId formId:currentRoute.value.meta.formId,
type:'edit',
id: record.id,
disabled: 1,
} }
}); });
} }
// router.push({
// path: '/form/Customer/' + record.id + '/viewForm',
// query: {
// formPath: 'sales/Customer',
// formName: formName,
// formId:currentRoute.value.meta.formId
// }
// });
}
} }
function buttonClick(code) { function buttonClick(code) {
@ -231,7 +244,7 @@
}); });
} else { } else {
router.push({ router.push({
path: '/form/Customer/' + record.id + '/createFormCustomer', path: '/form/Customer/' + record.id + '/createForm',
query: { query: {
formPath: 'sales/Customer', formPath: 'sales/Customer',
formName: formName, formName: formName,

View File

@ -38,7 +38,7 @@
</template> </template>
</a-space> </a-space>
</div> </div>
<component v-if="customFormConfig.codeList.includes(curPageCode)" :is="componentName" ref="formInformation" :disabled="true" /> <component v-if="customFormConfig.codeList.includes(curPageCode)" :is="componentName" ref="formInformation" :disabled="readonly" />
<FormInformation <FormInformation
v-else v-else
:key="renderKey" :key="renderKey"
@ -251,6 +251,10 @@
message: t('撤回'), message: t('撤回'),
description: t('撤回成功') description: t('撤回成功')
}); });
setTimeout(() => {
bus.emit(FLOW_PROCESSED);
close();
}, 500);
} else { } else {
notification.open({ notification.open({
type: 'error', type: 'error',
@ -335,6 +339,10 @@
} }
} }
async function saveDraft() { async function saveDraft() {
if (customFormConfig.codeList.includes(curPageCode.value)) {
await formInformation.value.handleSubmit();
return
}
try { try {
spinning.value = true; spinning.value = true;
let formModels = await formInformation.value.saveDraftData(); let formModels = await formInformation.value.saveDraftData();
@ -402,6 +410,7 @@
return; return;
} }
} else { } else {
await formInformation.value.handleSubmit(true);
validateSuccess.value = true validateSuccess.value = true
} }
const params = await getApproveParams(); const params = await getApproveParams();

View File

@ -10,16 +10,16 @@
</slot> </slot>
关闭 关闭
</a-button> </a-button>
<a-button :disabled="data.submitLoading" type="primary" @click="saveLaunch"> <a-button v-if="!disabled" :disabled="data.submitLoading" type="primary" @click="saveLaunch">
<slot name="icon"> <slot name="icon">
<send-outlined /> <send-outlined />
</slot> </slot>
提交 提交
</a-button> </a-button>
<a-button v-if="customFormConfig.codeList.includes(curPageCode)" @click="onSave"> <a-button v-if="customFormConfig.codeList.includes(curPageCode)&&!disabled" @click="onSave">
<slot name="icon"><save-outlined /></slot>保存 <slot name="icon"><save-outlined /></slot>保存
</a-button> </a-button>
<a-button v-else :disabled="data.submitLoading" @click="saveDraft"> <a-button v-if="!customFormConfig.codeList.includes(curPageCode)&&!disabled" :disabled="data.submitLoading" @click="saveDraft">
<slot name="icon"> <slot name="icon">
<clock-circle-outlined /> <clock-circle-outlined />
</slot> </slot>
@ -32,7 +32,7 @@
</slot> </slot>
流程图 流程图
</a-button> </a-button>
<div v-if="customFormConfig.codeList.includes(curPageCode)"> <div v-if="customFormConfig.codeList.includes(curPageCode)&&!disabled">
<a-button> <a-button>
<slot name="icon"><download-outlined /></slot>下载模板 <slot name="icon"><download-outlined /></slot>下载模板
</a-button> </a-button>
@ -43,7 +43,7 @@
</a-space> </a-space>
</div> </div>
<div class="flow-content"> <div class="flow-content">
<component v-if="customFormConfig.codeList.includes(curPageCode)" :is="componentName" ref="formInformation" /> <component v-if="customFormConfig.codeList.includes(curPageCode)" :is="componentName" :disabled="disabled" ref="formInformation" />
<FormInformation v-else :key="randKey" ref="formInformation" :disabled="false" :formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions" :opinionsComponents="data.opinionsComponents" /> <FormInformation v-else :key="randKey" ref="formInformation" :disabled="false" :formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions" :opinionsComponents="data.opinionsComponents" />
</div> </div>
</div> </div>
@ -98,6 +98,7 @@
let pageMode = 'new'; let pageMode = 'new';
const showFlowChart = ref(false); const showFlowChart = ref(false);
const disableSubmit = ref(false); const disableSubmit = ref(false);
const disabled = ref(currentRoute.query?.disabled)
const mainFormModels = ref(); const mainFormModels = ref();
let randKey = ref('randkey'); // 强制表单重新渲染 let randKey = ref('randkey'); // 强制表单重新渲染
let approvalData = reactive({ let approvalData = reactive({
@ -157,7 +158,9 @@
onMounted(async () => { onMounted(async () => {
try { try {
// 发起流程 // 发起流程
loading.value = true
let res = await getStartProcessInfo(rSchemaId); let res = await getStartProcessInfo(rSchemaId);
loading.value = false
const title = res?.schemaInfo?.name; const title = res?.schemaInfo?.name;
if (title) { if (title) {
const tabPrefix = pageMode === 'new' ? '新建' : '草稿'; const tabPrefix = pageMode === 'new' ? '新建' : '草稿';
@ -165,7 +168,9 @@
} }
curPageCode.value = res?.schemaInfo?.code curPageCode.value = res?.schemaInfo?.code
initProcessData(res); initProcessData(res);
} catch (error) {} } catch (error) {
loading.value = false
}
randKey.value = Math.random() + ''; randKey.value = Math.random() + '';
// 这里的顺序不能变 表单不渲染的时候 设置表单初值没用 // 这里的顺序不能变 表单不渲染的时候 设置表单初值没用
await nextTick(); await nextTick();
@ -326,7 +331,7 @@
}; };
} }
async function onSave() { async function onSave() {
let value = await formInformation.value.handleSubmit(true); let value = await formInformation.value.handleSubmit();
} }
async function saveLaunchNew() { async function saveLaunchNew() {
if (!taskId.value && rDraftsId.value != '0') { if (!taskId.value && rDraftsId.value != '0') {