From a841f6038d08521190ac1fd6b6bf68d147208ecc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?=
<14103883+leaf-phos@user.noreply.gitee.com>
Date: Fri, 21 Feb 2025 10:05:06 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/yh/reportProd.js | 10 +
src/components/Business/Price/PriceSelect.vue | 9 +-
.../edit-v2/components/ReportProductList.vue | 229 +++++++++++++-----
src/views/yh/report/edit-v2/index.vue | 42 ++--
.../ReportOrderProdDescriptions.vue | 2 +-
.../components/ReportUserProdDescriptions.vue | 2 +-
src/views/yh/reportProd/index.vue | 119 +++++----
7 files changed, 287 insertions(+), 126 deletions(-)
diff --git a/src/api/yh/reportProd.js b/src/api/yh/reportProd.js
index fead3d9..261e0d3 100644
--- a/src/api/yh/reportProd.js
+++ b/src/api/yh/reportProd.js
@@ -42,3 +42,13 @@ export function delReportProd(id) {
method: 'delete'
})
}
+
+// 刷新单价匹配报表产量
+export function refreshPriceMatchReportProd(ids) {
+ return request({
+ url: '/yh/reportProd/priceMatch',
+ method: 'put',
+ data: ids
+ })
+}
+
diff --git a/src/components/Business/Price/PriceSelect.vue b/src/components/Business/Price/PriceSelect.vue
index 105835d..19103a9 100644
--- a/src/components/Business/Price/PriceSelect.vue
+++ b/src/components/Business/Price/PriceSelect.vue
@@ -20,11 +20,11 @@
>
{{ item.name | dv}} ({{ item.price | dv }}元)
-
+
{{ item.code | dv}}
-
+
共{{ total }}条数据
@@ -35,7 +35,6 @@
import { listPrice } from '@/api/yh/price'
export default {
name: 'PriceSelect',
- dicts: ['price_status'],
props: {
value: {
type: String,
@@ -60,6 +59,10 @@ export default {
query: {
type: Object,
default: () => ({}),
+ },
+ priceStatus: {
+ type: Array,
+ default: () => [],
}
},
data() {
diff --git a/src/views/yh/report/edit-v2/components/ReportProductList.vue b/src/views/yh/report/edit-v2/components/ReportProductList.vue
index bb163bf..f43e2e6 100644
--- a/src/views/yh/report/edit-v2/components/ReportProductList.vue
+++ b/src/views/yh/report/edit-v2/components/ReportProductList.vue
@@ -7,33 +7,40 @@
clearable
size="mini"
style="width: 300px;"
- @keyup.enter.native="handleSearch"
- @clear="handleSearch"
- @input="handleSearch"
+ @keyup.enter.native="getList"
+ @clear="getList"
+ @change="getList"
>
-
+
+ 仅看无单价:
显示图案:
自动汇总良品:
- 修改所选员工产量
- 复制所选工序
- 删除所选工序
+ 批量修改员工产量
+ 批量复制
+ 批量删除
-
+
+
+ {{d.$index + (pageNum - 1) * pageSize + 1}}
+
+
@@ -43,7 +50,7 @@
-
+
@@ -91,7 +98,7 @@
- 新增工序
+ 新增工序
复制
-
+
-
+
+
+
+
+
{
+ return searchRegex.test(item.priceName) ||
+ searchRegex.test(item.priceCode) ||
+ searchRegex.test(item.priceCategory) ||
+ searchRegex.test(item.priceSize) ||
+ searchRegex.test(item.pricePattern);
+ });
+ }
+ if (this.onlyNoPrice) {
+ filteredList = filteredList.filter(item => {
+ return item.priceId == null;
+ });
+ }
+ this.total = filteredList.length;
+
+ // 计算分页起始和结束索引
+ const start = (this.pageNum - 1) * this.pageSize;
+ const end = start + this.pageSize;
+
+ // 使用Array.from优化数组切片,避免创建新数组
+ const data = Array.from({length: Math.min(this.pageSize, filteredList.length - start)},
+ (_, i) => filteredList[start + i]);
+
+ this.loadLoading = true;
+ this.loadIndex = 0;
+ this.loadTotal = data.length;
+
+ let batchSize = 1; // 每批加载条目
+ let timeout = 50; // 每批加载时间
+
+ // 若tableData长度与data长度一致,则加快加载速度
+ if (this.tableData.length == this.loadTotal) {
+ batchSize = this.pageSize;
+ timeout = 10;
+ }
+
+ // 使用setTimeout实现缓慢加载
+ const loadNextBatch = () => {
+ for(let i = 0; i < batchSize && this.loadIndex <= this.loadTotal; i++) {
+ const item = data[this.loadIndex];
+ if (item) {
+ // 直接替换或设置元素,而不是push
+ this.$set(this.tableData, this.loadIndex, item);
+ }
+ this.loadIndex++;
+ }
+
+ // 处理最后一页,删除多余数据
+ if (this.loadIndex >= this.loadTotal) {
+ // 如果tableData长度大于实际数据长度,删除多余元素
+ if (this.tableData.length > this.loadTotal) {
+ this.tableData.splice(this.loadTotal);
+ }
+ this.loadLoading = false;
+ } else {
+ setTimeout(loadNextBatch, timeout);
+ }
+ };
+
+ setTimeout(loadNextBatch, 100);
+ },
handleChangeShowPattern(val) {
localStorage.setItem("report_show_pattern", val);
},
@@ -240,6 +338,7 @@ export default {
selectPrice(index) {
this.$refs[`priceSelect${index}`].getOptionsAndSelectFirst();
},
+ // 优化展开行处理
handleDetail(row) {
// 展开行
this.$refs.table.toggleRowExpansion(row);
@@ -368,7 +467,6 @@ export default {
}
})
this.$message.success(`批量编辑成功,一共修改了${this.rows.length}行数据`);
- this.handleSearch();
})
},
// 复制所选工序
@@ -386,26 +484,49 @@ export default {
}).then(({ value }) => {
for (let i = 0; i < value; i++) {
for (let j = 0; j < this.rows.length; j++) {
- this.doCopy(null, this.rows[j]);
+ this.form.productList.push(this.getCopyData(null, this.rows[j]));
}
}
- this.$message.success(`复制成功,一共复制了${value * this.rows.length}行工序`);
+ // 如果当前在最后一页,调用getList刷新数据
+ if (Math.ceil(this.total / this.pageSize) === this.pageNum) {
+ this.getList();
+ }
})
},
- // 执行复制
- doCopy(index, row) {
+ // 获取复制数据
+ getCopyData(index, row) {
let data = JSON.parse(JSON.stringify(row));
+
+ // 清空ID
+ data.id = null;
+ if (data.userProdList != null) {
+ data.userProdList.forEach(item => {
+ item.id = null;
+ })
+ }
+ if (data.orderProdList != null) {
+ data.orderProdList.forEach(item => {
+ item.id = null;
+ })
+ }
+
+ // 重新排序
if (index == null) {
data.sort = this.getNewSort();
} else {
data.sort = row.sort + 1;
- for (let i = index + 1 ; i < this.form.productList.length; i ++) {
- this.form.productList[i].sort ++;
- }
+ }
+
+ return data;
+ },
+ doCopy(index, row) {
+ let data = this.getCopyData(index, row);
+ for (let i = index + 1 ; i < this.form.productList.length; i ++) {
+ this.form.productList[i].sort ++;
}
this.form.productList.push(data);
- this.handleSearch();
this.reorder();
+ this.getList();
},
// 选择行
handleSelectionChange(selection) {
@@ -414,9 +535,13 @@ export default {
isEmpty,
// 新增行
handleAdd() {
- this.form.productList.push(this.getNewRow());
- this.handleSearch();
- this.reorder();
+ let row = this.getNewRow();
+ this.form.productList.push(row);
+ this.total ++;
+ // 如果当前在最后一页,直接加入数据
+ if (Math.ceil(this.total / this.pageSize) <= this.pageNum) {
+ this.tableData.push(row);
+ }
},
// 获取新的行
getNewRow() {
@@ -502,23 +627,9 @@ export default {
}
this.$message.success(`删除成功,一共删除了${this.rows.length}行工序`);
this.rows = [];
- this.handleSearch();
+ this.getList();
});
},
- handleSearch() {
- if (!this.searchKey) {
- this.filteredProductList = this.form.productList;
- return;
- }
- const key = this.searchKey.toLowerCase();
- this.filteredProductList = this.form.productList.filter(item => {
- const priceName = (item.priceName || '').toLowerCase();
- const priceCode = (item.priceCode || '').toLowerCase();
- const surface = (item.surface || '').toLowerCase();
- const color = (item.color || '').toLowerCase();
- return priceName.includes(key) || priceCode.includes(key) || surface.includes(key) || color.includes(key);
- });
- }
}
}
diff --git a/src/views/yh/report/edit-v2/index.vue b/src/views/yh/report/edit-v2/index.vue
index aa26cc2..eeb31bc 100644
--- a/src/views/yh/report/edit-v2/index.vue
+++ b/src/views/yh/report/edit-v2/index.vue
@@ -37,12 +37,15 @@
-
+
-
+
-
@@ -97,9 +100,6 @@ export default {
{ required: true, message: "报表日期不能为空", trigger: "blur" }
],
productList: {
- priceId: [
- { required: true, message: "工序不能为空", trigger: "blur" }
- ],
isEnd: [
{ required: true, message: "是否成品不能为空", trigger: "blur" }
],
@@ -127,6 +127,11 @@ export default {
autoSaveInterval: null,
saveTime: null,
init: false,
+
+ loadLoading: false, // 加载状态
+ loadIndex: 0, // 加载索引
+ loadTotal: 0, // 加载总数
+ loadInterval: null, // 加载间隔
}
},
computed: {
@@ -184,8 +189,10 @@ export default {
// 10秒自动保存一次
if (this.autoSaveInterval == null) {
this.autoSaveInterval = setInterval(() => {
- this.saveTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}');
- localStorage.setItem('report', JSON.stringify(this.form));
+ if (this.form != null) {
+ this.saveTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}');
+ localStorage.setItem('report', JSON.stringify(this.form));
+ }
}, 1000 * 10);
}
},
@@ -202,7 +209,11 @@ export default {
},
// 获取保存的数据
getLocalSave() {
- return JSON.parse(localStorage.getItem('report'));
+ let save = localStorage.getItem('report');
+ if (save == null) {
+ return null;
+ }
+ return JSON.parse(save);
},
handleEditProduct(row, index) {
this.row = row;
@@ -232,9 +243,12 @@ export default {
getReport(reportId, {needProductList: true, needUserProd: true, needOrderProd: true}).then(response => {
this.form = response.data;
this.init = true;
+ }).catch(error => {
+ this.$modal.msgError("获取数据失败");
+ console.error(error);
}).finally(() => {
this.loading = false;
- })
+ });
},
submitForm(submit) {
this.$refs["form"].validate(valid => {
@@ -301,17 +315,13 @@ export default {
}
}
return null;
- }
+ },
}
}
\ No newline at end of file
diff --git a/src/views/yh/reportProd/components/ReportOrderProdDescriptions.vue b/src/views/yh/reportProd/components/ReportOrderProdDescriptions.vue
index 782fc12..6eb759b 100644
--- a/src/views/yh/reportProd/components/ReportOrderProdDescriptions.vue
+++ b/src/views/yh/reportProd/components/ReportOrderProdDescriptions.vue
@@ -1,7 +1,7 @@
-
+
{{item.orderErpBillNo | dv}}
{{item.num | fix2 | dv}} {{priceUnit}}
diff --git a/src/views/yh/reportProd/components/ReportUserProdDescriptions.vue b/src/views/yh/reportProd/components/ReportUserProdDescriptions.vue
index df325d7..fa9a8ed 100644
--- a/src/views/yh/reportProd/components/ReportUserProdDescriptions.vue
+++ b/src/views/yh/reportProd/components/ReportUserProdDescriptions.vue
@@ -1,5 +1,5 @@
-
+
{{item.userName | dv}}
{{item.num | dv}} {{priceUnit}}
diff --git a/src/views/yh/reportProd/index.vue b/src/views/yh/reportProd/index.vue
index deddc81..b191fc3 100644
--- a/src/views/yh/reportProd/index.vue
+++ b/src/views/yh/reportProd/index.vue
@@ -1,6 +1,6 @@
-
+
+
+
+ 全部
+ 有单价
+ 无单价
+
+
搜索
重置
@@ -41,6 +48,17 @@
+
+ 刷新单价
+
-
+
{{d.row.priceCategory | dv}}
{{d.row.priceSize | dv}}
{{d.row.pricePattern | dv}}
@@ -114,17 +132,27 @@
-
+
-
+
-
-
+
+ {{d.row[column.key] | dv}} {{d.row.priceUnit | dv}}
-
+
{{d.row[column.key] | dv}} 元
+
+
+ {{d.row[column.key] | dv}} 元
+
+
+
+ 暂无单价
+
+
+
{{d.row[column.key] | dv}}
@@ -134,24 +162,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ 修改报表
+
+