master
cody 3 months ago
parent 3f2b8ef3e7
commit 773f9ebab8

@ -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),

@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
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();
});
}
/**
* 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();
});
}
};
Loading…
Cancel
Save