|
|
<template> <view> <view class="head"> <view class="lf-row-between lf-color-gray list"> <view>采购单 492461046128742764</view> </view> <view class="lf-row-between list"> <image src="../../../static/logo.png" class="image"></image> <view class="info"> <view class="lf-font-32 lf-color-black lf-font-bold">广西美味生活有限公司</view> <view class="lf-font-24 lf-color-555">广西南宁青秀区民族大道118号可爱大厦A座0930室</view> </view> </view> </view> <self-line></self-line> <view class="lf-p-l-32 lf-p-r-32 lf-border-box lf-bg-white"> <lf-ysteps :stepList="stepList"></lf-ysteps> </view> <self-line></self-line> <view class="lf-m-t-30 lf-m-l-32"> <view class="lf-font-32 lf-color-black lf-font-bold lf-m-b-20">物资明细</view> <wyb-table :first-line-fixed="true" contentBgColor="#eef6fe" :headers="headers" :contents="contents" @onButtonClick="onButtonClick" width="100%" height="350rpx"></wyb-table> </view> <view style="height: 100rpx;"></view> <!-- 操作按钮 --> <view class="fixed-bottom"> <button class="btn btn1" @click="is_show_voucher = true">上传凭证</button> <button class="btn btn2">确认发货</button> </view> <!-- 弹出层-上传凭证 --> <u-popup v-model="is_show_voucher" mode="center" border-radius="20"> <view class="popup-box"> <view class="content"> <view class="popup-title">上传凭证信息</view> <view class="popup-desc">请在此处上传检验检疫凭证、售卖资质等证书</view> <view class="popup-images"> <view class="popup-image-item" v-for="(item, index) in voucher_list" :key="index" @click="lookImage(index)"> <image :src="item" mode="aspectFill"></image> <view class="remove-image" @click.stop="removeInage(index)"> <u-icon name="close-circle"></u-icon> </view> </view> <view class="popup-image-item popup-image-item-after" @click="uploadImage" v-if="voucher_list.length < 6"></view> </view> </view> <view class="foot-btn"> <u-button class="popup-btn" @click="is_show_voucher = false">取消</u-button> <u-button class="popup-btn" @click="submitImage">确定</u-button> </view> </view> </u-popup> </view></template>
<script> import lfYsteps from '@/components/lf-ysteps/lf-ysteps'; import wybTable from '@/components/wyb-table/wyb-table'; export default { components: { lfYsteps, wybTable }, data(){ return { stepList: [ { time: '2021-07-23 13:23:52', // 左侧时间 -- 必选
info: '订单创建', // 右侧内容 -- 可选
isFinished: true, // 是否已完成(完成 index 为 √)-- 可选
isActive: false, // 是否为当前节点 Active(当前节点 即使完成 index 也不会显示 √)-- 可选
isShowSlot: false // 右侧是否有 Slot(显示在 右侧内容下方)-- 可选
}, { time: '2021-07-23 13:23:52', info: '采购订单发起,等待供应商接单', isFinished: false, isActive: true, isShowSlot: true }, { time: '2021-07-23 13:23:52', info: '供应商已接单,正在装车', isFinished: false, isActive: true, isShowSlot: true } ], headers: [{ key: 'name', label: '姓名' },{ key: 'age', label: '年龄' },{ key: 'sex', label: '性别' },{ key: 'height', label: '身高' },{ key: 'info', label: '描述' },{ key: 'operation', label: '操作' }], contents: [{ name: '张三', age: '18', sex: '男', height: '192cm', info: '无敌叫是', operation: {button: true, key: 'delete', value: '删除'} }, { name: '李四', age: '18', sex: '男', height: '192cm', info: '无敌叫是' }, { name: '赵五', age: '18', sex: '男', height: '192cm', info: '无敌叫是' },{ name: '王六', age: '18', sex: '男', height: '192cm', info: '无敌叫是' }], is_show_voucher: false, // 是否显示凭证上传弹出层
voucher_list: [], // 已上传的凭证列表
voucher_count: 6 // 最多可以上传多少张凭证
} }, onLoad(){ }, methods: { // 监听table删除操作
onButtonClick(event){ uni.showModal({ title: '温馨提示', content: '您确定移除该项吗?', success: result => { if(result.confirm){ console.log("移除某一项", event); let { contentIndex } = event; this.contents.splice(contentIndex, 1); } } }) }, // 上传凭证图片
uploadImage(){ let current_count = this.voucher_count - this.voucher_list.length; if(current_count == 0) return; uni.chooseImage({ count: current_count, complete: result => { this.voucher_list.push(...result.tempFilePaths); } }) }, // 预览图片
lookImage(current){ if(this.voucher_list.length <= 0) return; this.$u.throttle(() => { uni.previewImage({ urls: this.voucher_list, current: current }) }, 500); }, // 移除图片
removeInage(current){ this.voucher_list.splice(current, 1); }, // 用户点击确定,将图片上传至oss,并将url发送给后端
submitImage(){ let that = this; let voucher_list = that.voucher_list; if(voucher_list.length <= 0){ return that.$msg('您未上传图片哦'); }; that.is_show_voucher = false; uni.showLoading({ title: '正在上传中...' }) let http_list = []; voucher_list.map(item => { let itemP = new Promise((resolve, reject) => { that.$http(that.API.XXXX, {url: item}) .then(res => resolve(res)) .catch(err => reject(err)); }) http_list.push(itemP); }) // todo 上传对接
Promise.all(http_list).then(res => { console.log("上传完毕", res); // 此处res需要处理一下,有可能格式是这样的,res.data.images
that.$http(that.API.XXXX, {urls: res}).then(result => { uni.hideLoading(); that.$msg('凭证已上传成功!') }).catch(err => uni.hideLoading()); }).catch(err => { uni.hideLoading(); uni.showModal({ title: '', content: JSON.stringify(err), showCancel: false, confirmColor: '#1833F2' }) }) } } }</script>
<style lang="scss" scoped="scoped"> .head{ padding: 0 32rpx; width: 750rpx; box-sizing: border-box; height: auto; .list{ padding: 30rpx 0; border-bottom: 1rpx solid #e5e5e5; font-size: 28rpx; color: #555555; &:last-child{ border-bottom: none; } .image{ width: 140rpx; height: 140rpx; border-radius: 10rpx; } .info{ display: flex; flex-direction: column; justify-content: space-around; width: 530rpx; height: 140rpx; } } } .fixed-bottom{ position: fixed; bottom: 0rpx; left: 0rpx; z-index: 99; width: 750rpx; height: 98rpx; display: flex; justify-content: flex-end; align-items: center; border-top: 1rpx solid #E5E5E5; background-color: #FFFFFF; box-sizing: border-box; padding: 0 32rpx; .btn{ width: 212rpx; height: 82rpx; border-radius: 41rpx; margin: 0; padding: 0; font-size: 32rpx; display: flex; justify-content: center; align-items: center; } .btn1{ border: 2rpx solid #555555; opacity: .5; } .btn2{ background: #1833F2; color: #FFFFFF; margin-left: 20rpx; } } .popup-box{ width: 686rpx; // height: 727rpx;
height: max-content; display: flex; justify-content: space-between; flex-direction: column; .content{ .popup-title{ font-size: 32rpx; font-weight: bold; color: #222222; text-align: center; margin-top: 40rpx; } .popup-desc{ font-size: 28rpx; color: #555555; text-align: center; margin-top: 20rpx; margin-bottom: 18rpx; } .popup-images{ display: flex; flex-wrap: wrap; padding: 22rpx; margin-bottom: 18rpx; .popup-image-item{ width: 198rpx; height: 198rpx; margin: 8rpx; background: #F5F5F5; border-radius: 10rpx; position: relative; image{ width: 100%; height: 100%; } .remove-image{ position: absolute; right: -8rpx; top: -16rpx; color: #e74c3c; font-size: 40rpx; padding: 8rpx; } } .popup-image-item-after::after{ content: '+'; position: absolute; left: 30%; top: 14%; font-size: 100rpx; color: #777777; } } } .foot-btn{ height: 90rpx; width: 100%; border-top: 1rpx solid #E5E5E5; display: flex; box-sizing: border-box; .popup-btn{ width: 50%; height: 100%; border: none; border-radius: initial; &:last-child{ border-left: 1rpx solid #E5E5E5; color: #1833F2; } } } } // 去掉u-button 外边框线
/deep/.u-hairline-border::after{ border: none; }</style>
|