276 lines
9.3 KiB
Vue
276 lines
9.3 KiB
Vue
<template>
|
|
<view>
|
|
<view class="filterBar">
|
|
<u-search v-model="filters.order_no" placeholder="进仓单号" :show-action="false" @search="applySearch" @custom="applySearch" @clear="applySearch" />
|
|
<view class="filterBtn" :class="{ 'filter-active': hasActiveFilter }" @click="filterShow = true">
|
|
<view class="filterBtn__icon">
|
|
<u-icon :key="filterIconColor" name="list" size="44" :color="filterIconColor"></u-icon>
|
|
<view v-if="hasActiveFilter" class="filterBtn__badge"></view>
|
|
</view>
|
|
<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" @close="cancelFilterEdit">
|
|
<view class="filterPanel">
|
|
<view class="filterTitle">筛选条件</view>
|
|
<view class="filterItem">
|
|
<text class="filterLabel">进仓单号</text>
|
|
<view class="filterInput">
|
|
<u-input v-model="filters.order_no" placeholder="请输入进仓单号" :height="100" :custom-style="{ fontSize: '36rpx', color: '#202328' }" placeholder-style="color: #aeb4bf; font-size: 34rpx;" />
|
|
</view>
|
|
</view>
|
|
<view class="filterItem" @click="openSupplierSelect">
|
|
<text class="filterLabel">供应商</text>
|
|
<view class="filterValue">{{ supplierLabel || '全部' }} <u-icon name="arrow-right" size="36"></u-icon></view>
|
|
</view>
|
|
<view class="filterItem" @click="openWarehouseSelect">
|
|
<text class="filterLabel">仓库</text>
|
|
<view class="filterValue">{{ warehouseLabel || '全部' }} <u-icon name="arrow-right" size="36"></u-icon></view>
|
|
</view>
|
|
<view class="filterItem" @click="openStatusSelect">
|
|
<text class="filterLabel">订单状态</text>
|
|
<view class="filterValue">{{ statusLabel || '全部' }} <u-icon name="arrow-right" size="36"></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 class="pdaSelect" v-model="statusSelectShow" title="选择订单状态" :list="statusSelectList" :default-value="statusSelectDefault" @confirm="onStatusConfirm"></u-select>
|
|
<u-select class="pdaSelect" v-model="unitSelectShow" :list="unitSelectList" :default-value="unitSelectDefault" remote :loading="selectSearching" @search="onUnitSearch" @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,
|
|
AUDIT_STATUS_MAP,
|
|
BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER,
|
|
WAREHOUSE_TYPE_FINISHED,
|
|
formatRoll,
|
|
mapToSelectOptions,
|
|
fetchAllOrderList,
|
|
} from '@/common/storeGoodsPurchaseIn';
|
|
import { withNameParam } from '@/common/remoteSelect';
|
|
import listFilterMixin from '@/mixins/listFilterMixin';
|
|
|
|
export default {
|
|
components: { addBtn, PurchaseInItem },
|
|
mixins: [listFilterMixin],
|
|
data() {
|
|
return {
|
|
list: [],
|
|
scrollHeight: '667px',
|
|
triggered: false,
|
|
listLoading: false,
|
|
filterShow: false,
|
|
statusSelectShow: false,
|
|
unitSelectShow: false,
|
|
unitSelectType: '',
|
|
supplierOptions: [],
|
|
warehouseOptions: [],
|
|
unitOptionsLoading: false,
|
|
selectSearching: false,
|
|
unitSearchSeq: 0,
|
|
unitSelectList: [{ value: '', label: '全部' }],
|
|
filterStorageKey: 'storeGoodsPurchaseInListFilters_v2',
|
|
filters: {
|
|
order_no: '',
|
|
supplier_id: '',
|
|
supplier_name: '',
|
|
warehouse_id: '',
|
|
warehouse_name: '',
|
|
audit_status: AUDIT_STATUS.PENDING,
|
|
},
|
|
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 || '';
|
|
},
|
|
},
|
|
onLoad() {
|
|
uni.setNavigationBarTitle({ title: '成品采购进仓' });
|
|
this.restoreFilterCache();
|
|
uni.getSystemInfo({
|
|
success: (res) => {
|
|
this.scrollHeight = `${res.windowHeight - 50}px`;
|
|
},
|
|
});
|
|
},
|
|
onShow() {
|
|
this.loadList();
|
|
},
|
|
methods: {
|
|
createDefaultFilters() {
|
|
return {
|
|
order_no: '',
|
|
supplier_id: '',
|
|
supplier_name: '',
|
|
warehouse_id: '',
|
|
warehouse_name: '',
|
|
audit_status: AUDIT_STATUS.PENDING,
|
|
};
|
|
},
|
|
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) {
|
|
this.unitSelectType = type;
|
|
const cache = type === 'warehouse' ? this.warehouseOptions : this.supplierOptions;
|
|
this.applyUnitSelectList(cache);
|
|
this.unitSelectShow = true;
|
|
},
|
|
onUnitSearch(keyword) {
|
|
const seq = ++this.unitSearchSeq;
|
|
const type = this.unitSelectType;
|
|
const empty = !String(keyword || '').trim();
|
|
this.selectSearching = true;
|
|
const req = type === 'warehouse'
|
|
? this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
|
|
: this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER }, keyword));
|
|
req.then((res) => {
|
|
if (seq !== this.unitSearchSeq) return;
|
|
const list = mapToSelectOptions(res);
|
|
if (empty) {
|
|
if (type === 'warehouse') this.warehouseOptions = list;
|
|
else this.supplierOptions = list;
|
|
}
|
|
this.applyUnitSelectList(list, empty);
|
|
}).catch((e) => {
|
|
if (seq !== this.unitSearchSeq) return;
|
|
uni.showToast({ title: (e && e.message) || '搜索失败', icon: 'none' });
|
|
}).then(() => {
|
|
if (seq === this.unitSearchSeq) this.selectSearching = false;
|
|
}, () => {
|
|
if (seq === this.unitSearchSeq) this.selectSearching = 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 filters = this.appliedFilters || this.filters;
|
|
const params = {};
|
|
if (filters.order_no) params.order_no = filters.order_no;
|
|
if (filters.supplier_id) params.supplier_id = filters.supplier_id;
|
|
if (filters.warehouse_id) params.warehouse_id = filters.warehouse_id;
|
|
if (this.hasFilterValue(filters.audit_status)) {
|
|
params.audit_status = 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; },
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
@import '@/common/list-filter.scss';
|
|
</style>
|