Commit efb302d9 by LJM

优化

parent 0100b9e1
Showing with 116 additions and 9 deletions
......@@ -40,6 +40,7 @@
<text class="iconfont icon-a-juxing11" @click="clearInput()" v-if="input_flag"></text>
</view>
</view>
<!-- 采购类型筛选 -->
<view class="radio-wrap row verCenter" style="padding-bottom: 0;">
<radio-group name="radio1" @change="radioChange($event, 1)">
<label>
......@@ -56,6 +57,7 @@
</label>
</radio-group>
</view>
<!-- 理货状态筛选 -->
<view class="radio-wrap row verCenter">
<radio-group name="radio" @change="radioChange($event, 2)">
<label>
......@@ -72,6 +74,7 @@
</label>
</radio-group>
</view>
<!-- 列表 -->
<view class="list row bothSide" v-if="list.length > 0">
<view class="box" v-for="(item, index) in list" :key="index" :class="{ curr: filter_list[index] }" style="padding-bottom: 50rpx;">
<view class="check-box-icon" @click="filterChange(index)"></view>
......@@ -179,8 +182,8 @@
<text>货品信息</text>
</template>
</view>
<!-- 区分深圳自营和非深圳自营 -->
<template v-if="curr == 0">
<!-- 非深圳自营 -->
<view class="field-item row">
<view class="item row verCenter">
<text class="label">货品编码:</text>
......@@ -285,13 +288,18 @@
<view class="pic-list">
<view class="pic-title">理货照片:</view>
<view class="row pic-wrap">
<view class="box" v-for="(item, index) in image_list" :key="index">
<image @click="previewChange(image_list, index)" :src="item" mode="aspectFill" lazy-load="true"></image>
</view>
<template v-if="image_list.length > 0">
<view class="box" v-for="(item, index) in image_list" :key="index">
<image :src="item" mode="aspectFill" @click="previewChange(image_list, index)"></image>
<text class="iconfont icon-a-juxing11" @click="deletePic(index)"></text>
</view>
</template>
<view class="default row rowCenter verCenter" @click="chooseImageChange()" v-if="image_list.length < maxNum"><text class="iconfont icon-a-juxing3"></text></view>
</view>
</view>
</template>
<template v-else>
<!-- 深圳自营 -->
<view class="field-item row">
<view class="item row verCenter" style="flex: 0 0 100%;" v-if="detail.sku_id">
<text class="label">自营货品ID:</text>
......@@ -374,6 +382,7 @@
input_flag: false,
index: 0,
curr: 0,
noexebshowFalg: true, //控制是否会触发生命周期
item: ['货品信息', '其他信息'],
array: ['全量搜索', '入仓号'],
list: [],
......@@ -382,6 +391,8 @@
detail: {}, //详情的数据
image_list: [], //图片列表
hasMoreData: true, //是否分页加载
image_list: [], //图片列表
maxNum: 10, //最大上传图片数量
searchParams: {
create_time_begin: '', //起始日期
create_time_end: '', //结束日期
......@@ -393,6 +404,11 @@
}
};
},
watch: {
image_list(arr) {
}
},
onReachBottom() {
if (!this.hasMoreData) {
return;
......@@ -408,8 +424,10 @@
}
},
onShow() {
this.resetChange();
this.getData();
if (this.noexebshowFalg) {
this.resetChange();
this.getData();
}
},
methods: {
/**
......@@ -443,7 +461,7 @@
if (timeB < timeA) {
uni.showToast({
title: '不能小于开始时间',
title: '注意,不能小于开始时间',
icon: 'none'
});
this.searchParams.create_time_end = this.searchParams.create_time_begin;
......@@ -568,7 +586,9 @@
showDrawer(data) {
this.$refs.showRight.open();
this.detail = data;
this.image_list = data.image_ids.split(',');
if (data.image_ids) {
this.image_list = data.image_ids.split(',');
}
},
closeDrawer() {
this.$refs.showRight.close();
......@@ -732,11 +752,97 @@
});
},
/**
* 选择图片
*/
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
count: this.maxNum,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
// 显示loading
uni.showLoading({
title: '上传中...'
});
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
// 判断选择的图片数量是否超过最大限制数量
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
if (maxNum > this.maxNum) {
uni.hideLoading();
uni.showToast({
title: '图片不超过' + this.maxNum + '张',
icon: 'none'
});
return false;
}
// 遍历图片路径数组,对每张图片进行压缩
imagePaths.forEach(imagePath => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
// 在这里处理压缩后的图片,上传到服务器
uni.uploadFile({
url: API.upload + '?sys_type=4',
filePath: compressedImagePath,
name: 'file',
header: {
'Content-Type': 'multipart/form-data'
},
success: uploadFileRes => {
console.log('服务器上传图片成功:', uploadFileRes);
uni.hideLoading();
let data = JSON.parse(uploadFileRes.data);
if (data.code === 0) {
this.image_list.push(data.data.oss_image_url);
} else {
uni.showToast({
title: data.msg,
icon: 'none'
});
}
},
fail: error => {
console.log('上传图片失败:', error);
uni.hideLoading();
}
});
},
fail: err => {
console.log('压缩图片失败:', err);
}
});
});
}
});
},
/**
* 删除图片
* @param {Object} index
*/
deletePic(index) {
this.image_list.splice(index, 1);
},
/**
* 预览图片
* @param {Object} img
* @param {Object} index
*/
previewChange(img, index) {
this.noexebshowFalg = false;
uni.previewImage({
current: index,
urls: img
......@@ -754,5 +860,5 @@
</script>
<style scoped lang="scss">
@import '@/assets/css/tallyReceive/index.scss';
@import '@/assets/css/tallyReceive/record.scss';
</style>
\ 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 sign in to comment