|
|
@@ -1,16 +1,48 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <ele-pro-table
|
|
|
- ref="table"
|
|
|
- :needPage="false"
|
|
|
- :columns="columns"
|
|
|
- :datasource="tableForm.detailList"
|
|
|
- row-key="id"
|
|
|
- >
|
|
|
- <template v-slot:toolbar>
|
|
|
- <span>已开票金额:{{ invoiceAmount }}</span>
|
|
|
+ <el-form ref="form" :model="tableForm">
|
|
|
+ <ele-pro-table
|
|
|
+ ref="table"
|
|
|
+ :needPage="false"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="tableForm.detailList"
|
|
|
+ row-key="id"
|
|
|
+ class="time-form"
|
|
|
+ >
|
|
|
+ <template v-slot:toolbar>
|
|
|
+ <span>已开票金额:{{ invoiceAmount }}</span>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-slot:totalCount="scope">
|
|
|
+ <el-form-item
|
|
|
+ style="width: 100%;"
|
|
|
+ :prop="'detailList.' + scope.$index + '.totalCount'"
|
|
|
+ :rules="[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入数量',
|
|
|
+ trigger: 'blur'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value === undefined || value === null || value === '') {
|
|
|
+ callback('请输入数量');
|
|
|
+ } else if (parseFloat(value) <= 0) {
|
|
|
+ callback('数量必须大于0');
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ <el-input v-model="scope.row.totalCount" type="number" @input="updateTotalPrice(scope.row)"></el-input>
|
|
|
+ </el-form-item>
|
|
|
</template>
|
|
|
- </ele-pro-table>
|
|
|
+
|
|
|
+ </ele-pro-table>
|
|
|
+ </el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
@@ -115,11 +147,11 @@
|
|
|
// },
|
|
|
|
|
|
{
|
|
|
- width: 80,
|
|
|
+ width: 100,
|
|
|
prop: 'totalCount',
|
|
|
label: '数量',
|
|
|
slot: 'totalCount',
|
|
|
- align: 'center'
|
|
|
+ align: 'center',
|
|
|
},
|
|
|
|
|
|
{
|
|
|
@@ -207,7 +239,7 @@
|
|
|
label: '采购退货',
|
|
|
value: '21'
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -273,6 +305,12 @@
|
|
|
link: []
|
|
|
};
|
|
|
},
|
|
|
+ // 当数量变化时更新金额
|
|
|
+ updateTotalPrice(row) {
|
|
|
+ if (row.totalCount && row.singlePrice) {
|
|
|
+ row.totalPrice = (parseFloat(row.totalCount) * parseFloat(row.singlePrice)).toFixed(2);
|
|
|
+ }
|
|
|
+ },
|
|
|
getTableValidate() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
if (
|
|
|
@@ -283,6 +321,18 @@
|
|
|
resolve(this.tableForm);
|
|
|
});
|
|
|
},
|
|
|
+ validateForm(callback) {
|
|
|
+ //开始表单校验
|
|
|
+ this.$refs.form.validate((valid, obj) => {
|
|
|
+ if (obj) {
|
|
|
+ let messages = Object.keys(obj).map((key) => obj[key][0]);
|
|
|
+ if (messages.length > 0) {
|
|
|
+ this.$message.warning(messages[0].message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ callback(valid);
|
|
|
+ });
|
|
|
+ },
|
|
|
setSelectData(val) {
|
|
|
this.tableForm.link = [{}];
|
|
|
this.$set(this.tableForm.link[0], 'linkId', val.id);
|
|
|
@@ -296,4 +346,8 @@
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style scoped lang="scss"></style>
|
|
|
+<style scoped lang="scss">
|
|
|
+.time-form .el-form-item {
|
|
|
+ margin-bottom: 0 !important;
|
|
|
+}
|
|
|
+</style>
|