fix(storefabric): 限制接收单位下拉仅显示织厂类型

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
李天佑 2026-07-04 11:19:22 +08:00
parent 530ca0c3ad
commit 02f192cac6
3 changed files with 42 additions and 21 deletions

View File

@ -69,6 +69,9 @@ export const BILL_TYPES = [
/** 列表分页拉取每页条数 */ /** 列表分页拉取每页条数 */
export const LIST_PAGE_SIZE = 100; export const LIST_PAGE_SIZE = 100;
/** 往来单位类型:织厂(接收单位下拉筛选) */
export const BUSINESS_UNIT_TYPE_KNITTING_FACTORY = 11;
export function getStatusOptions() { export function getStatusOptions() {
return Object.keys(AUDIT_STATUS_MAP).map((value) => ({ return Object.keys(AUDIT_STATUS_MAP).map((value) => ({
value, value,

View File

@ -70,6 +70,7 @@ import {
getStatusOptions, getStatusOptions,
AUDIT_STATUS_MAP, AUDIT_STATUS_MAP,
BILL_TYPES, BILL_TYPES,
BUSINESS_UNIT_TYPE_KNITTING_FACTORY,
formatRoll, formatRoll,
mapToSelectOptions, mapToSelectOptions,
fetchAllOrderList, fetchAllOrderList,
@ -86,7 +87,8 @@ export default {
statusSelectShow: false, statusSelectShow: false,
unitSelectShow: false, unitSelectShow: false,
unitSelectType: '', unitSelectType: '',
unitOptions: [], deliveryUnitOptions: [],
businessUnitOptions: [],
unitOptionsLoading: false, unitOptionsLoading: false,
billTypeName: (BILL_TYPES[0] || {}).label || '坯布其他出货单', billTypeName: (BILL_TYPES[0] || {}).label || '坯布其他出货单',
filters: { filters: {
@ -117,7 +119,8 @@ export default {
return this.filters.business_unit_name || ''; return this.filters.business_unit_name || '';
}, },
unitSelectList() { unitSelectList() {
return [{ value: '', label: '全部' }, ...this.unitOptions]; const options = this.unitSelectType === 'delivery' ? this.deliveryUnitOptions : this.businessUnitOptions;
return [{ value: '', label: '全部' }, ...options];
}, },
}, },
onLoad() { onLoad() {
@ -127,39 +130,53 @@ export default {
this.scrollHeight = `${res.windowHeight - 50}px`; this.scrollHeight = `${res.windowHeight - 50}px`;
}, },
}); });
this.loadUnitOptions();
this.loadList(); this.loadList();
}, },
onShow() { onShow() {
this.loadList(); this.loadList();
}, },
methods: { methods: {
loadUnitOptions() { loadDeliveryUnitOptions() {
if (this.unitOptions.length || this.unitOptionsLoading) return Promise.resolve(this.unitOptions); if (this.deliveryUnitOptions.length) return Promise.resolve(this.deliveryUnitOptions);
this.unitOptionsLoading = true;
return this.$u.api.businessUnit.list({}) return this.$u.api.businessUnit.list({})
.then((res) => { .then((res) => {
this.unitOptions = mapToSelectOptions(res); this.deliveryUnitOptions = mapToSelectOptions(res);
return this.unitOptions; return this.deliveryUnitOptions;
}) })
.catch(() => { .catch(() => {
this.unitOptions = []; this.deliveryUnitOptions = [];
return this.unitOptions; return this.deliveryUnitOptions;
});
},
loadBusinessUnitOptions() {
if (this.businessUnitOptions.length) return Promise.resolve(this.businessUnitOptions);
return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_KNITTING_FACTORY })
.then((res) => {
this.businessUnitOptions = mapToSelectOptions(res);
return this.businessUnitOptions;
})
.catch(() => {
this.businessUnitOptions = [];
return this.businessUnitOptions;
});
},
openUnitSelect(type) {
if (this.unitOptionsLoading) return;
this.unitOptionsLoading = true;
const loadFn = type === 'delivery' ? this.loadDeliveryUnitOptions : this.loadBusinessUnitOptions;
loadFn.call(this)
.then((list) => {
if (!list.length) {
uni.showToast({ title: '暂无可选单位', icon: 'none' });
return;
}
this.unitSelectType = type;
this.unitSelectShow = true;
}) })
.finally(() => { .finally(() => {
this.unitOptionsLoading = false; this.unitOptionsLoading = false;
}); });
}, },
openUnitSelect(type) {
this.loadUnitOptions().then((list) => {
if (!list.length) {
uni.showToast({ title: '暂无可选单位', icon: 'none' });
return;
}
this.unitSelectType = type;
this.unitSelectShow = true;
});
},
openDeliveryUnitSelect() { openDeliveryUnitSelect() {
this.openUnitSelect('delivery'); this.openUnitSelect('delivery');
}, },

View File

@ -13,6 +13,7 @@ import scanMixin from '@/common/scanMixin.js';
import { import {
AUDIT_STATUS_MAP, AUDIT_STATUS_MAP,
BILL_TYPES, BILL_TYPES,
BUSINESS_UNIT_TYPE_KNITTING_FACTORY,
normalizeOrder, normalizeOrder,
mapToSelectOptions, mapToSelectOptions,
getFineCodeScanCode, getFineCodeScanCode,
@ -135,7 +136,7 @@ export default {
}, },
ensureBusinessUnitOptions() { ensureBusinessUnitOptions() {
if (this.businessUnitOptions.length) return Promise.resolve(this.businessUnitOptions); if (this.businessUnitOptions.length) return Promise.resolve(this.businessUnitOptions);
return this.$u.api.businessUnit.list({}) return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_KNITTING_FACTORY })
.then((res) => { .then((res) => {
this.businessUnitOptions = mapToSelectOptions(res); this.businessUnitOptions = mapToSelectOptions(res);
return this.businessUnitOptions; return this.businessUnitOptions;