diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 03b836f..36c0beb 100755 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -817,6 +817,12 @@ class UserController extends BaseController $tempFile = $file->getRealPath(); $dataArray = (new FastExcel)->import($tempFile)->toArray(); + // 从 Excel 第一行获取表头 + $headers = []; + if (!empty($dataArray)) { + $headers = array_keys($dataArray[0]); + } + // 数据过滤,只能导入数据表有的字段 $tableName = $this->model->getTable(); $rowTableFieldByComment = (new CustomFormField)->getRowTableFieldsByComment($tableName); @@ -885,7 +891,7 @@ class UserController extends BaseController // 构建返回结果 $result = [ - 'headers' => $rowTableFieldByComment, // 表头信息,键为字段名,值为中文注释 + 'headers' => $headers, // 表头信息,直接使用 Excel 文件中的表头 'list' => $list, 'matched_count' => count($list) - count($unmatchedUsers), 'unmatched_count' => count($unmatchedUsers), diff --git a/database/migrations/2026_01_14_110320_modify_users_table_fields_comment_and_position.php b/database/migrations/2026_01_14_110320_modify_users_table_fields_comment_and_position.php new file mode 100644 index 0000000..67ba335 --- /dev/null +++ b/database/migrations/2026_01_14_110320_modify_users_table_fields_comment_and_position.php @@ -0,0 +1,51 @@ +string('from')->nullable()->comment('学员标签')->change(); + + // 修改 talent_tags 字段注释为 '人才标签' + $table->string('talent_tags')->nullable()->comment('人才标签')->change(); + + // 修改 company_area 字段注释为 '公司所属区域' + $table->string('company_area')->nullable()->comment('公司所属区域')->change(); + + // 修改 type 字段注释为 '个人荣誉' + $table->string('type')->nullable()->comment('个人荣誉')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + // 回滚 from 字段注释 + $table->string('from')->nullable()->comment('来源')->change(); + + // 回滚 talent_tags 字段注释 + $table->string('talent_tags')->nullable()->comment('人才标签,多个值用英文逗号分隔')->change(); + + // 回滚 company_area 字段注释 + $table->string('company_area')->nullable()->comment('公司区域')->change(); + + // 回滚 type 字段注释 + $table->string('type')->nullable()->comment('人才类型')->change(); + }); + } +};