Browse Source

feat:[模板管理][update]

lkf
luojie 2 months ago
parent
commit
30b56e3059
2 changed files with 62 additions and 28 deletions
  1. +1
    -1
      src/components/Template/BaseInfoFormPackage.vue
  2. +61
    -27
      src/components/Template/HandleFormItem.vue

+ 1
- 1
src/components/Template/BaseInfoFormPackage.vue View File

@ -70,7 +70,7 @@
</div> </div>
</template> </template>
<template v-else-if="item.type === 'cellItem'"> <template v-else-if="item.type === 'cellItem'">
<div class="form-item " :class="sItem.span == 1 ? 'full-row' : ''">
<div class="form-item ">
<div class="form-title fs-16" v-if="item.label">{{ $t( item.label) }}</div> <div class="form-title fs-16" v-if="item.label">{{ $t( item.label) }}</div>
<div class="grid-container gap2"> <div class="grid-container gap2">
<div v-for="(sItem, key) in item.config" class="c-Item" :class="getSpanClass(sItem)" :key="key"> <div v-for="(sItem, key) in item.config" class="c-Item" :class="getSpanClass(sItem)" :key="key">

+ 61
- 27
src/components/Template/HandleFormItem.vue View File

@ -52,14 +52,16 @@
<span v-else class="default-placeholder-text">{{ getPlaceholder() }}</span> <span v-else class="default-placeholder-text">{{ getPlaceholder() }}</span>
</div> </div>
<template v-else-if="type === 'attachment'"> <template v-else-if="type === 'attachment'">
<el-upload class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview"
<el-upload ref="uploadRef" class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview"
:headers="headers" :headers="headers"
:before-remove="beforeRemove"
:on-remove="handleRemove" multiple :limit="10" :on-remove="handleRemove" multiple :limit="10"
:on-success="handleSuccess" :on-success="handleSuccess"
:before-upload="beforeUpload"
:on-exceed="handleExceed" :file-list="fileList">
:on-change="handleChange"
:on-exceed="handleExceed" :file-list="fileList"
:auto-upload="false">
<el-button :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" size="small" type="primary">点击上传</el-button> <el-button :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">支持扩展名.rar .zip .doc .docx .pdf .jpg</div>
<div slot="tip" class="el-upload__tip">支持扩展名.rar .zip .doc .docx .pdf .jpg文件大小不超过2MB</div>
</el-upload> </el-upload>
</template> </template>
@ -203,7 +205,7 @@ export default {
visible: false,// visible: false,//
checkboxValue: this.getChecked(),// checkboxValue: this.getChecked(),//
uuid: getuuid(), // EventBus uuid: getuuid(), // EventBus
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq','jcb'], ////
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq'], ////
selectRegentInfo: {},//// selectRegentInfo: {},////
fileList: [],// fileList: [],//
uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload", uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload",
@ -253,6 +255,53 @@ export default {
this.selectRegentInfo = data; this.selectRegentInfo = data;
console.log(data,"yq") console.log(data,"yq")
}, },
//
beforeRemove(file) {
return this.$confirm(`确定移除 ${file.name}`)
},
//
handleChange(file, fileList) {
// statusready
if (file.status === 'ready') {
const isAllowedType = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf',
'application/x-rar-compressed', 'application/zip',
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'].includes(file.raw.type)
const isLt2M = file.size / 1024 / 1024 < 2
if (!isAllowedType) {
this.$message.error(`文件 ${file.name} 格式不支持!只能上传 JPG/PNG/GIF/PDF/RAR/ZIP/DOC/DOCX 格式的文件`)
// fileList
const index = fileList.indexOf(file);
if (index > -1) {
fileList.splice(index, 1);
}
this.fileList = [...fileList];
return
}
if (!isLt2M) {
this.$message.error(`文件 ${file.name} 大小超过2MB!`)
// fileList
const index = fileList.indexOf(file);
if (index > -1) {
fileList.splice(index, 1);
}
this.fileList = [...fileList];
return
}
//
this.$nextTick(() => {
// upload
const uploadComponent = this.$refs.uploadRef;
if (uploadComponent) {
uploadComponent.submit();
}
});
}
// fileList
this.fileList = fileList;
},
handleSuccess(res, file, fileList) { handleSuccess(res, file, fileList) {
if(res.code == 200){ if(res.code == 200){
this.fileList = fileList; this.fileList = fileList;
@ -263,6 +312,12 @@ export default {
this.$message.success('文件上传成功'); this.$message.success('文件上传成功');
} else { } else {
this.$message.error(res.message || '文件上传失败'); this.$message.error(res.message || '文件上传失败');
//
const index = fileList.indexOf(file);
if (index > -1) {
fileList.splice(index, 1);
this.fileList = [...fileList];
}
} }
}, },
getFileList(fileList) { getFileList(fileList) {
@ -292,33 +347,13 @@ export default {
// //
this.onCommonHandleSaveRecord(); this.onCommonHandleSaveRecord();
this.$message.info(`文件 ${file.name} 已移除`);
this.$message.success(`文件 ${file.name} 已移除`);
}, },
handlePreview(file) { handlePreview(file) {
//
if (file.url) { if (file.url) {
window.open(process.env.VUE_APP_FILE_DOMAIN + file.url, '_blank'); window.open(process.env.VUE_APP_FILE_DOMAIN + file.url, '_blank');
} }
}, },
//
beforeUpload(file) {
console.log(file,"fff")
const isAllowedType = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf'].includes(file.type)
const isLt2M = file.size / 1024 / 1024 < 2
if (!isAllowedType) {
this.$message.error('只能上传 JPG/PNG/GIF/PDF 格式的文件!')
return false
}
if (!isLt2M) {
this.$message.error('文件大小不能超过 2MB!')
return false
}
return true
},
handleExceed(files, fileList) { handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
}, },
@ -352,7 +387,6 @@ export default {
mjy: "5",// mjy: "5",//
xj: "9",// xj: "9",//
xb: "11",// xb: "11",//
jcb: "13",//
} }
params = { params = {
...params, ...params,

Loading…
Cancel
Save