Ver a proveniência

Merge branch '长阳分支中职' of http://123.57.209.16:3000/bjquanjiang/DigitalScholl into 长阳分支中职

临城职教中职
杨晓琪 há 2 anos
ascendente
cometimento
c4b12c333e
3 ficheiros alterados com 231 adições e 8 eliminações
  1. +17
    -6
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/upload-file.vue
  2. +211
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/upload-file2.vue
  3. +3
    -2
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/LogisticsManagement/Acc_DailyAssess/single.vue

+ 17
- 6
Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/upload-file.vue Ver ficheiro

@@ -1,10 +1,12 @@
<template>
<view>
<view class="cu-form-group" style="border-bottom: none; padding-bottom: 0;">
<view class="title">
<text v-if="required" class="lr-required">*</text>
{{ title || '' }}
</view>
</view>
<view class="cu-form-group">
<view class="grid">
<view class="title">
附件上传
</view>
</view>
<view class="grid col-4 grid-square flex-sub">
<view v-for="(item, index) in imgList" @tap="viewImg(item)" :key="index" class="bg-img">
<image v-if="showfile()&&item&&(typeof item == 'string'||isImage(item.type))" :src="item.url?CONFIG('webHost') + item.url:item" mode="aspectFill">
@@ -25,10 +27,17 @@

</view>
</view>
</view>
</template>

<script>
/**
* 附件上传组件
* 直接选择手机文件
*
* 注意:可以是图片、文档、等;
*/
export default {

props: {
@@ -40,6 +49,8 @@
default: () => []
},
folderId: {},
title: {},
required: {}
},

data() {


+ 211
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/upload-file2.vue Ver ficheiro

@@ -0,0 +1,211 @@
<template>
<view>
<view class="cu-form-group" style="border-bottom: none; padding-bottom: 0;">
<view class="title">
<text v-if="required" class="lr-required">*</text>
{{ title || '' }}
</view>
</view>
<view class="cu-form-group">
<view class="grid col-4 grid-square flex-sub">
<view v-for="(item, index) in imgList" @tap="viewImg(item)" :key="index" class="bg-img">
<image v-if="showfile()&&item&&(typeof item == 'string'||isImage(item.type))" :src="item.url?CONFIG('webHost') + item.url:item" mode="aspectFill">
</image>
<l-icon v-if="showfile()&&!isImage(item.type)" type="text" />
<text class="file-name">{{item.name}}</text>
<view v-if="!readonly" @tap.stop="delImg(index)" class="cu-tag bg-red"
style="width: 18px; height: 18px; font-size: 24px">
<l-icon type="close" style="width: 18px; height: 18px; font-size: 12px" />
</view>
</view>
<view v-if="!readonly && imgList.length < Number(number)" @click="chooseFile" class="solids">
<l-icon type="file" />
</view>
</view>
</view>
</view>

</template>

<script>
/**
* 附件上传组件
* 使用相机拍摄 和 从相册选图
*
* 注意:可以选择图片;如果选择文档的话则是从手机的‘文件管理’里面去选择,有可能会找不到文档;
*/
export default {

props: {
number: {
default: 1
},
readonly: {},
value: {
default: () => []
},
folderId: {},
title: {},
required: {}
},

data() {
return {
isShow: false,
imgList: [],
}
},

methods: {
chooseFile() {
uni.chooseImage({
count: Number(this.number),
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: ({ tempFilePaths,tempFiles }) => {
this.chooseChangeback(tempFilePaths,tempFiles)
}
})
},
delImg(index) {
this.CONFIRM("", "是否确认删除?", true).then(res => {
if(!res)return
this.LOADING('正在删除…');
const newList = JSON.parse(JSON.stringify(this.imgList));
this.HTTP_POST('/learun/adms/annexes/wxdelete', this.imgList[index].id, "文件删除失败").then((data) => {
this.HIDE_LOADING();
if (data) {
newList.splice(index, 1);
this.imgList = newList

this.$emit("update:value", newList);
this.$emit("input", newList);
this.$emit("change");
this.$emit("del");
}
})
})

},
showfile() {
return true;
},

async chooseChangeback(tempFilePaths, tempFiles) {
let uploadImageRes = await this.uploadImage(tempFilePaths[0], tempFiles[0] ? tempFiles[0].name : "")
let newList = this.imgList || []
if (uploadImageRes) {
//请求‘获取附件列表’接口
let data = await this.FETCH_FILEList(uploadImageRes);
if(data){
newList = data.map(t=>({
id: t.F_Id,
name: t.F_FileName,
url: t.F_FilePath.substring(t.F_FilePath.indexOf('Resource')),
type: t.F_FileType,
folderid:t.F_FolderId,
}))
}
}

this.imgList = newList

this.$emit("update:value", newList);
this.$emit("input", newList);
this.$emit("change", newList);
},

uploadImage(url, name) {
if (!url) return
// 文件上传
return new Promise(async (reslove, reject) => {
this.LOADING('正在上传…');
let params = name ? {
folderId: this.folderId,
name
} : {
folderId: this.folderId
}
this.HTTP_UPLOAD2('/learun/adms/annexes/wxuploadinsingle', url, params).then((data) => {
this.HIDE_LOADING();
if (data) {
reslove(data)
} else {
reject('上传失败!')
}
})
})

},
validate(array) {
// let type = array.every(item=>{
// return item.type && item.type.substring(0,6) == "image/"
// })
// if(!type){
// this.TOAST('文件类型错误');
// return false
// }
let size = array.every(item => {
return item.size && item.size <= 200 * 1024 * 1024
})
if (!size) {
this.TOAST('文件大小不得超过200M');
return false
}
return true
},

isImage(type) {
if (type && type.length) {
return ["png", "jpg"].includes(type.substring(type.length - 3, type.length))
} else {
return false
}
},

viewImg(item) {
if (!this.isImage(item.type)) {
window.location.href = this.CONFIG("webHost") + item.url
} else {
uni.previewImage({
urls: [this.CONFIG('webHost') + item.url],
current: this.CONFIG('webHost') + item.url
});
}
},
},
created() {
// console.log(this.value)
this.imgList = JSON.parse(JSON.stringify(this.value.map(item => {
return {
id: item.F_Id,
name: item.F_FileName,
url: item.F_FilePath.substring(item.F_FilePath.indexOf('Resource')),
type: item.F_FileType,
folderid:item.F_FolderId,
}
})))
this.$nextTick(() => {
this.isShow = true
})
}
};
</script>

<style scoped>
.file-name {
position: absolute;
bottom: 0;
width: 100%;
color: #606266;
font-size: 12px;
text-align: center;
background-color: rgba(255, 255, 255, 0.6);

text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
</style>

+ 3
- 2
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/LogisticsManagement/Acc_DailyAssess/single.vue Ver ficheiro

@@ -118,7 +118,7 @@
v-show="false"
title="附件值"
/>
<uploadFile :number="5" :folderId="folderId" :value="fileList" :readonly="!edit"></uploadFile>
<uploadFile :number="5" :folderId="folderId" :value="fileList" :readonly="!edit" :title="fileTitle" :required="false"></uploadFile>
</view>
@@ -157,7 +157,7 @@ import get from 'lodash/get'
import set from 'lodash/set'
import moment from 'moment'
import customPageMixins from '@/common/custompage.js'
import uploadFile from '@/components/upload-file.vue'
import uploadFile from '@/components/upload-file2.vue'
export default {
mixins: [customPageMixins],
@@ -173,6 +173,7 @@ export default {
ready: false,
fileList:[],//附件列表
folderId:null,//附件随机文件夹id
fileTitle:'附件上传',//附件label值
// 表单数据
current: {},


Carregando…
Cancelar
Guardar