王志国
4 weeks ago
5 changed files with 1551 additions and 35 deletions
@ -0,0 +1,456 @@ |
|||||
|
<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> |
||||
|
<work-station :workshopCode="jobContent.workshopCode" :productionLineCode="titleInfo.productionLineCode" |
||||
|
:workStationCode="titleInfo.workStationCode" :rawLocationCode="titleInfo.fromLocationCode"> |
||||
|
</work-station> |
||||
|
</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=""> |
||||
|
<com-return-detail-card :dataContent="item" :index="index" :settingParam="jobContent" |
||||
|
@remove="updateData" @updateData="updateData" |
||||
|
:locationAreaTypeList='toLocationAreaTypeList'> |
||||
|
</com-return-detail-card> |
||||
|
</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="locationCompare" title="目标库位" :recommendLocationCode="jobToLocationCode" |
||||
|
:locationCode="toLocationCode" @getLocation='scanLocationCode' |
||||
|
: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> |
||||
|
<!-- <win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult'></win-scan-pack-and-location> --> |
||||
|
<win-scan-pack ref="scanPopup" @getResult='getScanResult' headerType="HMQ,HPQ"></win-scan-pack> |
||||
|
<detail-info-popup ref="detailInfoPopup"></detail-info-popup> |
||||
|
<comMessage ref="comMessage"></comMessage> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
getProductionReturnJobDetail, |
||||
|
productionReturnJobSubmit, |
||||
|
takeProductionReturnJob, |
||||
|
cancleTakeProductionReturnJob |
||||
|
} from '@/api/request2.js'; |
||||
|
import { |
||||
|
goHome, |
||||
|
navigateBack, |
||||
|
getPackingNumberAndBatch |
||||
|
} from '@/common/basic.js'; |
||||
|
import { |
||||
|
getDirectoryItemArray, |
||||
|
getInventoryStatusName |
||||
|
} from '@/common/directory.js'; |
||||
|
|
||||
|
import { |
||||
|
getManagementPrecisions |
||||
|
} from '@/common/balance.js'; |
||||
|
|
||||
|
|
||||
|
import { |
||||
|
getDataSource, |
||||
|
createRecordInfo, |
||||
|
calcHandleQty, |
||||
|
getScanCount |
||||
|
} from '@/common/detail.js'; |
||||
|
|
||||
|
import winScanButton from '@/mycomponents/scan/winScanButton.vue' |
||||
|
import locationCompare from '@/mycomponents/location/locationCompare.vue' |
||||
|
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue" |
||||
|
import comReturnDetailCard from "@/pages/productionReturn/coms/comReturnDetailCard.vue" |
||||
|
import DetailInfoPopup from '@/pages/productionReturn/coms/detailInfoPopup.vue' |
||||
|
import jobTop from '@/mycomponents/job/jobTop.vue' |
||||
|
import winScanPack from '@/mycomponents/scan/winScanPack.vue' |
||||
|
import workStation from '@/mycomponents/workStation/workStation.vue' |
||||
|
|
||||
|
|
||||
|
import {ref, onMounted, onBeforeUnmount} from 'vue'; |
||||
|
import {onLoad, onPullDownRefresh, onBackPress, onNavigationBarButtonTap} from '@dcloudio/uni-app'; |
||||
|
import { useCountStore } from '@/store' |
||||
|
const store = useCountStore() |
||||
|
const id = ref(''); |
||||
|
const jobContent = ref({}); |
||||
|
const toLocationCode = ref(''); |
||||
|
const scanCount = ref(0); |
||||
|
const subList = ref([]); // 接口返回的任务subList |
||||
|
const detailSource = ref([]); // 绑定在页面上的数据源 |
||||
|
const fromLocationCode = ref(''); |
||||
|
const toLocationAreaTypeList = ref([]); |
||||
|
const toLocationInfo = ref({}); |
||||
|
const businessTypeInfo = ref({}); |
||||
|
const titleInfo = ref(""); |
||||
|
const jobStatus = ref(""); |
||||
|
const jobToLocationCode = ref(""); |
||||
|
|
||||
|
const detailInfoPopup = ref(null); |
||||
|
const scanPopup = ref(null); |
||||
|
const comMessage = ref(null); |
||||
|
const locationCompare = ref(null); |
||||
|
|
||||
|
// 页面加载时执行 |
||||
|
onLoad((option) => { |
||||
|
uni.setNavigationBarTitle({ |
||||
|
title: option.title + '详情' |
||||
|
}); |
||||
|
id.value = option.id; |
||||
|
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") { |
||||
|
cancleTakeProductionReturnJob(id.value).then(() => { |
||||
|
uni.navigateBack(); |
||||
|
}).catch(() => { |
||||
|
uni.navigateBack(); |
||||
|
}); |
||||
|
} else { |
||||
|
uni.navigateBack(); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 下拉刷新 |
||||
|
onPullDownRefresh(() => { |
||||
|
getDetail(); |
||||
|
uni.stopPullDownRefresh(); |
||||
|
}); |
||||
|
|
||||
|
// 页面挂载时执行 |
||||
|
onMounted(() => { |
||||
|
// 可以在这里添加一些初始化逻辑 |
||||
|
}); |
||||
|
|
||||
|
// 接收任务 |
||||
|
const receive = (callback) => { |
||||
|
if (id.value !== null) { |
||||
|
takeProductionReturnJob(id.value).then(() => { |
||||
|
callback(); |
||||
|
}).catch((error) => { |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 获取详情 |
||||
|
const getDetail = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
getProductionReturnJobDetail(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 = getDataSource(subList.value); |
||||
|
|
||||
|
fromLocationCode.value = subList.value[0].fromLocationCode; |
||||
|
jobToLocationCode.value = subList.value[0].toLocationCode; |
||||
|
titleInfo.value = subList.value[0]; |
||||
|
|
||||
|
toLocationAreaTypeList.value = getDirectoryItemArray(jobContent.value.toAreaTypes); |
||||
|
} else { |
||||
|
showMessage('列表数据为0'); |
||||
|
} |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 计算处理数量 |
||||
|
const calcHandleQty = () => { |
||||
|
calcHandleQty(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 = () => { |
||||
|
calcHandleQty(); |
||||
|
}; |
||||
|
|
||||
|
// 打开详情 |
||||
|
const openDetail = (item) => { |
||||
|
detailInfoPopup.value.openPopup(item); |
||||
|
}; |
||||
|
|
||||
|
// 打开扫描弹窗 |
||||
|
const openScanPopup = () => { |
||||
|
scanPopup.value.openScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
// 获取扫描结果 |
||||
|
const getScanResult = (result) => { |
||||
|
try { |
||||
|
const {packingNumber, batch, qty, itemCode} = result.label; |
||||
|
const detail = detailSource.value.find(r => r.itemCode === itemCode); |
||||
|
if (detail === undefined) { |
||||
|
showErrorMessage(`物料号【${itemCode}】不在列表中`); |
||||
|
} else { |
||||
|
const itemDetail = detail.subList.find(r => r.packingNumber === packingNumber && r.batch === batch); |
||||
|
if (itemDetail === undefined) { |
||||
|
showErrorMessage(`箱码[${packingNumber}]批次[${batch}]不在列表中`); |
||||
|
} else { |
||||
|
if (itemDetail.scaned) { |
||||
|
showErrorMessage(`箱码[${packingNumber}]批次[${batch}]已经扫描`); |
||||
|
} else { |
||||
|
itemDetail.scaned = true; |
||||
|
itemDetail.handleQty = Number(result.package.qty); |
||||
|
itemDetail.inventoryStatus = "OK"; |
||||
|
itemDetail.packQty = result.package.packQty; |
||||
|
itemDetail.packUnit = result.package.packUnit; |
||||
|
calcHandleQty(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
scanPopupGetFocus(); |
||||
|
} catch (e) { |
||||
|
showErrorMessage(e.message); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 扫描库位码 |
||||
|
const scanLocationCode = (location, code) => { |
||||
|
toLocationCode.value = code; |
||||
|
detailSource.value.forEach(item => { |
||||
|
item.subList.forEach(detail => { |
||||
|
detail.toLocationCode = code; |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 提交任务 |
||||
|
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") { |
||||
|
comMessage.value.showQuestionMessage1("任务明细未全部完成,是否提交?", 'red', res => { |
||||
|
if (res) { |
||||
|
submitJob(); |
||||
|
} |
||||
|
}); |
||||
|
} else { |
||||
|
comMessage.value.showErrorMessage("任务明细未全部完成,不允许部分提交!", res => { |
||||
|
if (res) { |
||||
|
openScanPopup(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 提交任务 |
||||
|
const submitJob = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "提交中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
const itemCodes = detailSource.value.map(item => item.itemCode); |
||||
|
|
||||
|
const param = { |
||||
|
itemCode: itemCodes, |
||||
|
locationCode: toLocationCode.value |
||||
|
}; |
||||
|
|
||||
|
getManagementPrecisions(itemCodes, toLocationCode.value, res => { |
||||
|
if (res.success) { |
||||
|
const managementList = res.list; |
||||
|
const params = setParams(); |
||||
|
console.log("提交参数", JSON.stringify(params)); |
||||
|
|
||||
|
productionReturnJobSubmit(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.id; |
||||
|
|
||||
|
detailSource.value.forEach(item => { |
||||
|
item.subList.forEach(detail => { |
||||
|
if (detail.scaned) { |
||||
|
const info = getPackingNumberAndBatch(managementList, detail.itemCode, detail.packingNumber, detail.batch); |
||||
|
detail.toPackingNumber = detail.packingNumber; |
||||
|
detail.toContainerNumber = detail.containerNumber; |
||||
|
detail.toBatch = detail.batch; |
||||
|
detail.toLocationCode = detail.toLocationCode; |
||||
|
subList.push(detail); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
jobContent.value.subList = subList; |
||||
|
jobContent.value.creator = creator; |
||||
|
return jobContent.value; |
||||
|
}; |
||||
|
|
||||
|
// 检查库位 |
||||
|
const checkLocation = () => { |
||||
|
if (toLocationCode.value === "" || toLocationCode.value === null) { |
||||
|
showMessageHint('请扫描收货库位', () => { |
||||
|
locationCompare.value.showLocation(); |
||||
|
}); |
||||
|
return false; |
||||
|
} |
||||
|
return true; |
||||
|
}; |
||||
|
|
||||
|
// 显示提示信息 |
||||
|
const showMessageHint = (hint, callback) => { |
||||
|
comMessage.value.showErrorMessage(hint, res => { |
||||
|
if (res) { |
||||
|
callback(); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 显示消息 |
||||
|
const showMessage = (message) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessage.value.showMessage(message, res => { |
||||
|
if (res) { |
||||
|
afterCloseMessage(); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 显示错误信息 |
||||
|
const showErrorMessage = (message) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessage.value.showErrorMessage(message, res => { |
||||
|
if (res) { |
||||
|
afterCloseMessage(); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 关闭消息后处理 |
||||
|
const afterCloseMessage = () => { |
||||
|
scanPopupGetFocus(); |
||||
|
}; |
||||
|
|
||||
|
// 关闭扫描弹窗 |
||||
|
const closeScanPopup = () => { |
||||
|
scanPopup.value.closeScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
// 聚焦扫描弹窗 |
||||
|
const scanPopupGetFocus = () => { |
||||
|
if (scanPopup.value) { |
||||
|
scanPopup.value.getfocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 失去焦点 |
||||
|
const scanPopupLoseFocus = () => { |
||||
|
if (scanPopup.value) { |
||||
|
scanPopup.value.losefocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 显示确认消息 |
||||
|
const showQuestionMessage = (message, callback) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessage.value.showQuestionMessage(message, res => { |
||||
|
if (res) { |
||||
|
callback(res); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 显示提交成功消息 |
||||
|
const showCommitSuccessMessage = (hint) => { |
||||
|
comMessage.value.showSuccessMessage(hint, res => { |
||||
|
navigateBack(1); |
||||
|
}); |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
|
||||
|
</style> |
@ -0,0 +1,308 @@ |
|||||
|
<template> |
||||
|
<view class=""> |
||||
|
<com-empty-view v-if="jobList.length==0"></com-empty-view> |
||||
|
<job-filter ref="filter" otherTitle="ASN" @switchChangeToday="switchChangeToday" |
||||
|
@switchChangeWait="switchChangeWait" @onScanNumber="getScanNumber" :checkedToday="checkedToday" |
||||
|
:checkedWaitTask="checkedWaitTask"> |
||||
|
</job-filter> |
||||
|
<view v-if="jobList.length>0"> |
||||
|
<u-swipe-action ref="swipeAction" v-for="(item, index) in jobList" |
||||
|
:key="index" :options="item.status=='2'?detailGiveupOptions:detailOptions" |
||||
|
@click="(...event)=>swipeClick(event,item)"> |
||||
|
<com-return-job-card :dataContent="item" @click='openJobDetail(item)'></com-return-job-card> |
||||
|
</u-swipe-action> |
||||
|
|
||||
|
<job-list-popup ref="jobListPopup" @selectedItem="selectedItem"></job-list-popup> |
||||
|
<job-info-popup ref='jobInfoPopup'></job-info-popup> |
||||
|
|
||||
|
<uni-load-more :status="loadingType" v-if="jobList.length>0"/> |
||||
|
|
||||
|
</view> |
||||
|
<comMessage ref="comMessage"></comMessage> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
getProductionHoldReturnJobList, |
||||
|
cancleTakeProductionReturnJob |
||||
|
} from '@/api/request2.js'; |
||||
|
|
||||
|
import { |
||||
|
goHome, |
||||
|
updateTitle |
||||
|
} from '@/common/basic.js'; |
||||
|
|
||||
|
import { |
||||
|
getDetailOption, |
||||
|
getDetailGiveupOption |
||||
|
} from '@/common/array.js'; |
||||
|
|
||||
|
import comEmptyView from '@/mycomponents/common/comEmptyView.vue' |
||||
|
import jobFilter from '@/mycomponents/job/jobFilter.vue' |
||||
|
import comReturnJobCard from '@/pages/productionReturn/coms/comReturnJobCard.vue' |
||||
|
import JobListPopup from '@/pages/productionReturn/coms/jobListPopup.vue' |
||||
|
|
||||
|
import {ref, onMounted, onBeforeUnmount, computed} from 'vue'; |
||||
|
import { |
||||
|
onLoad, |
||||
|
onShow, |
||||
|
onReady, |
||||
|
onReachBottom, |
||||
|
onPullDownRefresh, |
||||
|
onBackPress, |
||||
|
onNavigationBarButtonTap |
||||
|
} from '@dcloudio/uni-app'; |
||||
|
import {useCountStore} from '@/store' |
||||
|
|
||||
|
const store = useCountStore() |
||||
|
const jobList = ref([]); |
||||
|
const pageNo = ref(1); |
||||
|
const pageSize = ref(10); |
||||
|
const totalCount = ref(0); |
||||
|
const loadingType = ref("nomore"); |
||||
|
const checkedToday = ref(false); |
||||
|
const checkedWaitTask = ref(false); |
||||
|
const todayTime = ref(""); |
||||
|
const status = ref('1,2'); // 待处理 、进行中 |
||||
|
const detailOptions = ref([]); |
||||
|
const detailGiveupOptions = ref([]); |
||||
|
const title = ref(''); |
||||
|
|
||||
|
const filter = ref(null); |
||||
|
const jobListPopup = ref(null); |
||||
|
const jobInfoPopup = ref(null); |
||||
|
const comMessage = ref(null); |
||||
|
|
||||
|
onLoad((option) => { |
||||
|
title.value = option.title; |
||||
|
}); |
||||
|
|
||||
|
onShow(() => { |
||||
|
getList('refresh'); |
||||
|
}); |
||||
|
|
||||
|
onReady(() => { |
||||
|
detailOptions.value = getDetailOption(); |
||||
|
detailGiveupOptions.value = getDetailGiveupOption(); |
||||
|
}); |
||||
|
|
||||
|
onReachBottom(() => { |
||||
|
// 避免多次触发 |
||||
|
if (loadingType.value === 'loading' || loadingType.value === 'nomore') { |
||||
|
return; |
||||
|
} |
||||
|
getList("more"); |
||||
|
}); |
||||
|
|
||||
|
onPullDownRefresh(() => { |
||||
|
getList('refresh'); |
||||
|
}); |
||||
|
|
||||
|
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(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 获取列表 |
||||
|
const getList = (type) => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
loadingType.value = "loading"; |
||||
|
if (type === "refresh") { |
||||
|
pageNo.value = 1; |
||||
|
jobList.value = []; |
||||
|
} |
||||
|
|
||||
|
const filters = []; |
||||
|
if (checkedToday.value) { |
||||
|
filters.push({ |
||||
|
column: "create_time", |
||||
|
action: "between", |
||||
|
value: todayTime.value |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
filters.push({ |
||||
|
column: "status", |
||||
|
action: "in", |
||||
|
value: status.value |
||||
|
}); |
||||
|
|
||||
|
filters.push({ |
||||
|
column: "accept_user_id", |
||||
|
action: "==", |
||||
|
value: store.id |
||||
|
}); |
||||
|
|
||||
|
const params = { |
||||
|
filters: filters, |
||||
|
pageNo: pageNo.value, |
||||
|
pageSize: pageSize.value, |
||||
|
}; |
||||
|
|
||||
|
getProductionHoldReturnJobList(params).then((res) => { |
||||
|
uni.hideLoading(); |
||||
|
if (type === "refresh") { |
||||
|
uni.stopPullDownRefresh(); |
||||
|
} |
||||
|
|
||||
|
const list = res.data.list; |
||||
|
totalCount.value = res.data.total; |
||||
|
updateTitle(`${title.value}(${totalCount.value})`); |
||||
|
loadingType.value = "loadmore"; |
||||
|
|
||||
|
if (list == null || list.length === 0) { |
||||
|
loadingType.value = "nomore"; |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
jobList.value = type === "refresh" ? list : jobList.value.concat(list); |
||||
|
pageNo.value++; |
||||
|
}).catch((error) => { |
||||
|
if (type === "refresh") { |
||||
|
uni.stopPullDownRefresh(); |
||||
|
} |
||||
|
updateTitle(title.value); |
||||
|
loadingType.value = ""; |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 打开任务详情 |
||||
|
const openJobDetail = (item) => { |
||||
|
uni.navigateTo({ |
||||
|
url: `./holdToReturnDetail?id=${item.masterId}&status=${item.status}&title=${title.value}` |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 显示项目列表 |
||||
|
const showItemList = (itemList) => { |
||||
|
jobListPopup.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) => { |
||||
|
cancleTakeProductionReturnJob(id).then((res) => { |
||||
|
if (res.data) { |
||||
|
getList("refresh"); |
||||
|
uni.showToast({ |
||||
|
title: "放弃任务成功" |
||||
|
}); |
||||
|
} else { |
||||
|
showMessage("放弃任务失败"); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 切换今天任务 |
||||
|
const switchChangeToday = (state, creationTime) => { |
||||
|
checkedToday.value = state; |
||||
|
todayTime.value = creationTime; |
||||
|
getList("refresh"); |
||||
|
}; |
||||
|
|
||||
|
// 切换待处理任务 |
||||
|
const switchChangeWait = (state, jobStatus) => { |
||||
|
checkedWaitTask.value = state; |
||||
|
status.value = jobStatus; |
||||
|
getList("refresh"); |
||||
|
}; |
||||
|
|
||||
|
// 获取扫描编号 |
||||
|
const getScanNumber = (code) => { |
||||
|
getDataListByType(code); |
||||
|
}; |
||||
|
|
||||
|
// 根据类型获取数据列表 |
||||
|
const getDataListByType = (code) => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
const filters = [ |
||||
|
{ |
||||
|
column: "status", |
||||
|
action: "in", |
||||
|
value: '1,2' |
||||
|
}, |
||||
|
{ |
||||
|
column: "number", |
||||
|
action: "==", |
||||
|
value: code |
||||
|
} |
||||
|
]; |
||||
|
|
||||
|
const params = { |
||||
|
filters: filters, |
||||
|
pageNo: 1, |
||||
|
pageSize: 100, |
||||
|
}; |
||||
|
|
||||
|
getProductionHoldReturnJobList(params).then((res) => { |
||||
|
uni.hideLoading(); |
||||
|
if (res.data.list.length === 0) { |
||||
|
showMessage(`未查找到【${code}】的收货任务`); |
||||
|
} else if (res.data.list.length === 1) { |
||||
|
openJobDetail(res.data.list[0]); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 显示消息 |
||||
|
const showMessage = (message) => { |
||||
|
comMessage.value.showErrorMessage(message, (res) => { |
||||
|
if (res) { |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
|
||||
|
</style> |
@ -0,0 +1,457 @@ |
|||||
|
<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> |
||||
|
<work-station :workshopCode="jobContent.workshopCode" :productionLineCode="titleInfo.productionLineCode" |
||||
|
:workStationCode="titleInfo.workStationCode" :rawLocationCode="titleInfo.fromLocationCode"> |
||||
|
</work-station> |
||||
|
</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=""> |
||||
|
<com-return-detail-card :dataContent="item" :index="index" :settingParam="jobContent" |
||||
|
@remove="updateData" @updateData="updateData" |
||||
|
:locationAreaTypeList='toLocationAreaTypeList'> |
||||
|
</com-return-detail-card> |
||||
|
</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="locationCompare" title="目标库位" :recommendLocationCode="jobToLocationCode" |
||||
|
:locationCode="toLocationCode" @getLocation='scanLocationCode' |
||||
|
: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> |
||||
|
<!-- <win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult'></win-scan-pack-and-location> --> |
||||
|
<win-scan-pack ref="scanPopup" @getResult='getScanResult' headerType="HMQ,HPQ"></win-scan-pack> |
||||
|
<detail-info-popup ref="detailInfoPopup"></detail-info-popup> |
||||
|
<comMessage ref="comMessage"></comMessage> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
getProductionReturnJobDetail, |
||||
|
productionReturnJobSubmit, |
||||
|
takeProductionReturnJob, |
||||
|
cancleTakeProductionReturnJob |
||||
|
} from '@/api/request2.js'; |
||||
|
import { |
||||
|
goHome, |
||||
|
navigateBack, |
||||
|
getPackingNumberAndBatch |
||||
|
} from '@/common/basic.js'; |
||||
|
import { |
||||
|
getDirectoryItemArray, |
||||
|
getInventoryStatusName |
||||
|
} from '@/common/directory.js'; |
||||
|
|
||||
|
import { |
||||
|
getManagementPrecisions |
||||
|
} from '@/common/balance.js'; |
||||
|
|
||||
|
|
||||
|
import { |
||||
|
getDataSource, |
||||
|
createRecordInfo, |
||||
|
calcHandleQty, |
||||
|
getScanCount |
||||
|
} from '@/common/detail.js'; |
||||
|
|
||||
|
import WinScanButton from '@/mycomponents/scan/winScanButton.vue' |
||||
|
import LocationCompare from '@/mycomponents/location/locationCompare.vue' |
||||
|
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue" |
||||
|
import comReturnDetailCard from "@/pages/productionReturn/coms/comReturnDetailCard.vue" |
||||
|
import DetailInfoPopup from '@/pages/productionReturn/coms/detailInfoPopup.vue' |
||||
|
import jobTop from '@/mycomponents/job/jobTop.vue' |
||||
|
import WinScanPack from '@/mycomponents/scan/winScanPack.vue' |
||||
|
import workStation from '@/mycomponents/workStation/workStation.vue' |
||||
|
import {ref} from 'vue'; |
||||
|
import {onLoad, onPullDownRefresh, onBackPress, onNavigationBarButtonTap} from '@dcloudio/uni-app'; |
||||
|
import {useCountStore} from '@/store' |
||||
|
|
||||
|
const store = useCountStore() |
||||
|
const id = ref(''); |
||||
|
const jobContent = ref({}); |
||||
|
const toLocationCode = ref(''); |
||||
|
const scanCount = ref(0); |
||||
|
const subList = ref([]); // 接口返回的任务subList |
||||
|
const detailSource = ref([]); // 绑定在页面上的数据源 |
||||
|
const fromLocationCode = ref(''); |
||||
|
const toLocationAreaTypeList = ref([]); |
||||
|
const toLocationInfo = ref({}); |
||||
|
const businessTypeInfo = ref({}); |
||||
|
const titleInfo = ref(""); |
||||
|
const jobStatus = ref(""); |
||||
|
const jobToLocationCode = ref(""); |
||||
|
const managementList = ref([]); |
||||
|
const managementType = ref(''); |
||||
|
|
||||
|
const detailInfoPopup = ref(null); |
||||
|
const scanPopup = ref(null); |
||||
|
const comMessage = ref(null); |
||||
|
const locationCompare = ref(null); |
||||
|
|
||||
|
onLoad((option) => { |
||||
|
uni.setNavigationBarTitle({ |
||||
|
title: option.title + '详情' |
||||
|
}); |
||||
|
id.value = option.id; |
||||
|
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") { |
||||
|
cancleTakeProductionReturnJob(id.value).then(() => { |
||||
|
uni.navigateBack(); |
||||
|
}).catch(() => { |
||||
|
uni.navigateBack(); |
||||
|
}); |
||||
|
} else { |
||||
|
uni.navigateBack(); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onPullDownRefresh(() => { |
||||
|
getDetail(); |
||||
|
uni.stopPullDownRefresh(); |
||||
|
}); |
||||
|
|
||||
|
const receive = (callback) => { |
||||
|
if (id.value !== null) { |
||||
|
takeProductionReturnJob(id.value).then(() => { |
||||
|
callback(); |
||||
|
}).catch((error) => { |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const getDetail = async () => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
try { |
||||
|
const res = await getProductionReturnJobDetail(id.value); |
||||
|
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 = await getDataSource(subList.value); |
||||
|
|
||||
|
fromLocationCode.value = subList.value[0].fromLocationCode; |
||||
|
jobToLocationCode.value = subList.value[0].toLocationCode; |
||||
|
titleInfo.value = subList.value[0]; |
||||
|
|
||||
|
toLocationAreaTypeList.value = getDirectoryItemArray(jobContent.value.toAreaTypes); |
||||
|
|
||||
|
const itemCodes = []; |
||||
|
detailSource.value.forEach(item => { |
||||
|
itemCodes.push(item.itemCode); |
||||
|
item.scaned = false; |
||||
|
}); |
||||
|
|
||||
|
await getManagementPrecisions(itemCodes, fromLocationCode.value, (res) => { |
||||
|
if (res.success) { |
||||
|
managementList.value = res.list; |
||||
|
managementType.value = managementList.value.some(item => item.ManagementPrecision === 'BY_BATCH') ? 'BY_BATCH' : ''; |
||||
|
if (managementType.value === 'BY_BATCH') { |
||||
|
detailSource.value.forEach(item => { |
||||
|
item.subList.forEach(cur => { |
||||
|
cur.packingNumber = ''; |
||||
|
cur.toPackingNumber = ''; |
||||
|
cur.fromPackingNumber = ''; |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} else { |
||||
|
showMessage('列表数据为0'); |
||||
|
} |
||||
|
} |
||||
|
} catch (error) { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const calcHandleQty = () => { |
||||
|
calcHandleQty(detailSource.value); |
||||
|
continueScan(); |
||||
|
// Vue 3 不需要 $forceUpdate |
||||
|
}; |
||||
|
|
||||
|
const continueScan = () => { |
||||
|
scanCount.value = getScanCount(subList.value); |
||||
|
if (scanCount.value === subList.value.length) { |
||||
|
closeScanPopup(); |
||||
|
} else { |
||||
|
scanPopupGetFocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const updateData = () => { |
||||
|
calcHandleQty(); |
||||
|
}; |
||||
|
|
||||
|
const openDetail = (item) => { |
||||
|
detailInfoPopup.value.openPopup(item); |
||||
|
}; |
||||
|
|
||||
|
const openScanPopup = () => { |
||||
|
scanPopup.value.openScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
const getScanResult = (result) => { |
||||
|
try { |
||||
|
const packingNumber = result.label.packingNumber; |
||||
|
const batch = result.label.batch; |
||||
|
const qty = result.label.qty; |
||||
|
const itemCode = result.label.itemCode; |
||||
|
const detail = detailSource.value.find(r => r.itemCode === itemCode); |
||||
|
if (detail === undefined) { |
||||
|
showErrorMessage(`物料号【${itemCode}】不在列表中`); |
||||
|
} else { |
||||
|
const itemDetail = detail.subList.find(r => r.batch === batch); |
||||
|
if (itemDetail === undefined) { |
||||
|
showErrorMessage(`批次[${batch}]不在列表中`); |
||||
|
} else { |
||||
|
if (itemDetail.scaned) { |
||||
|
showErrorMessage(`批次[${batch}]已经扫描`); |
||||
|
} else { |
||||
|
itemDetail.scaned = true; |
||||
|
itemDetail.handleQty = Number(result.package.qty); |
||||
|
itemDetail.inventoryStatus = "OK"; |
||||
|
itemDetail.packQty = result.package.packQty; |
||||
|
itemDetail.packUnit = result.package.packUnit; |
||||
|
calcHandleQty(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
scanPopupGetFocus(); |
||||
|
} catch (e) { |
||||
|
showErrorMessage(e.message); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const scanLocationCode = (location, code) => { |
||||
|
toLocationCode.value = code; |
||||
|
detailSource.value.forEach(item => { |
||||
|
item.subList.forEach(detail => { |
||||
|
detail.toLocationCode = code; |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
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") { |
||||
|
comMessage.value.showQuestionMessage1("任务明细未全部完成,是否提交?", 'red', (res) => { |
||||
|
if (res) { |
||||
|
submitJob(); |
||||
|
} |
||||
|
}); |
||||
|
} else { |
||||
|
comMessage.value.showErrorMessage("任务明细未全部完成,不允许部分提交!", (res) => { |
||||
|
if (res) { |
||||
|
openScanPopup(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const submitJob = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "提交中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
const itemCodes = []; |
||||
|
detailSource.value.forEach(item => { |
||||
|
itemCodes.push(item.itemCode); |
||||
|
}); |
||||
|
|
||||
|
const param = { |
||||
|
itemCode: itemCodes, |
||||
|
locationCode: toLocationCode.value |
||||
|
}; |
||||
|
|
||||
|
getManagementPrecisions(itemCodes, toLocationCode.value, (res) => { |
||||
|
if (res.success) { |
||||
|
managementList.value = res.list; |
||||
|
const params = setParams(); |
||||
|
console.log("提交参数", JSON.stringify(params)); |
||||
|
|
||||
|
productionReturnJobSubmit(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.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 = detail.packingNumber; |
||||
|
detail.packingNumber = detail.packingNumber; |
||||
|
detail.fromPackingNumber = detail.packingNumber; |
||||
|
detail.toContainerNumber = detail.containerNumber; |
||||
|
detail.toBatch = detail.batch; |
||||
|
detail.toLocationCode = detail.toLocationCode; |
||||
|
subList.push(detail); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
jobContent.value.subList = subList; |
||||
|
jobContent.value.creator = creator; |
||||
|
return jobContent.value; |
||||
|
}; |
||||
|
|
||||
|
const checkLocation = () => { |
||||
|
if (toLocationCode.value === "" || toLocationCode.value === null) { |
||||
|
showMessageHint('请扫描收货库位', () => { |
||||
|
locationCompare.value.showLocation(); |
||||
|
}); |
||||
|
return false; |
||||
|
} |
||||
|
return true; |
||||
|
}; |
||||
|
|
||||
|
const showMessageHint = (hint, callback) => { |
||||
|
comMessage.value.showErrorMessage(hint, (res) => { |
||||
|
if (res) { |
||||
|
callback(); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showMessage = (message) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessage.value.showMessage(message, (res) => { |
||||
|
if (res) { |
||||
|
afterCloseMessage(); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showErrorMessage = (message) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessage.value.showErrorMessage(message, (res) => { |
||||
|
if (res) { |
||||
|
afterCloseMessage(); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const afterCloseMessage = () => { |
||||
|
scanPopupGetFocus(); |
||||
|
}; |
||||
|
|
||||
|
const closeScanPopup = () => { |
||||
|
scanPopup.value.closeScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
const scanPopupGetFocus = () => { |
||||
|
if (scanPopup.value !== undefined) { |
||||
|
scanPopup.value.getfocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const scanPopupLoseFocus = () => { |
||||
|
if (scanPopup.value !== undefined) { |
||||
|
scanPopup.value.losefocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const showQuestionMessage = (message, callback) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessage.value.showQuestionMessage(message, (res) => { |
||||
|
if (res) { |
||||
|
callback(res); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showCommitSuccessMessage = (hint) => { |
||||
|
comMessage.value.showSuccessMessage(hint, (res) => { |
||||
|
navigateBack(1); |
||||
|
}); |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
|
||||
|
</style> |
@ -0,0 +1,289 @@ |
|||||
|
<template> |
||||
|
<view class=""> |
||||
|
<com-empty-view v-if="jobList.length==0"></com-empty-view> |
||||
|
<job-filter ref="filter" otherTitle="ASN" @switchChangeToday="switchChangeToday" |
||||
|
@switchChangeWait="switchChangeWait" @onScanNumber="getScanNumber" :checkedToday="checkedToday" |
||||
|
:checkedWaitTask="checkedWaitTask"> |
||||
|
</job-filter> |
||||
|
<view v-if="jobList.length>0"> |
||||
|
<u-swipe-action ref="swipeAction" v-for="(item, index) in jobList" |
||||
|
:key="index" options="item.status=='2'?detailGiveupOptions:detailOptions" |
||||
|
@click="(...event)=>swipeClick(event,item)"> |
||||
|
<com-return-job-card :dataContent="item" @click='openJobDetail(item)'></com-return-job-card> |
||||
|
</u-swipe-action> |
||||
|
|
||||
|
<job-list-popup ref="jobListPopup" @selectedItem="selectedItem"></job-list-popup> |
||||
|
<job-info-popup ref='jobInfoPopup'></job-info-popup> |
||||
|
|
||||
|
<uni-load-more :status="loadingType" v-if="jobList.length>0" /> |
||||
|
|
||||
|
</view> |
||||
|
<comMessage ref="comMessage"></comMessage> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
getProductionOkReturnJobList, |
||||
|
cancleTakeProductionReturnJob |
||||
|
} from '@/api/request2.js'; |
||||
|
|
||||
|
import { |
||||
|
goHome, |
||||
|
updateTitle |
||||
|
} from '@/common/basic.js'; |
||||
|
|
||||
|
import { |
||||
|
getDetailOption, |
||||
|
getDetailGiveupOption |
||||
|
} from '@/common/array.js'; |
||||
|
|
||||
|
import comEmptyView from '@/mycomponents/common/comEmptyView.vue' |
||||
|
import jobFilter from '@/mycomponents/job/jobFilter.vue' |
||||
|
import comReturnJobCard from '@/pages/productionReturn/coms/comReturnJobCard.vue' |
||||
|
import JobListPopup from '@/pages/productionReturn/coms/jobListPopup.vue' |
||||
|
import JobInfoPopup from '@/pages/productionReturn/coms/jobInfoPopup.vue' |
||||
|
|
||||
|
|
||||
|
import { ref, onMounted, onBeforeUnmount, onActivated, onDeactivated } from 'vue'; |
||||
|
import { onLoad, onShow, onReady, onReachBottom, onPullDownRefresh, onBackPress, onNavigationBarButtonTap } from '@dcloudio/uni-app'; |
||||
|
import { useCountStore } from '@/store' |
||||
|
const store = useCountStore() |
||||
|
const jobList = ref([]); |
||||
|
const pageNo = ref(1); |
||||
|
const pageSize = ref(10); |
||||
|
const totalCount = ref(0); |
||||
|
const loadingType = ref("nomore"); |
||||
|
const checkedToday = ref(false); |
||||
|
const checkedWaitTask = ref(false); |
||||
|
const todayTime = ref(""); |
||||
|
const status = ref('1,2'); // 待处理 、进行中 |
||||
|
const detailOptions = ref([]); |
||||
|
const detailGiveupOptions = ref([]); |
||||
|
const title = ref(''); |
||||
|
|
||||
|
// 模板引用 |
||||
|
const filter = ref(null); |
||||
|
const jobListPopup = ref(null); |
||||
|
const jobInfoPopup = ref(null); |
||||
|
const comMessage = ref(null); |
||||
|
|
||||
|
onLoad((option) => { |
||||
|
title.value = option.title; |
||||
|
}); |
||||
|
|
||||
|
onShow(() => { |
||||
|
getList('refresh'); |
||||
|
}); |
||||
|
|
||||
|
onReady(() => { |
||||
|
detailOptions.value = getDetailOption(); |
||||
|
detailGiveupOptions.value = getDetailGiveupOption(); |
||||
|
}); |
||||
|
|
||||
|
onReachBottom(() => { |
||||
|
// 避免多次触发 |
||||
|
if (loadingType.value === 'loading' || loadingType.value === 'nomore') { |
||||
|
return; |
||||
|
} |
||||
|
getList("more"); |
||||
|
}); |
||||
|
|
||||
|
onPullDownRefresh(() => { |
||||
|
getList('refresh'); |
||||
|
}); |
||||
|
|
||||
|
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(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
const getList = (type) => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
loadingType.value = "loading"; |
||||
|
if (type === "refresh") { |
||||
|
pageNo.value = 1; |
||||
|
jobList.value = []; |
||||
|
} |
||||
|
|
||||
|
const filters = []; |
||||
|
if (checkedToday.value) { |
||||
|
filters.push({ |
||||
|
column: "create_time", |
||||
|
action: "between", |
||||
|
value: todayTime.value |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
filters.push({ |
||||
|
column: "status", |
||||
|
action: "in", |
||||
|
value: status.value |
||||
|
}); |
||||
|
|
||||
|
filters.push({ |
||||
|
column: "accept_user_id", |
||||
|
action: "==", |
||||
|
value: store.id |
||||
|
}); |
||||
|
|
||||
|
const params = { |
||||
|
filters: filters, |
||||
|
pageNo: pageNo.value, |
||||
|
pageSize: pageSize.value, |
||||
|
}; |
||||
|
|
||||
|
getProductionOkReturnJobList(params).then((res) => { |
||||
|
uni.hideLoading(); |
||||
|
if (type === "refresh") { |
||||
|
uni.stopPullDownRefresh(); |
||||
|
} |
||||
|
|
||||
|
const list = res.data.list; |
||||
|
totalCount.value = res.data.total; |
||||
|
updateTitle(title.value + "(" + totalCount.value + ")"); |
||||
|
loadingType.value = "loadmore"; |
||||
|
|
||||
|
if (list == null || list.length === 0) { |
||||
|
loadingType.value = "nomore"; |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
jobList.value = type === "refresh" ? list : jobList.value.concat(list); |
||||
|
pageNo.value++; |
||||
|
}).catch((error) => { |
||||
|
if (type === "refresh") { |
||||
|
uni.stopPullDownRefresh(); |
||||
|
} |
||||
|
updateTitle(title.value); |
||||
|
loadingType.value = ""; |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const openJobDetail = (item) => { |
||||
|
uni.navigateTo({ |
||||
|
url: './okToReturnDetail?id=' + item.masterId + '&status=' + item.status + '&title=' + title.value |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showItemList = (itemList) => { |
||||
|
jobListPopup.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) => { |
||||
|
cancleTakeProductionReturnJob(id).then((res) => { |
||||
|
if (res.data) { |
||||
|
getList("refresh"); |
||||
|
uni.showToast({ |
||||
|
title: "放弃任务成功" |
||||
|
}); |
||||
|
} else { |
||||
|
showMessage("放弃任务失败"); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const switchChangeToday = (state, creationTime) => { |
||||
|
checkedToday.value = state; |
||||
|
todayTime.value = creationTime; |
||||
|
getList("refresh"); |
||||
|
}; |
||||
|
|
||||
|
const switchChangeWait = (state, jobStatus) => { |
||||
|
checkedWaitTask.value = state; |
||||
|
status.value = jobStatus; |
||||
|
getList("refresh"); |
||||
|
}; |
||||
|
|
||||
|
const getScanNumber = (code) => { |
||||
|
getDataListByType(code); |
||||
|
}; |
||||
|
|
||||
|
const getDataListByType = (code) => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
const filters = []; |
||||
|
filters.push({ |
||||
|
column: "status", |
||||
|
action: "in", |
||||
|
value: '1,2' |
||||
|
}); |
||||
|
filters.push({ |
||||
|
column: "number", |
||||
|
action: "==", |
||||
|
value: code |
||||
|
}); |
||||
|
|
||||
|
const params = { |
||||
|
filters: filters, |
||||
|
pageNo: 1, |
||||
|
pageSize: 100, |
||||
|
}; |
||||
|
|
||||
|
getProductionOkReturnJobList(params).then((res) => { |
||||
|
uni.hideLoading(); |
||||
|
if (res.data.list.length === 0) { |
||||
|
showMessage('未查找到' + '【' + code + '】的收货任务'); |
||||
|
} else if (res.data.list.length === 1) { |
||||
|
openJobDetail(res.data.list[0]); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showMessage = (message) => { |
||||
|
comMessage.value.showErrorMessage(message, (res) => { |
||||
|
if (res) { |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
|
||||
|
</style> |
Loading…
Reference in new issue