123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- <template>
- <view class="uni-column" style="padding: 24rpx">
- <view v-if="allData.length>0" style="margin-bottom: 20rpx;">
- <view>
- <view class="item-info uni-row" style="height: 80rpx;">
- <view style="flex: 2;">
- <button :class="[ checkAll ? 'active' : 'select' ]" @click="handleAll"
- style="margin-left: 0px;display: flex; align-items: center; justify-content: center;">全选</button>
- </view>
- <button @click="handleSearch" style="margin-right: 20rpx ;">搜索</button>
- <uni-data-select v-model="workshopId" :localdata="workshopList" @change="handleChangeWorkshop"
- :clear="false" class="label right"
- style=" margin-right: 20rpx; outline: 2rpx solid #999999;border-radius: 10rpx;flex: 1;"></uni-data-select>
- </view>
- </view>
- </view>
- <view v-if="allData.length>0" style="overflow: auto; padding-bottom: 100rpx">
- <view v-for="(item, index) in listData" :key="index" :class="{'list-item':true,'selected':isSelected(item)}"
- @click="handleSelection(item)">
- <view class="title-container uni-row">
- <view class="title uni-row"><text class="label">{{item.lotCode}}</text></view>
- <view><button class="start-batch-btn uni-row"
- style="height: 70rpx; display: flex; align-items: center; justify-content: center;"
- type=primary @click.stop='handleChangeCarrier(item)'>换箱</button>
- </view>
- </view>
- <view class="item-info uni-row">
- <text class="label">产品描述</text>
- <text class="label right">{{item['productDescription']}}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">关联箱号</text>
- <text class="label right">{{item['carrierName']}}</text>
- </view>
- <!-- <view class="item-info uni-row">
- <text class="label">下序</text>
- <text class="label right">{{item['process']}}</text>
- </view> -->
- <view class="item-info uni-row">
- <text class="label">当前序</text>
- <text class="label right">{{item['process'].processAlias}}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">下序</text>
- <text class="label right">{{item['nextProcess'].processAlias}}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">下序工段</text>
- <text class="label right">{{item.quickInfo.deptName}}</text>
- </view>
- </view>
- </view>
- <view v-if="allData.length==0" style="color: #999;">
- <image style="width: 420rpx; height: 420rpx; padding-top: 30% ; margin: auto;"
- src="../../static/images/fastProductionPlan.png" />
- </view>
- <view v-if="allData.length==0" class='bottom-btn-container'>
- <text style="margin: auto; padding-bottom: 10%;">扫箱码开始快速报工</text>
- <button class="start-batch-btn uni-row" type=primary @click='handleAdd'>扫码开始报工</button>
- </view>
- <view v-if="allData.length>0" class='btn uni-row'>
- <button class='bottom-btn left-btn' type="warn" @click="handleEnd">结束报工</button>
- <button class='bottom-btn right-btn' type="primary" @click="handleContinue">继续扫码</button>
- </view>
- <dialog-lotReporting ref="lotReporting" :getList="init" @scan="handleAdd"></dialog-lotReporting>
- <dialog-Search ref="searchRef" @search="refreshSearch"></dialog-Search>
- <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
- </view>
- <view
- style="background-color: #99999999; z-index: 5; position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;"
- v-if="loading">
- </view>
- </template>
- <script setup>
- import {
- getPlanDetailsList
- } from '@/api/business/planDetails.js'
- import {
- store
- } from '@/store/index.js'
- import {
- onShow
- } from '@dcloudio/uni-app'
- import {
- getDayWorkList,
- showDaywork,
- showDayworkSave,
- turnoverDelete
- } from '@/api/business/dayWork.js'
- import QrScanner from '../vueQrCode/index.vue'
- import {
- getQuickDayworkList,
- finishQuick,
- getDayworkByCarrierId,
- getDayworkByCarrierCode,
- reportDaywork
- } from '@/api/business/quickDaywork'
- import {
- isTakeStock
- } from '@/api/business/taksStackLot.js'
- import {
- ref
- } from 'vue'
- import path from '@/api/base/path.js'
- const lotReporting = ref(null)
- const workshopId = ref(null);
- const searchRef = ref(null);
- const keyword = ref('')
- const loading = ref(false)
- const showQrCodeReader = ref(false);
- const form = ref([]); //表单数据true
- const checkAll = ref(false); //是否全选
- // 创建一个引用来存储最后一次请求的时间戳
- const lastRequestTimestamp = ref(0);
- const listData = ref([]);
- const allData = ref([])
- const selection = ref([]); //选中数据
- const workshopList = ref([]); //车间数据
- onShow(() => {
- init()
- })
- //初始化
- function init() {
- // console.log(store.curDeptDetails)
- uni.showLoading({
- title: '加载中'
- });
- checkAll.value = false
- getQuickDayworkList({
- deptId: store.curDeptDetails.deptId,
- }).then(res => {
- // console.log(res)
- if (res.code == 200) {
- allData.value = res.rows
- if (allData.value.length == 0) {
- listData.value = []
- }
- uni.hideLoading();
- }
- if (res.other.workShops != null) {
- workshopList.value = res.other.workShops.map(v => ({
- value: v.id,
- text: v.name,
- depts: v.depts
- }))
- if ((workshopId.value == null || !workshopList.value.some(e => e.value === workshopId.value)) &&
- workshopList.value.length > 0) {
- workshopId.value = workshopList.value[0].value
- handleChangeWorkshop(workshopId.value)
- } else {
- handleChangeWorkshop(workshopId.value)
- }
- } else {
- workshopList.value = []
- }
- uni.hideLoading();
- loading.value = false
- })
- }
- // 搜索按钮操作
- function handleSearch() {
- searchRef.value.open();
- }
- function refreshSearch(input) {
- // console.log(input)
- keyword.value = input
- handleChangeWorkshop(workshopId.value)
- }
- /* 【原有代码】
- function handleAdd() {
- 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;
- }
- getDayworkByCarrierId({
- carrierId: vehicleObj.carrierId,
- deptId: store.curDeptDetails.deptId,
- status: 7
- }).then(response => {
- if (response.code == 200) {
- // console.log(response.data.items.length)
- // console.log(response.data)
- // if (response.data.items[0].deptId !== store.curDeptDetails.deptId) {
- // uni.showToast({
- // icon: 'none',
- // title: '该批次不在当前工段',
- // duration: 2000
- // })
- // return
- // }
- if (response.data.items.length > 0) {
- lotReporting.value.open(response.data);
- } else {
- uni.showToast({
- icon: 'none',
- title: '该批次不在此计划单内, 或不在当前工段',
- duration: 2000
- })
- }
- } else {
- uni.showToast({
- icon: 'none',
- title: response.msg,
- duration: 2000
- })
- }
- })
- }
- );
- } else {
- // 测试时用
- getDayworkByCarrierId({
- carrierId: '1747500987688890381',
- status: 7,
- deptId: store.curDeptDetails.deptId,
- }).then(response => {
- console.log(response)
- if (response.code == 200) {
- //
- // if (response.data.items[0].deptId !== store.curDeptDetails.deptId) {
- // uni.showToast({
- // icon: 'none',
- // title: '该批次不在当前工段',
- // duration: 2000
- // })
- // return
- // }
- if (response.data.items.length > 0) {
- // console.log(response.data)
- lotReporting.value.open(response.data);
- } else {
- uni.showToast({
- icon: 'none',
- title: '该批次不在此计划单内, 或不在当前工段',
- duration: 2000
- })
- }
- } else {
- uni.showToast({
- icon: 'none',
- title: response.msg,
- duration: 2000
- })
- }
- })
- }
- // lotReporting.value.open(data);
- }
- */
- //H5扫码器回调
- function onDecodeHandler(data) {
- showQrCodeReader.value = false;
- let vehicleObj = {
- carrierCode: data
- };
- if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
- uni.showToast({
- icon: "none",
- title: "请扫载具码",
- duration: 1000
- })
- return;
- }
- getDayworkByCarrierCode({
- carrierCode: vehicleObj.carrierCode,
- deptId: store.curDeptDetails.deptId,
- status: 7
- }).then(response => {
- if (response.code == 200) {
- if (response.data.items.length > 0) {
- lotReporting.value.open(response.data);
- } else {
- uni.showToast({
- icon: 'none',
- title: '该批次不在此计划单内, 或不在当前工段',
- duration: 2000
- })
- }
- } else {
- uni.showToast({
- icon: 'none',
- title: response.msg,
- duration: 2000
- })
- }
- })
- }
- //H5扫码器关闭
- function qrReaderClose() {
- showQrCodeReader.value = false;
- }
- function handleAdd() {
- 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;
- // }
- // getDayworkByCarrierCode({
- // carrierCode: vehicleObj.carrierCode,
- // deptId: store.curDeptDetails.deptId,
- // status: 7
- // }).then(response => {
- // if (response.code == 200) {
- // if (response.data.items.length > 0) {
- // lotReporting.value.open(response.data);
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: '该批次不在此计划单内, 或不在当前工段',
- // duration: 2000
- // })
- // }
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: response.msg,
- // duration: 2000
- // })
- // }
- // })
- // }
- // );
- // } else {
- // // 测试时用
- // getDayworkByCarrierCode({
- // carrierCode: '900005',
- // status: 7,
- // deptId: store.curDeptDetails.deptId,
- // }).then(response => {
- // console.log(response)
- // if (response.code == 200) {
- // //
- // // if (response.data.items[0].deptId !== store.curDeptDetails.deptId) {
- // // uni.showToast({
- // // icon: 'none',
- // // title: '该批次不在当前工段',
- // // duration: 2000
- // // })
- // // return
- // // }
- // if (response.data.items.length > 0) {
- // // console.log(response.data)
- // lotReporting.value.open(response.data);
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: '该批次不在此计划单内, 或不在当前工段',
- // duration: 2000
- // })
- // }
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: response.msg,
- // duration: 2000
- // })
- // }
- // })
- // }
- // lotReporting.value.open(data);
- }
- function handleContinue() {
- // lotReporting.value.open('test')
- handleAdd()
- }
- // 全选按钮操作
- function handleAll() {
- //清空选中数据
- selection.value.length = 0;
- if (checkAll.value) {
- //变更选中状态
- checkAll.value = false;
- } else {
- checkAll.value = true;
- listData.value.findIndex(item => handleSelection(item))
- }
- }
- function handleChangeWorkshop(arg) {
- const workshop = workshopList.value.find(v => v.value === arg)
- // console.log(allData.value)
- // console.log(workshop)
- // console.log()
- listData.value = allData.value.filter(v => workshop.depts.some(e => e.deptId === v.quickInfo.deptId) && (v.lotCode
- .includes(keyword.value) || v.productDescription.includes(keyword.value) || v.carrierName.includes(
- keyword.value)))
- selection.value = []
- }
- function isSelected(item) {
- return selection.value.includes(item);
- }
- //
- function handleSelection(item) {
- const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
- if (buttonIndex > -1) {
- selection.value.splice(buttonIndex, 1); // 取消选中
- } else {
- selection.value.push(item); // 选中
- }
- if (selection.value.length == listData.value.length) {
- checkAll.value = true;
- } else {
- checkAll.value = false;
- }
- }
- function handleChangeCarrier(item) {
- uni.$once('refreshQuickReport', () => {
- init()
- })
- store.dayworkInfo = null
- uni.navigateTo({
- url: "/pages/changeBox/index",
- success: function(res) {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('acceptDataFromOpenerPage', {
- data: item
- })
- }
- })
- }
- function handleEnd() {
- if (selection.value.length === 0) {
- uni.showToast({
- icon: 'none',
- title: '请选择完成报工批次'
- })
- return
- }
- const currentTime = Date.now();
- // 检查是否已经过去了 2 秒
- if (currentTime - lastRequestTimestamp.value < 2000) {
- // 如果在 2 秒 内已经有请求发出,那么不执行
- uni.showToast({
- icon: 'none',
- title: `请勿重复点击`,
- duration: 2000
- })
- return;
- }
- lastRequestTimestamp.value = currentTime;
- // 更新请求时间戳
- isTakeStock().then(response => {
- if (response.data) {
- uni.showToast({
- icon: 'none',
- title: '正在盘点,不能结束报工',
- duration: 2000
- })
- } else {
- loading.value = true
- uni.showLoading({
- title: '加载中'
- });
- lastRequestTimestamp.value = currentTime;
- selection.value.forEach(item => {
- item.tenantId = !store.tenantId ? store.userInfo.tenantId : store.tenantId
- })
- finishQuick(selection.value).then(res => {
- // console.log(res)
- if (res.code === 200) {
- init()
- } else {
- // loading.value = false
- // uni.hideLoading()
- uni.showToast({
- icon: 'none',
- title: res.msg,
- duration: 2000
- });
- setTimeout(() => {
- init()
- }, 1500);
- }
- })
- }
- })
- }
- // init();
- </script>
- <style lang="scss">
- $nav-height: 60rpx;
- .bottom-btn-container {
- position: fixed;
- top: 80%;
- right: 20rpx;
- left: 20rpx;
- .start-batch-btn {
- margin-bottom: 24rpx;
- border-radius: 8rpx;
- background-color: #00e2a6;
- width: 80%;
- }
- }
- .active {
- flex: 1;
- height: 40rpx;
- background-color: #5e6eff;
- border: 1px solid #5e6eff;
- color: #000000;
- }
- .select {
- flex: 1;
- height: 40rpx;
- // font-size: 20rpx;
- background-color: #5e6eff;
- border: 1px solid #5e6eff;
- color: #ffffff;
- }
- .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;
- }
- }
- }
- .box-bg {
- width: 100%;
- background-color: #F5F5F5;
- padding: 5rpx 0;
- justify-content: space-around;
- align-items: center;
- .input-view {
- width: 100%;
- flex: 4;
- background-color: #f8f8f8;
- height: $nav-height;
- border: 1rpx solid #999;
- border-radius: 15rpx;
- padding: 0 15rpx;
- flex-wrap: nowrap;
- margin: 0 10rpx 20rpx;
- line-height: $nav-height;
- .input-uni-icon {
- line-height: $nav-height;
- }
- .nav-bar-input {
- width: 80%;
- height: $nav-height;
- line-height: $nav-height;
- padding: 0 5rpx;
- background-color: #f8f8f8;
- }
- }
- .search {
- width: 20%;
- text-align: center;
- color: #808080;
- margin-top: -20rpx;
- }
- }
- .list-item {
- background-color: #fff;
- position: relative;
- padding: 16rpx;
- padding-bottom: 24rpx;
- border-radius: 24rpx;
- margin-bottom: 24rpx;
- .title-container {
- justify-content: space-between;
- margin-top: 8rpx;
- margin-bottom: 16rpx;
- .title {
- height: 48rpx;
- align-items: center;
- .label {
- font-size: 32rpx;
- font-weight: bold;
- &.code {
- margin-left: 8rpx;
- }
- }
- }
- .tag {
- border: 1px solid #1ce5b0;
- background-color: #f6fffd;
- padding: 8rpx;
- border-radius: 8rpx;
- .label {
- color: #1ce5b0;
- font-size: 24rpx;
- }
- &.not-start {
- border: 1px solid #bbbbbb;
- background-color: #f5f5f5;
- .label {
- color: #bbbbbb;
- }
- }
- }
- }
- .item-info {
- margin-bottom: 8rpx;
- .label {
- font-size: 28rpx;
- width: 150rpx;
- color: #808080;
- &.right {
- flex: 1;
- color: #000000;
- }
- }
- }
- }
- .selected {
- border: 1rpx solid #c0c4fc;
- background-color: #c0c4fc;
- /* 选中之后样式 */
- }
- </style>
|