hookehuyr

过滤字段名为undefined的值,调试模式下打印提交数据

<!--
* @Date: 2022-07-18 10:22:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-01-17 16:41:38
* @LastEditTime: 2023-01-17 17:22:59
* @FilePath: /data-table/src/views/index.vue
* @Description: 首页
-->
......@@ -359,13 +359,16 @@ const validOther = () => {
};
const onSubmit = async (values) => {
// 过滤掉标识为ignore的字段数据
let { ignore, ...rest_data } = values;
// 过滤掉标识为 ignore,undefined 的字段数据
let { ignore, undefined, ...rest_data } = values;
// 合并自定义字段到提交表单字段
postData.value = _.assign(postData.value, rest_data);
// 检查非表单输入项
if (validOther().status) {
// 编辑模式不能提交数据
if (model === 'edit') {
console.warn(postData.value);
}
if (model === 'edit') return false;
// 通过验证
const result = await addFormDataAPI({
......