|
|
@@ -1,34 +1,65 @@
|
|
|
<template>
|
|
|
<ele-modal
|
|
|
:visible.sync="visible"
|
|
|
- title="取样"
|
|
|
+ :title="title"
|
|
|
width="80%"
|
|
|
append-to-body
|
|
|
:maxable="true"
|
|
|
+ @close="cancel"
|
|
|
>
|
|
|
+ <div class="switch" v-if="type == 'view'">
|
|
|
+ <div class="switch_left">
|
|
|
+ <ul>
|
|
|
+ <li
|
|
|
+ v-for="item in tabOptions"
|
|
|
+ :key="item.key"
|
|
|
+ :class="{ active: activeComp == item.key }"
|
|
|
+ @click="activeComp = item.key"
|
|
|
+ >
|
|
|
+ {{ item.name }}
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<el-form
|
|
|
+ v-show="activeComp === 'main'"
|
|
|
ref="form"
|
|
|
:model="form"
|
|
|
:rules="rules"
|
|
|
label-width="120px"
|
|
|
class="el-form-box"
|
|
|
+ :disabled="type == 'view'"
|
|
|
>
|
|
|
<header-title title="基本信息"></header-title>
|
|
|
<el-row>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="质检工单编码:" prop="code">
|
|
|
- <el-input disabled v-model="form.code" placeholder=" " />
|
|
|
+ <el-form-item label="质检工单编码:" prop="qualityWorkOrderCode">
|
|
|
+ <el-input
|
|
|
+ :disabled="!isSampleRecord || (isSampleRecord && type != 'add')"
|
|
|
+ readonly
|
|
|
+ v-model="form.qualityWorkOrderCode"
|
|
|
+ placeholder=" "
|
|
|
+ @click.native="$refs.inspectionWorkDialog.open()"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="质检工单名称:" prop="name">
|
|
|
- <el-input disabled v-model="form.name" placeholder=" " />
|
|
|
+ <el-form-item label="质检工单名称:" prop="qualityWorkOrderName">
|
|
|
+ <el-input
|
|
|
+ disabled
|
|
|
+ v-model="form.qualityWorkOrderName"
|
|
|
+ placeholder=" "
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="来源单号:" prop="sourceCode">
|
|
|
- <el-input disabled v-model="form.sourceCode" placeholder=" " />
|
|
|
+ <el-input
|
|
|
+ disabled
|
|
|
+ :value="form.qualityWorkOrderCode"
|
|
|
+ placeholder=" "
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
@@ -70,37 +101,73 @@
|
|
|
<el-input disabled v-model="form.brandNo" placeholder=" " />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="总数:" prop="total">
|
|
|
+ <el-input disabled v-model="form.total" placeholder=" ">
|
|
|
+ <template slot="append">
|
|
|
+ {{ tableList[0]?.measureUnit }}
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <!-- <el-col :span="8">
|
|
|
+ <el-form-item label="样品数:" prop="sampleQuantity">
|
|
|
+ <el-input disabled v-model="form.sampleQuantity" placeholder=" ">
|
|
|
+ <template slot="append">
|
|
|
+ {{ form.qualityMode == 1 ? form.measureUnit : form.unit }}
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col> -->
|
|
|
</el-row>
|
|
|
<header-title title="来源清单"></header-title>
|
|
|
<ele-pro-table
|
|
|
ref="sourceTable"
|
|
|
:columns="tableColumns"
|
|
|
- :datasource="datasource"
|
|
|
+ :datasource="tableList"
|
|
|
:initLoad="false"
|
|
|
:needPage="false"
|
|
|
- height="400px"
|
|
|
+ height="300px"
|
|
|
full-height="calc(100vh - 120px)"
|
|
|
:selection.sync="selection"
|
|
|
- ></ele-pro-table>
|
|
|
- <header-title title="取样信息"> </header-title>
|
|
|
+ >
|
|
|
+ <template v-slot:toolbar>
|
|
|
+ 累计请样数量:{{ workSampleQuantity
|
|
|
+ }}{{
|
|
|
+ form.conditionType == '1' ? tableList[0]?.measureUnit : form.unit
|
|
|
+ }}
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
+ <header-title title="请样信息"> </header-title>
|
|
|
<el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="请样目的:" prop="pleasePurpose">
|
|
|
+ <el-input
|
|
|
+ v-model="form.pleasePurpose"
|
|
|
+ placeholder="请输入"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="质检方式:" prop="qualityMode">
|
|
|
<DictSelection
|
|
|
dictName="取样类型"
|
|
|
v-model="form.qualityMode"
|
|
|
+ @change="handleQualityModeChange"
|
|
|
+ :disabled="form.isFirstSampling != '1'"
|
|
|
></DictSelection>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="检验方法:" prop="sampleQuantity">
|
|
|
+ <el-form-item label="记录方法:" prop="recordingMethod">
|
|
|
<el-select
|
|
|
style="width: 100%"
|
|
|
- v-model="form.sampleQuantity"
|
|
|
+ v-model="form.recordingMethod"
|
|
|
placeholder="请选择"
|
|
|
+ :disabled="form.isFirstSampling != '1'"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="item in sampleQuantityList"
|
|
|
+ v-for="item in recordingMethodList"
|
|
|
:label="item.label"
|
|
|
:value="item.value"
|
|
|
:key="item.value"
|
|
|
@@ -109,13 +176,15 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
+
|
|
|
<el-row v-if="form.qualityMode == '2'">
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="取样:" prop="sampleNumber">
|
|
|
+ <el-form-item label="请样类型:" prop="conditionType">
|
|
|
<el-select
|
|
|
style="width: 100%"
|
|
|
v-model="form.conditionType"
|
|
|
placeholder="请选择"
|
|
|
+ :disabled="form.isFirstSampling != '1'"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in sampleNumberList"
|
|
|
@@ -129,21 +198,21 @@
|
|
|
<el-col :span="16">
|
|
|
<el-row>
|
|
|
<el-col :span="6" v-if="form.conditionType == 2">
|
|
|
- <el-form-item prop="measureQ">
|
|
|
+ <el-form-item prop="quantity">
|
|
|
<el-input
|
|
|
- v-model="form.measureQ"
|
|
|
+ v-model="form.quantity"
|
|
|
placeholder="请输入"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6" v-if="form.conditionType == 2">
|
|
|
- <el-form-item prop="sampleUnit" label-width="0">
|
|
|
+ <el-form-item prop="unit" label-width="0">
|
|
|
<DictSelection
|
|
|
dictName="计量单位"
|
|
|
clearable
|
|
|
- v-model="form.sampleUnit"
|
|
|
+ :disabled="form.isFirstSampling != '1'"
|
|
|
+ v-model="form.unit"
|
|
|
filter-placeholder="请输入计量单位搜索"
|
|
|
- @change="changeSamUnit"
|
|
|
></DictSelection>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -165,12 +234,17 @@
|
|
|
</el-col>
|
|
|
<el-col :span="10" v-if="form.conditionType == 1">
|
|
|
<el-form-item prop="packingUnit" label="单位">
|
|
|
- <el-select v-model="form.packingUnit" placeholder="请选择">
|
|
|
+ <el-select
|
|
|
+ v-model="form.packingUnit"
|
|
|
+ placeholder="请选择"
|
|
|
+ :disabled="form.isFirstSampling != '1'"
|
|
|
+ >
|
|
|
<el-option
|
|
|
v-for="item in packingSpecificationOption"
|
|
|
:key="item.id"
|
|
|
:label="item.conversionUnit"
|
|
|
:value="item.id"
|
|
|
+ @click.native="handlePackingUnitChange(item)"
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
@@ -179,7 +253,7 @@
|
|
|
<el-col
|
|
|
:span="4"
|
|
|
style="text-align: right"
|
|
|
- v-if="form.conditionType == 2"
|
|
|
+ v-if="form.conditionType == 2 && type != 'view'"
|
|
|
>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
@@ -192,7 +266,7 @@
|
|
|
<el-col
|
|
|
:span="4"
|
|
|
style="text-align: right"
|
|
|
- v-if="form.conditionType == 1"
|
|
|
+ v-if="form.conditionType == 1 && type != 'view'"
|
|
|
>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
@@ -215,63 +289,120 @@
|
|
|
full-height="calc(100vh - 120px)"
|
|
|
></ele-pro-table>
|
|
|
</el-form>
|
|
|
-
|
|
|
+ <bpmDetail
|
|
|
+ v-if="activeComp == 'bpm' && form.processInstanceId"
|
|
|
+ :id="form.processInstanceId"
|
|
|
+ ></bpmDetail>
|
|
|
<template v-slot:footer>
|
|
|
- <el-button type="primary" @click="save()" v-lodading="loading"
|
|
|
- >确认</el-button
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="save()"
|
|
|
+ v-loading="loading"
|
|
|
+ v-if="type != 'view'"
|
|
|
+ >保存</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="save('submit')"
|
|
|
+ v-loading="loading"
|
|
|
+ v-if="type != 'view'"
|
|
|
+ >提交</el-button
|
|
|
>
|
|
|
|
|
|
<el-button @click="cancel">关闭</el-button>
|
|
|
</template>
|
|
|
+ <inspectionWorkDialog
|
|
|
+ ref="inspectionWorkDialog"
|
|
|
+ @changeParent="changeParent"
|
|
|
+ ></inspectionWorkDialog>
|
|
|
+ <processSubmitDialog
|
|
|
+ :processSubmitDialogFlag.sync="processSubmitDialogFlag"
|
|
|
+ v-if="processSubmitDialogFlag"
|
|
|
+ ref="processSubmitDialogRef"
|
|
|
+ @reload="search"
|
|
|
+ ></processSubmitDialog>
|
|
|
</ele-modal>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
|
|
|
+ import { recordingMethodList } from '@/utils/util.js';
|
|
|
+
|
|
|
const defForm = {
|
|
|
code: '', //编码
|
|
|
name: '', //名称
|
|
|
conditionType: '',
|
|
|
- measureQ: '',
|
|
|
- sampleUnit: '',
|
|
|
- portion: ''
|
|
|
+ quantity: '',
|
|
|
+ unit: '',
|
|
|
+ portion: '',
|
|
|
+ qualityMode: '',
|
|
|
+ recordingMethod: 1,
|
|
|
+ pleaseQuantity: '',
|
|
|
+ pleasePurpose: '',
|
|
|
+ pleaseUnit: '',
|
|
|
+ sampleQuantity: '',
|
|
|
+ qualityWorkOrderId: '',
|
|
|
+ qualityWorkOrderCode: '',
|
|
|
+ qualityWorkOrderName: '',
|
|
|
+ isFirstSampling: ''
|
|
|
};
|
|
|
import {
|
|
|
queryQualityInventory,
|
|
|
queryQualityTempleContent
|
|
|
} from '@/api/inspectionWork';
|
|
|
- import { getCodeList } from '@/api/login';
|
|
|
+ import {
|
|
|
+ samplingrecordSave,
|
|
|
+ getById,
|
|
|
+ samplingrecordUpdate,
|
|
|
+ samplingRecordsPage
|
|
|
+ } from '@/api/samplingRecords';
|
|
|
+ import bpmDetail from '@/views/bpm/processInstance/detail.vue';
|
|
|
+ import inspectionWorkDialog from './inspectionWorkDialog.vue';
|
|
|
+ import { getCodeList, getCode } from '@/api/login';
|
|
|
export default {
|
|
|
- components: {},
|
|
|
+ components: { bpmDetail, inspectionWorkDialog, processSubmitDialog },
|
|
|
+ props: {
|
|
|
+ isSampleRecord: {
|
|
|
+ default: false
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
+ recordingMethodList,
|
|
|
+ processSubmitDialogFlag: false,
|
|
|
form: { ...defForm },
|
|
|
+ activeComp: 'main',
|
|
|
+ tabOptions: [
|
|
|
+ { key: 'main', name: '请样详情' },
|
|
|
+ { key: 'bpm', name: '流程详情' }
|
|
|
+ ],
|
|
|
+ workSampleQuantity: 0,
|
|
|
visible: false,
|
|
|
loading: false,
|
|
|
rules: {
|
|
|
- name: [
|
|
|
- { required: true, message: '名称不能为空', trigger: 'change' }
|
|
|
- ],
|
|
|
- factoriesId: [
|
|
|
- { required: true, message: '请选择工厂', trigger: 'change' }
|
|
|
+ qualityWorkOrderCode: [
|
|
|
+ { required: true, message: '请选择质检工单', trigger: 'change' }
|
|
|
],
|
|
|
- bomId: [
|
|
|
- { required: true, message: '请选择BOM版本', trigger: 'change' }
|
|
|
+ qualityMode: [
|
|
|
+ { required: true, message: '请选择质检方式', trigger: 'change' }
|
|
|
],
|
|
|
- bomCategory: [
|
|
|
- { required: true, message: '请选择BOM类型', trigger: 'change' }
|
|
|
+ recordingMethod: [
|
|
|
+ { required: true, message: '请选择记录方法', trigger: 'change' }
|
|
|
],
|
|
|
- produceRoutingId: [
|
|
|
- { required: true, message: '请选择工艺路线', trigger: 'change' }
|
|
|
+ conditionType: [
|
|
|
+ { required: true, message: '请选择请样类型', trigger: 'change' }
|
|
|
],
|
|
|
- code: [{ required: true, message: '编码不能为空', trigger: 'change' }]
|
|
|
+ quantity: [{ required: true, message: '请输入', trigger: 'change' }],
|
|
|
+ portion: [{ required: true, message: '请输入', trigger: 'change' }],
|
|
|
+ unit: [{ required: true, message: '请选择', trigger: 'change' }],
|
|
|
+ packingUnit: [
|
|
|
+ { required: true, message: '请选择', trigger: 'change' }
|
|
|
+ ]
|
|
|
},
|
|
|
- sampleQuantityList: [
|
|
|
- { label: '依次检验', value: '1' },
|
|
|
- { label: '分别检验', value: '2' }
|
|
|
- ],
|
|
|
+
|
|
|
sampleNumberList: [
|
|
|
- { label: '取整样', value: '1' },
|
|
|
- { label: '取小样', value: '2' }
|
|
|
+ { label: '请整样', value: 1 },
|
|
|
+ { label: '请小样', value: 2 }
|
|
|
],
|
|
|
selection: [],
|
|
|
tableColumns1: [
|
|
|
@@ -478,49 +609,135 @@
|
|
|
],
|
|
|
packingSpecificationOption: [],
|
|
|
sampleList: [],
|
|
|
- schemeList: []
|
|
|
+ schemeList: [],
|
|
|
+ tableList: [],
|
|
|
+ type: 'add',
|
|
|
+ title: ''
|
|
|
};
|
|
|
},
|
|
|
|
|
|
computed: {},
|
|
|
created() {},
|
|
|
methods: {
|
|
|
- async open(row) {
|
|
|
+ handlePackingUnitChange(val) {
|
|
|
+ this.$set(this.form, 'unit', val.conversionUnit);
|
|
|
+ },
|
|
|
+ async open(type, row) {
|
|
|
+ this.activeComp = 'main';
|
|
|
this.visible = true;
|
|
|
- row.sourceCode = row.qualityPlanCode || row.workOrderCode;
|
|
|
- this.form = row;
|
|
|
- this.queryQualityTempleContent();
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.sourceTable.reload({
|
|
|
- page: 1,
|
|
|
- where: { qualityWorkerId: row.id }
|
|
|
+ this.type = type;
|
|
|
+ this.title =
|
|
|
+ type == 'add' ? '请样' : type == 'edit' ? '修改请样' : '详情';
|
|
|
+ if (type == 'add') {
|
|
|
+ if (row) {
|
|
|
+ this.init(row);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.getById(row.id);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async init(row) {
|
|
|
+ let data = await samplingRecordsPage({
|
|
|
+ qualityWorkOrderId: row.id
|
|
|
+ });
|
|
|
+ let list = data.list.filter(
|
|
|
+ (item) => item.status === 0 || item.status === 4
|
|
|
+ );
|
|
|
+ let list1 = data.list.filter((item) => item.status != 3);
|
|
|
+ if (list?.length) {
|
|
|
+ this.getById(list[0].id);
|
|
|
+ this.type = 'edit';
|
|
|
+ this.title = '修改请样';
|
|
|
+ } else {
|
|
|
+ row.sourceCode = row.qualityPlanCode || row.workOrderCode;
|
|
|
+ this.form = JSON.parse(JSON.stringify(row));
|
|
|
+ this.form.qualityWorkOrderId = row.id;
|
|
|
+ this.form.qualityWorkOrderCode = row.code;
|
|
|
+ this.form.qualityWorkOrderName = row.name;
|
|
|
+ this.workSampleQuantity = Number(row.sampleQuantity) || 0;
|
|
|
+
|
|
|
+ if (!list1?.length) {
|
|
|
+ this.form.isFirstSampling = 1;
|
|
|
+ } else {
|
|
|
+ this.$set(this.form, 'unit', list1[0].unit);
|
|
|
+ }
|
|
|
+ await this.datasource(list1[0]?.unit);
|
|
|
+ await this.queryQualityTempleContent(
|
|
|
+ !list1.length && row.qualityMode == 1
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getById(id) {
|
|
|
+ getById(id).then((res) => {
|
|
|
+ this.workSampleQuantity =
|
|
|
+ Number(res.qualityWorkOrderVO.sampleQuantity) || 0;
|
|
|
+ [
|
|
|
+ 'id',
|
|
|
+ 'code',
|
|
|
+ 'name',
|
|
|
+ 'createTime',
|
|
|
+ 'createUserId',
|
|
|
+ 'status',
|
|
|
+ 'approvalStatus',
|
|
|
+ 'approvalUserId',
|
|
|
+ 'sampleQuantity',
|
|
|
+ 'processInstanceId'
|
|
|
+ ].forEach((it) => {
|
|
|
+ delete res.qualityWorkOrderVO[it];
|
|
|
});
|
|
|
+ this.form = { ...res, ...res.qualityWorkOrderVO };
|
|
|
+ this.datasource(this.form.unit);
|
|
|
+ this.queryQualityTempleContent();
|
|
|
+ if (this.form.qualityMode == 2) {
|
|
|
+ if (res.qualityWorkOrderVO.conditionType == 1) {
|
|
|
+ // if (res.unit != res.qualitySampleList[0].measureUnit) {
|
|
|
+ // this.$set(this.form, 'portion', res.qualitySampleList.length);
|
|
|
+ // } else {
|
|
|
+
|
|
|
+ // }
|
|
|
+ this.$set(this.form, 'portion', res.quantity);
|
|
|
+ this.$set(this.form, 'quantity', 0);
|
|
|
+ } else {
|
|
|
+ this.$set(this.form, 'portion', res.copies);
|
|
|
+ // this.$set(this.form, 'quantity', res.quantity / res.copies);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.sampleList = res.qualitySampleList;
|
|
|
});
|
|
|
},
|
|
|
- async queryQualityTempleContent() {
|
|
|
+ /* 查询质检模板内容 */
|
|
|
+ async queryQualityTempleContent(is) {
|
|
|
const res = await queryQualityTempleContent({
|
|
|
- qualityWorkerId: this.form.id,
|
|
|
+ qualityWorkerId: this.form.qualityWorkOrderId,
|
|
|
page: 1,
|
|
|
size: 10000
|
|
|
});
|
|
|
this.schemeList = res.list;
|
|
|
+ if (is) {
|
|
|
+ this.updatePackingList();
|
|
|
+ }
|
|
|
},
|
|
|
cancel() {
|
|
|
this.form = {
|
|
|
...defForm
|
|
|
};
|
|
|
this.schemeList = [];
|
|
|
+ this.packingSpecificationOption = [];
|
|
|
+ this.sampleList = [];
|
|
|
+ this.tableList = [];
|
|
|
+
|
|
|
this.visible = false;
|
|
|
},
|
|
|
- async datasource({ page, limit, where }) {
|
|
|
+ changeParent(row) {
|
|
|
+ this.init(row);
|
|
|
+ },
|
|
|
+ async datasource(unit) {
|
|
|
const res = await queryQualityInventory({
|
|
|
- ...where,
|
|
|
- pageNum: page,
|
|
|
+ qualityWorkerId: this.form.qualityWorkOrderId,
|
|
|
+ pageNum: 1,
|
|
|
size: -1
|
|
|
});
|
|
|
- if (res.list.length == 0) {
|
|
|
- return res;
|
|
|
- }
|
|
|
|
|
|
let o = res.list[0];
|
|
|
let listArr = [];
|
|
|
@@ -538,7 +755,14 @@
|
|
|
id: '222'
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+ if (unit) {
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ 'packingUnit',
|
|
|
+ listArr.find((item) => unit == item.conversionUnit)?.id
|
|
|
+ );
|
|
|
+ }
|
|
|
+ this.form.pleaseUnit = res.list[0]?.measureUnit;
|
|
|
res.list.map((el) => {
|
|
|
el.weightProportion = el.weight
|
|
|
? (el.weight / el.measureQuantity).toFixed(4)
|
|
|
@@ -546,6 +770,7 @@
|
|
|
el.weightProportion = el.weightProportion - 0;
|
|
|
});
|
|
|
this.packingSpecificationOption = listArr;
|
|
|
+ this.tableList = res.list;
|
|
|
return res;
|
|
|
},
|
|
|
|
|
|
@@ -554,8 +779,8 @@
|
|
|
// if (valid) {
|
|
|
let params = {
|
|
|
conditionType: this.form.conditionType,
|
|
|
- measureQ: this.form.measureQ,
|
|
|
- sampleUnit: this.form.sampleUnit,
|
|
|
+ quantity: this.form.quantity,
|
|
|
+ sampleUnit: this.form.unit,
|
|
|
portion: this.form.portion
|
|
|
};
|
|
|
let specifications = this.packingSpecificationOption.find(
|
|
|
@@ -569,63 +794,56 @@
|
|
|
async sampleFn(data, specifications) {
|
|
|
this.sampleList = [];
|
|
|
if (!this.selection || this.selection.length == 0) {
|
|
|
- this.$message.warning('请先选择样品!');
|
|
|
+ this.$message.warning('请先选择来源清单!');
|
|
|
return;
|
|
|
}
|
|
|
- const measureQ = data.measureQ || 1;
|
|
|
+ const quantity = data.quantity || 1;
|
|
|
const unit = data.sampleUnit;
|
|
|
const sampleCount = Number(data.portion);
|
|
|
try {
|
|
|
- if (
|
|
|
- this.form.inspectionStandards === 1 ||
|
|
|
- ([2, 3, 4, 5].includes(this.form.inspectionStandards) &&
|
|
|
- this.form.conditionType == 2)
|
|
|
- ) {
|
|
|
- // 新增校验 数量 取整样 ***
|
|
|
- if (this.form.conditionType == 1) {
|
|
|
- let isFlag = this.validateSampleQuantity(
|
|
|
- sampleCount,
|
|
|
- specifications
|
|
|
- );
|
|
|
- if (!isFlag) return;
|
|
|
- }
|
|
|
- // ***
|
|
|
- //抽检计量整样小样或者抽检计重小样
|
|
|
- if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
|
|
|
+ // 2 取小样
|
|
|
+ if (this.form.conditionType == 2) {
|
|
|
+ if (!this.validateMeasureQuantity(quantity, unit, sampleCount))
|
|
|
return; //取样数量验证
|
|
|
- if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
|
|
|
+ if (unit === 'KG' && !this.validateWeight(quantity, sampleCount))
|
|
|
return; // 若计量单位为重量,还需验证总重量是否足够
|
|
|
await this.getNewFullSampleList(
|
|
|
Math.ceil(sampleCount),
|
|
|
// sampleCount,
|
|
|
- measureQ,
|
|
|
+ quantity,
|
|
|
unit,
|
|
|
specifications
|
|
|
);
|
|
|
- // 这里是取整样 非数量
|
|
|
- } else if (
|
|
|
- [2, 3, 4, 5].includes(this.form.inspectionStandards) &&
|
|
|
- this.form.conditionType == 1
|
|
|
- ) {
|
|
|
- console.log('这里是取整样 吗');
|
|
|
- //抽检取计重取整样
|
|
|
- if (!this.validateSampleCount(sampleCount, specifications)) return;
|
|
|
- await this.handleWeightFullSample(sampleCount, specifications);
|
|
|
+ } else {
|
|
|
+ let isFlag = this.validateSampleQuantity(
|
|
|
+ sampleCount,
|
|
|
+ specifications
|
|
|
+ );
|
|
|
+ if (!isFlag) return;
|
|
|
+ if (this.form.inspectionStandards == 1) {
|
|
|
+ await this.getNewFullSampleList(
|
|
|
+ Math.ceil(sampleCount),
|
|
|
+ quantity,
|
|
|
+ unit,
|
|
|
+ specifications
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ await this.handleWeightFullSample(sampleCount, specifications);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('取样处理失败:', error);
|
|
|
- this.$message.error('取样处理失败');
|
|
|
+ console.error('请样处理失败:', error);
|
|
|
+ this.$message.error('请样处理失败');
|
|
|
}
|
|
|
},
|
|
|
- validateWeight(measureQ, sampleCount) {
|
|
|
+ validateWeight(quantity, sampleCount) {
|
|
|
let totalMaxPossible = 0;
|
|
|
this.selection.forEach((item) => {
|
|
|
- totalMaxPossible += item.measureQuantity / measureQ;
|
|
|
+ totalMaxPossible += item.measureQuantity / quantity;
|
|
|
});
|
|
|
|
|
|
if (totalMaxPossible < sampleCount) {
|
|
|
- // this.form.portion = totalMaxPossible;
|
|
|
- this.$message.info(`最大取样条数为${totalMaxPossible}`);
|
|
|
+ this.$message.info(`最大请样条数为${totalMaxPossible}`);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -636,76 +854,50 @@
|
|
|
const weightUnit = this.selection[0].weightUnit;
|
|
|
if (weightUnit === 'G') totalWeight /= 1000;
|
|
|
|
|
|
- if (measureQ * sampleCount > totalWeight) {
|
|
|
- this.$message.info('取样计量重量不能大于总计量重量');
|
|
|
+ if (quantity * sampleCount > totalWeight) {
|
|
|
+ this.$message.info('请样计量重量不能大于总计量重量');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
const invalidItem = this.selection.find((item) => {
|
|
|
const weight =
|
|
|
item.weightUnit === 'G' ? item.weight / 1000 : item.weight;
|
|
|
- return weight < measureQ;
|
|
|
+ return weight < quantity;
|
|
|
});
|
|
|
|
|
|
if (invalidItem) {
|
|
|
- this.$message.info('勾选条目重量小于取样重量');
|
|
|
+ this.$message.info('勾选条目重量小于请样重量');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
},
|
|
|
|
|
|
- validateMeasureQuantity(measureQ, unit, sampleCount) {
|
|
|
- if (this.form.conditionType == 2 && measureQ <= 0) {
|
|
|
- this.$message.info('取样计量数量必须大于0');
|
|
|
+ validateMeasureQuantity(quantity, unit, sampleCount) {
|
|
|
+ if (quantity <= 0) {
|
|
|
+ this.$message.info('请样计量数量必须大于0');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- const totalQuantity = this.selection.reduce(
|
|
|
- (sum, item) => sum + item.measureQuantity,
|
|
|
- 0
|
|
|
- );
|
|
|
+ const totalQuantity =
|
|
|
+ this.selection.reduce((sum, item) => sum + item.measureQuantity, 0) -
|
|
|
+ this.workSampleQuantity;
|
|
|
+
|
|
|
if (
|
|
|
- (this.selection[0].measureUnit === unit ||
|
|
|
- this.form.conditionType == 1) &&
|
|
|
- measureQ * sampleCount > totalQuantity
|
|
|
+ this.selection[0].measureUnit === unit &&
|
|
|
+ quantity * sampleCount > totalQuantity
|
|
|
) {
|
|
|
- this.$message.info('取样计量数量不能大于总计量数量');
|
|
|
+ this.$message.info('请样计量数量不能大于总计量数量');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
const invalidItem = this.selection.find(
|
|
|
- (item) => item.measureQuantity < measureQ
|
|
|
+ (item) => item.measureQuantity < quantity
|
|
|
);
|
|
|
if (invalidItem) {
|
|
|
- this.$message.info('条目计量数量小于取样计量数量');
|
|
|
+ this.$message.info('条目计量数量小于请样计量数量');
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- return true;
|
|
|
- },
|
|
|
-
|
|
|
- // 抽检取整样 校验
|
|
|
- validateSampleCount(sampleCount, specifications) {
|
|
|
- // 新增校验 ***
|
|
|
- let isFlag = this.validateSampleQuantity(sampleCount, specifications);
|
|
|
- if (!isFlag) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- // ***
|
|
|
- const chooseNumber = this.selection.reduce((acc, pro) => {
|
|
|
- return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
|
|
|
- }, 0);
|
|
|
- const invalidItem = chooseNumber < sampleCount;
|
|
|
- // console.log(this.selection, 'this.selection');
|
|
|
- // const invalidItem = this.selection.find(
|
|
|
- // (item) => item.measureQuantity < sampleCount
|
|
|
- // );
|
|
|
- if (invalidItem) {
|
|
|
- this.$message.info('所选的条目计量数量小于取样计量数量');
|
|
|
- return false;
|
|
|
- }
|
|
|
- // ***
|
|
|
return true;
|
|
|
},
|
|
|
|
|
|
@@ -730,7 +922,7 @@
|
|
|
dataList.push({
|
|
|
...item,
|
|
|
measureQuantity: 1, //作为计量数量
|
|
|
- sampleCode: await this.getSampleCode(),
|
|
|
+ sampleCode: await getCode('sample_code'),
|
|
|
qualitySampleTemplateList
|
|
|
});
|
|
|
} else {
|
|
|
@@ -738,7 +930,7 @@
|
|
|
dataList.push({
|
|
|
...item,
|
|
|
measureQuantity: currentNum1 > 1 ? 1 : currentNum1, //作为计量数量
|
|
|
- sampleCode: await this.getSampleCode(),
|
|
|
+ sampleCode: await getCode('sample_code'),
|
|
|
qualitySampleTemplateList
|
|
|
});
|
|
|
currentNum1 -= 1;
|
|
|
@@ -771,6 +963,7 @@
|
|
|
}
|
|
|
// 更改
|
|
|
this.sampleList = dataList;
|
|
|
+ this.getTotal();
|
|
|
},
|
|
|
// 小数点数据判断
|
|
|
formatNumber(a, b, maxDecimals = 4) {
|
|
|
@@ -905,26 +1098,99 @@
|
|
|
if (this.sampleList.length > sampleCount) {
|
|
|
this.sampleList = this.sampleList.splice(0, sampleCount);
|
|
|
}
|
|
|
+ this.getTotal();
|
|
|
},
|
|
|
// 当计量类型 是数量的时候 取整样 校验
|
|
|
validateSampleQuantity(sampleCount, specifications) {
|
|
|
let packingUnit = this.selection[0].packingUnit?.trim() || '';
|
|
|
let totalS = 0;
|
|
|
+ let measureQuantityCount = 0;
|
|
|
let labelKey =
|
|
|
packingUnit == specifications.conversionUnit.trim()
|
|
|
? 'packingQuantity'
|
|
|
: 'measureQuantity';
|
|
|
let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
|
|
|
totalS = this.selection.reduce((total, el) => total + el[labelKey], 0);
|
|
|
-
|
|
|
+ let formTotalS = this.tableList.reduce(
|
|
|
+ (total, el) => total + el.measureQuantity,
|
|
|
+ 0
|
|
|
+ );
|
|
|
if (sampleCount > totalS) {
|
|
|
this.$message.info(
|
|
|
`所填的条目数量不能超过所选${labelName}总和${totalS}`
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
+ if (labelKey == 'packingQuantity') {
|
|
|
+ measureQuantityCount =
|
|
|
+ sampleCount * this.selection[0].measureQuantity;
|
|
|
+ } else {
|
|
|
+ measureQuantityCount = sampleCount;
|
|
|
+ }
|
|
|
+ if (measureQuantityCount > formTotalS - this.workSampleQuantity) {
|
|
|
+ this.$message.info(
|
|
|
+ `请样数量不能大于${formTotalS - this.workSampleQuantity} ${
|
|
|
+ this.selection[0].measureUnit
|
|
|
+ }`
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return true;
|
|
|
},
|
|
|
+
|
|
|
+ handleQualityModeChange(val) {
|
|
|
+ if (val == 1) {
|
|
|
+ this.updatePackingList();
|
|
|
+ } else {
|
|
|
+ this.sampleList = [];
|
|
|
+ this.getTotal();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 全检
|
|
|
+ async updatePackingList() {
|
|
|
+ let list = this.tableList;
|
|
|
+
|
|
|
+ let sampleCount = this.form.total;
|
|
|
+
|
|
|
+ const dataList = [];
|
|
|
+ let count = list ? list.length : 0;
|
|
|
+ console.log(count, 'count');
|
|
|
+ const codeList = await this.batchCodes(count);
|
|
|
+ for (const [index, item] of list.entries()) {
|
|
|
+ const qualitySampleTemplateList = item.qualitySampleTemplateList
|
|
|
+ ?.length
|
|
|
+ ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
|
|
|
+ : JSON.parse(
|
|
|
+ JSON.stringify(
|
|
|
+ this.schemeList.map((item) => {
|
|
|
+ item['qualityResults'] = 1;
|
|
|
+ return item;
|
|
|
+ })
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ // if (sampleCount >= list.length) {
|
|
|
+ dataList.push({
|
|
|
+ ...item,
|
|
|
+ measureQuantity: item.measureQuantity, //作为计量数量
|
|
|
+ sampleCode: codeList[index],
|
|
|
+ qualitySampleTemplateList
|
|
|
+ });
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ console.log(dataList, 'dataList');
|
|
|
+
|
|
|
+ this.sampleList = dataList;
|
|
|
+ this.getTotal();
|
|
|
+ },
|
|
|
+ getTotal() {
|
|
|
+ this.form.sampleQuantity = this.sampleList
|
|
|
+ .reduce((total, el) => total + Number(el.measureQuantity), 0)
|
|
|
+ .toFixed(2);
|
|
|
+ this.form.sampleWeight = this.sampleList
|
|
|
+ .reduce((total, el) => total + Number(el.weight), 0)
|
|
|
+ .toFixed(2);
|
|
|
+ },
|
|
|
async batchCodes(count) {
|
|
|
if (count <= 0) return;
|
|
|
let params = { count };
|
|
|
@@ -932,21 +1198,85 @@
|
|
|
return res;
|
|
|
},
|
|
|
/* 保存编辑 */
|
|
|
- save() {
|
|
|
+ save(type) {
|
|
|
+ if (this.type == 'add') {
|
|
|
+ [
|
|
|
+ 'id',
|
|
|
+ 'code',
|
|
|
+ 'name',
|
|
|
+ 'createTime',
|
|
|
+ 'createUserId',
|
|
|
+ 'status',
|
|
|
+ 'approvalStatus',
|
|
|
+ 'approvalUserId'
|
|
|
+ ].forEach((key) => {
|
|
|
+ delete this.form[key];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ let data = JSON.parse(JSON.stringify(this.form));
|
|
|
+
|
|
|
+ let api =
|
|
|
+ this.type == 'add' ? samplingrecordSave : samplingrecordUpdate;
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
if (valid) {
|
|
|
+ if (!this.sampleList.length) {
|
|
|
+ this.$message.error('样品清单不能为空!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //抽检
|
|
|
+ if (data.qualityMode == 2) {
|
|
|
+ //取整样
|
|
|
+ if (data.conditionType == 1) {
|
|
|
+ data.quantity = data.portion;
|
|
|
+
|
|
|
+ data.measureUnit = this.tableList[0].measureUnit;
|
|
|
+ } else {
|
|
|
+ data.measureUnit = data.unit;
|
|
|
+ data.copies = data.portion;
|
|
|
+ }
|
|
|
+ }
|
|
|
this.loading = true;
|
|
|
- saveOrUpdate(this.form)
|
|
|
+
|
|
|
+ api({
|
|
|
+ ...data,
|
|
|
+ sampleList: this.sampleList
|
|
|
+ })
|
|
|
.then((res) => {
|
|
|
this.$message.success('操作成功');
|
|
|
- this.cancel();
|
|
|
- this.$emit('done');
|
|
|
+
|
|
|
+ if (type == 'submit') {
|
|
|
+ this.approvalSubmit(this.type == 'add' ? res : data.id);
|
|
|
+ } else {
|
|
|
+ this.cancel();
|
|
|
+ this.$emit('reload');
|
|
|
+ }
|
|
|
})
|
|
|
.finally(() => {
|
|
|
this.loading = false;
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
+ },
|
|
|
+ async approvalSubmit(id) {
|
|
|
+ const res = await getById(id);
|
|
|
+ this.processSubmitDialogFlag = true;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ let params = {
|
|
|
+ businessId: res.id,
|
|
|
+ businessKey: 'sampling_approval_process',
|
|
|
+ formCreateUserId: res.createUserId,
|
|
|
+ variables: {
|
|
|
+ businessCode: res.code,
|
|
|
+ businessName: '请样',
|
|
|
+ businessType: res.conditionType == 1 ? '整样' : '小样'
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.$refs.processSubmitDialogRef.init(params);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ search() {
|
|
|
+ this.cancel();
|
|
|
+ this.$emit('reload');
|
|
|
}
|
|
|
}
|
|
|
};
|