|
|
@@ -11,7 +11,7 @@
|
|
|
<!-- -->
|
|
|
<el-tab-pane label="来源清单" name="1">
|
|
|
<ele-pro-table ref="sourceTable" :columns="tableColumns1" :datasource="datasource"
|
|
|
- @selection-change="$emit('selection-change', $event)" :initLoad="false" :pagination="true">
|
|
|
+ @selection-change="handleSelectionChange" :initLoad="false" :pagination="true">
|
|
|
|
|
|
<template v-slot:toolbar v-if="form.qualityMode == 2">
|
|
|
<el-dropdown trigger="click" @command="handleSampleNumber">
|
|
|
@@ -23,24 +23,34 @@
|
|
|
</el-dropdown>
|
|
|
</template>
|
|
|
<template v-slot:toolkit v-if="form.qualityMode == 2 && conditionType == 2">
|
|
|
- <div>
|
|
|
- <div style="display: flex;align-items: center;">
|
|
|
- <el-input v-model="formData.number" style="width: 120px;" placeholder="请输入" size="mini"
|
|
|
- @change="handleInputNumber"></el-input>
|
|
|
- <DictSelection dictName="计量单位" clearable v-model="formData.sampleUnit" size="mini"
|
|
|
- style="width: 120px;margin-left: 12px;" @change="changeSamUnit">
|
|
|
- </DictSelection>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <div style="margin-left: 12px;display: flex;align-items: center;">
|
|
|
- <div>数量:</div>
|
|
|
- <el-input v-model="formData.portion" style="width: 120px;margin:0 12px;" placeholder="请输入" size="mini"
|
|
|
- @change="handleInput" :disabled="conditionType == 1"></el-input>
|
|
|
- <el-button type="primary" size="mini" @click="handleSampleSubmit"
|
|
|
- style="margin-right: 12px;">确认</el-button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <el-row>
|
|
|
+ <el-form ref="ruleForm" :model="formData" label-width="60px" size="mini" :rules="rules" class="flex"
|
|
|
+ :show-message="false">
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item prop="number" label-width="0" style="margin-bottom: 0;">
|
|
|
+ <el-input v-model="formData.number" placeholder="请输入" size="mini"
|
|
|
+ @change="handleInputNumber"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item prop="sampleUnit" label-width="0" style="margin: 0;">
|
|
|
+ <DictSelection dictName="计量单位" clearable v-model="formData.sampleUnit" size="mini"
|
|
|
+ @change="changeSamUnit">
|
|
|
+ </DictSelection>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item prop="portion" label="数量" style="margin: 0;">
|
|
|
+ <el-input v-model="formData.portion" placeholder="请输入" size="mini" @change="handleInput"
|
|
|
+ :disabled="conditionType == 1"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="4" style="text-align: right;">
|
|
|
+ <el-button type="primary" size="mini" @click="handleSampleSubmit"
|
|
|
+ style="margin-right: 12px;">确认</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </el-row>
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:materielDesignation="{ row }">
|
|
|
@@ -239,6 +249,30 @@ export default {
|
|
|
sampleUnit: '',
|
|
|
portion: null
|
|
|
},
|
|
|
+ rules: {
|
|
|
+ number: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入',
|
|
|
+ trigger: 'blur'
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ sampleUnit: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请选择样品单位',
|
|
|
+ trigger: 'change'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ portion: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -357,10 +391,20 @@ export default {
|
|
|
console.log('清空勾选')
|
|
|
this.$refs.sourceTable.clearSelection();
|
|
|
},
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ this.formData.portion = selection.length;
|
|
|
+ this.formData.sampleUnit = selection[0]?.measureUnit;
|
|
|
+
|
|
|
+ this.$set(this.form, 'sampleNumber', selection.length);
|
|
|
+ this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
|
|
|
+
|
|
|
+ this.$emit('handleSelectionChange', selection)
|
|
|
+ },
|
|
|
|
|
|
handleSampleNumber(val) {
|
|
|
console.log(val, 'val')
|
|
|
this.conditionType = val;
|
|
|
+ this.$emit('getConditionType', val)
|
|
|
|
|
|
//取整样
|
|
|
let data = this.$refs.sourceTable.getData()
|
|
|
@@ -377,40 +421,42 @@ export default {
|
|
|
},
|
|
|
handleInputNumber(val) {
|
|
|
let packingList = this.$refs.sourceTable.getData()
|
|
|
- if (packingList.length > 1) {
|
|
|
- if (val > packingList.length) {
|
|
|
- this.$message.warning('数量不能大于来源清单数量!');
|
|
|
- return;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (packingList.length == 1) {
|
|
|
- if (val > packingList[0].measureQuantity) {
|
|
|
- this.$message.warning('数量不能大于计量数量!');
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ const maxValue = packingList.length > 1 ? packingList.length : packingList[0].measureQuantity;
|
|
|
+
|
|
|
+ if (val > maxValue) {
|
|
|
+ this.$message.warning('数量不能大于计量数量!');
|
|
|
+ this.formData.number = maxValue;
|
|
|
+ return;
|
|
|
}
|
|
|
},
|
|
|
- handleInput() {
|
|
|
- if (this.formData.portion == null || this.formData.portion == '' || this.formData.portion == 0) {
|
|
|
- this.$message.warning('生成取样数量不能为空!');
|
|
|
- this.tableSelClear();
|
|
|
+ handleInput(val) {
|
|
|
+ if (val == 0 || val == '' || val == null) {
|
|
|
+ this.$refs.table12.clearSelection();
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let packingList = this.$refs.sourceTable.getData();
|
|
|
+ if (!packingList || packingList.length === 0) {
|
|
|
return;
|
|
|
}
|
|
|
- let packingList = this.$refs.sourceTable.getData()
|
|
|
+
|
|
|
+ const portion = Number(this.formData.portion);
|
|
|
|
|
|
if (packingList.length > 1) {
|
|
|
- if (this.formData.portion > packingList.length) {
|
|
|
+ if (portion > packingList.length) {
|
|
|
this.$message.warning('取样数量不能大于来源清单数量!');
|
|
|
+ this.formData.portion = packingList.length;
|
|
|
return;
|
|
|
}
|
|
|
- const rows = packingList.slice(0, this.formData.portion);
|
|
|
- rows.forEach((row) => {
|
|
|
- this.$refs.sourceTable.toggleRowSelection(row);
|
|
|
+ packingList.slice(0, this.formData.portion).forEach(row => {
|
|
|
+ this.$refs.table12.toggleRowSelection(row);
|
|
|
});
|
|
|
} else {
|
|
|
- if (this.formData.portion > packingList[0].measureQuantity) {
|
|
|
+ const maxQuantity = Number(packingList[0].measureQuantity);
|
|
|
+ if (portion > maxQuantity) {
|
|
|
this.$message.warning('取样数量不能大于计量数量!');
|
|
|
+ this.formData.portion = maxQuantity;
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -420,28 +466,20 @@ export default {
|
|
|
this.$emit('changeSamUnit', val)
|
|
|
},
|
|
|
handleSampleSubmit() {
|
|
|
- if (this.formData.portion == null || this.formData.portion == 0) {
|
|
|
- this.$message.warning('生成取样数量不能为空!');
|
|
|
- return;
|
|
|
- }
|
|
|
- //取小样 赋值右上角单位
|
|
|
- this.changeSamUnit(this.formData.sampleUnit)
|
|
|
-
|
|
|
- console.log(this.formData.number, 'this.formData.number')
|
|
|
- console.log(this.formData.sampleUnit, 'this.formData.sampleUnit')
|
|
|
+ this.$refs.ruleForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ //取小样 赋值右上角单位
|
|
|
+ this.changeSamUnit(this.formData.sampleUnit)
|
|
|
|
|
|
- if (this.formData.number == null || this.formData.sampleUnit == '') {
|
|
|
- this.$message.warning('请先选择取样的数量和单位!');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- let params = {
|
|
|
- conditionType: this.conditionType,
|
|
|
- measureQ: this.formData.number,
|
|
|
- sampleUnit: this.formData.sampleUnit,
|
|
|
- portion: this.formData.portion
|
|
|
- }
|
|
|
- this.$emit('handleSampleSubmit', params)
|
|
|
+ let params = {
|
|
|
+ conditionType: this.conditionType,
|
|
|
+ measureQ: this.formData.number,
|
|
|
+ sampleUnit: this.formData.sampleUnit,
|
|
|
+ portion: this.formData.portion
|
|
|
+ }
|
|
|
+ this.$emit('handleSampleSubmit', params)
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
|