Browse Source

page/productionReturn/job 文件迁移 8/8-10/25

hella_vue3
王志国 3 weeks ago
parent
commit
ee8d706cb0
  1. 456
      src/pages/productionReturn/job/holdToReturnDetail.vue
  2. 308
      src/pages/productionReturn/job/holdToReturnJob.vue
  3. 457
      src/pages/productionReturn/job/okToReturnDetail.vue
  4. 289
      src/pages/productionReturn/job/okToReturnJob.vue
  5. 76
      src/pages/productionReturn/job/returnDetail.vue

456
src/pages/productionReturn/job/holdToReturnDetail.vue

@ -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>

308
src/pages/productionReturn/job/holdToReturnJob.vue

@ -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>

457
src/pages/productionReturn/job/okToReturnDetail.vue

@ -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>

289
src/pages/productionReturn/job/okToReturnJob.vue

@ -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>

76
src/pages/productionReturn/job/returnDetail.vue

@ -60,8 +60,8 @@ import jobTop from '@/mycomponents/job/jobTop.vue'
import winScanPack from '@/mycomponents/scan/winScanPack.vue'
import workStation from '@/mycomponents/workStation/workStation.vue'
import { useCountStore } from '@/store'
// store
const store = useCountStore()
const { proxy } = getCurrentInstance()
const id = ref('')
const scanCount = ref(0)
@ -189,7 +189,7 @@ const openScanPopup = () => {
}
const getScanResult = (result) => {
try {
const { packingNumber } = result.label.package
const { packingNumber } = result.label.packingNumber
const { batch } = result.label
const { qty } = result.label
const { itemCode } = result.label
@ -232,40 +232,46 @@ const commit = () => {
showErrorMessage('扫描数为0,请先扫描')
return
}
//
let str = ''
detailSource.value.forEach((item) => {
item.subList.forEach(cur => {
if (cur.qty != cur.handleQty) {
str += `包装号【${cur.packingNumber}】提交数量【${cur.handleQty}】与任务物料数量【${cur.qty}】不一致`
}
})
})
if (str) {
str += ',是否确认提交?'
comMessageRef.value.showQuestionMessage1(str, 'red', res => {
if (res) {
submitJob()
}
});
} else {
submitJob()
}
// //
// if (scanCount.value == subList.value.length) {
// //
// let str = ''
// detailSource.value.forEach((item) => {
// item.subList.forEach(cur => {
// if (cur.qty != cur.handleQty) {
// str += `${cur.packingNumber}${cur.handleQty}${cur.qty}`
// }
// })
// })
// if (str) {
// str += '?'
// comMessageRef.value.showQuestionMessage1(str, 'red', res => {
// if (res) {
// submitJob()
// }
// });
// } else {
// submitJob()
// } else if (scanCount.value < subList.value.length) {
// //
// if (jobContent.value.allowPartialComplete == 'TRUE') {
// //
// submitJob()
// } else {
// //
// comMessageRef.value.showErrorMessage(',<br>' + `[${scanCount.value}][${subList.value.length}]`, (res) => {
// openScanPopup()
// })
// }
// }
//
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 = () => {
@ -287,7 +293,7 @@ const submitJob = () => {
.then((res) => {
uni.hideLoading()
if (res.data) {
showCommitSuccessMessage(`提交成功<br>生成生产退料记录:${res.data}`)
showCommitSuccessMessage(`提交成功\n生成生产退料记录:${res.data}`)
} else {
showErrorMessage(`提交失败[${res.msg}]`)
}

Loading…
Cancel
Save