@@ -47,7 +47,7 @@
|
||||
</u-popup>
|
||||
|
||||
<u-select v-model="statusSelectShow" :list="statusSelectList" @confirm="onStatusConfirm"></u-select>
|
||||
<u-select v-model="unitSelectShow" :list="unitSelectList" @confirm="onUnitConfirm"></u-select>
|
||||
<u-select v-model="unitSelectShow" :list="unitSelectList" remote :loading="selectSearching" @search="onUnitSearch" @confirm="onUnitConfirm"></u-select>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -63,6 +63,7 @@ import {
|
||||
mapToSelectOptions,
|
||||
fetchAllOrderList,
|
||||
} from '@/common/storeGoodsPurchaseIn';
|
||||
import { withNameParam } from '@/common/remoteSelect';
|
||||
|
||||
export default {
|
||||
components: { addBtn, PurchaseInItem },
|
||||
@@ -79,6 +80,9 @@ export default {
|
||||
supplierOptions: [],
|
||||
warehouseOptions: [],
|
||||
unitOptionsLoading: false,
|
||||
selectSearching: false,
|
||||
unitSearchSeq: 0,
|
||||
unitSelectList: [{ value: '', label: '全部' }],
|
||||
filters: {
|
||||
order_no: '',
|
||||
supplier_id: '',
|
||||
@@ -104,10 +108,6 @@ export default {
|
||||
warehouseLabel() {
|
||||
return this.filters.warehouse_name || '';
|
||||
},
|
||||
unitSelectList() {
|
||||
const options = this.unitSelectType === 'warehouse' ? this.warehouseOptions : this.supplierOptions;
|
||||
return [{ value: '', label: '全部' }, ...options];
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
uni.setNavigationBarTitle({ title: '成品采购进仓' });
|
||||
@@ -145,22 +145,40 @@ export default {
|
||||
return this.warehouseOptions;
|
||||
});
|
||||
},
|
||||
applyUnitSelectList(list) {
|
||||
const rows = Array.isArray(list) ? list.slice() : [];
|
||||
this.unitSelectList = [{ value: '', label: '全部' }].concat(rows);
|
||||
},
|
||||
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;
|
||||
});
|
||||
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);
|
||||
}).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');
|
||||
|
||||
Reference in New Issue
Block a user