cqp 1 ヶ月 前
コミット
9b6d068dbb

+ 76 - 0
app/Http/Controllers/Api/TeamController.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Service\TeamService;
+use Illuminate\Http\Request;
+
+class TeamController extends BaseController
+{
+    public function teamEdit(Request $request)
+    {
+        $service = new TeamService();
+        $user = $request->userData;
+        list($status,$data) = $service->teamEdit($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function teamAdd(Request $request)
+    {
+        $service = new TeamService();
+        $user = $request->userData;
+        list($status,$data) = $service->teamAdd($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+    public function teamDel(Request $request)
+    {
+        $service = new TeamService();
+        $user = $request->userData;
+        list($status,$data) = $service->teamDel($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+    public function teamList(Request $request)
+    {
+        $service = new TeamService();
+        $user = $request->userData;
+        list($status,$data) = $service->teamList($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function teamDetail(Request $request)
+    {
+        $service = new TeamService();
+        $user = $request->userData;
+        list($status,$data) = $service->teamDetail($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+}

+ 21 - 0
app/Model/Team.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Model;
+
+class Team extends DataScopeBaseModel
+{
+    protected $table = "item"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+    const employee_column = "crt_id";
+
+    public static $field = ['title','id','code','mark','crt_id','crt_time','state','charge_id'];
+
+    const TYPE_ZERO = 0;
+    const TYPE_ONE = 1;
+    const State_Type = [
+        self::TYPE_ZERO => '停用',
+        self::TYPE_ONE => '启用',
+    ];
+}

+ 12 - 0
app/Model/TeamDetails.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Model;
+
+class TeamDetails extends DataScopeBaseModel
+{
+    protected $guarded = [];
+    protected $table = "team_details"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+}

+ 241 - 0
app/Service/ImportService.php

@@ -21,6 +21,8 @@ use App\Model\PLeaveOverOrder;
 use App\Model\Priority;
 use App\Model\RuleSet;
 use App\Model\RuleSetDetails;
+use App\Model\Team;
+use App\Model\TeamDetails;
 use Illuminate\Support\Facades\DB;
 use Maatwebsite\Excel\Facades\Excel;
 use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\F;
@@ -47,6 +49,7 @@ class ImportService extends Service
         'feeOrder', // 费用项目单
         'RDOrder', // 研发支出辅助帐
         'priority', // 优先级
+        'team', // 团队
     ];
 
     public function getTableTitleXls($data,$user){
@@ -4105,6 +4108,244 @@ class ImportService extends Service
         return [$error_string, $update];
     }
 
+    // 团队 -----------------------------------
+    private function getTeamList($array, $user, $index){
+        $codes = array_unique(array_filter(array_column($array,$index)));
+
+        return Team::where('del_time', 0)
+            ->where('top_depart_id', $user['top_depart_id'])
+            ->whereIn('code', $codes)
+            ->pluck('id','code')
+            ->toArray();
+    }
+
+    public function teamImport($array, $user, $other_param)
+    {
+        $upload = $array[0];
+        list($status, $msg) = $this->compareTableAndReturn($upload, $other_param);
+        if (!$status) return [false, $msg];
+        $table_config = $msg;
+
+        unset($array[0]);
+        if (empty($array)) return [false, '导入数据不能为空'];
+
+        // 1. 公共校验 (必填、唯一性等)
+        list($array, $error) = $this->checkCommon($array, $table_config);
+        if (!empty($error)) return [0, $error];
+
+        // 2. 业务详细校验 (包含一致性校验、明细解析)
+        list($error, $update_map, $detail_data_map) = $this->teamCheck($array, $user, $table_config);
+        if (!empty($error)) return [0, $error];
+
+        $time = time();
+        $insert_data = [];
+        $update_data = [];
+        $all_detail_insert = [];
+        $update_main_ids = [];
+
+        $keys = array_column($table_config, 'key');
+        $codeIdx = array_search('code', $keys);
+
+        // 3. 数据分拣(聚合平铺数据)
+        foreach ($array as $key => $value) {
+            $itemCode = trim($value[$codeIdx]);
+            $main_tmp = [];
+            foreach ($value as $k => $val) {
+                if (!empty($table_config[$k]['is_main'])) {
+
+                    if ($table_config[$k]['key'] == 'employee_title') continue;
+
+                    $main_tmp[$table_config[$k]['key']] = $val;
+                }
+            }
+
+            if (isset($update_map[$key])) {
+                // 更新逻辑:以 ID 为键去重
+                $itemId = $update_map[$key];
+                $update_main_ids[$itemId] = $itemId;
+                $update_data[$itemId] = array_merge($main_tmp, ['id' => $itemId]);
+
+                if (isset($detail_data_map[$key])) {
+                    foreach ($detail_data_map[$key] as $d) {
+                        $all_detail_insert[] = array_merge($d, [
+                            'team_id' => $itemId,
+                            'crt_time' => $time,
+                            'top_depart_id' => $user['top_depart_id']
+                        ]);
+                    }
+                }
+            } else {
+                // 新增逻辑:以项目编码为键去重
+                if (!isset($insert_data[$itemCode])) {
+                    $main_tmp['top_depart_id'] = $user['top_depart_id'];
+                    $main_tmp['crt_id'] = $user['id'];
+                    $main_tmp['crt_time'] = $time;
+                    $insert_data[$itemCode] = $main_tmp;
+                }
+
+                if (isset($detail_data_map[$key])) {
+                    foreach ($detail_data_map[$key] as $d) {
+                        $all_detail_insert[] = array_merge($d, [
+                            '_code' => $itemCode,
+                            'crt_time' => $time,
+                            'top_depart_id' => $user['top_depart_id']
+                        ]);
+                    }
+                }
+            }
+        }
+
+        DB::beginTransaction();
+        try {
+            // 4. 执行新增主表
+            $new_item_maps = [];
+            if (!empty($insert_data)) {
+                foreach (array_chunk(array_values($insert_data), 500) as $chunk) {
+                    Team::insert($chunk);
+                }
+                $new_item_maps = Team::whereIn('code', array_keys($insert_data))
+                    ->where('del_time', 0)
+                    ->where('top_depart_id', $user['top_depart_id'])
+                    ->pluck('id', 'code')->toArray();
+            }
+
+            // 5. 执行更新主表
+            if (!empty($update_data)) {
+                foreach ($update_data as $id => $uItem) {
+                    unset($uItem['id']);
+                    Team::where('id', $id)->update($uItem);
+                }
+            }
+
+            // 6. 处理明细表 (先全删后插)
+            if (!empty($update_main_ids)) {
+                TeamDetails::whereIn('team_id', array_values($update_main_ids))
+                    ->where('del_time', 0)
+                    ->update(['del_time' => $time]);
+            }
+
+            foreach ($all_detail_insert as &$di) {
+                if (isset($di['_code'])) {
+                    $di['item_id'] = $new_item_maps[$di['_code']] ?? 0;
+                    unset($di['_code']);
+                }
+            }
+            unset($di);
+
+            if (!empty($all_detail_insert)) {
+                foreach (array_chunk($all_detail_insert, 500) as $chunk) {
+                    TeamDetails::insert($chunk);
+                }
+            }
+
+            DB::commit();
+        } catch (\Exception $e) {
+            DB::rollBack();
+            return [false, "失败:" . $e->getMessage() . " (行号:" . $e->getLine() . ")"];
+        }
+
+        return [true, ''];
+    }
+
+    private function teamCheck(&$array, $user, $table_config)
+    {
+        $keys = array_column($table_config, 'key');
+        $codeIdx = array_search('code', $keys);
+        $stateIdx = array_search('state', $keys);
+        $code2Idx = array_search('code_2', $keys);  // 工号列
+        $empIdx = array_search('charge_id', $keys);
+
+        // 假设 $array 是你的数据集
+        $allEmpNumbers = array_values(array_filter(array_unique([
+            array_column($array, $empIdx),
+            array_column($array, $code2Idx)
+        ])));
+
+        $dbEmps = Employee::where('del_time', 0)
+            ->whereIn('number', $allEmpNumbers)
+            ->where('top_depart_id', $user['top_depart_id'])
+            ->pluck('id', 'number')->toArray();
+
+        $code_map = $this->getTeamList($array, $user, $codeIdx);
+        $man_map = $this->getFlatDataList2($array, $user, $code2Idx);
+
+        $errors = [];
+        $update_mapping = [];
+        $detail_storage = [];
+        $mainDataConsistency = []; // 一致性校验
+
+        $state_type_map = array_flip(Team::State_Type);
+
+        // 识别主表字段列索引
+        $mainColIndices = [];
+        foreach ($table_config as $index => $conf) {
+            if (!empty($conf['is_main'])) $mainColIndices[$index] = $conf['value'];
+        }
+
+        foreach ($array as $rowIndex => $rowValue) {
+            $displayLine = $rowIndex + 1;
+            $valCode = trim($rowValue[$codeIdx] ?? '');
+            $valEmp = trim($rowValue[$empIdx] ?? '');
+            if ($valCode === '') continue;
+
+            // --- A. 主表一致性校验 ---
+            if (!isset($mainDataConsistency[$valCode])) {
+                $mainDataConsistency[$valCode] = array_intersect_key($rowValue, $mainColIndices);
+            } else {
+                foreach ($mainColIndices as $idx => $label) {
+                    if (trim($rowValue[$idx] ?? '') != trim($mainDataConsistency[$valCode][$idx] ?? '')) {
+                        $errors[] = "第{$displayLine}行:团队[{$valCode}]的主表信息[{$label}]与前文不一致";
+                    }
+                }
+            }
+
+            // --- B. 基础校验 ---
+            if (isset($code_map[$valCode])) {
+                $update_mapping[$rowIndex] = $code_map[$valCode];
+            }
+
+            // 状态
+            $state_text = $rowValue[$stateIdx] ?? '';
+            if (!isset($state_type_map[$state_text])) {
+                $errors[] = "第{$displayLine}行:状态[{$state_text}]无效";
+            } else {
+                $array[$rowIndex][$stateIdx] = $state_type_map[$state_text];
+            }
+
+            // D. 人员校验
+            if(! empty($valEmp)){
+                if (!isset($dbEmps[$valEmp])) {
+                    $errors[] = "第{$displayLine}行:负责人工号[{$valEmp}]不存在";
+                } else {
+                    $array[$rowIndex][$empIdx] = $dbEmps[$valEmp];
+                }
+            }
+
+            $subCode  = trim($rowValue[$code2Idx] ?? '');
+
+            if ($subCode !== '') {
+                if (!isset($man_map[$subCode])) {
+                    $errors[] = "第{$displayLine}行:人员工号[{$subCode}]不存在";
+                } else {
+                    $detail_storage[$rowIndex][] = ['data_id' => $man_map[$subCode]];
+                }
+            }
+        }
+
+        $error_str = !empty($errors) ? implode('|', $errors) : "";
+        return [$error_str, $update_mapping, $detail_storage];
+    }
+
+    private function getFlatDataList2($array, $user, $code2Idx)
+    {
+        $codes = array_unique(array_filter(array_column($array, $code2Idx)));
+        return Employee::where('del_time', 0)
+            ->where('top_depart_id', $user['top_depart_id'])
+            ->whereIn('number', $codes)
+            ->pluck('id', 'number')
+            ->toArray();
+    }
+
     /**
      * 解析并校验时间
      */

+ 1 - 1
app/Service/ItemService.php

@@ -215,7 +215,7 @@ class ItemService extends Service
         $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('title');
         $customer['charge_name'] = Employee::where('id',$customer['charge_id'])->value('title');
         $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
-        $customer['state_title'] = Employee::State_Type[$customer['state']] ?? '';
+        $customer['state_title'] = Item::State_Type[$customer['state']] ?? '';
 
         $details = $this->getDetail($data['id']);
         $customer = array_merge($customer, $details);

+ 316 - 0
app/Service/TeamService.php

@@ -0,0 +1,316 @@
+<?php
+
+namespace App\Service;
+
+use App\Model\Employee;
+use App\Model\Team;
+use App\Model\TeamDetails;
+use Illuminate\Support\Facades\DB;
+
+class TeamService extends Service
+{
+    public function teamEdit($data,$user){
+        list($status,$msg) = $this->teamRule($data, $user, false);
+        if(!$status) return [$status,$msg];
+
+        try {
+            DB::beginTransaction();
+
+            $model = Team::where('id',$data['id'])->first();
+            $model->code = $data['code'] ?? '';
+            $model->title = $data['title'] ?? '';
+            $model->mark = $data['mark'] ?? '';
+            $model->state = $data['state'] ?? 0;
+            $model->charge_id = $data['charge_id'] ?? 0;
+            $model->save();
+
+            $time = time();
+            TeamDetails::where('del_time',0)
+                ->where('team_id', $model->id)
+                ->update(['del_time' => $time]);
+            $this->saveDetail($model->id, $time, $data);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true, ''];
+    }
+
+    public function teamAdd($data,$user){
+        list($status,$msg) = $this->teamRule($data, $user);
+        if(!$status) return [$status,$msg];
+
+        try {
+            DB::beginTransaction();
+
+            $model = new Team();
+            $model->code = $data['code'] ?? '';
+            $model->title = $data['title'] ?? '';
+            $model->mark = $data['mark'] ?? '';
+            $model->state = $data['state'] ?? 0;
+            $model->charge_id = $data['charge_id'] ?? 0;
+            $model->crt_id = $user['id'];
+            $model->top_depart_id = $user['top_depart_id'];
+            $model->save();
+
+            $this->saveDetail($model->id, time(), $data);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true, ''];
+    }
+
+    private function saveDetail($id, $time, $data){
+        if(! empty($data['man_list'])){
+            $unit = [];
+            foreach ($data['man_list'] as $value){
+                $unit[] = [
+                    'team_id' => $id,
+                    'data_id' => $value['data_id'],
+                    'crt_time' => $time,
+                    'top_depart_id' => $value['top_depart_id'],
+                ];
+            }
+            if(! empty($unit)) TeamDetails::insert($unit);
+        }
+    }
+
+    private function getDetail($id){
+        $data = TeamDetails::where('del_time',0)
+            ->where('team_id', $id)
+            ->get()->toArray();
+
+        $map = Employee::whereIn('id', array_unique(array_column($data,'data_id')))
+            ->select('title','id','number')
+            ->get()->toArray();
+        $map = array_column($map,null,'id');
+
+        $unit = $receipt = [];
+        foreach ($data as $value){
+            $tmp = $map[$value['data_id']] ?? [];
+            $unit[] = [
+                'type' => $value['type'],
+                'data_id' => $value['data_id'],
+                'data_title' => $tmp['title'],
+                'data_code' => $tmp['number'],
+            ];
+        }
+
+        $detail = [
+            'man_list' => $unit,
+        ];
+
+        return $detail;
+    }
+
+    public function teamDel($data){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+
+        try {
+            DB::beginTransaction();
+            $time = time();
+
+            Team::where('del_time',0)
+                ->whereIn('id',$data['id'])
+                ->update(['del_time' => $time]);
+
+            TeamDetails::where('del_time',0)
+                ->whereIn('team_id', $data['id'])
+                ->update(['del_time' => $time]);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true, ''];
+    }
+
+    public function teamDetail($data, $user){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+        $customer = Team::where('del_time',0)
+            ->where('id',$data['id'])
+            ->first();
+        if(empty($customer)) return [false,'团队不存在或已被删除'];
+        $customer = $customer->toArray();
+        $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('title');
+        $customer['charge_name'] = Employee::where('id',$customer['charge_id'])->value('title');
+        $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
+        $customer['state_title'] = Employee::State_Type[$customer['state']] ?? '';
+
+        $details = $this->getDetail($data['id']);
+        $customer = array_merge($customer, $details);
+
+        return [true, $customer];
+    }
+
+    public function teamCommon($data,$user, $field = []){
+        if(empty($field)) $field = Team::$field;
+
+        $model = Team::TopClear($user,$data);
+        $model = $model->where('del_time',0)
+            ->select($field)
+            ->orderby('id', 'desc');
+
+        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
+        if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
+        if(! empty($data['id'])) $model->whereIn('id', $data['id']);
+        if(isset($data['state'])) $model->where('state', $data['state']);
+        if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
+            $model->where('crt_time','>=',$return[0]);
+            $model->where('crt_time','<=',$return[1]);
+        }
+
+        return $model;
+    }
+
+    public function teamList($data,$user){
+        $model = $this->teamCommon($data, $user);
+        $list = $this->limit($model,'',$data);
+        $list = $this->fillData($list);
+
+        return [true, $list];
+    }
+
+    public function teamRule(&$data, $user, $is_add = true){
+        if(empty($data['code'])) return [false, '团队编码不能为空'];
+        if(! is_numeric($data['code'])) return [false, '团队编码请输入数字'];
+        if(empty($data['title'])) return [false, '团队名称不能为空'];
+        if(! isset($data['state'])) return [false, '状态不能为空'];
+        if(! isset(Team::State_Type[$data['state']])) return [false, '状态不存在'];
+        if(empty($data['man_list'])) return [false, '人员不能为空'];
+        foreach ($data['man_list'] as $key => $value){
+            if(empty($value['type'])) return [false, '类型不能为空'];
+            if(empty($value['data_id'])) return [false, '人员不能为空'];
+            $data['man_list'][$key]['top_depart_id'] = $data['top_depart_id'];
+        }
+        list($status, $msg) = $this->checkArrayRepeat($data['man_list'],'data_id','人员');
+        if(! $status) return [false, $msg];
+
+        if($is_add){
+            $bool = Team::where('code',$data['code'])
+                ->where('top_depart_id', $data['top_depart_id'])
+                ->where('del_time',0)
+                ->exists();
+        }else{
+            if(empty($data['id'])) return [false,'ID不能为空'];
+            $bool = Team::where('code',$data['code'])
+                ->where('top_depart_id', $data['top_depart_id'])
+                ->where('id','<>',$data['id'])
+                ->where('del_time',0)
+                ->exists();
+        }
+        if($bool) return [false, '团队编码已存在'];
+
+        return [true, ''];
+    }
+
+    public function fillData($data){
+        if(empty($data['data'])) return $data;
+
+        $emp = (new EmployeeService())->getEmployeeMap(array_unique(array_merge_recursive(array_column($data['data'],'charge_id'), array_column($data['data'],'crt_id'))));
+        foreach ($data['data'] as $key => $value){
+            $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
+            $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
+            $data['data'][$key]['charge_name'] = $emp[$value['charge_id']] ?? '';
+            $data['data'][$key]['state_title'] = Team::State_Type[$value['state']] ?? "";
+        }
+
+        return $data;
+    }
+
+    /**
+     * 填充项目导出数据(主表与明细平铺)
+     */
+    public function fillDataForExport($data, $column, $user, &$return)
+    {
+        if (empty($data)) return;
+
+        $dataArray = is_array($data) ? $data : $data->toArray();
+        $mainIds = array_column($dataArray, 'id');
+
+        // 1. 获取详情映射 [team_id => [ [type_title=>..., code_2=>..., title=>...], ... ]]
+        $detailsMap = $this->getDetailsMap($mainIds, $user);
+
+        // 2. 获取主表状态映射
+        $stateMap = \App\Model\Team::State_Type;
+
+        $empMap = Employee::whereIn('id', array_unique(array_column($dataArray,'charge_id')))->get()->keyBy('id');
+
+        foreach ($dataArray as $main) {
+            $teamId = $main['id'];
+            $details = $detailsMap[$teamId] ?? [];
+
+            // 3. 提取并格式化主表信息
+            $mainInfo = $main;
+            $mainInfo['state_title'] = $stateMap[$main['state'] ?? ''] ?? '';
+
+            $tmpEmp = $empMap[$main['charge_id']] ?? null;
+            $mainInfo['charge_number'] = $tmpEmp ? $tmpEmp->number : '';
+            $mainInfo['charge_name'] = $tmpEmp ? $tmpEmp->title : '';
+
+            if (empty($details)) {
+                // 如果单据没有明细,保底出一行
+                $tempRow = [];
+                foreach ($column as $col) {
+                    $tempRow[] = $mainInfo[$col] ?? '';
+                }
+                $return[] = $tempRow;
+            } else {
+                // 4. 核心平铺逻辑:每一行明细都带上主表信息
+                foreach ($details as $sub) {
+                    // 合并主表数据和详情数据(sub 中包含 type_title, code_2, title 等)
+                    $fullRowData = array_merge($mainInfo, $sub);
+
+                    $tempRow = [];
+                    foreach ($column as $col) {
+                        $tempRow[] = $fullRowData[$col] ?? '';
+                    }
+                    $return[] = $tempRow;
+                }
+            }
+        }
+    }
+
+    /**
+     * 获取明细聚合映射表
+     */
+    public function getDetailsMap($mainIds, $user)
+    {
+        $details = TeamDetails::where('del_time', 0)
+            ->whereIn('team_id', $mainIds)
+            ->where('top_depart_id', $user['top_depart_id'])
+            ->get();
+
+        if ($details->isEmpty()) return [];
+
+        // 1. 批量提取关联 ID
+        $empIds = $details->pluck('data_id')->unique();
+
+        // 2. 批量获取档案 Map
+        $empMap = Employee::whereIn('id', $empIds)->get()->keyBy('id');
+
+        $res = [];
+        foreach ($details as $team) {
+            $detailRow = [];
+
+            $emp = $empMap[$team->data_id] ?? null;
+            $detailRow['code_2'] = $emp ? $emp->number : '';
+            $detailRow['title_2']  = $emp ? $emp->title : '';
+
+            // 归档到对应的主表 ID 下
+            $res[$team->team_id][] = $detailRow;
+        }
+
+        return $res;
+    }
+}

+ 94 - 0
config/excel/team.php

@@ -0,0 +1,94 @@
+<?php
+return [
+    "name" => "团队档案",
+    "array" => [
+        [
+            'key' =>'code',
+            'export' =>'code',
+            'value' => '团队编码',
+            'required' => true,
+            'is_main' => true,
+            'default' => "",
+            'unique' => false,
+            'enums' => [],
+            'comments' => '必填'
+        ],
+        [
+            'key' =>'title',
+            'export' =>'title',
+            'value' => '团队名称',
+            'required' => true,
+            'is_main' => true,
+            'default' => "",
+            'unique' => false,
+            'enums' => [],
+            'comments' => '必填'
+        ],
+        [
+            'key' =>'charge_id',
+            'export' =>'charge_number',
+            'value' => '负责人工号',
+            'required' => false,
+            'is_main' => true,
+            'default' => "",
+            'unique' => false,
+            'enums' => [],
+            'comments' => '选填(填写负责人工号)'
+        ],
+        [
+            'key' =>'employee_title',
+            'export' =>'charge_name',
+            'value' => '负责人名称',
+            'required' => false,
+            'is_main' => true,
+            'default' => "",
+            'unique' => false,
+            'enums' => [],
+            'comments' => '选填(便于操作人查看编码对应的名称)'
+        ],
+        [
+            'key' =>'state',
+            'export' =>'state_title',
+            'value' => '状态',
+            'required' => true,
+            'is_main' => true,
+            'default' => \App\Model\Team::TYPE_ONE,
+            'unique' => false,
+            'enums' => array_values(\App\Model\Team::State_Type),
+            'comments' => '必填'
+        ],
+        [
+            'key' =>'mark',
+            'export' =>'mark',
+            'value' => '团队描述',
+            'required' => false,
+            'is_main' => true,
+            'unique' => false,
+            'enums' => [],
+            'default' => "",
+            'comments' => ""
+        ],
+        [
+            'key' =>'code_2',
+            'export' =>'code_2',
+            'value' => '人员工号',
+            'required' => true,
+            'is_main' => false,
+            'default' => "",
+            'unique' => false,
+            'enums' => [],
+            'comments' => '必填(人员的工号)'
+        ],
+        [
+            'key' =>'title_2',
+            'export' =>'title_2',
+            'value' => '人员名称',
+            'required' => false,
+            'is_main' => false,
+            'default' => "",
+            'unique' => false,
+            'enums' => [],
+            'comments' => '选填(便于操作人查看编码对应的名称)'
+        ],
+    ]
+];

+ 7 - 8
routes/api.php

@@ -92,14 +92,6 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('itemDel', 'Api\ItemController@itemDel');
     $route->any('itemDetail', 'Api\ItemController@itemDetail');
 
-    //中台新建角色 以及分配菜单权限
-    $route->any('roleMiddleGroundAdd', 'Api\RoleMiddleGroudController@roleAdd');
-    $route->any('roleMiddleGroundEdit', 'Api\RoleMiddleGroudController@roleEdit');
-    $route->any('roleMiddleGroundDel', 'Api\RoleMiddleGroudController@roleDel');
-    $route->any('roleMiddleGroundList', 'Api\RoleMiddleGroudController@roleList');
-    $route->any('roleMiddleGroundDetail', 'Api\RoleMiddleGroudController@roleDetail');
-    $route->any('roleMiddleGroundMenu', 'Api\RoleMiddleGroudController@roleMenu');
-
     //优先级
     $route->any('priorityList', 'Api\PriorityController@priorityList');
     $route->any('priorityEdit', 'Api\PriorityController@priorityEdit');
@@ -107,6 +99,13 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('priorityDel', 'Api\PriorityController@priorityDel');
     $route->any('priorityDetail', 'Api\PriorityController@priorityDetail');
 
+    //团队
+    $route->any('teamList', 'Api\TeamController@teamList');
+    $route->any('teamEdit', 'Api\TeamController@teamEdit');
+    $route->any('teamAdd', 'Api\TeamController@teamAdd');
+    $route->any('teamDel', 'Api\TeamController@teamDel');
+    $route->any('teamDetail', 'Api\TeamController@teamDetail');
+
     //费用类型
     $route->any('feeAdd', 'Api\FeeController@feeAdd')->name('fee.add');
     $route->any('feeEdit', 'Api\FeeController@feeEdit')->name('fee.edit');