This commit is contained in:
quantulr
2023-09-01 17:14:27 +08:00
parent a09291a1c8
commit cf3e2db09d
27 changed files with 308 additions and 330 deletions

View File

@ -10,6 +10,9 @@ Page({
data: {
permissions: [],
authToken: undefined,
storageLoadingStatus: 1,
inLoadingStatus: 1,
outLoadingStatus: 1,
stockType: 0, // 库存类型
// 统计数据
statisticsData: {
@ -47,6 +50,16 @@ Page({
storageCompleted: false,
inStockCompleted: false,
outStockCompleted: false,
types: [
{
label: "入库",
value: "1",
},
{
label: "出库",
value: "2",
},
],
},
onTabsChange(e: any) {
const { value: stockType } = e.detail;
@ -91,11 +104,13 @@ Page({
if (stockType == 1) {
this.setData({
inStockLoading: true,
inLoadingStatus: 0,
});
query = inStockQuery;
} else if (stockType == 2) {
this.setData({
outStockLoading: true,
outLoadingStatus: 0,
});
query = outStockQuery;
} else {
@ -117,6 +132,7 @@ Page({
this.setData({
inStockCompleted: completed,
inLoadingStatus: completed ? 3 : 1,
// @ts-ignore
inStockList: [
...this.data.inStockList,
@ -147,6 +163,7 @@ Page({
}
this.setData({
outStockCompleted: completed,
outLoadingStatus: completed ? 3 : 1,
// @ts-ignore
outStockList: [
...this.data.outStockList,
@ -170,46 +187,77 @@ Page({
}
}
} catch (error) {
if (stockType == 1) {
this.setData({
inLoadingStatus: 2,
});
} else if (stockType == 2) {
this.setData({
outLoadingStatus: 2,
});
}
console.log(error);
}
if (this.data.stockType == 1) {
if (stockType == 1) {
this.setData({
inStockLoading: false,
});
} else if (this.data.stockType == 2) {
} else if (stockType == 2) {
this.setData({
outStockLoading: false,
});
}
},
/**
* 获取库存列表
*/
async getStorageList() {
this.setData({
storageLoading: false,
storageLoading: true,
storageLoadingStatus: 0,
});
const { storageQuery } = this.data;
try {
const resp: any = await storageList(storageQuery);
let completed = false;
if (
Math.ceil(resp.total / storageQuery.pageSize) == storageQuery.pageNum
) {
completed = true;
}
const rows = resp.rows.map((el: any) => {
const specUrls = el.specPic?.split(",") ?? [];
const specPics = specUrls.map((pic: string) => {
let url;
if (pic.startsWith("https://") || pic.startsWith("http://")) {
url = pic;
} else {
url = `${httpClient.baseUrl}${pic}`;
}
return url;
});
return {
...el,
specPics,
};
});
this.setData({
// @ts-ignore
storageList: [...this.data.storageList, ...resp.rows],
storageList: [...this.data.storageList, ...rows],
storageCompleted: completed,
storageLoadingStatus: completed ? 3 : 1,
});
if (!completed) {
this.setData({
[`storageQuery.pageNum`]: storageQuery.pageNum + 1,
});
}
} catch (error) {}
} catch (error) {
this.setData({
storageLoadingStatus: 2,
});
}
this.setData({
storageLoading: false,
});