|
|
@@ -118,7 +118,9 @@
|
|
|
ref="table12"
|
|
|
:columns="tableColumns"
|
|
|
:datasource="sourceList"
|
|
|
+ :needPage="false"
|
|
|
@selection-change="handleSelectionChange"
|
|
|
+ height="500"
|
|
|
>
|
|
|
<template
|
|
|
v-slot:toolbar
|
|
|
@@ -249,7 +251,7 @@
|
|
|
ref="showSampleListTable"
|
|
|
:data="paginatedSampleList"
|
|
|
tooltip-effect="dark"
|
|
|
- :max-height="300"
|
|
|
+ height="500"
|
|
|
border
|
|
|
row-key="sampleCode"
|
|
|
>
|
|
|
@@ -270,7 +272,7 @@
|
|
|
></el-table-column>
|
|
|
</template>
|
|
|
</el-table>
|
|
|
- <el-pagination
|
|
|
+ <!-- <el-pagination
|
|
|
v-show="activeName === '2' && sampleList.length > 0"
|
|
|
@size-change="handleSampleSizeChange"
|
|
|
@current-change="handleSampleCurrentChange"
|
|
|
@@ -280,7 +282,7 @@
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
:total="samplePagination.total"
|
|
|
style="margin-top: 10px"
|
|
|
- ></el-pagination>
|
|
|
+ ></el-pagination> -->
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="质检方案" name="3">
|
|
|
<el-button
|
|
|
@@ -295,7 +297,7 @@
|
|
|
ref="showSchemeListTable"
|
|
|
:data="paginatedSchemeList"
|
|
|
tooltip-effect="dark"
|
|
|
- :max-height="300"
|
|
|
+ height="500"
|
|
|
border
|
|
|
row-key="id"
|
|
|
>
|
|
|
@@ -388,7 +390,7 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
- <el-pagination
|
|
|
+ <!-- <el-pagination
|
|
|
v-show="activeName === '3' && schemeList.length > 0"
|
|
|
@size-change="handleSchemeSizeChange"
|
|
|
@current-change="handleSchemeCurrentChange"
|
|
|
@@ -398,7 +400,7 @@
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
:total="schemePagination.total"
|
|
|
style="margin-top: 10px"
|
|
|
- ></el-pagination>
|
|
|
+ ></el-pagination> -->
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
</el-row>
|
|
|
@@ -435,7 +437,7 @@
|
|
|
import baseInfo from './new-baseInfo.vue';
|
|
|
// 质检方案的弹窗
|
|
|
import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
|
|
|
- import { getCode } from '@/api/login';
|
|
|
+ import { getCode, getCodeList } from '@/api/login';
|
|
|
import { save, update, planIssued } from '@/api/inspectionPlan';
|
|
|
import {
|
|
|
getQualityTemplateList,
|
|
|
@@ -637,14 +639,18 @@
|
|
|
watch: {
|
|
|
// 样品清单
|
|
|
sampleList: {
|
|
|
- handler(newVal) {
|
|
|
+ handler: async function (newVal) {
|
|
|
// 计算重量跟数量
|
|
|
this.calculate(newVal);
|
|
|
- newVal.map(async (el) => {
|
|
|
- if (!el.sampleCode) {
|
|
|
- el.sampleCode = await this.getSampleCode();
|
|
|
- }
|
|
|
- });
|
|
|
+ if (newVal && newVal.length > 0 && !newVal[0].sampleCode) {
|
|
|
+ let count = newVal ? newVal.length : 0;
|
|
|
+ const codeList = await this.batchCodes(count);
|
|
|
+ newVal.map(async (el, index) => {
|
|
|
+ if (!el.sampleCode) {
|
|
|
+ el.sampleCode = codeList[index];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
deep: true,
|
|
|
immediate: true
|
|
|
@@ -716,7 +722,8 @@
|
|
|
label: '供应商代号',
|
|
|
prop: 'supplierCode',
|
|
|
align: 'center',
|
|
|
- width: '120'
|
|
|
+ width: '120',
|
|
|
+ showOverflowTooltip: true
|
|
|
},
|
|
|
{ label: '刻码', prop: 'engrave', align: 'center' },
|
|
|
{ label: '重量', prop: 'weight', align: 'center' },
|
|
|
@@ -759,33 +766,36 @@
|
|
|
//分页后的来源列表
|
|
|
paginatedSourceList() {
|
|
|
console.log('分页', this.sourceList);
|
|
|
- const { currentPage, pageSize } = this.sourcePagination;
|
|
|
- const start = (currentPage - 1) * pageSize;
|
|
|
- const end = start + pageSize;
|
|
|
- return this.sourceList.slice(start, end);
|
|
|
+ // const { currentPage, pageSize } = this.sourcePagination;
|
|
|
+ // const start = (currentPage - 1) * pageSize;
|
|
|
+ // const end = start + pageSize;
|
|
|
+ // return this.sourceList.slice(start, end);
|
|
|
+ return this.sourceList;
|
|
|
},
|
|
|
|
|
|
// 分页后的样品列表
|
|
|
paginatedSampleList() {
|
|
|
- if (this.rowIds && this.isSampleList) {
|
|
|
- console.log(this.sampleList, 'sampleList');
|
|
|
- return this.sampleList;
|
|
|
- }
|
|
|
- const { currentPage, pageSize } = this.samplePagination;
|
|
|
- const start = (currentPage - 1) * pageSize;
|
|
|
- const end = start + pageSize;
|
|
|
- return this.sampleList.slice(start, end);
|
|
|
+ return this.sampleList;
|
|
|
+ // if (this.rowIds && this.isSampleList) {
|
|
|
+ // console.log(this.sampleList, 'sampleList');
|
|
|
+ // return this.sampleList;
|
|
|
+ // }
|
|
|
+ // const { currentPage, pageSize } = this.samplePagination;
|
|
|
+ // const start = (currentPage - 1) * pageSize;
|
|
|
+ // const end = start + pageSize;
|
|
|
+ // return this.sampleList.slice(start, end);
|
|
|
},
|
|
|
// 分页后的质检方案列表
|
|
|
paginatedSchemeList() {
|
|
|
- if (this.rowIds && this.isScheme) {
|
|
|
- console.log(this.schemeList, 'test');
|
|
|
- return this.schemeList;
|
|
|
- }
|
|
|
- const { currentPage, pageSize } = this.schemePagination;
|
|
|
- const start = (currentPage - 1) * pageSize;
|
|
|
- const end = start + pageSize;
|
|
|
- return this.schemeList.slice(start, end);
|
|
|
+ // if (this.rowIds && this.isScheme) {
|
|
|
+ // console.log(this.schemeList, 'test');
|
|
|
+ // return this.schemeList;
|
|
|
+ // }
|
|
|
+ // const { currentPage, pageSize } = this.schemePagination;
|
|
|
+ // const start = (currentPage - 1) * pageSize;
|
|
|
+ // const end = start + pageSize;
|
|
|
+ // return this.schemeList.slice(start, end);
|
|
|
+ return this.schemeList;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -1268,21 +1278,22 @@
|
|
|
return list;
|
|
|
},
|
|
|
async getSampleList(id) {
|
|
|
- let res = await getSampleListByPlanId({
|
|
|
- planId: id,
|
|
|
- pageNum: this.samplePagination.currentPage,
|
|
|
- size: this.samplePagination.pageSize
|
|
|
- });
|
|
|
+ // console.log('执行?')
|
|
|
+ // let res = await getSampleListByPlanId({
|
|
|
+ // planId: id,
|
|
|
+ // pageNum: this.samplePagination.currentPage,
|
|
|
+ // size: this.samplePagination.pageSize
|
|
|
+ // });
|
|
|
|
|
|
- this.sampleList = res?.list || [];
|
|
|
- this.samplePagination.total = res.count;
|
|
|
+ // this.sampleList = res?.list || [];
|
|
|
+ // this.samplePagination.total = res.count;
|
|
|
|
|
|
let newRes = await getSampleListByPlanId({
|
|
|
planId: id,
|
|
|
pageNum: 1,
|
|
|
size: -1
|
|
|
});
|
|
|
-
|
|
|
+ this.sampleList = newRes?.list || [];
|
|
|
this.newSampleList = newRes?.list || [];
|
|
|
},
|
|
|
|
|
|
@@ -1290,7 +1301,8 @@
|
|
|
let res = await getTemplateListByPlanId({
|
|
|
planId: id,
|
|
|
pageNum: this.schemePagination.currentPage,
|
|
|
- size: this.schemePagination.pageSize
|
|
|
+ // size: this.schemePagination.pageSize,
|
|
|
+ size: 100000
|
|
|
});
|
|
|
this.schemeList = res?.list || [];
|
|
|
this.schemePagination.total = res.count;
|
|
|
@@ -1681,6 +1693,7 @@
|
|
|
oldItem.qualitySampleTemplateList = JSON.parse(
|
|
|
JSON.stringify(this.schemeList)
|
|
|
);
|
|
|
+
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
ProductSampleList.push({
|
|
|
...oldItem,
|
|
|
@@ -1721,23 +1734,35 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 批量生成编码 4444444 getCodeList
|
|
|
+ async batchCodes(count) {
|
|
|
+ if (count <= 0) return;
|
|
|
+ let params = { count };
|
|
|
+ const res = await getCodeList('sample_code', params);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+
|
|
|
//更新样品清单数据
|
|
|
async updatePackingList(list) {
|
|
|
+ console.log('进来了没有 pppppp');
|
|
|
// 计量类型1是数量,2是重量
|
|
|
- if (this.baseForm.inspectionStandards == 1) {
|
|
|
- this.createSampleList(list);
|
|
|
- }
|
|
|
-
|
|
|
+ // if (this.baseForm.inspectionStandards == 1) {
|
|
|
+ // this.createSampleList(list);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ let count = list ? list.length : 0;
|
|
|
+ const codeList = await this.batchCodes(count);
|
|
|
if (this.baseForm.inspectionStandards == 2) {
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
- list[i].sampleCode = await this.getSampleCode();
|
|
|
+ // list[i].sampleCode = await this.getSampleCode();
|
|
|
+ list[i].sampleCode = codeList[i];
|
|
|
}
|
|
|
// this.updatePackingList(list, this.form.total);
|
|
|
// this.handleWeightFullSample(this.form.total);
|
|
|
}
|
|
|
|
|
|
console.log(this.baseForm.inspectionStandards);
|
|
|
-
|
|
|
+ console.log(list, 'list +++++++++++ 00000000000');
|
|
|
this.sampleList = list;
|
|
|
this.baseForm.sampleNumber = list.length;
|
|
|
this.samplePagination.currentPage = 1;
|
|
|
@@ -2153,9 +2178,11 @@
|
|
|
const result = [];
|
|
|
let remainingCount = sampleCount;
|
|
|
console.log(remainingCount, 'remainingCount ========');
|
|
|
+ let count = Math.ceil(remainingCount);
|
|
|
+ const codeList = await this.batchCodes(count);
|
|
|
+ let codeIdx = 0;
|
|
|
// 尽可能均匀地从各条目取样
|
|
|
while (remainingCount > 0) {
|
|
|
-
|
|
|
// 按剩余可取样比例排序
|
|
|
items.sort(
|
|
|
(a, b) =>
|
|
|
@@ -2166,28 +2193,38 @@
|
|
|
let distributed = false;
|
|
|
|
|
|
for (const item of items) {
|
|
|
+ console.log(
|
|
|
+ remainingCount,
|
|
|
+ 'remainingCount remainingCount remainingCount'
|
|
|
+ );
|
|
|
let values = remainingCount > 1 ? 1 : remainingCount;
|
|
|
// sampleQuantity = remainingCount > 1 ? 1 : remainingCount;
|
|
|
- console.log(sampleQuantity, 'sampleQuantity ----');
|
|
|
+ // console.log(sampleQuantity, 'sampleQuantity ----');
|
|
|
if (
|
|
|
(!isUnitMismatch && remainingCount > 0) ||
|
|
|
(item.remainingQuantity >= sampleQuantity && remainingCount > 0)
|
|
|
) {
|
|
|
// 添加到结果数组
|
|
|
this.samplePagination.total = 0;
|
|
|
- let sampleCode = await this.getSampleCode();
|
|
|
+ // let sampleCode = await this.getSampleCode();
|
|
|
+ let sampleCode = codeList[codeIdx];
|
|
|
if (
|
|
|
this.conditionType == 1 &&
|
|
|
this.baseForm.inspectionStandards == 1
|
|
|
) {
|
|
|
- console.log('进来1')
|
|
|
- result.push({ ...item, measureQuantity: values, sampleCode });
|
|
|
+ console.log('进来1');
|
|
|
+ result.push({
|
|
|
+ ...item,
|
|
|
+ // measureQuantity: values,
|
|
|
+ measureQuantity: 1,
|
|
|
+ sampleCode
|
|
|
+ });
|
|
|
} else if (
|
|
|
this.conditionType == 2 &&
|
|
|
(this.baseForm.inspectionStandards == 1 ||
|
|
|
this.baseForm.inspectionStandards == 2)
|
|
|
) {
|
|
|
- console.log('进来2')
|
|
|
+ console.log('进来2');
|
|
|
let weight = (item.weight / item.maxPossible).toFixed(2);
|
|
|
result.push({
|
|
|
...item,
|
|
|
@@ -2202,7 +2239,8 @@
|
|
|
if (!isUnitMismatch) {
|
|
|
item.remainingQuantity -= sampleQuantity;
|
|
|
}
|
|
|
- remainingCount--;
|
|
|
+ remainingCount = (remainingCount - 1).toFixed(2);
|
|
|
+ codeIdx++;
|
|
|
distributed = true;
|
|
|
}
|
|
|
}
|
|
|
@@ -2605,7 +2643,7 @@
|
|
|
if (this.btnType != 'issued') {
|
|
|
this.baseForm.sampleNumber = '';
|
|
|
}
|
|
|
-
|
|
|
+ console.log(this.baseForm, 'this.baseForm 0000000000000');
|
|
|
if (this.baseForm.type == '3') {
|
|
|
console.log(this.sourceList, this.dimensionType, '更改检验方式223');
|
|
|
if (
|
|
|
@@ -2725,8 +2763,8 @@
|
|
|
}
|
|
|
// ***
|
|
|
//抽检计量整样小样或者抽检计重小样
|
|
|
- // if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
|
|
|
- // return;
|
|
|
+ if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
|
|
|
+ return;
|
|
|
if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
|
|
|
return; // 若计量单位为重量,还需验证总重量是否足够
|
|
|
console.log('getNewFullSampleList');
|
|
|
@@ -2736,8 +2774,8 @@
|
|
|
} else {
|
|
|
console.log('2222222222222 --', Math.ceil(sampleCount));
|
|
|
await this.getNewFullSampleList(
|
|
|
- // Math.ceil(sampleCount),
|
|
|
- sampleCount,
|
|
|
+ Math.ceil(sampleCount),
|
|
|
+ // sampleCount,
|
|
|
measureQ,
|
|
|
unit,
|
|
|
specifications
|
|
|
@@ -2803,32 +2841,32 @@
|
|
|
},
|
|
|
|
|
|
validateMeasureQuantity(measureQ, unit, sampleCount) {
|
|
|
- // if (this.conditionType == 2 && measureQ <= 0) {
|
|
|
- // this.$message.info('取样计量数量必须大于0');
|
|
|
- // return false;
|
|
|
- // }
|
|
|
+ if (this.conditionType == 2 && measureQ <= 0) {
|
|
|
+ this.$message.info('取样计量数量必须大于0');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- // const totalQuantity = this.selectedList.reduce(
|
|
|
- // (sum, item) => sum + item.measureQuantity,
|
|
|
- // 0
|
|
|
- // );
|
|
|
- // if (
|
|
|
- // (this.selectedList[0].measureUnit === unit ||
|
|
|
- // this.conditionType == 1) &&
|
|
|
- // measureQ * sampleCount > totalQuantity
|
|
|
- // ) {
|
|
|
- // this.$message.info('取样计量数量不能大于总计量数量');
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // console.log(this.selectedList,'33333333333')
|
|
|
- // console.log(measureQ,'measureQ 0000')
|
|
|
- // const invalidItem = this.selectedList.find(
|
|
|
- // (item) => item.measureQuantity < measureQ
|
|
|
- // );
|
|
|
- // if (invalidItem) {
|
|
|
- // this.$message.info('条目计量数量小于取样计量数量');
|
|
|
- // return false;
|
|
|
- // }
|
|
|
+ const totalQuantity = this.selectedList.reduce(
|
|
|
+ (sum, item) => sum + item.measureQuantity,
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ if (
|
|
|
+ (this.selectedList[0].measureUnit === unit ||
|
|
|
+ this.conditionType == 1) &&
|
|
|
+ measureQ * sampleCount > totalQuantity
|
|
|
+ ) {
|
|
|
+ this.$message.info('取样计量数量不能大于总计量数量');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ console.log(this.selectedList, '33333333333');
|
|
|
+ console.log(measureQ, 'measureQ 0000');
|
|
|
+ const invalidItem = this.selectedList.find(
|
|
|
+ (item) => item.measureQuantity < measureQ
|
|
|
+ );
|
|
|
+ if (invalidItem) {
|
|
|
+ this.$message.info('条目计量数量小于取样计量数量');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
},
|