Browse Source

商品库存优化

hcf 1 year ago
parent
commit
49fc760fc6
1 changed files with 63 additions and 12 deletions
  1. 63 12
      src/views/audit/store/index.vue

+ 63 - 12
src/views/audit/store/index.vue

@@ -1,7 +1,7 @@
 <template>
 	<div class="my-container">
 		<div class="bill-main">
-			<module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="search" @resert="onRefresh"
+			<module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList" @resert="onRefresh"
 				@detail="shortBarge" @onRefresh="onRefresh">
 			</module-view>
 		</div>
@@ -34,7 +34,7 @@
 							label: '标题',
 							prop: 'skuTitle',
 							component: 'by-input',
-							labelWidth: '70px',
+							// labelWidth: '70px',
 							compConfig: {
 								attr: {
 									placeholder: '请输入标题',
@@ -47,7 +47,7 @@
 							label: '物料编码',
 							prop: 'skuCode',
 							component: 'by-input',
-							labelWidth: '70px',
+							// labelWidth: '70px',
 							compConfig: {
 								attr: {
 									placeholder: '请输入物料编码',
@@ -81,14 +81,14 @@
 				},
 				columns: [
 					{
-						width: '200px',
+						// width: '200px',
 						title: '标题',
 						field: 'skuTitle',
 						// isDetail: true,
 						fixed: 'left'
 					},
 					{
-						width: '200px',
+						// width: '200px',
 						title: '副标题',
 						field: 'skuSubtitle',
 					},
@@ -128,8 +128,62 @@
 				return
 			}
 			clearInterval(this.timer)
-			this.getPageList();
+			// this.getPageList(); //旧代码无分页
+			
+			// 新分页
+			let query = (this.$refs.moduleView as any).getQuery();
+			this.newsGetPageList(query)
 		}
+		// 新分页
+		newsGetPageList(query : any) {
+			let loading = this.$loading({ target: '.main-container' });
+			api.getMaterialInventory().then((res : any) => {
+				if (res.code === 200) {
+					this.skuInfo = res.data;
+				} else loading.close();
+			}).then(() => {
+				api.pageList({}, 'maindataStorehouse').then((res : any) => {
+					if (res.code === 200) {
+						this.storeHouseInfo = res.data.records;
+					} else loading.close();
+					if (res.code === 200) {
+						let moduleConfig = (this as any).$lodash.cloneDeep(this.config.table);
+						this.storeHouseInfo = res.data.records;
+						res.data.records.map((v : any, i : any) => {
+							moduleConfig.columns.push({
+								// width: '150px',
+								title: v.name,
+								field: 'custom' + i,
+							});
+						});
+						(this as any).$refs.moduleView.setTableConfig(moduleConfig);
+					}
+				}).then(() => {
+					api.pageList(query, 'maindataMaterialSku').then((res : any) => {
+						loading.close();
+						if (res.code === 200) {
+							for (let i = 0; i < res.data.records.length; i++) {
+								for (let j = 0; j < this.storeHouseInfo.length; j++) {
+									let nowData = this.skuInfo.filter((v : any) => v.skuId == res.data.records[i].id && v.storeHouseId == this.storeHouseInfo[j].id);
+									if (nowData[0]) res.data.records[i]['custom' + j] = nowData[0].inventory;
+								}
+							}
+							(this.$refs.moduleView as any).setTableValue(res.data.records);
+							this.tableInfo = res.data.records;
+							loading.close();
+							let page = {
+								pageNo: res.data.current, //当前页
+								pageSize: res.data.size, //每页条数
+								total: res.data.total //总条数
+							};
+							(this.$refs.moduleView as any).setPage(page);
+						} else this.$message.error(res.msg);
+					}).catch(() => loading.close());
+				}).catch(() => loading.close());
+			}).catch(() => loading.close());
+		}
+		
+		//旧代码无分页
 		getPageList() {
 			let loading = this.$loading({ target: '.main-container' });
 			api.getMaterialInventory().then((res : any) => {
@@ -137,10 +191,7 @@
 					this.skuInfo = res.data;
 				} else loading.close();
 			}).then(() => {
-				api.pageList({
-					pageNum: 1,
-					pageSize: 9999,
-				}, 'maindataStorehouse').then((res : any) => {
+				api.pageList({}, 'maindataStorehouse').then((res : any) => {
 					if (res.code === 200) {
 						this.storeHouseInfo = res.data.records;
 					} else loading.close();
@@ -176,8 +227,8 @@
 					}
 				}).then(() => {
 					api.pageList({
-						pageNum: 1,
-						pageSize: 9999
+						pageNo: 1,
+						pageSize: 20,
 					}, 'maindataMaterialSku').then((res : any) => {
 						if (res.code === 200) {
 							for (let i = 0; i < res.data.records.length; i++) {