fix: 移除 layui.use 异步包裹,解决表单提交索引字段丢失问题 - #138
Open
JacksonHei wants to merge 1 commit into
Open
Conversation
问题描述 在 syncTableData() 执行表格重载后,表单提交时 form.val 无法获取 keys[0][columns] 的值(索引字段丢失)。 复现步骤 表单中使用 xmSelect 组件作为索引字段; 触发表格重载(如 syncTableData()); 提交表单,form.val 返回的数据中缺少 keys[0][columns]。 解决方案 移除 keyColumnMultiSelectRender 函数内的 layui.use 异步包裹,使 xmSelect.render 同步执行,确保 DOM 渲染完成后再收集表单数据。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
在 syncTableData() 执行表格重载后,表单提交时 form.val 无法获取 keys[0][columns] 的值(索引字段丢失)。
{
"code": 500,
"msg": "Undefined array key "columns"",
"type": "failed",
"traces": "ErrorException: Undefined array key "columns" in H:\go_project\workerman\webman\plugin\admin\app\controller\TableController.php:267\nStack trace:\n#0 H:\go_project\workerman\webman\plugin\admin\app\controller\TableController.php(267): {closure}(2, 'Undefined array...', 'H:\\go_project\\w...', 267)\n#1 H:\go_project\workerman\webman\vendor\workerman\webman-framework\src\App.php(428): plugin\admin\app\controller\TableController->modify(Object(support\Request))\n#2 H:\go_project\workerman\webman\vendor\workerman\webman-framework\src\App.php(444): Webman\App::Webman\{closure}(Object(support\Request))\n#3 H:\go_project\workerman\webman\plugin\admin\app\middleware\AccessControl.php(40): Webman\App::Webman\{closure}(Object(support\Request))\n#4 H:\go_project\workerman\webman\vendor\workerman\webman-framework\src\App.php(468): plugin\admin\app\middleware\AccessControl->process(Object(support\Request), Object(Closure))\n#5 H:\go_project\workerman\webman\vendor\workerman\webman-framework\src\App.php(198): Webman\App::Webman\{closure}(Object(support\Request))\n#6 H:\go_project\workerman\webman\vendor\workerman\workerman\src\Connection\TcpConnection.php(816): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))\n#7 H:\go_project\workerman\webman\vendor\workerman\workerman\src\Events\Select.php(406): Workerman\Connection\TcpConnection->baseRead(Resource id #684)\n#8 H:\go_project\workerman\webman\vendor\workerman\workerman\src\Worker.php(1620): Workerman\Events\Select->run()\n#9 H:\go_project\workerman\webman\vendor\workerman\workerman\src\Worker.php(1536): Workerman\Worker::forkWorkersForWindows()\n#10 H:\go_project\workerman\webman\vendor\workerman\workerman\src\Worker.php(603): Workerman\Worker::forkWorkers()\n#11 H:\go_project\workerman\webman\runtime\windows\start_webman.php(33): Workerman\Worker::runAll()\n#12 {main}"
}
复现步骤
表单中使用 xmSelect 组件作为索引字段;
触发表格重载(如 syncTableData());
提交表单,form.val 返回的数据中缺少 keys[0][columns]。
解决方案
移除 keyColumnMultiSelectRender 函数内的 layui.use 异步包裹,使 xmSelect.render 同步执行,确保 DOM 渲染完成后再收集表单数据。
测试结果
验证方法:本地启动项目,复现问题步骤,提交表单后检查 form.val 是否包含 keys[0][columns]。
结果:修改后,form.val 正确获取索引字段值,问题解决。
副作用检查:未影响 jquery、table 等模块的正常使用,xmSelect 渲染功能正常。