feat(storegoods): 新增成品采购进仓模块
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="filterBar">
|
||||
<u-search v-model="filters.order_no" placeholder="进仓单号" :show-action="false" @search="loadList" @custom="loadList" />
|
||||
<view class="filterBtn" @click="filterShow = true">
|
||||
<u-icon name="list" size="40" color="#666"></u-icon>
|
||||
<text>筛选</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y :style="{ height: scrollHeight }" refresher-enabled
|
||||
:refresher-triggered="triggered" @refresherrefresh="onRefresh">
|
||||
<dataNull v-if="list.length === 0" src="/src/static/img/chahua/gjNull.png"
|
||||
title="暂无采购进仓单" title1="请点击右下角按钮新增">
|
||||
</dataNull>
|
||||
<view v-for="(item, index) in list" :key="item.id" @click="goView(item)">
|
||||
<PurchaseInItem :item="item" :index="index" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<addBtn url="./storeGoodsPurchaseInAdd"></addBtn>
|
||||
|
||||
<u-popup v-model="filterShow" mode="right" width="580rpx" :safe-area-inset-bottom="true">
|
||||
<view class="filterPanel">
|
||||
<view class="filterTitle">筛选条件</view>
|
||||
<view class="filterItem">
|
||||
<text class="filterLabel">进仓单号</text>
|
||||
<u-input v-model="filters.order_no" placeholder="请输入进仓单号" />
|
||||
</view>
|
||||
<view class="filterItem" @click="openSupplierSelect">
|
||||
<text class="filterLabel">供应商</text>
|
||||
<view class="filterValue">{{ supplierLabel || '全部' }} <u-icon name="arrow-right" size="28"></u-icon></view>
|
||||
</view>
|
||||
<view class="filterItem" @click="openWarehouseSelect">
|
||||
<text class="filterLabel">仓库</text>
|
||||
<view class="filterValue">{{ warehouseLabel || '全部' }} <u-icon name="arrow-right" size="28"></u-icon></view>
|
||||
</view>
|
||||
<view class="filterItem" @click="openStatusSelect">
|
||||
<text class="filterLabel">订单状态</text>
|
||||
<view class="filterValue">{{ statusLabel || '全部' }} <u-icon name="arrow-right" size="28"></u-icon></view>
|
||||
</view>
|
||||
<view class="filterActions">
|
||||
<u-button type="warning" size="medium" @click="resetFilter">重置</u-button>
|
||||
<u-button type="primary" size="medium" @click="applyFilter">确定</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<u-select v-model="statusSelectShow" :list="statusSelectList" @confirm="onStatusConfirm"></u-select>
|
||||
<u-select v-model="unitSelectShow" :list="unitSelectList" @confirm="onUnitConfirm"></u-select>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import addBtn from '@/components/addBtn/addBtn.vue';
|
||||
import PurchaseInItem from '@/components/card/storeGoodsPurchaseInItem.vue';
|
||||
import {
|
||||
getStatusOptions,
|
||||
AUDIT_STATUS_MAP,
|
||||
BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER,
|
||||
WAREHOUSE_TYPE_FINISHED,
|
||||
formatRoll,
|
||||
mapToSelectOptions,
|
||||
fetchAllOrderList,
|
||||
} from '@/common/storeGoodsPurchaseIn';
|
||||
|
||||
export default {
|
||||
components: { addBtn, PurchaseInItem },
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
scrollHeight: '667px',
|
||||
triggered: false,
|
||||
listLoading: false,
|
||||
filterShow: false,
|
||||
statusSelectShow: false,
|
||||
unitSelectShow: false,
|
||||
unitSelectType: '',
|
||||
supplierOptions: [],
|
||||
warehouseOptions: [],
|
||||
unitOptionsLoading: false,
|
||||
filters: {
|
||||
order_no: '',
|
||||
supplier_id: '',
|
||||
supplier_name: '',
|
||||
warehouse_id: '',
|
||||
warehouse_name: '',
|
||||
audit_status: '',
|
||||
},
|
||||
statusSelectList: [
|
||||
{ value: '', label: '全部' },
|
||||
...getStatusOptions(),
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
statusLabel() {
|
||||
if (this.filters.audit_status === '' || this.filters.audit_status === null) return '';
|
||||
return AUDIT_STATUS_MAP[Number(this.filters.audit_status)] || '';
|
||||
},
|
||||
supplierLabel() {
|
||||
return this.filters.supplier_name || '';
|
||||
},
|
||||
warehouseLabel() {
|
||||
return this.filters.warehouse_name || '';
|
||||
},
|
||||
unitSelectList() {
|
||||
const options = this.unitSelectType === 'warehouse' ? this.warehouseOptions : this.supplierOptions;
|
||||
return [{ value: '', label: '全部' }, ...options];
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
uni.setNavigationBarTitle({ title: '成品采购进仓' });
|
||||
uni.getSystemInfo({
|
||||
success: (res) => {
|
||||
this.scrollHeight = `${res.windowHeight - 50}px`;
|
||||
},
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
this.loadList();
|
||||
},
|
||||
methods: {
|
||||
loadSupplierOptions() {
|
||||
if (this.supplierOptions.length) return Promise.resolve(this.supplierOptions);
|
||||
return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER })
|
||||
.then((res) => {
|
||||
this.supplierOptions = mapToSelectOptions(res);
|
||||
return this.supplierOptions;
|
||||
})
|
||||
.catch(() => {
|
||||
this.supplierOptions = [];
|
||||
return this.supplierOptions;
|
||||
});
|
||||
},
|
||||
loadWarehouseOptions() {
|
||||
if (this.warehouseOptions.length) return Promise.resolve(this.warehouseOptions);
|
||||
return this.$u.api.physicalWarehouse.getDropdownList({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED })
|
||||
.then((res) => {
|
||||
this.warehouseOptions = mapToSelectOptions(res);
|
||||
return this.warehouseOptions;
|
||||
})
|
||||
.catch(() => {
|
||||
this.warehouseOptions = [];
|
||||
return this.warehouseOptions;
|
||||
});
|
||||
},
|
||||
openUnitSelect(type) {
|
||||
if (this.unitOptionsLoading) return;
|
||||
this.unitOptionsLoading = true;
|
||||
const loadFn = type === 'warehouse' ? this.loadWarehouseOptions : this.loadSupplierOptions;
|
||||
loadFn.call(this)
|
||||
.then((list) => {
|
||||
if (!list.length) {
|
||||
uni.showToast({ title: '暂无可选数据', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
this.unitSelectType = type;
|
||||
this.unitSelectShow = true;
|
||||
})
|
||||
.finally(() => {
|
||||
this.unitOptionsLoading = false;
|
||||
});
|
||||
},
|
||||
openSupplierSelect() {
|
||||
this.openUnitSelect('supplier');
|
||||
},
|
||||
openWarehouseSelect() {
|
||||
this.openUnitSelect('warehouse');
|
||||
},
|
||||
onUnitConfirm(e) {
|
||||
const item = e[0] || {};
|
||||
if (this.unitSelectType === 'warehouse') {
|
||||
this.filters.warehouse_id = item.value;
|
||||
this.filters.warehouse_name = item.value ? item.label : '';
|
||||
} else {
|
||||
this.filters.supplier_id = item.value;
|
||||
this.filters.supplier_name = item.value ? item.label : '';
|
||||
}
|
||||
},
|
||||
loadList() {
|
||||
if (this.listLoading) return;
|
||||
this.listLoading = true;
|
||||
const params = {};
|
||||
if (this.filters.order_no) params.order_no = this.filters.order_no;
|
||||
if (this.filters.supplier_id) params.supplier_id = this.filters.supplier_id;
|
||||
if (this.filters.warehouse_id) params.warehouse_id = this.filters.warehouse_id;
|
||||
if (this.filters.audit_status !== '' && this.filters.audit_status !== null) {
|
||||
params.audit_status = this.filters.audit_status;
|
||||
}
|
||||
fetchAllOrderList((p) => this.$u.api.fpmPrcInOrder.list(p), params)
|
||||
.then((rows) => {
|
||||
this.list = rows.map(this.mapToCard);
|
||||
})
|
||||
.catch((err) => {
|
||||
this.list = [];
|
||||
uni.showToast({ title: err.message || '加载失败', icon: 'none' });
|
||||
})
|
||||
.finally(() => {
|
||||
this.listLoading = false;
|
||||
this.triggered = false;
|
||||
// 避免并发请求下 uView 全局 loading 遮罩关不掉
|
||||
uni.hideLoading();
|
||||
});
|
||||
},
|
||||
mapToCard(order) {
|
||||
return {
|
||||
id: order.id,
|
||||
order_no: order.order_no || '',
|
||||
biz_unit_id: order.biz_unit_id || '',
|
||||
biz_unit_name: order.biz_unit_name || '',
|
||||
warehouse_id: order.warehouse_id || '',
|
||||
warehouse_name: order.warehouse_name || '',
|
||||
create_user_name: order.creator_name || '',
|
||||
create_time: order.create_time || '',
|
||||
auditor_name: order.auditor_name || '',
|
||||
audit_date: order.audit_time || '',
|
||||
audit_status: order.audit_status,
|
||||
audit_status_name: order.audit_status_name || AUDIT_STATUS_MAP[order.audit_status] || '',
|
||||
total_roll: formatRoll(order.total_roll),
|
||||
};
|
||||
},
|
||||
onRefresh() {
|
||||
this.triggered = true;
|
||||
this.loadList();
|
||||
},
|
||||
goView(item) {
|
||||
const page = Number(item.audit_status) === 1
|
||||
? 'storeGoodsPurchaseInEdit'
|
||||
: 'storeGoodsPurchaseInView';
|
||||
uni.navigateTo({ url: `./${page}?id=${item.id}` });
|
||||
},
|
||||
openStatusSelect() { this.statusSelectShow = true; },
|
||||
onStatusConfirm(e) { this.filters.audit_status = e[0].value; },
|
||||
resetFilter() {
|
||||
this.filters = {
|
||||
order_no: '',
|
||||
supplier_id: '',
|
||||
supplier_name: '',
|
||||
warehouse_id: '',
|
||||
warehouse_name: '',
|
||||
audit_status: '',
|
||||
};
|
||||
},
|
||||
applyFilter() {
|
||||
this.filterShow = false;
|
||||
this.loadList();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
page { background-color: #F8F8F8; }
|
||||
.filterBar { display: flex; align-items: center; padding: 16rpx 20rpx; background: #fff; gap: 16rpx; }
|
||||
.filterBtn { display: flex; flex-direction: column; align-items: center; font-size: 22rpx; color: #666; min-width: 80rpx; }
|
||||
.filterPanel { padding: 30rpx; }
|
||||
.filterTitle { font-size: 32rpx; font-weight: bold; margin-bottom: 30rpx; }
|
||||
.filterItem { margin-bottom: 24rpx; }
|
||||
.filterLabel { display: block; font-size: 28rpx; color: #666; margin-bottom: 12rpx; }
|
||||
.filterValue { display: flex; align-items: center; justify-content: space-between; padding: 16rpx; background: #f5f5f5; border-radius: 8rpx; font-size: 28rpx; }
|
||||
.filterActions { display: flex; gap: 20rpx; margin-top: 40rpx; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user