db_upload_file
v0.0.23
Published
鼎邦文件上传组件
Readme
db_approval_flow
基于iview的文件上传组件,仅适用于本公司内部框架。1.插件安装
npm镜像库
npm install db_upload_file
淘宝镜像库
npm install db_upload_file --registry=https://registry.npm.taobao.org2.插件卸载
npm uninstall db_upload_file3.配制流程服务api
VUE_APP_FileURL='http://192.168.1.118:7008'4.文件上传组件
A.添加引用
import uploadFile from 'db_upload_file'
B.注册组件
components: { uploadFile },
C.添加页面标签
<UploadFile
v-model="VFormObj.uploadFile"
fileCode=""
fileType=""
:modelId="VFormObj.id"
:father="this"
:readonly="type == 'read'"
loadingName="loading"
placeholder="点击上传文件"
ref="uploadFile"
multiple
/>
-------------------------------------------
v-model:现仅用来进行表单校验
modelId:对应文件的systemId
fypeCode:文件属性大类
fypeType:文件属性小类
father:父节点对象(需要调用父级loading时必填)
lodingName:添加文件时调用父组件loading框的属性名
placeholder:默认显示文字
multiple:是否要多选
accept:文件类型,如:image/png,image/jpeg
readonly:是否只读(bool类型,默认为false,true:查看模式)
C.组件文件回显
this.$refs.uploadFile.show(this.father.selectInfo.id) //手动进行文件回显(参数1:文件关联systemId,参数2:数据排序)
this.$refs.uploadFile.displayFile([]) //手动进行文件回显(参数:文件列表)
E.文件上传事件
let that = this
Promise.all([
that.$refs.uploadFile1.uploadFile(),
that.$refs.uploadFile2.uploadFile()
]).then(data=>{
//上传结果判断
var isUpLoadOk = true;
data.forEach((z) => {
if (!z.status) {
isUpLoadOk = false;
this.loading = false;
this.$Message.error("文件上传失败");
return;
}
});
if (isUpLoadOk) return
obj.fileList = []
data.forEach(y=>{
obj.fileList = obj.fileList.concat(y.result)
})
//调用业务api
...
})