123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- <template>
- <view class="uni-column container">
- <scroll-view class="scroll-container" scroll-y>
- <view v-for="(item, index) in listData" :key="index"
- :class="{'list-item':true,'selected':isSelected(item)}">
- <!-- @click="handleSelection(item,index)" -->
- <view class="title-container uni-row">
- <view class="title uni-row">
- <text class="label">{{ item['dictDataLabel'] }}</text>
- <text class="label code">{{ item['preDeptName'] }}</text>
- <text class="label code" style="margin-left: 16rpx;">→</text>
- <text class="label code" style="margin-left: 16rpx;">{{ item['deptName'] }}</text>
- </view>
- <view class="right-info uni-row">
- <view class="uni-row"><text class="label right" @click="handleDeleteTurnover(item)">删除</text>
- </view>
- </view>
- </view>
- <view class="item-info uni-row"> <text class="label ">产品描述</text>
- <text class="label right" style="color: #000000;">{{ item['productDescription'] }}</text>
- </view>
- <view class="item-info uni-row"> <text class="label">批次</text>
- <text class="label right ">{{ item['lotCode'] }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">箱数</text>
- <text class="label right">{{ item['carriers'] }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">箱号</text>
- <text class="label right">{{ item['carrierName']}}</text>
- </view>
- </view>
- </scroll-view>
- <view class="bottom uni-row">
- <button class="bottom-btn left-btn" @click="HandleScanCode">扫码添加</button>
- <button class="bottom-btn right-btn" @click="handleStartTurnover" :disabled="flag">确认周转</button>
- </view>
- <dialog-turnoverTask ref="turnoverTaskDialog" />
- </view>
- <dialog-turnoverTask ref="turnoverTask"></dialog-turnoverTask>
- <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad,
- } from '@dcloudio/uni-app'
- import {
- getDayworkItemByCarrierId,
- getDayworkItemByCarrierCode
- } from '@/api/business/dayWorkItem.js'
- import QrScanner from '../vueQrCode/index.vue'
- import {
- isTakeStock
- } from '@/api/business/taksStackLot.js'
- const active = ref(false)
- const selection = ref([])
- const turnoverTaskDialog = ref(null)
- const listData = ref([])
- const turnoverTask = ref(null)
- const flag = ref(false);
- const showQrCodeReader = ref(false);
- onLoad(() => {
- init();
- uni.$once('clearListData', () => {
- listData.value = [];
- })
- })
- function init() {
- flag.value = listData.value.length > 0 ? false : true;
- }
- /*
- function HandleScanCode() {
- // 引入原生插件
- const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
- if (mpaasScanModule) {
- // 调用插件的 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: "请扫载具码",
- duration: 1000
- })
- return;
- }
- getDayworkItemByCarrierId({
- carrierId: vehicleObj.carrierId,
- status: 4
- }).then(response => {
- console.log(response)
- for (let i = 0; i < listData.value.length; i++) {
- if (listData.value[i].lotCode === response.data[0].lotCode) {
- uni.showToast({
- icon: "none",
- title: "该批次已存在"
- })
- console.log("该批次已存在")
- return;
- }
- }
- for (let i = 0; i < response.data.length; i++) {
- listData.value.push(response.data[i]);
- }
- for (let i = 0; i < listData.value.length; i++) {
- listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
- }
- console.log(listData.value);
- init();
- })
- }
- );
- } else {
- getDayworkItemByCarrierId({
- carrierId: '1747500989324668942',
- status: 4
- }).then(response => {
- console.log(response)
- for (let i = 0; i < listData.value.length; i++) {
- if (listData.value[i].lotCode === response.data[0].lotCode) {
- uni.showToast({
- icon: "none",
- title: "该批次已存在"
- })
- console.log("该批次已存在")
- return;
- }
- }
- for (let i = 0; i < response.data.length; i++) {
- listData.value.push(response.data[i]);
- }
- for (let i = 0; i < listData.value.length; i++) {
- listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
- }
- console.log(listData.value);
- init();
- })
- }
- }
- */
- //H5扫码器回调
- function onDecodeHandler(data) {
- showQrCodeReader.value = false;
- let vehicleObj = {
- carrierCode: data
- };
- if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
- uni.showToast({
- icon: "none",
- title: "请扫载具码",
- duration: 1000
- })
- return;
- }
- getDayworkItemByCarrierCode({
- carrierCode: vehicleObj.carrierCode,
- status: 4
- }).then(response => {
- console.log(response)
- for (let i = 0; i < listData.value.length; i++) {
- if (listData.value[i].lotCode === response.data[0].lotCode) {
- uni.showToast({
- icon: "none",
- title: "该批次已存在"
- })
- console.log("该批次已存在")
- return;
- }
- }
- for (let i = 0; i < response.data.length; i++) {
- listData.value.push(response.data[i]);
- }
- for (let i = 0; i < listData.value.length; i++) {
- listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
- }
- console.log(listData.value);
- init();
- })
- }
- //H5扫码器关闭
- function qrReaderClose() {
- showQrCodeReader.value = false;
- }
- function HandleScanCode() {
- showQrCodeReader.value = true;
- // 引入原生插件
- // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
- // if (mpaasScanModule) {
- // // 调用插件的 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: "请扫载具码",
- // duration: 1000
- // })
- // return;
- // }
- // getDayworkItemByCarrierCode({
- // carrierCode: vehicleObj.carrierCode,
- // status: 4
- // }).then(response => {
- // console.log(response)
- // for (let i = 0; i < listData.value.length; i++) {
- // if (listData.value[i].lotCode === response.data[0].lotCode) {
- // uni.showToast({
- // icon: "none",
- // title: "该批次已存在"
- // })
- // console.log("该批次已存在")
- // return;
- // }
- // }
- // for (let i = 0; i < response.data.length; i++) {
- // listData.value.push(response.data[i]);
- // }
- // for (let i = 0; i < listData.value.length; i++) {
- // listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
- // }
- // console.log(listData.value);
- // init();
- // })
- // }
- // );
- // } else {
- // getDayworkItemByCarrierCode({
- // carrierCode: '000828',
- // status: 4
- // }).then(response => {
- // console.log(response)
- // for (let i = 0; i < listData.value.length; i++) {
- // if (listData.value[i].lotCode === response.data[0].lotCode) {
- // uni.showToast({
- // icon: "none",
- // title: "该批次已存在"
- // })
- // console.log("该批次已存在")
- // return;
- // }
- // }
- // for (let i = 0; i < response.data.length; i++) {
- // listData.value.push(response.data[i]);
- // }
- // for (let i = 0; i < listData.value.length; i++) {
- // listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
- // }
- // console.log(listData.value);
- // init();
- // })
- // }
- }
- function handleStartTurnover() {
- isTakeStock().then(response => {
- if (response.data) {
- uni.showToast({
- icon: 'none',
- title: '正在盘点,不能开始周转',
- duration: 2000
- })
- } else {
- // 调用子组件中的方法
- turnoverTask.value.open(listData.value);
- }
- })
- }
- 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 handleDeleteTurnover(item) {
- uni.showModal({
- title: '提示', // 标题
- content: '是否删除此条周转', // 提示内容
- cancelText: "取消", // 取消按钮的文字
- confirmText: "确认", // 确认按钮的文字
- //点击确定之后执行的代码
- success(res) {
- if (res.confirm) {
- listData.value = listData.value.filter(it => it.carrierName != item.carrierName);
- uni.showToast({
- icon: 'none',
- title: '该箱子绑定的所有批次已删除',
- duration: 2000
- })
- }
- }
- });
- }
- </script>
- <style lang="scss">
- .container {
- height: 100%;
- background-color: #f5f5f5;
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- }
- .scroll-container {
- position: fixed;
- top: 54px;
- right: 0;
- bottom: 160rpx;
- left: 0;
- }
- .selected {
- border: 1px solid #1684fc;
- }
- .list-item {
- background-color: #fff;
- position: relative;
- padding: 16rpx;
- padding-bottom: 24rpx;
- margin: 0 24rpx;
- margin-bottom: 24rpx;
- border-radius: 8rpx;
- .title-container {
- justify-content: space-between;
- margin-top: 8rpx;
- margin-bottom: 16rpx;
- .title {
- height: 48rpx;
- align-items: center;
- .label {
- color: #1684fc;
- font-size: 32rpx;
- font-weight: bold;
- &.code {
- color: #000000;
- margin-left: 32rpx;
- }
- }
- }
- }
- .item-info {
- margin-bottom: 16rpx;
- .label {
- font-size: 28rpx;
- width: 152rpx;
- color: #808080;
- &.right {
- flex: 1;
- color: #808080;
- }
- }
- }
- .right-info {
- justify-content: flex-end;
- margin-top: 2rpx;
- .label {
- font-size: 28rpx;
- color: #ff0000;
- }
- }
- }
- .bottom {
- 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: #1684fc;
- }
- &.right-btn {
- background-color: rgb(255, 121, 1);
- margin-left: 24rpx;
- }
- }
- }
- </style>
|