Переглянути джерело

修改上传组件 区分图片非图片

新疆影视学院高职
杨晓琪 2 роки тому
джерело
коміт
e5906e55d0
4 змінених файлів з 23 додано та 15 видалено
  1. +7
    -1
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/customform.js
  2. +0
    -1
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js
  3. +15
    -13
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue
  4. +1
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js

+ 7
- 1
Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/customform.js Переглянути файл

@@ -273,8 +273,14 @@ export default {
return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : ''

case 'upload':
const valArray = val.map(item=>{
return {
uid:item.uid,
path:item.path===undefined?item:item.path
}
})
const uploadUid = []
for (const { path, uid } of val) {
for (const { path, uid } of valArray) {
if (uid) {
uploadUid.push(uid)
continue


+ 0
- 1
Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js Переглянути файл

@@ -197,7 +197,6 @@ export default {
uploadUid.push(entity.uid)
continue
} else {

const fileId = await this.HTTP_UPLOAD(entity)
if (fileId) {
uploadUid.push(fileId)


+ 15
- 13
Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue Переглянути файл

@@ -11,13 +11,13 @@
<view class="grid col-4 grid-square flex-sub">
<view v-for="(file, index) in value" :key="index" class="bg-img">
<image
v-if="isImgFile(file.type)"
v-if="isImgFile(file)"
@click="fileClick(index)"
:src="file.path?file.path:file"
:webp="file.type === 'webp'"
mode="aspectFill"
></image>
<view v-else-if="isDocFile(file.type)" @click="fileClick(index)" class="file-icon solids">
<view v-else-if="isDocFile(file)" @click="fileClick(index)" class="file-icon solids">
<l-icon type="text" />
</view>
<view v-else class="file-icon solids"><l-icon type="text" /></view>
@@ -51,16 +51,16 @@ export default {
getFileExt(path) {
return /\.(\w{2,5})$/.exec(path)[1] || null
},

isImgFile(type) {
const typeString = (type || '').toLowerCase()
//return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'image'].includes(typeString)
return true;
isImgFile(file) {
const typeString = (file.type || '').toLowerCase()
return ['jpg','image/jpg','jpeg','image/jpeg', 'png', 'image/png','gif', 'image/gif','bmp', 'image/bmp','webp', 'image/webp','image'].includes(typeString)
},

isDocFile(type) {
const typeString = (type || '').toLowerCase()
isDocFile(file) {
const typeString = (file.type || '').toLowerCase()
return ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf'].includes(typeString)
return true
},

delFile(index) {
@@ -93,9 +93,11 @@ export default {
count: Number(this.number),
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: ({ tempFilePaths }) => {
success: ({ tempFilePaths,tempFiles }) => {
console.log(tempFiles)
const newList = JSON.parse(JSON.stringify(this.value || [])).concat(
tempFilePaths//.map(t => ({ path: t, type: this.getFileExt(t) }))
// tempFilePaths//.map(t => ({ path: t, type: this.getFileExt(t) }))
tempFilePaths.map((t,i) => ({ path: t, type: tempFiles[i].type,size:tempFiles[i].size }))
)
this.$emit('input', newList)
this.$emit('change', newList)
@@ -107,9 +109,9 @@ export default {

async fileClick(index) {
const { path, type, uid, size = 0 } = this.value[index]
if (this.isImgFile(type)) {
if (this.isImgFile(this.value[index])) {
uni.previewImage({ urls: [path], current: path })
} else if (this.isDocFile(type)) {
} else if (this.isDocFile(this.value[index])) {
// #ifndef H5 || MP-DINGTALK
if (size >= 50 * 1024 * 1024) {
this.TOAST('小程序端无法下载超过50MB的文件,此文件大小为${size}KB,超过限制')


+ 1
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js Переглянути файл

@@ -220,6 +220,7 @@ export default {
* 遍历 formValue,将其中的表单值依次使用 convertToPostData 这个方法转化为提交值
*/
async getPostData(originFormValue, scheme) {
console.log(originFormValue, scheme)
const formValue = this.COPY(originFormValue)

// 依次按照 scheme 项目遍历


Завантаження…
Відмінити
Зберегти