|
|
@@ -2,7 +2,6 @@
|
|
|
<el-form ref="form" :model="form" :rules="rules">
|
|
|
<ele-pro-table
|
|
|
ref="table"
|
|
|
- :needPage="false"
|
|
|
:columns="columns"
|
|
|
height="400"
|
|
|
full-height="calc(100vh - 76px)"
|
|
|
@@ -1271,10 +1270,10 @@
|
|
|
item.key = this.form.datasource.length + 1;
|
|
|
this.form.datasource.push(item);
|
|
|
},
|
|
|
-
|
|
|
- validateForm(callback) {
|
|
|
+ validateForm1(callback) {
|
|
|
//开始表单校验
|
|
|
this.$refs.form.validate((valid, obj) => {
|
|
|
+ console.log(valid, obj);
|
|
|
if (obj) {
|
|
|
let messages = Object.keys(obj).map((key) => obj[key][0]);
|
|
|
if (messages.length > 0) {
|
|
|
@@ -1283,6 +1282,48 @@
|
|
|
}
|
|
|
callback(valid);
|
|
|
});
|
|
|
+ },
|
|
|
+ validateForm(callback) {
|
|
|
+ //开始表单校验
|
|
|
+ this.$refs.form.validate((valid, obj) => {
|
|
|
+ console.log(valid, obj);
|
|
|
+ if (obj) {
|
|
|
+ let messages = Object.keys(obj).map((key) => obj[key][0]);
|
|
|
+ if (messages.length > 0) {
|
|
|
+ this.$message.warning(messages[0].message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果表单校验未通过,不需要进行下面的额外校验
|
|
|
+ if (valid) {
|
|
|
+ // 额外校验数量和到货日期是否填写
|
|
|
+ if (this.form && this.form.datasource) {
|
|
|
+ let isDataSourceValid = true;
|
|
|
+ let errorItemIndex = -1;
|
|
|
+ for (let i = 0; i < this.form.datasource.length; i++) {
|
|
|
+ const item = this.form.datasource[i];
|
|
|
+ // 检查数量和到货日期是否填写(数量可以为0)
|
|
|
+ if (item.totalCount == null || item.totalCount === '' || !item.expectReceiveDate) {
|
|
|
+ isDataSourceValid = false;
|
|
|
+ errorItemIndex = i;
|
|
|
+ break; // 找到第一个未填写的项目
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果有未填写的项目
|
|
|
+ if (!isDataSourceValid) {
|
|
|
+ this.$message.warning(`第${errorItemIndex + 1}项数据未完整填写,请检查数量和到货日期`);
|
|
|
+ // let currentPage = this.$refs.table.tablePage;
|
|
|
+ // const pageSize = this.$refs.table.tableLimit; // 每页显示10条数据
|
|
|
+ // const targetPage = Math.floor(errorItemIndex / pageSize) + 1; // 计算目标页码
|
|
|
+ // if (currentPage !== targetPage) {
|
|
|
+ // currentPage = targetPage;
|
|
|
+ // this.$refs.table.reload({ page: currentPage });
|
|
|
+ // }
|
|
|
+ valid = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ callback(valid);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|