web-public-jinzhan
v1.0.2
Published
金盏web前端公用组件
Downloads
3
Readme
第一步 使用命令下载
npm install web-public-jinzhan
第二步 在相应的页面引用
import 'web-public-jinzhan/css/index.css'
import webPublicJy from 'web-public-jinzhan' // 引入
一、文件上传
listData:[] // 绑定的数据
whiteList="['.doc']" // 允许上传的白名单
fileType:"fileType" // 文件类型别名
fileSize:"fileSize" // 文件大小别名
filePath:"filePath" // 文件路径别名
fileName:"fileName" // 文件名称别名
fileId:"fileId" // 文件ID别名
hide:"false" //是否禁用
width:100 // 文件类型
<JyUploadFile :listData="列表数据" ></JyUploadFile>
备注1:文件上传
新方法,
1、引入此方法需要在main.js中引入import 'web-public-jy/css/index.css',
2、还需要在request.js文件service.interceptors.request.use中添加
service.interceptors.request.use(
config => {
if (!config.noShowLoading) {
showLoading() // 显示加载中
}
import { fileSliceSizeUpload } from "@jy/utils/fileSliceSize.js";
const fieldName = {
fileId: 'fileId',
fileName: 'fileName',
filePath: 'filePath',
fileSize: 'fileSize',
fileType: 'fileType',
};
const data = {
file: item.file, // 文件内容
fieldName: fieldName, // 需要返回的数据字段名
businessType: 0, // 0 其他,1头像,3分片上传
whiteList:['.doc'] // 允许上传的白名单
};
// 文件上传接口
fileSliceSizeUpload(data).then((res) => {
this.listData.push(res);
});
备注:默认允许文件上传的类型
使用方式
import { fileTypeName,imgTypeName,zipTypeName } from '@jy/constant/url'
// 数据类型
// 基本文件类型
export const fileTypeName = ['.xlsx', '.xls', '.doc', '.docx', '.wps', '.csv'];
// 基本图片类型
export const imgTypeName = ['.pdf', '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.txt'];
// 基本压缩文件类型
export const zipTypeName = ['.zip', '.rar'];
此方法将来作废,不兼容后版本,仅向前兼容
import { fileSliceSize } from "@jy/utils/fileSliceSize.js";
// 参数必传
fileSliceSize(file,fieldName,whiteList)
二、文件预览
fileItem:{
fileType:"文件类型",
filePath:"文件路径",
fileName:"文件名字"
}
@closeFun:为啦清空传入fileItem的数据
<JyFileZipDoor :fileItem="fileItem" @closeFun="fileItem={}"></JyFileZipDoor>
备注1:换取预览的路径 (非压缩文件)
fileType:" " //文件类型
filePath:" " //文件路径
fileName:" " //文件名称
import { filePreviewFun } from "@jy/utils/filePreview.js";
// 参数必传
filePreviewFun({fileType:"doc",filePath:"路径地址",fileName:"文件名字"})
// 返回数据格式
{path:"文件路径",type:"文件分类,方便上面的预览组件使用"}
备注2:文件下载 (非压缩文件)
filePath:" " //文件路径
fileName:" " //文件名称
import { fileDownloadFun } from "@jy/utils/filePreview.js";
// 参数必传
fileDownloadFun({filePath:"路径地址",fileName:"文件名字"})
备注3:换取可以解压后的文件列表(压缩文件)
fileType:" " //文件类型
filePath:" " //文件路径
fileName:" " //文件名称
import { filePreviewFun } from "@jy/utils/filePreview.js";
// 参数必传
filePreviewFun({fileType:"doc",filePath:"路径地址",fileName:"文件名字"})
// 返回数据格式
{listDataPopup:"解压后数据",type:"文件分类,方便上面的预览组件使用"}
// listDataPopup 数据格式
{
fileName: 被解压的文件名字,
filePath: 被解压的文件路径,
fileType: 文件类型,
downName: 文件路径,
name: 文件名字,
type: "文件分类,预览的时候传入的type"
}
备注4:压缩文件预览路径(压缩文件)
downName:" " //解压后的每个文件的名字
filePath:" " //压缩文件路径
fileName:" " //压缩文件名称
import { rarFileShow } from "@jy/utils/filePreview.js";
// 参数必传
rarFileShow({downName:"解压后的每个文件的名字",filePath:"路径地址",fileName:"文件名字"})
// 返回数据格式
{path:"路径",type:"文件分类,方便上面的预览组件使用"}
备注5:压缩文件下载(压缩文件)
downName:" " //解压后的每个文件的名字
filePath:" " //压缩文件路径
fileName:" " //压缩文件名称
import { rarListDownload } from "@jy/utils/filePreview.js";
// 参数必传
rarListDownload({downName:"解压后的每个文件的名字",filePath:"路径地址",fileName:"文件名字"})