123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- <template>
- <!-- 选择配送信息 -->
- <view>
- <u-navbar title="" autoBack placeholder></u-navbar>
- <view class="card_incubator_anti_fake">
- <view class="title_fake">保温箱/冰排</view>
- <view class="card_input_send">
- <view class="incubator_title"><span>*</span>保温箱</view>
- <view class="card_search_gray frame" @click="focus(false)">
- <span v-if="incubator.name">{{incubator.name}}</span>
- <span class="title_gray" v-else>请选择保温箱</span>
- <u-icon name="arrow-down" color="#c8c9cc" size="18"></u-icon>
- </view>
- </view>
- <view class="card_input_send">
- <view class="incubator_title"><span>*</span>冰排编号</view>
- <u-input placeholder="请输入冰排编号" border="surround" v-model="iceNumber" @blur="iceRaftBlur">
- <template slot="suffix">
- <u-icon name="scan" size="24" @click="sweep"></u-icon>
- </template>
- </u-input>
- <view class="add_card center_in" @click="addIce">
- <u-icon name="plus" size="18"></u-icon>
- </view>
- </view>
- <view class="card_frequency">
- <view class="card_high space_between">
- <view class="card_frequency_title">已扫冰排编号</view>
- <view class="card_bottle">已扫<span>{{iceList.length}}</span></view>
- </view>
- <scroll-view :scroll-top="scrollTop" scroll-y="true" class="swept_card">
- <view class="scrollView" style="width: 100%;" v-if="iceList.length > 0">
- <view class="item_coding" v-for="(item,index) in iceList" :key="index">
- <view style="display: flex;align-items: center;">
- <view class="num_index">{{index + 1}}</view>
- <view class="title_coding">{{item}}</view>
- </view>
- <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
- @click="removeWaybill(item)"></u-icon>
- </view>
- </view>
- <view v-else>
- <u-empty mode="list"></u-empty>
- </view>
- </scroll-view>
- </view>
- </view>
- <view class="card_incubator_anti_fake1">
- <view class="title_fake" style="margin-left: 20rpx;">防拆标签</view>
- <x-form ref="goods" :list="goodsList" :model="goodsModel" :rules="goodsRules"></x-form>
- </view>
- <view class="btn_confirm_ching center_in">
- <u-button style="margin: 0rpx 30rpx;" size="small" type="primary" text="确定" @click="confirm()"></u-button>
- </view>
- </view>
- </template>
- <script>
- import {
- formRules,
- } from "../../components/waybill.js";
- export default {
- data() {
- return {
- goodsList: formRules(),
- goodsModel: {
- tamperProofLabel: '',
- tamperProofLabelImg: '',
- },
- goodsRules: {
- tamperProofLabel: {
- required: false,
- message: '请输入防拆标签码',
- trigger: ['blur', 'change']
- },
- tamperProofLabelImg: {
- required: false,
- message: '请上传防拆标签图片',
- trigger: ['blur', 'change']
- },
- },
- incubator: {
- id: null,
- name: '',
- },
- iceNumber: '',
- iceList: [],
- scrollTop: null,
- waybillId: null,
- deliveryId: null,
- }
- },
- onUnload() {
- // console.log('页面销毁')
- uni.removeStorageSync('incubatorValue');
- this.getempty()
- },
- onLoad() {
- let orderList = uni.getStorageSync('orderValue')
- if (orderList) {
- let arr = JSON.parse(orderList)
- this.waybillId = arr.id
- this.deliveryId = arr.deliveryId
- this.goodsModel.tamperProofLabel = arr.tamperProofLabel
- this.goodsModel.tamperProofLabelImg = arr.tamperProofLabelImg
- if (arr.tamperProofLabelImg) {
- let arrImg = arr.tamperProofLabelImg.split(',')
- let arrImgList = []
- arrImg.forEach((item) => {
- const arr = {
- url: item,
- }
- arrImgList.push(arr)
- })
- this.$nextTick(() => {
- this.$refs.goods.fileList1 = arrImgList
- })
- }
- }
- },
- onShow() {
- let incubator = uni.getStorageSync('incubatorValue')
- if (incubator) {
- if (incubator.id != this.incubator.id) {
- this.incubator.id = incubator.id
- this.incubator.name = incubator.name
- this.getIceList(incubator.id)
- }
- }
- },
- methods: {
- getempty() {
- this.iceList = []
- this.incubator.id = ''
- this.incubator.name = ''
- this.iceNumber = ''
- uni.removeStorageSync('incubatorValue');
- },
- // 确定配送
- async confirm() {
- if (this.incubator.id) {
- if (this.iceList.length > 0) {
- let flag2 = await this.$refs['goods'].validateForm();
- if (flag2) {
- const arr = []
- arr.push(this.waybillId)
- this.$api.post('/api/waybill/delivery', {
- waybillIds: arr,
- deliveryId: Number(this.deliveryId),
- coolerBoxId: this.incubator.id,
- iceRaftCode: this.iceList,
- tamperProofLabel: this.goodsModel.tamperProofLabel,
- tamperProofLabelImg: this.goodsModel.tamperProofLabelImg,
- status: 4,
- }).then(res => {
- if (res.code == 200) {
- uni.$u.toast('操作成功')
- uni.$emit('send', '成功');
- uni.navigateBack({
- delta: 1
- });
- } else if (res.code == 2000) {
- let arrTitle = res.data
- let title = ' ,请将冰排' + arrTitle.toString() + '重新入库'
- uni.$u.toast(res.msg + title)
- } else {
- uni.$u.toast(res.msg)
- }
- })
- }
- } else {
- uni.$u.toast('请先扫描冰排')
- }
- } else {
- uni.$u.toast('请先选择保温箱')
- }
- },
- // 获取保温箱存在冰排
- getIceList(iceId) {
- this.$api.get('/api/ice-raft/cooler-box', {
- coolerBoxId: iceId,
- }).then(res => {
- if (res.code == 200) {
- this.iceList = res.data
- }
- })
- },
- // 移除错误运单号
- removeWaybill(value) {
- if (this.iceNumber == value) {
- this.iceNumber = ''
- }
- const arr = deleteElementById(this.iceList, value)
- this.iceList = arr
- function deleteElementById(arr, key) {
- return arr.filter((item) => item !== key);
- }
- },
- // 添加冰排
- addIce() {
- if (this.iceNumber) {
- this.iceList.push(this.iceNumber)
- this.iceList = this.uniqueArray(this.iceList)
- this.$nextTick(() => {
- // 获取scroll-view的高度
- const query = uni.createSelectorQuery().in(this);
- query.select('.scrollView').boundingClientRect(data => {
- this.scrollTop = data.height;
- }).exec();
- });
- this.iceNumber = ''
- }
- },
- // 冰排失去焦点
- iceRaftBlur(value) {
- if (value) {
- this.iceList.push(value)
- this.iceList = this.uniqueArray(this.iceList)
- }
- },
- // 去重
- uniqueArray(arr) {
- return [...new Set(arr)];
- },
- // 扫一扫
- sweep() {
- // 允许从相机和相册扫码
- uni.scanCode({
- scanType: ['barCode'],
- // scanType: ['qrCode'],
- autoZoom: false,
- success: (res) => {
- console.log(res);
- if (res.result) {
- let url = res.result;
- this.iceNumber = url
- this.iceList.push(url)
- function methods1(arr) {
- return Array.from(new Set(arr));
- }
- this.iceList = methods1(this.iceList)
- } else {
- console.log('请重新扫描');
- return false;
- }
- },
- fail: (res) => {
- console.log('未识别到二维码');
- }
- })
- },
- // 鼠标聚焦
- focus() {
- uni.navigateTo({
- url: '/pages/order/Incubator'
- });
- }
- }
- }
- </script>
- <style lang="scss">
- .card_send {
- padding: 20rpx;
- min-height: 600rpx;
- }
- .send_title {
- text-align: center;
- margin: 10px;
- }
- .card_input_send {
- position: relative;
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .incubator_title {
- width: 150rpx;
- margin-right: 10rpx;
- font-size: 34rpx;
- span {
- color: red;
- }
- }
- .add_card {
- margin-left: 10rpx;
- width: 50rpx;
- height: 46rpx;
- border-radius: 8rpx;
- padding: 6px 9px;
- border: 1px solid #dadbde;
- }
- .scroll-view {
- transition: max-height 1s ease-out;
- max-height: 0;
- overflow: hidden;
- }
- .card_frequency {
- display: flex;
- flex-wrap: wrap;
- }
- .swept_card {
- padding: 0rpx 20rpx;
- width: calc(100% - 40rpx);
- max-height: 600rpx;
- // overflow-y: auto;
- }
- .card_high {
- margin-bottom: 20rpx;
- }
- .card_frequency_title {
- font-size: 32rpx;
- }
- .card_bottle {
- font-size: 30rpx;
- span {
- color: red;
- }
- }
- .item_coding {
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 100%;
- padding: 20rpx 0rpx;
- }
- .num_index {
- font-size: 30rpx;
- margin-right: 10rpx;
- }
- .title_coding {
- font-size: 30rpx;
- }
- .card_search_gray {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- flex: 1;
- padding: 12rpx 18rpx;
- border-radius: 8rpx;
- line-height: 48rpx;
- }
- .title_gray {
- font-size: 30rpx;
- color: #c8c9cc;
- }
- // 伪元素1rpx边框
- .frame {
- position: relative; //重要
- }
- .frame::after {
- position: absolute;
- content: '';
- border: 2rpx solid #e7e6e4;
- border-radius: 16rpx;
- width: 200%;
- height: 200%;
- top: 0;
- left: 0;
- transform: scale(0.5);
- transform-origin: 0 0;
- pointer-events: none;
- /* 使伪元素不会阻止鼠标事件 */
- }
- .card_incubator_anti_fake {
- padding: 20rpx;
- width: calc(100% - 80rpx);
- margin: 20rpx 20rpx;
- border-radius: 10rpx;
- background-color: #fff;
- }
- .card_incubator_anti_fake1 {
- padding: 20rpx 0rpx;
- width: calc(100% - 40rpx);
- margin: 20rpx 20rpx;
- border-radius: 10rpx;
- background-color: #fff;
- }
- .title_fake {
- margin-bottom: 20rpx;
- font-size: 34rpx;
- font-weight: bold;
- }
- .btn_confirm_ching {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- height: 120rpx;
- background-color: #fff;
- }
- </style>
|