|
@@ -0,0 +1,338 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <van-nav-bar
|
|
|
|
|
+ title="调拨" left-arrow left-text="返回" right-text="拍照" fixed placeholder @click-left="goBack()"
|
|
|
|
|
+ @click-right="goTakePhoto"
|
|
|
|
|
+ />
|
|
|
|
|
+ <van-search v-model="stockTransferSearch" placeholder="请输入搜索关键词" @search="searchStockTransfer" />
|
|
|
|
|
+ <div class="content">
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <van-list
|
|
|
|
|
+ v-model:loading="loading" :finished="finished" finished-text="" :immediate-check="false"
|
|
|
|
|
+ @load="loadTransferList"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div v-for="(item, index) in transferList" :key="item.id" class="list-container">
|
|
|
|
|
+ <van-form :scroll-to-error="true">
|
|
|
|
|
+ <div class="in-header">
|
|
|
|
|
+ <strong>{{ index + 1 }}. {{ item.inventoryName }}</strong>
|
|
|
|
|
+ <van-button type="primary" plain @click="transfer(item)">调拨</van-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <van-field v-model="item.inventoryNo" name="inventoryNo" label="物料编号:" readonly />
|
|
|
|
|
+ <van-field v-model="item.inventoryName" name="inventoryName" label="物料名称:" readonly />
|
|
|
|
|
+ <van-field v-model="item.inventoryType" name="inventoryType" label="规格型号:" readonly />
|
|
|
|
|
+ <van-field v-model="item.quantity" name="quantity" label="库存:" readonly />
|
|
|
|
|
+ <van-field v-model="item.positionName" name="positionName" label="货位:" readonly />
|
|
|
|
|
+ </van-form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </van-list>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <van-empty v-if="transferList.length === 0" description="暂无调拨库存" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <van-dialog v-model:show="isShowStockTransfer" title="填写调拨信息" :show-confirm-button="false">
|
|
|
|
|
+ <van-form :scroll-to-error="true">
|
|
|
|
|
+ <van-field v-model="formData.inventoryNo" name="inventoryNo" label="物料编号:" readonly />
|
|
|
|
|
+ <van-field v-model="formData.inventoryName" name="inventoryName" label="物料名称:" readonly />
|
|
|
|
|
+ <van-field v-model="formData.inventoryType" name="inventoryType" label="规格型号:" readonly />
|
|
|
|
|
+ <van-field v-model="formData.quantity" name="quantity" label="库存:" readonly />
|
|
|
|
|
+ <van-field v-model="formData.batchNo" name="batchNo" label="批号:" placeholder="点击输入批号" readonly />
|
|
|
|
|
+ <van-field
|
|
|
|
|
+ v-model="formData.positionBeforeName" is-link readonly name="warehouse" label="调拨前货位:"
|
|
|
|
|
+ placeholder="点击选择调拨前货位" :default-selected-id="formData.positionBeforeId" @click="isShowCurrent = true"
|
|
|
|
|
+ />
|
|
|
|
|
+ <van-field
|
|
|
|
|
+ v-model="formData.positionAfterName" is-link readonly name="warehouse" label="调拨后货位:"
|
|
|
|
|
+ placeholder="点击选择调拨后货位" @click="isShowTransfer = true"
|
|
|
|
|
+ />
|
|
|
|
|
+ </van-form>
|
|
|
|
|
+
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <div class="footer-btn">
|
|
|
|
|
+ <van-button style="width: 40%;" plain type="primary" @click="cancelTransfer">
|
|
|
|
|
+ 取消
|
|
|
|
|
+ </van-button>
|
|
|
|
|
+ <van-button style="width: 40%;" type="primary" @click="transferConfirm">
|
|
|
|
|
+ 提交
|
|
|
|
|
+ </van-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </van-dialog>
|
|
|
|
|
+ <position-selector
|
|
|
|
|
+ ref="currentPositionSelector" v-model:show="isShowCurrent" position-type="current"
|
|
|
|
|
+ is-user="transfer" :default-selected-id="formData.positionBeforeId" @confirm="currentPositionSelected"
|
|
|
|
|
+ />
|
|
|
|
|
+ <position-selector
|
|
|
|
|
+ ref="transferPositionSelector" v-model:show="isShowTransfer" position-type="idle"
|
|
|
|
|
+ is-user="transfer" @confirm="onTransferPositionSelected"
|
|
|
|
|
+ />
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script setup>
|
|
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
|
|
+import { useRouter } from 'vue-router';
|
|
|
|
|
+import PositionSelector from './PositionSelector.vue';
|
|
|
|
|
+import { processException } from '../common/Common.js';
|
|
|
|
|
+import { ajaxApiGet, ajaxApiPost } from '../common/utils.js';
|
|
|
|
|
+import { showFailToast, showSuccessToast, showConfirmDialog } from 'vant';
|
|
|
|
|
+
|
|
|
|
|
+const router = useRouter();
|
|
|
|
|
+
|
|
|
|
|
+const stockTransferSearch = ref('');
|
|
|
|
|
+const currentPositionSelector = ref(null);
|
|
|
|
|
+const transferPositionSelector = ref(null);
|
|
|
|
|
+
|
|
|
|
|
+const transferList = ref([]);
|
|
|
|
|
+const loading = ref(false);
|
|
|
|
|
+const finished = ref(false);
|
|
|
|
|
+
|
|
|
|
|
+const page = ref(1);
|
|
|
|
|
+const total = ref(0);
|
|
|
|
|
+const pageSize = ref(10);
|
|
|
|
|
+
|
|
|
|
|
+const formData = ref({
|
|
|
|
|
+ currentStockId:'',
|
|
|
|
|
+ inventoryId: '',
|
|
|
|
|
+ inventoryNo: '',
|
|
|
|
|
+ inventoryName: '',
|
|
|
|
|
+ inventoryType: '',
|
|
|
|
|
+ quantity: '',
|
|
|
|
|
+ batchNo: '',
|
|
|
|
|
+ positionBeforeName: '',
|
|
|
|
|
+ positionBeforeId: '',
|
|
|
|
|
+ positionBeforeNo: '',
|
|
|
|
|
+ positionAfterId: '',
|
|
|
|
|
+ positionAfterNo: '',
|
|
|
|
|
+ positionAfterName: '',
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const isShowStockTransfer = ref(false);
|
|
|
|
|
+const isShowCurrent = ref(false);
|
|
|
|
|
+const isShowTransfer = ref(false);
|
|
|
|
|
+
|
|
|
|
|
+const goBack = () => {
|
|
|
|
|
+ router.push('/app-menus');
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 搜索调拨物料
|
|
|
|
|
+const searchStockTransfer = value => {
|
|
|
|
|
+ page.value = 1;
|
|
|
|
|
+ total.value = 0;
|
|
|
|
|
+ transferList.value = [];
|
|
|
|
|
+ loadTransferList();
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 调拨前货位选择结果
|
|
|
|
|
+const currentPositionSelected = item => {
|
|
|
|
|
+ getTransferInfo(item);
|
|
|
|
|
+};
|
|
|
|
|
+// 调拨后货位选择结果
|
|
|
|
|
+const onTransferPositionSelected = item => {
|
|
|
|
|
+ formData.value.positionAfterId = item.id;
|
|
|
|
|
+ formData.value.positionAfterNo = item.no;
|
|
|
|
|
+ formData.value.positionAfterName = item.name;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 调拨
|
|
|
|
|
+const transfer = item => {
|
|
|
|
|
+ console.log(item, '调拨');
|
|
|
|
|
+ formData.value.currentStockId = item.currentStockId;
|
|
|
|
|
+ formData.value.inventoryId = item.inventoryId;
|
|
|
|
|
+ formData.value.inventoryNo = item.inventoryNo;
|
|
|
|
|
+ formData.value.inventoryName = item.inventoryName;
|
|
|
|
|
+ formData.value.inventoryType = item.inventoryType;
|
|
|
|
|
+ formData.value.quantity = item.quantity;
|
|
|
|
|
+ formData.value.batchNo = item.batchNo;
|
|
|
|
|
+ formData.value.positionBeforeId = item.positionId;
|
|
|
|
|
+ formData.value.positionBeforeName = item.positionName;
|
|
|
|
|
+ formData.value.positionBeforeNo = item.positionNo;
|
|
|
|
|
+ isShowStockTransfer.value = true;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 调拨确认
|
|
|
|
|
+const transferConfirm = () => {
|
|
|
|
|
+ console.log(formData.value, '调拨确认');
|
|
|
|
|
+
|
|
|
|
|
+ if (!formData.value.positionBeforeId) {
|
|
|
|
|
+ showFailToast('请选择调拨前货位');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.value.positionAfterId) {
|
|
|
|
|
+ showFailToast('请选择调拨后货位');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ showConfirmDialog({
|
|
|
|
|
+ title: '确认要调拨吗?',
|
|
|
|
|
+ message: '如果确认要调拨,请点击【确认】按钮,否则点击【取消】按钮。',
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(() => {
|
|
|
|
|
+ submitTransfer();
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ console.log('取消');
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 加载调拨物料列表
|
|
|
|
|
+const loadTransferList = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await getList(page.value, pageSize.value);
|
|
|
|
|
+
|
|
|
|
|
+ // 搜索时替换数据,上拉加载时追加数据
|
|
|
|
|
+ transferList.value =
|
|
|
|
|
+ page.value === 1
|
|
|
|
|
+ ? res.data
|
|
|
|
|
+ : [...transferList.value, ...res.data];
|
|
|
|
|
+
|
|
|
|
|
+ total.value = res.total;
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否已加载全部数据
|
|
|
|
|
+ if (transferList.value.length >= total.value) {
|
|
|
|
|
+ finished.value = true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ page.value++; // 只有在成功加载后才增加页码
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ finished.value = true;
|
|
|
|
|
+ if (error.responseText === '未查询出对应库存信息。') return;
|
|
|
|
|
+ processException(error);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 获取调拨物料列表API
|
|
|
|
|
+const getList = (page, pageSize) => {
|
|
|
|
|
+ const start = (page - 1) * pageSize;
|
|
|
|
|
+ const length = pageSize;
|
|
|
|
|
+ const filter = stockTransferSearch.value;
|
|
|
|
|
+ const url = `/api/StockOutResource/queryCurrentStockStockOut?start=${start}&length=${length}&filter=${filter}`;
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
|
+ ajaxApiGet(url).then(
|
|
|
|
|
+ success => {
|
|
|
|
|
+ const { errorCode, errorMessage, datas, total } = success;
|
|
|
|
|
+ if (errorCode === 0) {
|
|
|
|
|
+ if (datas && datas.length) {
|
|
|
|
|
+ resolve({ data: datas, total: total });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ resolve({ data: [], total: 0 });
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const error = { status: 200, responseText: errorMessage };
|
|
|
|
|
+ reject(error);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ error => {
|
|
|
|
|
+ reject(error);
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 提交API
|
|
|
|
|
+const submitTransfer = () => {
|
|
|
|
|
+ const url = '/api/adjustPositionResource/scanGeneratorAdjustPosition';
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ ...formData.value,
|
|
|
|
|
+ };
|
|
|
|
|
+ ajaxApiPost(url, params).then(
|
|
|
|
|
+ success => {
|
|
|
|
|
+ if (success.errorCode === 0) {
|
|
|
|
|
+ const filter = stockTransferSearch.value;
|
|
|
|
|
+ clearFormData();
|
|
|
|
|
+ searchStockTransfer(filter);
|
|
|
|
|
+ showSuccessToast('调拨成功');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showFailToast(success.errorMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ error => {
|
|
|
|
|
+ processException(error);
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 根据货位、物料、批号查询库存
|
|
|
|
|
+const getTransferInfo = info => {
|
|
|
|
|
+ const positionId = info.id;
|
|
|
|
|
+ const inventoryId = formData.value.inventoryId;
|
|
|
|
|
+ const url = `/api/StockOutResource/queryByInventoryAndPosition?positionId=${positionId}&inventoryId=${inventoryId}`;
|
|
|
|
|
+ ajaxApiGet(url).then(
|
|
|
|
|
+ success => {
|
|
|
|
|
+ const { errorCode, errorMessage, data } = success;
|
|
|
|
|
+ if (errorCode === 0) {
|
|
|
|
|
+ console.log(data, '根据货位、物料、批号查询库存');
|
|
|
|
|
+ if (data) {
|
|
|
|
|
+ formData.value = { ...formData.value, ...data };
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showFailToast({ duration: 4000, message: errorMessage });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ error => {
|
|
|
|
|
+ processException(error);
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 取消调拨
|
|
|
|
|
+const cancelTransfer = () => {
|
|
|
|
|
+ clearFormData();
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 清除表单数据
|
|
|
|
|
+const clearFormData = () => {
|
|
|
|
|
+ formData.value = {
|
|
|
|
|
+ currentStockId: '',
|
|
|
|
|
+ inventoryId: '',
|
|
|
|
|
+ inventoryNo: '',
|
|
|
|
|
+ inventoryName: '',
|
|
|
|
|
+ inventoryType: '',
|
|
|
|
|
+ quantity: '',
|
|
|
|
|
+ batchNo: '',
|
|
|
|
|
+ positionBeforeName: '',
|
|
|
|
|
+ positionBeforeId: '',
|
|
|
|
|
+ positionBeforeNo: '',
|
|
|
|
|
+ positionAfterId: '',
|
|
|
|
|
+ positionAfterNo: '',
|
|
|
|
|
+ positionAfterName: '',
|
|
|
|
|
+ };
|
|
|
|
|
+ currentPositionSelector.value.clearSelected();
|
|
|
|
|
+ transferPositionSelector.value.clearSelected();
|
|
|
|
|
+ isShowStockTransfer.value = false;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 拍照
|
|
|
|
|
+const goTakePhoto = () => {
|
|
|
|
|
+ router.push('/stock-transfer-photo');
|
|
|
|
|
+};
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ loadTransferList();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+.van-search {
|
|
|
|
|
+ padding-bottom: 4px !important;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.list-container {
|
|
|
|
|
+ padding: 3px 10px;
|
|
|
|
|
+ border: 1px solid #ccc;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ margin: 6px 12px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.in-header {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ border-bottom: 1px solid #ccc;
|
|
|
|
|
+ padding-bottom: 3px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.footer-btn {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-around;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ margin-bottom: 10px;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|