Commit 0819347e by zhangzhen

功能优化

parent 59067845
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
if(res.data.result && res.data.result.length){ if(res.data.result && res.data.result.length){
this.swiperList = res.data.result.map(item =>{ this.swiperList = res.data.result.map(item =>{
return { return {
img:this.assetsPath+"/hggp/file/download/docId/"+item.DOC_ID img:this.assetsPath+"/hggp/file/download/"+item.DOC_ID
} }
}) })
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
let list = resData.map(item=>{ let list = resData.map(item=>{
return { return {
...item, ...item,
appIconUrl: item.docIdApp ? this.assetsPath+"/hggp/file/download/docId/"+item.docIdApp: '' appIconUrl: item.docIdApp ? this.assetsPath+"/hggp/file/download/"+item.docIdApp: ''
} }
}) })
this.companyInfo = list[0] this.companyInfo = list[0]
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
this.list = res.data.menu.map(item=>{ this.list = res.data.menu.map(item=>{
return { return {
...item, ...item,
imagePath: item.imagePath? this.assetsPath+"/hggp/file/download/docId/"+item.imagePath:false imagePath: item.imagePath? this.assetsPath+"/hggp/file/download/"+item.imagePath:false
} }
}); });
}else{ }else{
......
...@@ -155,8 +155,8 @@ ...@@ -155,8 +155,8 @@
<text class="text-black text-title text-lg">图片上传:</text> <text class="text-black text-title text-lg">图片上传:</text>
</view> </view>
<view class=""> <view class="">
<u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple <u-upload :fileList="fileList" @oversize="afterRead" @afterRead="afterRead" @delete="deletePic" name="1" multiple
:maxCount="6"></u-upload> :maxCount="6" :maxSize="1024*1024*5"></u-upload>
</view> </view>
</view> </view>
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
this.orderInfo = { this.orderInfo = {
...rows[0], ...rows[0],
quantity: rows[0].unregisterQuantity, quantity: rows[0].unregisterQuantity,
weight: Number(rows[0].unregisterQuantity)*Number(rows[0].singleWeight) weight: (Number(rows[0].unregisterQuantity)*Number(rows[0].singleWeight)).toFixed(2)
}; };
} }
} }
...@@ -243,10 +243,30 @@ ...@@ -243,10 +243,30 @@
deletePic(event) { deletePic(event) {
this.fileList.splice(event.index, 1) this.fileList.splice(event.index, 1)
}, },
onOversize(fileData){
let indexS = [];
let upLoad = []
fileData.file.forEach((item,k) => {
if(item.size> 1024*1024*5){
indexS.push(k+1)
}else{
upLoad.push(item)
}
})
if(indexS.length){
uni.showToast({
icon:"none",
title: `图片第${indexS.join('、')}张,大小超出5MB限制`,
duration:3000
})
}
return upLoad
},
// 新增图片 // 新增图片
async afterRead(event) { async afterRead(event) {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式 console.log(event,"文件资源")
let lists = [].concat(event.file); let lists = this.onOversize(event);
console.log(lists,9999)
let fileListLen = this.fileList.length; let fileListLen = this.fileList.length;
lists.map((item) => { lists.map((item) => {
this.fileList.push({ this.fileList.push({
...@@ -260,12 +280,13 @@ ...@@ -260,12 +280,13 @@
url: lists[i].url url: lists[i].url
}) })
console.log(result,99999) console.log(result,99999)
let res = JSON.parse(result.data)
let item = this.fileList[fileListLen] let item = this.fileList[fileListLen]
this.fileList.splice(fileListLen, 1, Object.assign(item, { this.fileList.splice(fileListLen, 1, Object.assign(item, {
status: 'success', status: res.status == 500?'failed':'success',
message: '', message: '',
url: lists[i].url, url: lists[i].url,
id: JSON.parse(result.data).id id: res.id
})) }))
fileListLen++ fileListLen++
} }
......
...@@ -84,12 +84,12 @@ ...@@ -84,12 +84,12 @@
<text class="text-gray part-2">:</text> <text class="text-gray part-2">:</text>
<text class="text-title">{{orderInfo.registeredQuantity}}</text> <text class="text-title">{{orderInfo.registeredQuantity}}</text>
</view> </view>
<view class="flex-row"> <view v-if="Number(orderInfo.unregisterQuantity)" class="flex-row">
<text class="text-gray part-1">待报工数量</text> <text class="text-gray part-1">待报工数量</text>
<text class="text-gray part-2">:</text> <text class="text-gray part-2">:</text>
<text class="text-title">{{orderInfo.unregisterQuantity}}</text> <text class="text-title">{{orderInfo.unregisterQuantity}}</text>
</view> </view>
<view class="flex-row"> <view v-if="Number(orderInfo.unregisterWeight)" class="flex-row">
<text class="text-gray part-1">待报工重量</text> <text class="text-gray part-1">待报工重量</text>
<text class="text-gray part-2">:</text> <text class="text-gray part-2">:</text>
<text class="text-title">{{Number(orderInfo.unregisterWeight)}}</text> <text class="text-title">{{Number(orderInfo.unregisterWeight)}}</text>
...@@ -163,6 +163,7 @@ ...@@ -163,6 +163,7 @@
<script> <script>
import config from "@/config/index.config"; import config from "@/config/index.config";
import {checkIsImg} from "@/utils/tools.js";
import { import {
pathToBase64, pathToBase64,
base64ToPath base64ToPath
...@@ -278,12 +279,12 @@ ...@@ -278,12 +279,12 @@
matId: item.id, matId: item.id,
bizType: "SCBG" bizType: "SCBG"
}) })
let imgList = toJsonData(imgDatas.data.__blocks__.result.rows, imgDatas.data.__blocks__.result.meta.columns) let imgList = toJsonData(imgDatas.data.__blocks__.result.rows, imgDatas.data.__blocks__.result.meta.columns).filter(item=>checkIsImg(item.docName))
list.push({ list.push({
...item, ...item,
imgList : imgList.length? imgList.map(val=>{ imgList : imgList.length? imgList.map(val=>{
return { return {
url: this.assetsPath+"/hggp/file/download/docId/"+val.docId url: this.assetsPath+"/hggp/file/download/"+val.docId
} }
}):[] }):[]
}) })
......
...@@ -182,3 +182,9 @@ export function formatForLen14 (dateStr) { ...@@ -182,3 +182,9 @@ export function formatForLen14 (dateStr) {
} }
return dateStr return dateStr
} }
export function checkIsImg(fileName){
const extension = fileName.split(".").pop().toLowerCase();
const imgExtensions = ["jpg","png","jpeg","gif","bmp","webp","svg"]
return imgExtensions.includes(extension)
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment