王志国
4 weeks ago
4 changed files with 1223 additions and 69 deletions
@ -0,0 +1,517 @@ |
|||||
|
<template> |
||||
|
<view class=""> |
||||
|
<view class="" v-if="jobList.length>0" |
||||
|
style="background: white;padding: 20rpx;position: fixed;width: 100%;box-shadow: 0px 0px 10px 10px rgba(1, 1, 1, 0.05);z-index: 22; "> |
||||
|
<uni-pagination :total="totalCount" title="每页30" :pageSize='pageSize' @change="changePage" |
||||
|
:current="pageNo"/> |
||||
|
|
||||
|
<view class="uni-flex uni-row"> |
||||
|
<view class="uni-flex uni-row"> |
||||
|
<view class=""> |
||||
|
<u-checkbox size="40" v-model="checkAll" @change="checkAllItems"> |
||||
|
</u-checkbox> |
||||
|
</view> |
||||
|
<view> |
||||
|
<text |
||||
|
style="margin-left: 2rpx; font-size: 32rpx;font-weight: bold;">当前页({{ jobList.length }}) |
||||
|
</text> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="" |
||||
|
style=" margin-left: 10rpx; font-size: 32rpx; align-items: center; text-align: center;"> |
||||
|
第{{ pageNo }}页,每页/{{ pageSize }}, 共:{{ totalCount }} |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
|
||||
|
</view> |
||||
|
<com-empty-view v-if="jobList.length==0"></com-empty-view> |
||||
|
<job-filter ref="filter" otherTitle="ASN" :isShowToAreaCode="true" :isShowQurery='true' :isShowStatus='false' |
||||
|
:isShowToLocationCode="true" :isShowItemCode="true" @onQuery="getListByFilter"> |
||||
|
</job-filter> |
||||
|
|
||||
|
<view v-if="jobList.length>0" style="padding-bottom: 100rpx;padding-top: 150rpx;"> |
||||
|
<view class="" style="padding-left: 60rpx; padding-top: 10rpx; padding-bottom: 10rpx; background-color:#D3D1CC"> |
||||
|
<locationCompare ref='comScanLocation' title="目标库位" |
||||
|
:recommendLocationCode="toSubmitLocationCode" @getLocation='scanLocationCode' |
||||
|
:isShowEdit="true" |
||||
|
:locationAreaTypeList="toLocationAreaTypeList"></locationCompare> |
||||
|
</view> |
||||
|
|
||||
|
<uni-swipe-action ref="swipeAction"> |
||||
|
<view v-for="(item, index) in jobList" :key="index"> |
||||
|
<uni-swipe-action-item :right-options="item.status=='2'?detailGiveupOptions:detailOptions" |
||||
|
@click="swipeClick($event,item)"> |
||||
|
<view class="flex" style="flex-direction: row; align-items: center;"> |
||||
|
<view class="uni-flex" style="flex-direction: column; align-items: center;"> |
||||
|
|
||||
|
<text style="margin-bottom: 10rpx;">({{ index + 1 }})</text> |
||||
|
<u-checkbox v-model="item.checked" :name="item.id" size="50" shape="circle"> |
||||
|
</u-checkbox> |
||||
|
</view> |
||||
|
<view class="" style="width: 100%;"> |
||||
|
<com-putaway-job-card :dataContent="item" |
||||
|
@click='checkedItem(item)'></com-putaway-job-card> |
||||
|
</view> |
||||
|
</view> |
||||
|
</uni-swipe-action-item> |
||||
|
</view> |
||||
|
</uni-swipe-action> |
||||
|
|
||||
|
<putaway-info-popup ref='jobInfoPopup'></putaway-info-popup> |
||||
|
<putaway-job-list-popup ref="jobListPopup" @selectedItem="selectedItem"></putaway-job-list-popup> |
||||
|
<!-- <uni-load-more :status="loadingType" v-if="jobList.length>0" /> --> |
||||
|
|
||||
|
</view> |
||||
|
|
||||
|
<jobList ref="jobList" @selectItem="selectItem"></jobList> |
||||
|
<view class="footer" v-if="jobList.length>0"> |
||||
|
<button class="btn_single_commit" hover-class="btn_commit_after" @click="takeAllJob">执行当前已选择项</button> |
||||
|
</view> |
||||
|
<comMessage ref="comMessage"></comMessage> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import jobList from '@/mycomponents/jobList/jobList.vue' |
||||
|
|
||||
|
import { |
||||
|
getPutawayJobList, |
||||
|
cancleTakePutawayJob, |
||||
|
putawayJobAllExecute, |
||||
|
takeAllPutawayJob, |
||||
|
cancleAllTakePutawayJob |
||||
|
} from '@/api/request2.js'; |
||||
|
|
||||
|
import { |
||||
|
getDirectoryItemArray, |
||||
|
} from '@/common/directory.js'; |
||||
|
|
||||
|
import { |
||||
|
goHome, |
||||
|
updateTitle |
||||
|
} from '@/common/basic.js'; |
||||
|
|
||||
|
import { |
||||
|
getDetailOption, |
||||
|
getDetailGiveupOption |
||||
|
} from '@/common/array.js'; |
||||
|
import winScanButton from '@/mycomponents/scan/winScanButton.vue' |
||||
|
|
||||
|
import comEmptyView from '@/mycomponents/common/comEmptyView.vue' |
||||
|
import jobFilter from '@/mycomponents/job/jobFilter.vue' |
||||
|
import comPutawayJobCard from '@/pages/putaway/coms/comPutawayJobCard.vue' |
||||
|
import putawayJobListPopup from '@/pages/putaway/coms/putawayJobListPopup.vue' |
||||
|
import putawayInfoPopup from '@/pages/putaway/coms/putawayInfoPopup.vue' |
||||
|
import winScanPackJob from "@/mycomponents/scan/winScanPackJob.vue" |
||||
|
import comCheckAll from "@/mycomponents/button/comCheckAll.vue" |
||||
|
import locationCompare from '@/mycomponents/location/locationCompare.vue' |
||||
|
|
||||
|
|
||||
|
import { |
||||
|
Exception |
||||
|
} from 'sass'; |
||||
|
|
||||
|
import {ref, onMounted, onBeforeUnmount} from 'vue'; |
||||
|
import {onLoad, onShow, onReady, onBackPress, onNavigationBarButtonTap, onPullDownRefresh} from '@dcloudio/uni-app'; |
||||
|
|
||||
|
// 定义数据 |
||||
|
const jobList = ref([]); |
||||
|
const pageNo = ref(1); |
||||
|
const currentPageNo = ref(1); |
||||
|
const pageSize = ref(30); |
||||
|
const totalCount = ref(0); |
||||
|
const loadingType = ref("nomore"); |
||||
|
const checkedToday = ref(false); |
||||
|
const checkedWaitTask = ref(false); |
||||
|
const todayTime = ref(""); |
||||
|
const status = ref('1'); // 待处理 |
||||
|
const detailOptions = ref([]); |
||||
|
const detailGiveupOptions = ref([]); |
||||
|
const title = ref(''); |
||||
|
const scanMessage = ref(""); |
||||
|
const jobNumberList = ref([]); // 全部承接参数 |
||||
|
const creationTime = ref(""); |
||||
|
const itemCode = ref(""); |
||||
|
const toAreaCode = ref(""); |
||||
|
const toLocationCode = ref(""); |
||||
|
const checkAll = ref(false); |
||||
|
const toSubmitLocationCode = ref(""); |
||||
|
const toLocationAreaTypeList = ref([]); |
||||
|
const filter = ref(null) |
||||
|
const scanList = ref(null) |
||||
|
const jobInfoPopup = ref(null) |
||||
|
const comMessage = ref(null) |
||||
|
const scanPopup = ref(null) |
||||
|
const comScanLocation = ref(null) |
||||
|
// 生命周期钩子 |
||||
|
onLoad((option) => { |
||||
|
title.value = option.title; |
||||
|
}); |
||||
|
|
||||
|
onShow(() => { |
||||
|
getList('refresh'); |
||||
|
}); |
||||
|
|
||||
|
onReady(() => { |
||||
|
detailOptions.value = getDetailOption(); |
||||
|
detailGiveupOptions.value = getDetailGiveupOption(); |
||||
|
}); |
||||
|
|
||||
|
onBackPress((options) => { |
||||
|
if (options.from === 'navigateBack') { |
||||
|
uni.navigateBack({ |
||||
|
delta: 1 |
||||
|
}); |
||||
|
return false; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onNavigationBarButtonTap((e) => { |
||||
|
if (e.index === 0) { |
||||
|
goHome(); |
||||
|
} else if (e.index == 1) { |
||||
|
filter.value.openFilter(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// onReachBottom(() => { |
||||
|
// // 避免多次触发 |
||||
|
// if (loadingType.value == 'loading' || loadingType.value == 'nomore') { |
||||
|
// return; |
||||
|
// } |
||||
|
// getList("more"); |
||||
|
// }); |
||||
|
|
||||
|
onPullDownRefresh(() => { |
||||
|
getList('refresh'); |
||||
|
}); |
||||
|
|
||||
|
// 方法 |
||||
|
const getList = (type) => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
loadingType.value = "loading"; |
||||
|
if (type === "refresh") { |
||||
|
pageNo.value = 1; |
||||
|
jobList.value = []; |
||||
|
} |
||||
|
|
||||
|
const queryFiltersParams = setQueryParam(); |
||||
|
const params = { |
||||
|
filters: queryFiltersParams, |
||||
|
pageNo: pageNo.value, |
||||
|
pageSize: pageSize.value, |
||||
|
}; |
||||
|
currentPageNo.value = pageNo.value; |
||||
|
|
||||
|
getPutawayJobList(params).then((res) => { |
||||
|
uni.hideLoading(); |
||||
|
if (type === "refresh") { |
||||
|
uni.stopPullDownRefresh(); |
||||
|
} |
||||
|
|
||||
|
const list = res.data.list; |
||||
|
list.forEach((item) => { |
||||
|
item.checked = false; |
||||
|
}); |
||||
|
checkAll.value = false; |
||||
|
totalCount.value = res.data.total; |
||||
|
updateTitle(title.value + "(" + totalCount.value + ")"); |
||||
|
|
||||
|
jobList.value = list; |
||||
|
if (jobList.value.length > 0) { |
||||
|
toLocationAreaTypeList.value = getDirectoryItemArray(jobList.value[0].toAreaTypes); |
||||
|
} |
||||
|
toSubmitLocationCode.value = ""; |
||||
|
|
||||
|
// pageNo.value++; |
||||
|
}).catch((error) => { |
||||
|
if (type === "refresh") { |
||||
|
uni.stopPullDownRefresh(); |
||||
|
} |
||||
|
loadingType.value = ""; |
||||
|
updateTitle(title.value); |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const openJobDetail = (item) => { |
||||
|
uni.navigateTo({ |
||||
|
url: './putawayDetail?id=' + item.masterId + '&status=' + item.status + '&title=' + title.value |
||||
|
}); |
||||
|
scanMessage.value = ""; |
||||
|
}; |
||||
|
|
||||
|
const setQueryParam = () => { |
||||
|
const filterParams = []; |
||||
|
const queryParams = { |
||||
|
status: status.value, |
||||
|
creationTime: creationTime.value, |
||||
|
itemCode: itemCode.value, |
||||
|
toAreaCode: toAreaCode.value, |
||||
|
toLocationCode: toLocationCode.value |
||||
|
}; |
||||
|
|
||||
|
if (queryParams.creationTime) { |
||||
|
filterParams.push({ |
||||
|
column: "create_time", |
||||
|
action: "between", |
||||
|
value: queryParams.creationTime |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (queryParams.status) { |
||||
|
filterParams.push({ |
||||
|
column: "status", |
||||
|
action: "in", |
||||
|
value: queryParams.status |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (queryParams.itemCode) { |
||||
|
filterParams.push({ |
||||
|
column: "itemCode", |
||||
|
action: "like", |
||||
|
value: queryParams.itemCode |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (queryParams.toAreaCode) { |
||||
|
filterParams.push({ |
||||
|
column: "toAreaCode", |
||||
|
action: "==", |
||||
|
value: queryParams.toAreaCode |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (queryParams.toLocationCode) { |
||||
|
filterParams.push({ |
||||
|
column: "toLocationCode", |
||||
|
action: "==", |
||||
|
value: queryParams.toLocationCode |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return filterParams; |
||||
|
}; |
||||
|
|
||||
|
const showItemList = (itemList) => { |
||||
|
scanList.value.openPopup(itemList); |
||||
|
}; |
||||
|
|
||||
|
const selectedItem = (item) => { |
||||
|
openJobDetail(item); |
||||
|
}; |
||||
|
|
||||
|
const swipeClick = (e, dataContent) => { |
||||
|
if (e.content.text === "详情") { |
||||
|
openjobInfoPopup(dataContent); |
||||
|
} else if (e.content.text === "放弃") { |
||||
|
comMessage.value.showQuestionMessage("确定要放弃当前任务?", (res) => { |
||||
|
if (res) { |
||||
|
cancleJob(dataContent.masterId); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const openjobInfoPopup = (item) => { |
||||
|
jobInfoPopup.value.openPopup(item); |
||||
|
}; |
||||
|
|
||||
|
const cancleJob = (id) => { |
||||
|
cancleTakePutawayJob(id).then((res) => { |
||||
|
if (res.data) { |
||||
|
getList("refresh"); |
||||
|
uni.showToast({ |
||||
|
title: "放弃任务成功" |
||||
|
}); |
||||
|
} else { |
||||
|
showMessage("放弃任务失败"); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showMessage = (message) => { |
||||
|
if (comMessage.value) { |
||||
|
comMessage.value.packLoseFocus(); |
||||
|
} |
||||
|
comMessage.value.showErrorMessage(message, (res) => { |
||||
|
if (res) { |
||||
|
if (comMessage.value) { |
||||
|
comMessage.value.packGetFocus(); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const openScanPopup = () => { |
||||
|
scanPopup.value.openScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
const selectItem = (item) => { |
||||
|
scanPopup.value.closeScanPopup(); |
||||
|
uni.navigateTo({ |
||||
|
url: './putawayDetail?id=' + |
||||
|
item.masterId + |
||||
|
'&status=' + item.status + |
||||
|
'&scaned=' + item.packingNumber + |
||||
|
'&title=' + title.value + |
||||
|
"&scanMessage=" + scanMessage.value |
||||
|
}); |
||||
|
scanMessage.value = ""; |
||||
|
}; |
||||
|
|
||||
|
const getListByFilter = (params) => { |
||||
|
console.log('getListByFilter', params); |
||||
|
|
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
creationTime.value = params.creationTime; |
||||
|
itemCode.value = params.itemCode; |
||||
|
toAreaCode.value = params.toAreaCode; |
||||
|
toLocationCode.value = params.toLocationCode; |
||||
|
getList('refresh'); |
||||
|
}; |
||||
|
|
||||
|
const takeAllJob = () => { |
||||
|
if (!toSubmitLocationCode.value) { |
||||
|
comMessage.value.showQuestionMessage("是否要修改目标库位?", (res) => { |
||||
|
if (res) { |
||||
|
comScanLocation.value.showLocation(); |
||||
|
} else { |
||||
|
submitJob(); |
||||
|
} |
||||
|
}); |
||||
|
} else { |
||||
|
submitJob(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const submitJob = () => { |
||||
|
jobNumberList.value = []; |
||||
|
jobList.value.forEach((item) => { |
||||
|
if (item.checked) { |
||||
|
jobNumberList.value.push(item.number); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
if (jobNumberList.value.length === 0) { |
||||
|
showMessage("最少选择一条数据"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
takeAllPutawayJob({ |
||||
|
jobNumberList: jobNumberList.value |
||||
|
}).then((res) => { |
||||
|
if (res.data) { |
||||
|
executeAllJob(); |
||||
|
} else { |
||||
|
uni.hideLoading(); |
||||
|
showMessage("承接任务失败"); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const executeAllJob = () => { |
||||
|
const params = { |
||||
|
toLocationCode: toSubmitLocationCode.value, |
||||
|
jobNumberList: jobNumberList.value |
||||
|
}; |
||||
|
|
||||
|
putawayJobAllExecute(params).then((res) => { |
||||
|
if (res.data) { |
||||
|
uni.hideLoading(); |
||||
|
comMessage.value.showSuccessMessage("执行任务成功", (res) => { |
||||
|
if (res) { |
||||
|
getList('refresh'); |
||||
|
} |
||||
|
}); |
||||
|
} else { |
||||
|
uni.hideLoading(); |
||||
|
showMessage("执行任务失败"); |
||||
|
cancleAllJob(); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
cancleAllJob(); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const cancleAllJob = () => { |
||||
|
cancleAllTakePutawayJob({ |
||||
|
jobNumberList: jobNumberList.value |
||||
|
}).then(() => { |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const changePage = (e) => { |
||||
|
console.log(e); |
||||
|
pageNo.value = e.current; |
||||
|
status.value = 1; |
||||
|
getList(); |
||||
|
}; |
||||
|
|
||||
|
const checkAllItems = (checkAll) => { |
||||
|
if (checkAll.value) { |
||||
|
jobList.value.forEach((res) => { |
||||
|
res.checked = true; |
||||
|
}); |
||||
|
} else { |
||||
|
jobList.value.forEach((res) => { |
||||
|
res.checked = false; |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const cancleAll = () => { |
||||
|
jobList.value.forEach((res) => { |
||||
|
res.checked = false; |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const checkedItem = (item) => { |
||||
|
item.checked = !item.checked; |
||||
|
}; |
||||
|
|
||||
|
const scanLocationCode = (location, code) => { |
||||
|
toSubmitLocationCode.value = code; |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
.footer { |
||||
|
position: fixed; |
||||
|
bottom: 0px; |
||||
|
background: white; |
||||
|
width: 100%; |
||||
|
padding: 16rpx 20rpx; |
||||
|
box-shadow: 0px 0px 20rpx 20rpx rgba(0, 0, 0, 0.05); |
||||
|
|
||||
|
button { |
||||
|
width: 100%; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,508 @@ |
|||||
|
<template> |
||||
|
<view class="page-wraper"> |
||||
|
<view class="page-header"> |
||||
|
<view class="header-view"> |
||||
|
<view class="header_job_top"> |
||||
|
<job-top :dataContent="jobContent"></job-top> |
||||
|
</view> |
||||
|
<view class="header_item"> |
||||
|
申请单号 : {{ jobContent.requestNumber }} |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="page-main"> |
||||
|
<scroll-view scroll-y="true" class="page-main-scroll"> |
||||
|
<view class="detail-list" v-for="(item, index) in detailSource" :key="item.id"> |
||||
|
<view class=""> |
||||
|
<comJobDetailCard :dataContent="item" :index="index" :settingParam="jobContent" |
||||
|
:isShowStatus="false" @remove="updateData" @updateData="updateData" |
||||
|
:locationAreaTypeList='toLocationAreaTypeList'> |
||||
|
</comJobDetailCard> |
||||
|
</view> |
||||
|
</view> |
||||
|
</scroll-view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="page-footer"> |
||||
|
<view class="uni-flex u-col-center space-between padding_10" |
||||
|
style="background-color:ghostwhite; width: 100%; "> |
||||
|
<view class=""> |
||||
|
<locationCompare ref='comScanLocation' title="目标库位" :recommendLocationCode="jobToLocationCode" |
||||
|
:locationCode="toLocationCode" @getLocation='scanLocationCode' :isShowEdit="isCheckLocation" |
||||
|
:locationAreaTypeList="toLocationAreaTypeList"></locationCompare> |
||||
|
</view> |
||||
|
<view class=" uni-flex uni-row"> |
||||
|
<button class="btn_single_commit" hover-class="btn_commit_after" @click="commit">提交</button> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<win-scan-button @goScan='openScanPopup'></win-scan-button> |
||||
|
<!-- <winScanPackAndLocationNoBalance ref="scanPopup" @getResult='getScanResult' :allowNullBalance="true"> |
||||
|
</winScanPackAndLocationNoBalance> --> |
||||
|
|
||||
|
<winScanPackAndLocation :balanceFromInventoryStatuses="false" ref="scanPopup" @getResult='getScanResult' |
||||
|
:noShowBalanceMessage="true"> |
||||
|
</winScanPackAndLocation> |
||||
|
|
||||
|
<comMessage ref="comMessage"></comMessage> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
getManagementPrecisions, |
||||
|
} from '@/common/balance.js'; |
||||
|
|
||||
|
import { |
||||
|
getPutawayJobDetail, |
||||
|
putawayJobSubmit, |
||||
|
takePutawayJob, |
||||
|
cancleTakePutawayJob, |
||||
|
getSwitchByCode |
||||
|
} from '@/api/request2.js'; |
||||
|
import { |
||||
|
goHome, |
||||
|
getCurrDateTime, |
||||
|
getPackingNumberAndBatch, |
||||
|
navigateBack, |
||||
|
compareAsc, |
||||
|
getSwitchInfoByCode |
||||
|
} from '@/common/basic.js'; |
||||
|
|
||||
|
import { |
||||
|
getDirectoryItemArray, |
||||
|
getInventoryStatusName |
||||
|
} from '@/common/directory.js'; |
||||
|
|
||||
|
import { |
||||
|
getTreeDataSource, |
||||
|
calcHandleQty, |
||||
|
calcTreeHandleQty, |
||||
|
getScanCount |
||||
|
} from '@/common/detail.js'; |
||||
|
|
||||
|
import winScanButton from '@/mycomponents/scan/winScanButton.vue' |
||||
|
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue" |
||||
|
import comJobDetailCard from "@/mycomponents/detail/comJobDetailCard.vue" |
||||
|
import locationCompare from '@/mycomponents/location/locationCompare.vue' |
||||
|
import jobTop from '@/mycomponents/job/jobTop.vue' |
||||
|
|
||||
|
import {ref, onMounted, onBeforeUnmount} from 'vue'; |
||||
|
import {onLoad, onPullDownRefresh, onBackPress, onNavigationBarButtonTap} from '@dcloudio/uni-app'; |
||||
|
|
||||
|
const id = ref(''); |
||||
|
const scanCount = ref(0); |
||||
|
const jobContent = ref({}); |
||||
|
const subList = ref([]); |
||||
|
const detailSource = ref([]); |
||||
|
const managementList = ref([]); |
||||
|
const fromLocationCode = ref(""); |
||||
|
const toLocationCode = ref(""); |
||||
|
const toLocationAreaTypeList = ref([]); |
||||
|
const jobStatus = ref(""); |
||||
|
const jobToLocationCode = ref(""); |
||||
|
const isCheckLocation = ref(false); |
||||
|
const scanMessage = ref(""); |
||||
|
|
||||
|
const scanPopupRef = ref(null); |
||||
|
const jobDetailPopupRef = ref(null); |
||||
|
const comScanLocationRef = ref(null); |
||||
|
const comMessageRef = ref(null); |
||||
|
// 生命周期函数 |
||||
|
onLoad((option) => { |
||||
|
uni.setNavigationBarTitle({ |
||||
|
title: option.title + '详情' |
||||
|
}); |
||||
|
id.value = option.id; |
||||
|
scanMessage.value = option.scanMessage; |
||||
|
if (id.value !== undefined) { |
||||
|
if (option.status === "1") { |
||||
|
receive(() => { |
||||
|
getDetail(); |
||||
|
}); |
||||
|
} else { |
||||
|
getDetail(); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onNavigationBarButtonTap((e) => { |
||||
|
if (e.index === 0) { |
||||
|
goHome(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onBackPress((e) => { |
||||
|
if (e.from === 'backbutton') { |
||||
|
if (jobStatus.value === "2") { |
||||
|
cancleTakePutawayJob(id.value).then(() => { |
||||
|
uni.navigateBack(); |
||||
|
}).catch(() => { |
||||
|
uni.navigateBack(); |
||||
|
}); |
||||
|
} else { |
||||
|
uni.navigateBack(); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onPullDownRefresh(() => { |
||||
|
getDetail(); |
||||
|
uni.stopPullDownRefresh(); |
||||
|
}); |
||||
|
|
||||
|
const receive = (callback) => { |
||||
|
if (id.value !== null) { |
||||
|
takePutawayJob(id.value).then(() => { |
||||
|
callback(); |
||||
|
}).catch((error) => { |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const getDetail = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
getPutawayJobDetail(id.value).then((res) => { |
||||
|
uni.hideLoading(); |
||||
|
if (res.data === null) { |
||||
|
showMessage('未获取到详情'); |
||||
|
} else { |
||||
|
if (res.data.subList.length > 0) { |
||||
|
jobContent.value = res.data; |
||||
|
jobStatus.value = res.data.status; |
||||
|
subList.value = res.data.subList; |
||||
|
detailSource.value = getTreeDataSource(subList.value); |
||||
|
fromLocationCode.value = subList.value[0].fromLocationCode; |
||||
|
jobToLocationCode.value = subList.value[0].toLocationCode; |
||||
|
toLocationAreaTypeList.value = getDirectoryItemArray(jobContent.value.toAreaTypes); |
||||
|
isCheckLocation.value = getSwitchInfoByCode("PurchasePutawayToLocationCodeValidate"); |
||||
|
if (isCheckLocation.value) { |
||||
|
toLocationCode.value = ""; |
||||
|
} else { |
||||
|
toLocationCode.value = jobToLocationCode.value; |
||||
|
} |
||||
|
if (scanMessage.value) { |
||||
|
openScanPopupSimulate(scanMessage.value); |
||||
|
} |
||||
|
} else { |
||||
|
showMessage('列表数据为0'); |
||||
|
} |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const calcScanCount = (closeScan) => { |
||||
|
const items = subList.value.filter(r => r.scaned); |
||||
|
scanCount.value = items.length; |
||||
|
if (scanCount.value === subList.value.length) { |
||||
|
closeScanPopup(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const calcHandleQty = () => { |
||||
|
calcTreeHandleQty(detailSource.value); |
||||
|
continueScan(); |
||||
|
// this.$forceUpdate(); // Vue 3 不需要手动强制更新 |
||||
|
}; |
||||
|
|
||||
|
const continueScan = () => { |
||||
|
scanCount.value = getScanCount(subList.value); |
||||
|
if (scanCount.value === subList.value.length) { |
||||
|
closeScanPopup(); |
||||
|
} else { |
||||
|
scanPopupGetFocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const updateData = () => { |
||||
|
console.log("updateData"); |
||||
|
calcTreeHandleQty(detailSource.value); |
||||
|
}; |
||||
|
|
||||
|
const openScanPopupSimulate = (message) => { |
||||
|
let fromlocationCode = ''; |
||||
|
let fromlocationList = []; |
||||
|
for (let i = 0; i < detailSource.value.length; i++) { |
||||
|
let item = detailSource.value[i]; |
||||
|
item.subList.forEach(l => { |
||||
|
if (!fromlocationList.includes(l.fromLocationCode)) { |
||||
|
fromlocationList.push(l.fromLocationCode); |
||||
|
} |
||||
|
if (fromlocationCode === '') { |
||||
|
fromlocationCode = l.fromLocationCode; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
scanPopupRef.value.openScanPopupForJobSimulate(fromlocationCode, fromlocationList, jobContent.value, message); |
||||
|
}; |
||||
|
|
||||
|
const openScanPopup = () => { |
||||
|
let fromlocationCode = ''; |
||||
|
let fromlocationList = []; |
||||
|
for (let i = 0; i < detailSource.value.length; i++) { |
||||
|
let item = detailSource.value[i]; |
||||
|
item.subList.forEach(l => { |
||||
|
if (!fromlocationList.includes(l.fromLocationCode)) { |
||||
|
fromlocationList.push(l.fromLocationCode); |
||||
|
} |
||||
|
if (fromlocationCode === '' && !l.scaned) { |
||||
|
fromlocationCode = l.fromLocationCode; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
scanPopupRef.value.openScanPopupForJob(fromlocationCode, fromlocationList, jobContent.value); |
||||
|
}; |
||||
|
|
||||
|
const closeScanPopup = () => { |
||||
|
scanPopupRef.value.closeScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
const getScanResult = (result) => { |
||||
|
try { |
||||
|
const {packingNumber, batch, qty, itemCode, fromLocationCode, balance} = result.label; |
||||
|
if (!balance) { |
||||
|
showMessage(`箱码【${packingNumber}】没有库存余额`); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
const detail = detailSource.value.find(r => r.itemCode === itemCode); |
||||
|
if (!detail) { |
||||
|
showErrorMessage(`物料号【${itemCode}】不在列表中`); |
||||
|
} else { |
||||
|
const itemDetail = detail.subList.find(r => r.packingNumber === packingNumber && r.batch === batch && r.fromLocationCode === fromLocationCode); |
||||
|
if (!itemDetail) { |
||||
|
let isExit; |
||||
|
for (let subItem of detail.subList) { |
||||
|
for (let pack of subItem.packList) { |
||||
|
if (pack.packingNumber === packingNumber && pack.batch === batch) { |
||||
|
isExit = pack; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
if (isExit) { |
||||
|
subItem.scaned = true; |
||||
|
subItem.handleQty = 0; |
||||
|
isExit = undefined; |
||||
|
} |
||||
|
} |
||||
|
if (!isExit) { |
||||
|
showErrorMessage(`箱码【${packingNumber}】,批次【${batch}】库位【${fromLocationCode}】不在列表中`); |
||||
|
} else { |
||||
|
if (!isExit.cancleScanedHiht && isExit.scaned) { |
||||
|
showMessage(`箱码【${packingNumber}】已经扫描`); |
||||
|
} else { |
||||
|
isExit.scaned = true; |
||||
|
const qtyValue = result.balance?.qty ? Number(result.balance.qty) : Number(qty); |
||||
|
isExit.handleQty = Number(qty); |
||||
|
isExit.toLocationCode = toLocationCode.value; |
||||
|
} |
||||
|
} |
||||
|
calcTreeHandleQty(detailSource.value); |
||||
|
continueScan(); |
||||
|
} else { |
||||
|
const scanedLength = itemDetail.packList.filter(res => res.scaned).length; |
||||
|
itemDetail.fromInventoryStatus = result.balance.inventoryStatus; |
||||
|
if (!itemDetail.cancleScanedHiht && itemDetail.scaned && scanedLength === itemDetail.packList.length) { |
||||
|
showMessage(`箱码【${packingNumber}】已经扫描`); |
||||
|
} else { |
||||
|
itemDetail.scaned = true; |
||||
|
detailSource.value[0].subList.sort(compareAsc('scaned')); |
||||
|
itemDetail.handleQty = qty; |
||||
|
itemDetail.packList.forEach(pac => { |
||||
|
pac.scaned = true; |
||||
|
pac.handleQty = Number(pac.qty); |
||||
|
pac.toLocationCode = toLocationCode.value; |
||||
|
}); |
||||
|
calcTreeHandleQty(detailSource.value); |
||||
|
continueScan(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} catch (e) { |
||||
|
showMessage(e.message); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const scanLocationCode = (location, code) => { |
||||
|
toLocationCode.value = code; |
||||
|
detailSource.value.forEach(item => { |
||||
|
item.subList.forEach(detail => { |
||||
|
detail.toLocationCode = code; |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const openDetail = (item) => { |
||||
|
jobDetailPopupRef.value.openPopup(item); |
||||
|
}; |
||||
|
|
||||
|
const checkLocation = () => { |
||||
|
if (!toLocationCode.value) { |
||||
|
showMessageHint('请扫描收货库位', () => { |
||||
|
comScanLocationRef.value.showLocation(); |
||||
|
}); |
||||
|
return false; |
||||
|
} |
||||
|
return true; |
||||
|
}; |
||||
|
|
||||
|
const showMessageHint = (hint, callback) => { |
||||
|
comMessageRef.value.showErrorMessage(hint, res => { |
||||
|
if (res) { |
||||
|
callback(); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const commit = () => { |
||||
|
scanCount.value = getScanCount(subList.value); |
||||
|
if (scanCount.value === 0) { |
||||
|
showErrorMessage("扫描数为0,请先扫描"); |
||||
|
return; |
||||
|
} |
||||
|
if (!checkLocation()) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (scanCount.value === subList.value.length) { |
||||
|
submitJob(); |
||||
|
} else if (scanCount.value < subList.value.length) { |
||||
|
if (jobContent.value.allowPartialComplete === "TRUE") { |
||||
|
comMessageRef.value.showQuestionMessage1("任务明细未全部完成,是否提交?", 'red', res => { |
||||
|
if (res) { |
||||
|
submitJob(); |
||||
|
} |
||||
|
}); |
||||
|
} else { |
||||
|
comMessageRef.value.showErrorMessage("任务明细未全部完成,不允许部分提交!", res => { |
||||
|
if (res) { |
||||
|
openScanPopup(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const submitJob = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "提交中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
const itemCodes = detailSource.value.map(item => item.itemCode); |
||||
|
|
||||
|
getManagementPrecisions(itemCodes, toLocationCode.value, res => { |
||||
|
if (res.success) { |
||||
|
managementList.value = res.list; |
||||
|
const params = setParams(); |
||||
|
console.log("提交参数", JSON.stringify(params)); |
||||
|
putawayJobSubmit(params).then(res => { |
||||
|
uni.hideLoading(); |
||||
|
if (res.data) { |
||||
|
showCommitSuccessMessage(`提交成功\n生成采购上架记录\n${res.data}`); |
||||
|
} else { |
||||
|
showErrorMessage(`提交失败[${res.msg}]`); |
||||
|
} |
||||
|
}).catch(error => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} else { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(res.message); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const setParams = () => { |
||||
|
const subList = []; |
||||
|
const creator = store.state.user.id; |
||||
|
detailSource.value.forEach(item => { |
||||
|
item.subList.forEach(detail => { |
||||
|
if (detail.scaned) { |
||||
|
const info = getPackingNumberAndBatch(managementList.value, detail.itemCode, detail.packingNumber, detail.batch); |
||||
|
detail.toPackingNumber = info.packingNumber; |
||||
|
detail.toBatch = info.batch; |
||||
|
detail.toContainerNumber = ''; |
||||
|
detail.singlePrice = 1; |
||||
|
detail.amount = 11; |
||||
|
detail.arriveDate = getCurrDateTime(); |
||||
|
detail.produceDate = getCurrDateTime(); |
||||
|
detail.expireDate = getCurrDateTime(); |
||||
|
detail.packList = detail.packList.filter(p => p.scaned); |
||||
|
subList.push(detail); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
jobContent.value.subList = subList; |
||||
|
jobContent.value.creator = creator; |
||||
|
return jobContent.value; |
||||
|
}; |
||||
|
|
||||
|
const showMessage = (message) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessageRef.value.showMessage(message, res => { |
||||
|
if (res) { |
||||
|
afterCloseMessage(); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showErrorMessage = (message) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessageRef.value.showErrorMessage(message, res => { |
||||
|
if (res) { |
||||
|
afterCloseMessage(); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showQuestionMessage = (message, callback) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessageRef.value.showQuestionMessage(message, res => { |
||||
|
if (res) { |
||||
|
callback(res); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const scanPopupGetFocus = () => { |
||||
|
scanPopupRef.value.packGetFocus(); |
||||
|
}; |
||||
|
|
||||
|
const scanPopupLoseFocus = () => { |
||||
|
scanPopupRef.value.packLoseFocus(); |
||||
|
}; |
||||
|
|
||||
|
const afterCloseMessage = () => { |
||||
|
scanPopupGetFocus(); |
||||
|
}; |
||||
|
|
||||
|
const showCommitSuccessMessage = (hint) => { |
||||
|
comMessageRef.value.showSuccessMessage(hint, res => { |
||||
|
navigateBack(1); |
||||
|
}); |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
|
||||
|
</style> |
Loading…
Reference in new issue