|
|
@@ -137,8 +137,7 @@
|
|
|
style="margin-bottom: 20px"
|
|
|
:prop="'datasource.' + scope.$index + '.totalCount'"
|
|
|
:rules="[
|
|
|
- { required: true, message: '请输入数字', trigger: 'blur' },
|
|
|
- { validator: validateTotalCount(scope.row), trigger: 'blur' }
|
|
|
+ { validator: validateTotalCount(scope.row), trigger: ['blur', 'change'] }
|
|
|
]"
|
|
|
>
|
|
|
<el-input
|
|
|
@@ -147,6 +146,16 @@
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
+ <template v-slot:packingQuantity="{ row, $index }">
|
|
|
+ <el-form-item
|
|
|
+ v-if="row.packageId || row.packingUnit"
|
|
|
+ :prop="'datasource.' + $index + '.packingQuantity'"
|
|
|
+ :rules="{ validator: validatePackingQuantity(row), trigger: ['blur', 'change'] }"
|
|
|
+ >
|
|
|
+ <el-input v-model="row.packingQuantity" placeholder="请输入包装数量"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <span v-else>{{ row.packingQuantity }}</span>
|
|
|
+ </template>
|
|
|
<template v-slot:headerTotalCount="{ column }">
|
|
|
<span class="is-required">{{ column.label }}</span>
|
|
|
</template>
|
|
|
@@ -320,6 +329,7 @@
|
|
|
{
|
|
|
minWidth: 100,
|
|
|
prop: 'packingQuantity',
|
|
|
+ slot: 'packingQuantity',
|
|
|
align: 'center',
|
|
|
label: '包装数量',
|
|
|
showOverflowTooltip: true
|
|
|
@@ -334,7 +344,9 @@
|
|
|
{
|
|
|
minWidth: 100,
|
|
|
prop: 'totalCount',
|
|
|
- label: '计量数量',
|
|
|
+ slot: 'totalCount',
|
|
|
+ headerSlot: 'headerTotalCount',
|
|
|
+ label: '退货数量',
|
|
|
showOverflowTooltip: true,
|
|
|
align: 'center'
|
|
|
},
|
|
|
@@ -505,15 +517,7 @@
|
|
|
computed: {
|
|
|
totalAmount() {
|
|
|
let num = 0;
|
|
|
- this.form.datasource.forEach((item, index) => {
|
|
|
- if (item.pricingWay == 1) {
|
|
|
- this.$set(
|
|
|
- this.form.datasource[index],
|
|
|
- 'totalPrice',
|
|
|
- item.singlePrice * item.totalCount || 0
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
+ this.form.datasource.forEach((item) => {
|
|
|
if (item.totalPrice) {
|
|
|
num += Number(item.totalPrice);
|
|
|
}
|
|
|
@@ -527,6 +531,47 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 退货数量变化时按已选出库包装的最小包装单元预填卷数,仍允许按实际退回包装修改。
|
|
|
+ changeNum(value, index) {
|
|
|
+ const row = this.form.datasource[index];
|
|
|
+ const count = Number(value);
|
|
|
+ const unit = Number(row._minPackingQuantity);
|
|
|
+ if (value !== '' && Number.isFinite(count) && count > 0 && Number.isFinite(unit) && unit > 0 && row.packingUnit && row.measuringUnit === row._sourceMeasureUnit) {
|
|
|
+ this.$set(row, 'packingQuantity', Math.ceil(count / unit));
|
|
|
+ } else if (row._sourceMeasureQuantity != null && value !== '' && Number.isFinite(count) && count > 0 && Number(row._sourceMeasureQuantity) === count) {
|
|
|
+ this.$set(row, 'packingQuantity', row._sourcePackingQuantity);
|
|
|
+ } else if (row.packageId || row.packingUnit) {
|
|
|
+ this.$set(row, 'packingQuantity', '');
|
|
|
+ }
|
|
|
+ if (row.pricingWay == 1) {
|
|
|
+ this.$set(row, 'totalPrice', Number.isFinite(count) && count > 0
|
|
|
+ ? (Number(row.singlePrice) * count).toFixed(2) : '');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ validateTotalCount(row) {
|
|
|
+ return (_rule, value, callback) => {
|
|
|
+ const count = Number(value);
|
|
|
+ if (value === '' || value == null || !Number.isFinite(count) || count <= 0) {
|
|
|
+ return callback(new Error('退货数量必须大于0'));
|
|
|
+ }
|
|
|
+ if (row._sourceMeasureQuantity != null && count > Number(row._sourceMeasureQuantity)) {
|
|
|
+ return callback(new Error('退货数量不能超过所选出库明细数量'));
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ };
|
|
|
+ },
|
|
|
+ validatePackingQuantity(row) {
|
|
|
+ return (_rule, value, callback) => {
|
|
|
+ const count = Number(value);
|
|
|
+ if (value === '' || value == null || !Number.isFinite(count) || count <= 0) {
|
|
|
+ return callback(new Error('包装数量必须大于0'));
|
|
|
+ }
|
|
|
+ if (row._sourcePackingQuantity != null && count > Number(row._sourcePackingQuantity)) {
|
|
|
+ return callback(new Error('包装数量不能超过所选出库包装数量'));
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ };
|
|
|
+ },
|
|
|
//出库单详情
|
|
|
handleOutBound(e, rows, index) {
|
|
|
this.curIndex = index;
|
|
|
@@ -647,13 +692,17 @@
|
|
|
|
|
|
// 返回列表数据
|
|
|
getTableValue() {
|
|
|
- let comitDatasource = this.form.datasource;
|
|
|
- if (comitDatasource.length === 0) return { productList: [] };
|
|
|
- comitDatasource.forEach((v) => {
|
|
|
+ if (this.form.datasource.length === 0) return { productList: [] };
|
|
|
+ const comitDatasource = this.form.datasource.map((row) => {
|
|
|
+ const { _sourceMeasureQuantity, _sourcePackingQuantity, _minPackingQuantity, _sourceMeasureUnit, ...v } = row;
|
|
|
v.totalCount = Number(v.totalCount);
|
|
|
+ if (v.packingQuantity !== '' && v.packingQuantity != null) {
|
|
|
+ v.packingQuantity = Number(v.packingQuantity);
|
|
|
+ }
|
|
|
v.technicalDrawings = Array.isArray(v.technicalDrawings)
|
|
|
? v.technicalDrawings
|
|
|
: [];
|
|
|
+ return v;
|
|
|
});
|
|
|
return { productList: comitDatasource, payAmount: this.payAmount };
|
|
|
},
|
|
|
@@ -665,6 +714,12 @@
|
|
|
putTableValue(data) {
|
|
|
if (data && data?.length) {
|
|
|
data.forEach((v) => {
|
|
|
+ if (v.measureQuantity != null && v._sourceMeasureQuantity == null) {
|
|
|
+ this.$set(v, '_sourceMeasureQuantity', v.measureQuantity);
|
|
|
+ this.$set(v, '_sourcePackingQuantity', v.packingQuantity);
|
|
|
+ this.$set(v, '_sourceMeasureUnit', v.measureUnit);
|
|
|
+ this.$set(v, '_minPackingQuantity', v.minPackingQuantity);
|
|
|
+ }
|
|
|
v.returnReason = v.returnReason || '';
|
|
|
v.returnType = v.returnType || '';
|
|
|
v.sendTotalCount = v.sendTotalCount || v.totalCount;
|