123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- <template>
- <view class='container '>
- <view v-if="products.length == 0" style="color: #999;margin: 50% auto;">
- <text>扫码添加批次</text>
- </view>
- <view v-else class='content'>
- <text class='title'>{{title}}</text>
- <view :class="{'item-table':true, 'selected':isSelected(item)}" scroll-y v-for="(item,index) in products"
- @click="handleSelection(item,index)">
- <view class="uni-row table-layout">
- <text class='tbhead left'>产品描述</text>
- <text class='tbhead right'>{{item['productDescription']}}</text>
- </view>
- <view class="uni-row table-layout">
- <text class='tbbody left'>批次</text>
- <text class='tbbody right'>{{item['lotCode']}}</Text>
- </view>
- <view class="uni-row table-layout">
- <text class='tbbody left'>箱数</text>
- <text class='tbbody right'>{{item['carriers']}}</Text>
- </view>
- <view class="uni-row table-layout">
- <text class='tbbody left'>箱号</text>
- <text class='tbbody right'>{{item['carrierName']}}</text>
- </view>
- </view>
- </view>
- <view class='btn uni-row'>
- <button class='bottom-btn left-btn' type="primary" @click="handleScanCode">扫码添加</button>
- <button class='bottom-btn right-btn' type="primary" @click="handleConfirmReceipt">确定领取</button>
- </view>
- </view>
- <dialog-receipt ref="receipt" @submit="handleDoIt"></dialog-receipt>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad
- } from '@dcloudio/uni-app'
- import {
- getDayworkItemByCarrierId,
- getDayworkItemByCarrierCode,
- updateDayWorkItemBatch
- } from '@/api/business/dayWorkItem.js'
- import {
- store
- } from '@/store/index.js'
- const title = ref(null)
- const sum = ref(0)
- const products = ref([])
- const receipt = ref(null)
- const flag = ref(false)
- const selection = ref([])
- onLoad(() => {})
- function init() {}
- /*
- function handleScanCode() {
- // 引入原生插件
- const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
- // 调用插件的 mpaasScan 方法
- mpaasScanModule.mpaasScan({
- // 扫码识别类型,参数可多选,qrCode、barCode,
- // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
- scanType: ["qrCode", "barCode"],
- // 是否隐藏相册,默认false不隐藏
- hideAlbum: false,
- },
- (ret) => {
- let vehicleObj = JSON.parse(ret.resp_result);
- if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
- uni.showToast({
- icon: "none",
- title: "请扫载具码",
- })
- return;
- }
- getDayworkItemByCarrierId({
- carrierId: vehicleObj.carrierId,
- status: 6
- }).then(response => {
- console.log(response)
- if (response.data.length == 0) {
- uni.showToast({
- icon: 'none',
- title: '该批次已被领取'
- })
- return;
- }
-
- for (let i = 0; i < response.data.length; i++) {
- if(products.value.some(item => item.id == response.data[i].id)){
- uni.showToast({
- icon: 'none',
- title: '该设批次已存在,请勿重复扫码添加'
- })
- return;
- }
- products.value.push(response.data[i]);
- console.log(products.value)
- }
- console.log(products.value)
- let sum = 0; //总箱数
- for (let i = 0; i < products.value.length; i++) {
- products.value[i].carriers = products.value[i].carrierName.split('、').length;
- sum += products.value[i].carriers;
- }
- title.value = products.value[0].deptName + ' (' + sum + '箱)';
- console.log(products.value)
- init();
- })
- }
- );
- }
- */
-
- function handleScanCode() {
- // 引入原生插件
- const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
- // 调用插件的 mpaasScan 方法
- mpaasScanModule.mpaasScan({
- // 扫码识别类型,参数可多选,qrCode、barCode,
- // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
- scanType: ["qrCode", "barCode"],
- // 是否隐藏相册,默认false不隐藏
- hideAlbum: false,
- },
- (ret) => {
- let vehicleObj = {carrierCode: ret.resp_result};
- if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
- uni.showToast({
- icon: "none",
- title: "请扫载具码",
- })
- return;
- }
- getDayworkItemByCarrierCode({
- carrierCode: vehicleObj.carrierCode,
- status: 6
- }).then(response => {
- console.log(response)
- if (response.data.length == 0) {
- uni.showToast({
- icon: 'none',
- title: '该批次已被领取'
- })
- return;
- }
-
- for (let i = 0; i < response.data.length; i++) {
- if(products.value.some(item => item.id == response.data[i].id)){
- uni.showToast({
- icon: 'none',
- title: '该设批次已存在,请勿重复扫码添加'
- })
- return;
- }
- products.value.push(response.data[i]);
- console.log(products.value)
- }
- console.log(products.value)
- let sum = 0; //总箱数
- for (let i = 0; i < products.value.length; i++) {
- products.value[i].carriers = products.value[i].carrierName.split('、').length;
- sum += products.value[i].carriers;
- }
- title.value = products.value[0].deptName + ' (' + sum + '箱)';
- console.log(products.value)
- init();
- })
- }
- );
- }
- function handleConfirmReceipt() {
- if (selection.value.length > 0) {
- receipt.value.open();
- }else{
- uni.showToast({
- icon: 'none',
- title: '请选择批次后再确认领取',
- duration: 2000
- })
- }
- }
- function isSelected(item) {
- return selection.value.includes(item);
- }
- function handleSelection(item, index) {
- const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
- if (buttonIndex > -1) {
- selection.value.splice(buttonIndex, 1); // 取消选中
- } else {
- selection.value.push(item); // 选中
- }
- console.log(selection.value, "selection");
- }
- function handleDoReceipt(data) {
- // 设置周转状态
- for (var i = 0; i < selection.value.length; i++) {
- selection.value[i].status = '7';
- selection.value[i].recipientId = store.userInfo.userId;
- selection.value[i].place = data;
- }
- console.log(selection.value)
- updateDayWorkItemBatch(selection.value).then(res => {
- if (res.code === 200) {
- uni.showToast({
- icon: 'success',
- title: '操作成功',
- duration: 2000
- });
- init();
- } else {
- uni.showToast({
- icon: 'none',
- title: '操作失败',
- duration: 2000
- });
- }
- })
- products.value = [];
- selection.value = [];
- title.value = null;
- }
- function handleDoIt(data) {
- handleDoReceipt(data);
- }
- </script>
- <style lang="scss">
- .container {
- height: 100%;
- overflow: auto;
- background-color: rgba(245, 245, 245, 1);
- .content {
- width: 94%;
- /* height: auto; */
- background-color: rgba(255, 255, 255, 1);
- margin: 50rpx auto;
- border-radius: 12rpx;
- .selected {
- border: 1px solid #1684fc;
- }
- .title {
- margin-left: 10rpx;
- width: 90%;
- font-size: 36rpx;
- font-weight: bold;
- }
- .item-table {
- margin: 10rpx auto;
- width: 90%;
- .table-layout {
- background-color: rgba(236, 245, 255, 1);
- align-items: center;
- .tbhead {
- background-color: rgba(236, 245, 255, 1);
- font-size: 28rpx;
- height: 56rpx;
- line-height: 56rpx;
- padding-left: 6rpx;
- border-bottom: 1px solid lightgray;
- }
- .tbbody {
- font-size: 28rpx;
- background-color: rgba(238, 240, 245, 1);
- width: 70%;
- height: 56rpx;
- line-height: 56rpx;
- padding-left: 6rpx;
- border-bottom: 1px solid lightgray;
- }
- .left {
- color: rgba(136, 136, 136, 1);
- flex: 1;
- }
- .right {
- flex: 3;
- }
- }
- }
- }
- .btn {
- position: fixed;
- right: 0;
- bottom: 0;
- left: 0;
- height: 100rpx;
- padding: 16rpx 24rpx;
- align-items: center;
- background-color: #FFFFFF;
- justify-content: space-between;
- .bottom-btn {
- flex: 1;
- font-size: 28rpx;
- color: #FFFFFF;
- &.left-btn {
- // background-color: #a4adb3;
- }
- &.right-btn {
- background-color: #1684fc;
- margin-left: 24rpx;
- }
- }
- }
- }
- </style>
|