处理镜像管理-服务指令-操作日志-新增数据不显示文件资源问题
This commit is contained in:
parent
01568397c5
commit
5ae4edeb47
|
|
@ -23,6 +23,7 @@ enum Api {
|
||||||
getElderTagMain = '/sys/sysDepart/getElderTagMain', //查询当前标准标签库机构信息
|
getElderTagMain = '/sys/sysDepart/getElderTagMain', //查询当前标准标签库机构信息
|
||||||
getETMOrgInfo = '/api/common/getETMOrgInfo', //标准标签库信息
|
getETMOrgInfo = '/api/common/getETMOrgInfo', //标准标签库信息
|
||||||
queryUpBizPrefix = '/api/sysUtils/queryUpBizPrefix',
|
queryUpBizPrefix = '/api/sysUtils/queryUpBizPrefix',
|
||||||
|
getMediaUrlByOrgCode = '/api/baseInfo/getMediaUrlByOrgCode',
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -222,3 +223,11 @@ export const getElderTagMain = () => {
|
||||||
export const queryUpBizPrefix = () => {
|
export const queryUpBizPrefix = () => {
|
||||||
return defHttp.get({ url: Api.queryUpBizPrefix }, { isTransformResponse: false });
|
return defHttp.get({ url: Api.queryUpBizPrefix }, { isTransformResponse: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对应机构媒体资源地址
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const getMediaUrlByOrgCode = (params) => {
|
||||||
|
return defHttp.get({ url: Api.getMediaUrlByOrgCode, params });
|
||||||
|
};
|
||||||
|
|
@ -1,18 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<a-upload
|
<a-upload :listType="listType" accept="image/*" :multiple="multiple" :action="uploadUrl" :headers="headers"
|
||||||
:listType="listType"
|
:data="{ biz: bizPath }" v-model:fileList="uploadFileList" :beforeUpload="beforeUpload" :disabled="disabled"
|
||||||
accept="image/*"
|
@change="handleChange" @preview="handlePreview">
|
||||||
:multiple="multiple"
|
|
||||||
:action="uploadUrl"
|
|
||||||
:headers="headers"
|
|
||||||
:data="{ biz: bizPath }"
|
|
||||||
v-model:fileList="uploadFileList"
|
|
||||||
:beforeUpload="beforeUpload"
|
|
||||||
:disabled="disabled"
|
|
||||||
@change="handleChange"
|
|
||||||
@preview="handlePreview"
|
|
||||||
>
|
|
||||||
<div v-if="uploadVisible">
|
<div v-if="uploadVisible">
|
||||||
<div v-if="listType == 'picture-card'">
|
<div v-if="listType == 'picture-card'">
|
||||||
<LoadingOutlined v-if="loading" />
|
<LoadingOutlined v-if="loading" />
|
||||||
|
|
@ -25,7 +15,7 @@
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
</a-upload>
|
</a-upload>
|
||||||
<!-- <img alt="example" style="width: 100%" :src="previewImage" /> -->
|
<!-- <img alt="example" style="width: 100%" :src="previewImage" /> -->
|
||||||
<!-- <a-modal :open="previewVisible" width="70%" class="imgView" :footer="null" @cancel="handleCancel()">
|
<!-- <a-modal :open="previewVisible" width="70%" class="imgView" :footer="null" @cancel="handleCancel()">
|
||||||
<div class="img-container">
|
<div class="img-container">
|
||||||
<img
|
<img
|
||||||
|
|
@ -36,301 +26,294 @@
|
||||||
</div>
|
</div>
|
||||||
</a-modal> -->
|
</a-modal> -->
|
||||||
|
|
||||||
<a-modal
|
<a-modal :open="previewVisible" :width="modalWidth"
|
||||||
:open="previewVisible"
|
:bodyStyle="{ padding: 0, display: 'flex', justifyContent: 'center', alignItems: 'center' }" :footer="null"
|
||||||
:width="modalWidth"
|
@cancel="handleCancel">
|
||||||
:bodyStyle="{ padding: 0, display: 'flex', justifyContent: 'center', alignItems: 'center' }"
|
<img ref="previewImgRef" class="preview-img" :src="previewImage" @load="handleImageLoad" />
|
||||||
:footer="null"
|
</a-modal>
|
||||||
@cancel="handleCancel"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
ref="previewImgRef"
|
|
||||||
class="preview-img"
|
|
||||||
:src="previewImage"
|
|
||||||
@load="handleImageLoad"
|
|
||||||
/>
|
|
||||||
</a-modal>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted, nextTick } from 'vue';
|
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted, nextTick } from 'vue';
|
||||||
import { LoadingOutlined, UploadOutlined } from '@ant-design/icons-vue';
|
import { LoadingOutlined, UploadOutlined } from '@ant-design/icons-vue';
|
||||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import { propTypes } from '/@/utils/propTypes';
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { getFileAccessHttpUrl, getHeaders, getRandom } from '/@/utils/common/compUtils';
|
import { getFileAccessHttpUrl, getHeaders, getRandom } from '/@/utils/common/compUtils';
|
||||||
import { uploadUrl } from '/@/api/common/api';
|
import { uploadUrl } from '/@/api/common/api';
|
||||||
import { getToken } from '/@/utils/auth';
|
import { getToken } from '/@/utils/auth';
|
||||||
|
|
||||||
const { createMessage, createErrorModal } = useMessage();
|
const { createMessage, createErrorModal } = useMessage();
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JImageUpload',
|
name: 'JImageUpload',
|
||||||
components: { LoadingOutlined, UploadOutlined },
|
components: { LoadingOutlined, UploadOutlined },
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
//绑定值
|
//绑定值
|
||||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
//按钮文本
|
//按钮文本
|
||||||
listType: {
|
listType: {
|
||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
default: 'picture-card',
|
default: 'picture-card',
|
||||||
},
|
|
||||||
//按钮文本
|
|
||||||
text: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: '上传',
|
|
||||||
},
|
|
||||||
//这个属性用于控制文件上传的业务路径
|
|
||||||
bizPath: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: 'temp',
|
|
||||||
},
|
|
||||||
//是否禁用
|
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
//上传数量
|
|
||||||
fileMax: {
|
|
||||||
type: Number,
|
|
||||||
required: false,
|
|
||||||
default: 1,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
emits: ['options-change', 'change', 'update:value'],
|
//按钮文本
|
||||||
setup(props, { emit, refs }) {
|
text: {
|
||||||
const emitData = ref<any[]>([]);
|
type: String,
|
||||||
const attrs = useAttrs();
|
required: false,
|
||||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
default: '上传',
|
||||||
//获取文件名
|
|
||||||
const getFileName = (path) => {
|
|
||||||
if (path.lastIndexOf('\\') >= 0) {
|
|
||||||
let reg = new RegExp('\\\\', 'g');
|
|
||||||
path = path.replace(reg, '/');
|
|
||||||
}
|
|
||||||
return path.substring(path.lastIndexOf('/') + 1);
|
|
||||||
};
|
|
||||||
//token
|
|
||||||
const headers = getHeaders();
|
|
||||||
//上传状态
|
|
||||||
const loading = ref<boolean>(false);
|
|
||||||
//是否是初始化加载
|
|
||||||
const initTag = ref<boolean>(true);
|
|
||||||
//文件列表
|
|
||||||
let uploadFileList = ref<any[]>([]);
|
|
||||||
//预览图
|
|
||||||
const previewImage = ref<string | undefined>('');
|
|
||||||
//预览框状态
|
|
||||||
const previewVisible = ref<boolean>(false);
|
|
||||||
|
|
||||||
|
|
||||||
//计算是否开启多图上传
|
|
||||||
const multiple = computed(() => {
|
|
||||||
return props['fileMax'] > 1 || props['fileMax'] === 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
//计算是否可以继续上传
|
|
||||||
const uploadVisible = computed(() => {
|
|
||||||
if (props['fileMax'] === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return uploadFileList.value.length < props['fileMax'];
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 监听value变化
|
|
||||||
*/
|
|
||||||
watch(
|
|
||||||
() => props.value,
|
|
||||||
(val, prevCount) => {
|
|
||||||
//update-begin---author:liusq ---date:20230601 for:【issues/556】JImageUpload组件value赋初始值没显示图片------------
|
|
||||||
if (val && val instanceof Array) {
|
|
||||||
val = val.join(',');
|
|
||||||
}
|
|
||||||
if (initTag.value == true) {
|
|
||||||
initFileList(val);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
//update-end---author:liusq ---date:20230601 for:【issues/556】JImageUpload组件value赋初始值没显示图片------------
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化文件列表
|
|
||||||
*/
|
|
||||||
function initFileList(paths) {
|
|
||||||
if (!paths || paths.length == 0) {
|
|
||||||
uploadFileList.value = [];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let files = [];
|
|
||||||
let arr = paths.split(',');
|
|
||||||
arr.forEach((value) => {
|
|
||||||
let url = getFileAccessHttpUrl(value);
|
|
||||||
files.push({
|
|
||||||
uid: getRandom(10),
|
|
||||||
name: getFileName(value),
|
|
||||||
status: 'done',
|
|
||||||
url: url,
|
|
||||||
response: {
|
|
||||||
status: 'history',
|
|
||||||
message: value,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
uploadFileList.value = files;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传前校验
|
|
||||||
*/
|
|
||||||
function beforeUpload(file) {
|
|
||||||
let fileType = file.type;
|
|
||||||
if (fileType.indexOf('image') < 0) {
|
|
||||||
createMessage.info('请上传图片');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 文件上传结果回调
|
|
||||||
*/
|
|
||||||
function handleChange({ file, fileList, event }) {
|
|
||||||
initTag.value = false;
|
|
||||||
// update-begin--author:liaozhiyang---date:20231116---for:【issues/846】上传多个列表只显示一个
|
|
||||||
// uploadFileList.value = fileList;
|
|
||||||
if (file.status === 'error') {
|
|
||||||
createMessage.error(`${file.name} 上传失败.`);
|
|
||||||
}
|
|
||||||
// update-begin--author:liaozhiyang---date:20240704---for:【TV360X-1640】上传图片大小超出限制显示优化
|
|
||||||
if (file.status === 'done' && file.response.success === false) {
|
|
||||||
const failIndex = uploadFileList.value.findIndex((item) => item.uid === file.uid);
|
|
||||||
if (failIndex != -1) {
|
|
||||||
uploadFileList.value.splice(failIndex, 1);
|
|
||||||
}
|
|
||||||
createMessage.warning(file.response.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// update-end--author:liaozhiyang---date:20240704---for:【TV360X-1640】上传图片大小超出限制显示优化
|
|
||||||
let fileUrls = [];
|
|
||||||
let noUploadingFileCount = 0;
|
|
||||||
if (file.status != 'uploading') {
|
|
||||||
fileList.forEach((file) => {
|
|
||||||
if (file.status === 'done') {
|
|
||||||
fileUrls.push(file.response.message);
|
|
||||||
}
|
|
||||||
if (file.status != 'uploading') {
|
|
||||||
noUploadingFileCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (file.status === 'removed') {
|
|
||||||
handleDelete(file);
|
|
||||||
}
|
|
||||||
if (noUploadingFileCount == fileList.length) {
|
|
||||||
state.value = fileUrls.join(',');
|
|
||||||
emit('update:value', fileUrls.join(','));
|
|
||||||
// update-begin---author:wangshuai ---date:20221121 for:[issues/248]原生表单内使用图片组件,关闭弹窗图片组件值不会被清空------------
|
|
||||||
nextTick(() => {
|
|
||||||
initTag.value = true;
|
|
||||||
});
|
|
||||||
// update-end---author:wangshuai ---date:20221121 for:[issues/248]原生表单内使用图片组件,关闭弹窗图片组件值不会被清空------------
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// update-end--author:liaozhiyang---date:20231116---for:【issues/846】上传多个列表只显示一个
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除图片
|
|
||||||
*/
|
|
||||||
function handleDelete(file) {
|
|
||||||
//如有需要新增 删除逻辑
|
|
||||||
console.log(file);
|
|
||||||
}
|
|
||||||
const previewImgRef = ref<HTMLImageElement | null>(null);
|
|
||||||
const modalWidth = ref('auto');
|
|
||||||
/**
|
|
||||||
* 预览图片
|
|
||||||
*/
|
|
||||||
async function handlePreview(file) {
|
|
||||||
if (!file.url && !file.preview) {
|
|
||||||
file.preview = (await getBase64(file.originFileObj)) as string;
|
|
||||||
}
|
|
||||||
previewImage.value = file.url || file.preview;
|
|
||||||
previewVisible.value = true;
|
|
||||||
}
|
|
||||||
function getBase64(file: File) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
reader.onload = () => resolve(reader.result);
|
|
||||||
reader.onerror = error => reject(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAvatarView() {
|
|
||||||
if (uploadFileList.length > 0) {
|
|
||||||
let url = uploadFileList[0].url;
|
|
||||||
return getFileAccessHttpUrl(url, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCancel() {
|
|
||||||
previewVisible.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 图片加载完成后计算宽高
|
|
||||||
const handleImageLoad = () => {
|
|
||||||
if (!previewImgRef.value) return;
|
|
||||||
|
|
||||||
const img = previewImgRef.value;
|
|
||||||
const maxWidth = window.innerWidth * 0.9; // 最大宽度为屏幕90%
|
|
||||||
const maxHeight = window.innerHeight * 0.8; // 最大高度为屏幕80%
|
|
||||||
|
|
||||||
// 计算适应比例
|
|
||||||
const ratio = Math.min(maxWidth / img.naturalWidth, maxHeight / img.naturalHeight, 1);
|
|
||||||
modalWidth.value = `${img.naturalWidth * ratio}px`;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
state,
|
|
||||||
attrs,
|
|
||||||
previewImage,
|
|
||||||
previewVisible,
|
|
||||||
uploadFileList,
|
|
||||||
multiple,
|
|
||||||
headers,
|
|
||||||
loading,
|
|
||||||
uploadUrl,
|
|
||||||
beforeUpload,
|
|
||||||
uploadVisible,
|
|
||||||
handlePreview,
|
|
||||||
handleCancel,
|
|
||||||
handleChange,
|
|
||||||
handleImageLoad,
|
|
||||||
previewImgRef,
|
|
||||||
modalWidth,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
//这个属性用于控制文件上传的业务路径
|
||||||
|
bizPath: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: 'temp',
|
||||||
|
},
|
||||||
|
//是否禁用
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
//上传数量
|
||||||
|
fileMax: {
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
default: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
emits: ['options-change', 'change', 'update:value'],
|
||||||
|
setup(props, { emit, refs }) {
|
||||||
|
const emitData = ref<any[]>([]);
|
||||||
|
const attrs = useAttrs();
|
||||||
|
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||||
|
//获取文件名
|
||||||
|
const getFileName = (path) => {
|
||||||
|
if (path.lastIndexOf('\\') >= 0) {
|
||||||
|
let reg = new RegExp('\\\\', 'g');
|
||||||
|
path = path.replace(reg, '/');
|
||||||
|
}
|
||||||
|
return path.substring(path.lastIndexOf('/') + 1);
|
||||||
|
};
|
||||||
|
//token
|
||||||
|
const headers = getHeaders();
|
||||||
|
//上传状态
|
||||||
|
const loading = ref<boolean>(false);
|
||||||
|
//是否是初始化加载
|
||||||
|
const initTag = ref<boolean>(true);
|
||||||
|
//文件列表
|
||||||
|
let uploadFileList = ref<any[]>([]);
|
||||||
|
//预览图
|
||||||
|
const previewImage = ref<string | undefined>('');
|
||||||
|
//预览框状态
|
||||||
|
const previewVisible = ref<boolean>(false);
|
||||||
|
|
||||||
|
|
||||||
|
//计算是否开启多图上传
|
||||||
|
const multiple = computed(() => {
|
||||||
|
return props['fileMax'] > 1 || props['fileMax'] === 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
//计算是否可以继续上传
|
||||||
|
const uploadVisible = computed(() => {
|
||||||
|
if (props['fileMax'] === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return uploadFileList.value.length < props['fileMax'];
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听value变化
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(val, prevCount) => {
|
||||||
|
//update-begin---author:liusq ---date:20230601 for:【issues/556】JImageUpload组件value赋初始值没显示图片------------
|
||||||
|
if (val && val instanceof Array) {
|
||||||
|
val = val.join(',');
|
||||||
|
}
|
||||||
|
if (initTag.value == true) {
|
||||||
|
initFileList(val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
//update-end---author:liusq ---date:20230601 for:【issues/556】JImageUpload组件value赋初始值没显示图片------------
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化文件列表
|
||||||
|
*/
|
||||||
|
function initFileList(paths) {
|
||||||
|
if (!paths || paths.length == 0) {
|
||||||
|
uploadFileList.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let files = [];
|
||||||
|
let arr = paths.split(',');
|
||||||
|
arr.forEach((value) => {
|
||||||
|
let url = getFileAccessHttpUrl(value);
|
||||||
|
files.push({
|
||||||
|
uid: getRandom(10),
|
||||||
|
name: getFileName(value),
|
||||||
|
status: 'done',
|
||||||
|
url: url,
|
||||||
|
response: {
|
||||||
|
status: 'history',
|
||||||
|
message: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
uploadFileList.value = files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传前校验
|
||||||
|
*/
|
||||||
|
function beforeUpload(file) {
|
||||||
|
let fileType = file.type;
|
||||||
|
if (fileType.indexOf('image') < 0) {
|
||||||
|
createMessage.info('请上传图片');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 文件上传结果回调
|
||||||
|
*/
|
||||||
|
function handleChange({ file, fileList, event }) {
|
||||||
|
initTag.value = false;
|
||||||
|
// update-begin--author:liaozhiyang---date:20231116---for:【issues/846】上传多个列表只显示一个
|
||||||
|
// uploadFileList.value = fileList;
|
||||||
|
if (file.status === 'error') {
|
||||||
|
createMessage.error(`${file.name} 上传失败.`);
|
||||||
|
}
|
||||||
|
// update-begin--author:liaozhiyang---date:20240704---for:【TV360X-1640】上传图片大小超出限制显示优化
|
||||||
|
if (file.status === 'done' && file.response.success === false) {
|
||||||
|
const failIndex = uploadFileList.value.findIndex((item) => item.uid === file.uid);
|
||||||
|
if (failIndex != -1) {
|
||||||
|
uploadFileList.value.splice(failIndex, 1);
|
||||||
|
}
|
||||||
|
createMessage.warning(file.response.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20240704---for:【TV360X-1640】上传图片大小超出限制显示优化
|
||||||
|
let fileUrls = [];
|
||||||
|
let noUploadingFileCount = 0;
|
||||||
|
if (file.status != 'uploading') {
|
||||||
|
fileList.forEach((file) => {
|
||||||
|
if (file.status === 'done') {
|
||||||
|
fileUrls.push(file.response.message);
|
||||||
|
}
|
||||||
|
if (file.status != 'uploading') {
|
||||||
|
noUploadingFileCount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (file.status === 'removed') {
|
||||||
|
handleDelete(file);
|
||||||
|
}
|
||||||
|
if (noUploadingFileCount == fileList.length) {
|
||||||
|
state.value = fileUrls.join(',');
|
||||||
|
emit('update:value', fileUrls.join(','));
|
||||||
|
// update-begin---author:wangshuai ---date:20221121 for:[issues/248]原生表单内使用图片组件,关闭弹窗图片组件值不会被清空------------
|
||||||
|
nextTick(() => {
|
||||||
|
initTag.value = true;
|
||||||
|
});
|
||||||
|
// update-end---author:wangshuai ---date:20221121 for:[issues/248]原生表单内使用图片组件,关闭弹窗图片组件值不会被清空------------
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20231116---for:【issues/846】上传多个列表只显示一个
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除图片
|
||||||
|
*/
|
||||||
|
function handleDelete(file) {
|
||||||
|
//如有需要新增 删除逻辑
|
||||||
|
console.log(file);
|
||||||
|
}
|
||||||
|
const previewImgRef = ref<HTMLImageElement | null>(null);
|
||||||
|
const modalWidth = ref('auto');
|
||||||
|
/**
|
||||||
|
* 预览图片
|
||||||
|
*/
|
||||||
|
async function handlePreview(file) {
|
||||||
|
if (!file.url && !file.preview) {
|
||||||
|
file.preview = (await getBase64(file.originFileObj)) as string;
|
||||||
|
}
|
||||||
|
previewImage.value = file.url || file.preview;
|
||||||
|
previewVisible.value = true;
|
||||||
|
}
|
||||||
|
function getBase64(file: File) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload = () => resolve(reader.result);
|
||||||
|
reader.onerror = error => reject(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAvatarView() {
|
||||||
|
if (uploadFileList.length > 0) {
|
||||||
|
let url = uploadFileList[0].url;
|
||||||
|
return getFileAccessHttpUrl(url, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCancel() {
|
||||||
|
previewVisible.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图片加载完成后计算宽高
|
||||||
|
const handleImageLoad = () => {
|
||||||
|
if (!previewImgRef.value) return;
|
||||||
|
|
||||||
|
const img = previewImgRef.value;
|
||||||
|
const maxWidth = window.innerWidth * 0.9; // 最大宽度为屏幕90%
|
||||||
|
const maxHeight = window.innerHeight * 0.8; // 最大高度为屏幕80%
|
||||||
|
|
||||||
|
// 计算适应比例
|
||||||
|
const ratio = Math.min(maxWidth / img.naturalWidth, maxHeight / img.naturalHeight, 1);
|
||||||
|
modalWidth.value = `${img.naturalWidth * ratio}px`;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
state,
|
||||||
|
attrs,
|
||||||
|
previewImage,
|
||||||
|
previewVisible,
|
||||||
|
uploadFileList,
|
||||||
|
multiple,
|
||||||
|
headers,
|
||||||
|
loading,
|
||||||
|
uploadUrl,
|
||||||
|
beforeUpload,
|
||||||
|
uploadVisible,
|
||||||
|
handlePreview,
|
||||||
|
handleCancel,
|
||||||
|
handleChange,
|
||||||
|
handleImageLoad,
|
||||||
|
previewImgRef,
|
||||||
|
modalWidth,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.ant-upload-select-picture-card i {
|
.ant-upload-select-picture-card i {
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-upload-select-picture-card .ant-upload-text {
|
||||||
|
margin-top: 8px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
.ant-upload-select-picture-card .ant-upload-text {
|
|
||||||
margin-top: 8px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
/* 确保 Modal 内容区域填满 */
|
/* 确保 Modal 内容区域填满 */
|
||||||
.imgView .ant-modal-body {
|
.imgView .ant-modal-body {
|
||||||
height: 80vh; /* 限制模态框高度,避免超出屏幕 */
|
height: 80vh;
|
||||||
|
/* 限制模态框高度,避免超出屏幕 */
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
@ -349,6 +332,7 @@ const handleImageLoad = () => {
|
||||||
.preview-img {
|
.preview-img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
object-fit: contain; /* 保持比例,不拉伸 */
|
object-fit: contain;
|
||||||
|
/* 保持比例,不拉伸 */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ import { getFileAccessHttpUrl, getHeaders, getRandom } from '/@/utils/common/com
|
||||||
import { uploadUrl } from '/@/api/common/api';
|
import { uploadUrl } from '/@/api/common/api';
|
||||||
import { getToken } from '/@/utils/auth';
|
import { getToken } from '/@/utils/auth';
|
||||||
import { Upload } from 'ant-design-vue';
|
import { Upload } from 'ant-design-vue';
|
||||||
|
import { getMediaUrlByOrgCode } from '@/api/common/api'
|
||||||
|
|
||||||
const { createMessage, createErrorModal } = useMessage();
|
const { createMessage, createErrorModal } = useMessage();
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|
@ -114,12 +115,13 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
emits: ['options-change', 'change', 'update:value'],
|
emits: ['options-change', 'change', 'update:value'],
|
||||||
setup(props, { emit, refs }) {
|
setup(props, { emit, refs }) {
|
||||||
|
const opeMediaAddress = ref<string>('');
|
||||||
const emitData = ref<any[]>([]);
|
const emitData = ref<any[]>([]);
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||||
const currentUploadUrl = ref(uploadUrl);
|
const currentUploadUrl = ref(uploadUrl);
|
||||||
const extraUploadData = ref<Record<string, any>>({});
|
const extraUploadData = ref<Record<string, any>>({});
|
||||||
const opeMediaAddress = import.meta.env.VITE_OPE_MEDIA_ADDRESS
|
|
||||||
//获取文件名
|
//获取文件名
|
||||||
const getFileName = (path) => {
|
const getFileName = (path) => {
|
||||||
if (path.lastIndexOf('\\') >= 0) {
|
if (path.lastIndexOf('\\') >= 0) {
|
||||||
|
|
@ -327,6 +329,10 @@ export default defineComponent({
|
||||||
modalWidth.value = `${img.naturalWidth * ratio}px`;
|
modalWidth.value = `${img.naturalWidth * ratio}px`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const res = await getMediaUrlByOrgCode({ orgCode: '' });
|
||||||
|
opeMediaAddress.value = res.mediaUrl;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state,
|
state,
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
<div class="ant-upload-text">{{ text }}123</div>
|
<div class="ant-upload-text">{{ text }}123</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="upload-area" style="padding: 20px;" v-else-if="uploadVisible" :disabled="buttonDisabled">
|
<div class="upload-area" style="padding: 20px;" v-if="fileList.length <= 0" :disabled="buttonDisabled">
|
||||||
<p class="upload-text">点击或者拖拽上传</p>
|
<p class="upload-text"></p>
|
||||||
<p class="upload-hint">
|
<p class="upload-hint">
|
||||||
<div class="upload-icon">
|
<div class="upload-icon">
|
||||||
<img src="../../../../../../assets/upload/mp3.png" style="width: 40px; height: 40px;" />
|
<img src="../../../../../../assets/upload/mp3.png" style="width: 40px; height: 40px;" />
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, computed, watch, nextTick, createApp, unref } from 'vue';
|
import { ref, reactive, computed, watch, nextTick, createApp, unref, onMounted } from 'vue';
|
||||||
import { Icon } from '/@/components/Icon';
|
import { Icon } from '/@/components/Icon';
|
||||||
import { getToken } from '/@/utils/auth';
|
import { getToken } from '/@/utils/auth';
|
||||||
import { uploadUrl } from '/@/api/common/api';
|
import { uploadUrl } from '/@/api/common/api';
|
||||||
|
|
@ -64,8 +64,9 @@ import { getFileAccessHttpUrl, getHeaders } from '/@/utils/common/compUtils';
|
||||||
import UploadItemActions from './components/UploadItemActions.vue';
|
import UploadItemActions from './components/UploadItemActions.vue';
|
||||||
import { InboxOutlined } from '@ant-design/icons-vue';
|
import { InboxOutlined } from '@ant-design/icons-vue';
|
||||||
import { Upload } from 'ant-design-vue';
|
import { Upload } from 'ant-design-vue';
|
||||||
|
import { getMediaUrlByOrgCode } from '@/api/common/api'
|
||||||
|
|
||||||
const opeMediaAddress = import.meta.env.VITE_OPE_MEDIA_ADDRESS
|
const opeMediaAddress = ref<string>('');
|
||||||
const { createMessage, createConfirm } = useMessage();
|
const { createMessage, createConfirm } = useMessage();
|
||||||
const { prefixCls } = useDesign('j-upload');
|
const { prefixCls } = useDesign('j-upload');
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
@ -449,6 +450,11 @@ const uploadVisible = computed(() => {
|
||||||
return fileList.value.length < props['maxCount'];
|
return fileList.value.length < props['maxCount'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const res = await getMediaUrlByOrgCode({ orgCode: '' });
|
||||||
|
opeMediaAddress.value = res.mediaUrl;
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
addActionsListener,
|
addActionsListener,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="ant-upload-text">{{ text }}123</div>
|
<div class="ant-upload-text">{{ text }}123</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="upload-area" style="padding: 20px;" v-else-if="uploadVisible" :disabled="buttonDisabled">
|
<div class="upload-area" style="padding: 20px;" v-if="fileList.length <= 0" :disabled="buttonDisabled">
|
||||||
<p class="upload-text">点击或者拖拽上传</p>
|
<p class="upload-text">点击或者拖拽上传</p>
|
||||||
<p class="upload-hint">
|
<p class="upload-hint">
|
||||||
<div class="upload-icon">
|
<div class="upload-icon">
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, computed, watch, nextTick, createApp, unref } from 'vue';
|
import { ref, reactive, computed, watch, nextTick, createApp, unref, onMounted } from 'vue';
|
||||||
import { Icon } from '/@/components/Icon';
|
import { Icon } from '/@/components/Icon';
|
||||||
import { getToken } from '/@/utils/auth';
|
import { getToken } from '/@/utils/auth';
|
||||||
import { uploadUrl } from '/@/api/common/api';
|
import { uploadUrl } from '/@/api/common/api';
|
||||||
|
|
@ -66,8 +66,9 @@ import { getFileAccessHttpUrl, getHeaders } from '/@/utils/common/compUtils';
|
||||||
import UploadItemActions from './components/UploadItemActions.vue';
|
import UploadItemActions from './components/UploadItemActions.vue';
|
||||||
import { InboxOutlined } from '@ant-design/icons-vue';
|
import { InboxOutlined } from '@ant-design/icons-vue';
|
||||||
import { Upload } from 'ant-design-vue';
|
import { Upload } from 'ant-design-vue';
|
||||||
|
import { getMediaUrlByOrgCode } from '@/api/common/api'
|
||||||
|
|
||||||
const opeMediaAddress = import.meta.env.VITE_OPE_MEDIA_ADDRESS
|
const opeMediaAddress = ref<string>('');
|
||||||
const { createMessage, createConfirm } = useMessage();
|
const { createMessage, createConfirm } = useMessage();
|
||||||
const { prefixCls } = useDesign('j-upload');
|
const { prefixCls } = useDesign('j-upload');
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
@ -458,6 +459,11 @@ const uploadVisible = computed(() => {
|
||||||
return fileList.value.length < props['maxCount'];
|
return fileList.value.length < props['maxCount'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const res = await getMediaUrlByOrgCode({ orgCode: '' });
|
||||||
|
opeMediaAddress.value = res.mediaUrl;
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
addActionsListener,
|
addActionsListener,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, nextTick, defineExpose } from 'vue';
|
import { ref, nextTick, defineExpose } from 'vue';
|
||||||
import DirectiveSyncLogInfoList from './DirectiveSyncLogInfoList.vue'
|
import DirectiveSyncLogInfoList from './DirectiveSyncLogInfoList.vue'
|
||||||
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
|
||||||
|
|
||||||
const title = ref<string>('');
|
const title = ref<string>('');
|
||||||
const width = ref<number>(800);
|
const width = ref<number>(800);
|
||||||
|
|
@ -67,6 +66,7 @@ function handleCancel() {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
add,
|
add,
|
||||||
edit,
|
edit,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@
|
||||||
<a-button @click="handleOpeLogClose" type="primary">关闭</a-button>
|
<a-button @click="handleOpeLogClose" type="primary">关闭</a-button>
|
||||||
</template>
|
</template>
|
||||||
<div>
|
<div>
|
||||||
<DirectiveOpeLogMainList v-if="opeLogOpen" ref="opeLogRef"></DirectiveOpeLogMainList>
|
<DirectiveOpeLogMainList v-if="opeLogOpen" :mediaApiAddress="mediaApiAddress" ref="opeLogRef">
|
||||||
|
</DirectiveOpeLogMainList>
|
||||||
</div>
|
</div>
|
||||||
</a-drawer>
|
</a-drawer>
|
||||||
|
|
||||||
|
|
@ -52,7 +53,8 @@
|
||||||
<a-button @click="handleSyncLogClose" type="primary">关闭</a-button>
|
<a-button @click="handleSyncLogClose" type="primary">关闭</a-button>
|
||||||
</template>
|
</template>
|
||||||
<div>
|
<div>
|
||||||
<DirectiveSyncLogMainList v-if="syncLogOpen" ref="syncLogRef"></DirectiveSyncLogMainList>
|
<DirectiveSyncLogMainList v-if="syncLogOpen" :mediaApiAddress="mediaApiAddress" ref="syncLogRef">
|
||||||
|
</DirectiveSyncLogMainList>
|
||||||
</div>
|
</div>
|
||||||
</a-drawer>
|
</a-drawer>
|
||||||
|
|
||||||
|
|
@ -87,6 +89,7 @@ import { idListByDS } from '/@/views/synchronization/directive/serviceDirective/
|
||||||
import DirectiveBkMainList from '/@/views/services/directivebk/DirectiveBkMainList.vue'
|
import DirectiveBkMainList from '/@/views/services/directivebk/DirectiveBkMainList.vue'
|
||||||
import DirectiveSyncLogMainList from './directivesynclog/DirectiveSyncLogMainList.vue'
|
import DirectiveSyncLogMainList from './directivesynclog/DirectiveSyncLogMainList.vue'
|
||||||
import DirectiveOpeLogMainList from './directiveopelog/DirectiveOpeLogMainList.vue'
|
import DirectiveOpeLogMainList from './directiveopelog/DirectiveOpeLogMainList.vue'
|
||||||
|
import { getMediaUrlByOrgCode } from '@/api/common/api'
|
||||||
|
|
||||||
const { createMessage, createConfirm } = useMessage()
|
const { createMessage, createConfirm } = useMessage()
|
||||||
const canAddDirectiveRef = ref()
|
const canAddDirectiveRef = ref()
|
||||||
|
|
@ -104,6 +107,7 @@ const backupsRef = ref()//指令备份
|
||||||
const syncLogRef = ref()//镜像日志ref
|
const syncLogRef = ref()//镜像日志ref
|
||||||
const opeLogOpen = ref(false)
|
const opeLogOpen = ref(false)
|
||||||
const opeLogRef = ref()
|
const opeLogRef = ref()
|
||||||
|
const mediaApiAddress = ref('')
|
||||||
|
|
||||||
const labelCol = reactive({
|
const labelCol = reactive({
|
||||||
xs: 24,
|
xs: 24,
|
||||||
|
|
@ -213,6 +217,9 @@ onMounted(() => {
|
||||||
reload();
|
reload();
|
||||||
getDirectiveMainOrgInfo()
|
getDirectiveMainOrgInfo()
|
||||||
orgListComRef.value?.reload();
|
orgListComRef.value?.reload();
|
||||||
|
getMediaUrlByOrgCode({ orgCode: '' }).then(res => {
|
||||||
|
mediaApiAddress.value = res.mediaUrl
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue