사용하지 않는 파일 정리 전 백업 (Phase 10 완료 후 상태)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
/// - 전화번호 처리
|
||||
/// - 중복 회사명 체크
|
||||
/// - 회사 유형 관리
|
||||
library;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/address_model.dart';
|
||||
@@ -15,7 +16,6 @@ import 'package:superport/models/company_model.dart';
|
||||
// import 'package:superport/services/mock_data_service.dart'; // Mock 서비스 제거
|
||||
import 'package:superport/services/company_service.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
import 'package:superport/utils/phone_utils.dart';
|
||||
import 'dart:async';
|
||||
import 'branch_form_controller.dart'; // 분리된 지점 컨트롤러 import
|
||||
|
||||
@@ -42,6 +42,10 @@ class CompanyFormController {
|
||||
|
||||
// 회사 유형 선택값 (복수)
|
||||
List<CompanyType> selectedCompanyTypes = [CompanyType.customer];
|
||||
|
||||
// 부모 회사 선택
|
||||
int? selectedParentCompanyId;
|
||||
List<Company> availableParentCompanies = [];
|
||||
|
||||
List<String> companyNames = [];
|
||||
List<String> filteredCompanyNames = [];
|
||||
@@ -96,15 +100,23 @@ class CompanyFormController {
|
||||
List<Company> companies;
|
||||
|
||||
// API만 사용 (PaginatedResponse에서 items 추출)
|
||||
final response = await _companyService.getCompanies();
|
||||
final response = await _companyService.getCompanies(page: 1, perPage: 1000);
|
||||
companies = response.items;
|
||||
|
||||
companyNames = companies.map((c) => c.name).toList();
|
||||
filteredCompanyNames = companyNames;
|
||||
|
||||
// 부모 회사 목록도 설정 (자기 자신은 제외)
|
||||
if (companyId != null) {
|
||||
availableParentCompanies = companies.where((c) => c.id != companyId).toList();
|
||||
} else {
|
||||
availableParentCompanies = companies;
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('❌ 회사명 목록 로드 실패: $e');
|
||||
companyNames = [];
|
||||
filteredCompanyNames = [];
|
||||
availableParentCompanies = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,86 +142,81 @@ class CompanyFormController {
|
||||
}
|
||||
|
||||
debugPrint('📝 로드된 회사 정보:');
|
||||
debugPrint(' - ID: ${company?.id}');
|
||||
debugPrint(' - 이름: ${company?.name}');
|
||||
debugPrint(' - 담당자: ${company?.contactName}');
|
||||
debugPrint(' - 연락처: ${company?.contactPhone}');
|
||||
debugPrint(' - 이메일: ${company?.contactEmail}');
|
||||
debugPrint(' - ID: ${company.id}');
|
||||
debugPrint(' - 이름: ${company.name}');
|
||||
debugPrint(' - 담당자: ${company.contactName}');
|
||||
debugPrint(' - 연락처: ${company.contactPhone}');
|
||||
debugPrint(' - 이메일: ${company.contactEmail}');
|
||||
|
||||
if (company != null) {
|
||||
// 폼 필드에 데이터 설정
|
||||
debugPrint('📝 회사명 설정 전: "${nameController.text}"');
|
||||
nameController.text = company.name;
|
||||
debugPrint('📝 회사명 설정 후: "${nameController.text}"');
|
||||
// 폼 필드에 데이터 설정
|
||||
debugPrint('📝 회사명 설정 전: "${nameController.text}"');
|
||||
nameController.text = company.name;
|
||||
debugPrint('📝 회사명 설정 후: "${nameController.text}"');
|
||||
|
||||
companyAddress = company.address;
|
||||
debugPrint('📝 주소 설정: $companyAddress');
|
||||
companyAddress = company.address;
|
||||
debugPrint('📝 주소 설정: $companyAddress');
|
||||
|
||||
contactNameController.text = company.contactName ?? '';
|
||||
debugPrint('📝 담당자명 설정: "${contactNameController.text}"');
|
||||
contactNameController.text = company.contactName ?? '';
|
||||
debugPrint('📝 담당자명 설정: "${contactNameController.text}"');
|
||||
|
||||
contactPositionController.text = company.contactPosition ?? '';
|
||||
debugPrint('📝 직급 설정: "${contactPositionController.text}"');
|
||||
contactPositionController.text = company.contactPosition ?? '';
|
||||
debugPrint('📝 직급 설정: "${contactPositionController.text}"');
|
||||
|
||||
contactEmailController.text = company.contactEmail ?? '';
|
||||
debugPrint('📝 이메일 설정: "${contactEmailController.text}"');
|
||||
contactEmailController.text = company.contactEmail ?? '';
|
||||
debugPrint('📝 이메일 설정: "${contactEmailController.text}"');
|
||||
|
||||
remarkController.text = company.remark ?? '';
|
||||
debugPrint('📝 비고 설정: "${remarkController.text}"');
|
||||
remarkController.text = company.remark ?? '';
|
||||
debugPrint('📝 비고 설정: "${remarkController.text}"');
|
||||
|
||||
// 전화번호 처리
|
||||
if (company.contactPhone != null && company.contactPhone!.isNotEmpty) {
|
||||
selectedPhonePrefix = extractPhonePrefix(
|
||||
company.contactPhone!,
|
||||
phonePrefixes,
|
||||
);
|
||||
contactPhoneController.text = extractPhoneNumberWithoutPrefix(
|
||||
company.contactPhone!,
|
||||
phonePrefixes,
|
||||
);
|
||||
debugPrint('📝 전화번호 설정: $selectedPhonePrefix-${contactPhoneController.text}');
|
||||
}
|
||||
|
||||
// 회사 유형 설정
|
||||
selectedCompanyTypes = List.from(company.companyTypes);
|
||||
debugPrint('📝 회사 유형 설정: $selectedCompanyTypes');
|
||||
|
||||
// 지점 정보 설정
|
||||
if (company.branches != null && company.branches!.isNotEmpty) {
|
||||
branchControllers.clear();
|
||||
for (final branch in company.branches!) {
|
||||
branchControllers.add(
|
||||
BranchFormController(
|
||||
branch: branch,
|
||||
positions: positions,
|
||||
phonePrefixes: phonePrefixes,
|
||||
),
|
||||
);
|
||||
}
|
||||
debugPrint('📝 지점 설정 완료: ${branchControllers.length}개');
|
||||
}
|
||||
|
||||
debugPrint('📝 폼 필드 설정 완료:');
|
||||
debugPrint(' - 회사명: "${nameController.text}"');
|
||||
debugPrint(' - 담당자: "${contactNameController.text}"');
|
||||
debugPrint(' - 이메일: "${contactEmailController.text}"');
|
||||
debugPrint(' - 전화번호: "$selectedPhonePrefix-${contactPhoneController.text}"');
|
||||
debugPrint(' - 지점 수: ${branchControllers.length}');
|
||||
debugPrint(' - 회사 유형: $selectedCompanyTypes');
|
||||
|
||||
// 강제로 TextEditingController 리스너 트리거
|
||||
nameController.notifyListeners();
|
||||
contactNameController.notifyListeners();
|
||||
contactPositionController.notifyListeners();
|
||||
contactEmailController.notifyListeners();
|
||||
contactPhoneController.notifyListeners();
|
||||
remarkController.notifyListeners();
|
||||
|
||||
debugPrint('✅ 폼 데이터 로드 완료');
|
||||
} else {
|
||||
debugPrint('❌ 회사 정보가 null입니다');
|
||||
// 전화번호 처리
|
||||
if (company.contactPhone != null && company.contactPhone!.isNotEmpty) {
|
||||
selectedPhonePrefix = extractPhonePrefix(
|
||||
company.contactPhone!,
|
||||
phonePrefixes,
|
||||
);
|
||||
contactPhoneController.text = extractPhoneNumberWithoutPrefix(
|
||||
company.contactPhone!,
|
||||
phonePrefixes,
|
||||
);
|
||||
debugPrint('📝 전화번호 설정: $selectedPhonePrefix-${contactPhoneController.text}');
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
|
||||
// 회사 유형 설정
|
||||
selectedCompanyTypes = List.from(company.companyTypes);
|
||||
debugPrint('📝 회사 유형 설정: $selectedCompanyTypes');
|
||||
|
||||
// 부모 회사 설정
|
||||
selectedParentCompanyId = company.parentCompanyId;
|
||||
debugPrint('📝 부모 회사 설정: $selectedParentCompanyId');
|
||||
|
||||
// 지점 정보 설정
|
||||
if (company.branches != null && company.branches!.isNotEmpty) {
|
||||
branchControllers.clear();
|
||||
for (final branch in company.branches!) {
|
||||
branchControllers.add(
|
||||
BranchFormController(
|
||||
branch: branch,
|
||||
positions: positions,
|
||||
phonePrefixes: phonePrefixes,
|
||||
),
|
||||
);
|
||||
}
|
||||
debugPrint('📝 지점 설정 완료: ${branchControllers.length}개');
|
||||
}
|
||||
|
||||
debugPrint('📝 폼 필드 설정 완료:');
|
||||
debugPrint(' - 회사명: "${nameController.text}"');
|
||||
debugPrint(' - 담당자: "${contactNameController.text}"');
|
||||
debugPrint(' - 이메일: "${contactEmailController.text}"');
|
||||
debugPrint(' - 전화번호: "$selectedPhonePrefix-${contactPhoneController.text}"');
|
||||
debugPrint(' - 지점 수: ${branchControllers.length}');
|
||||
debugPrint(' - 회사 유형: $selectedCompanyTypes');
|
||||
|
||||
// TextEditingController는 text 설정 시 자동으로 리스너 트리거됨
|
||||
// notifyListeners() 직접 호출은 불필요하고 부적절함
|
||||
|
||||
debugPrint('✅ 폼 데이터 로드 완료');
|
||||
} catch (e, stackTrace) {
|
||||
debugPrint('❌ 회사 정보 로드 실패: $e');
|
||||
debugPrint('❌ 스택 트레이스: $stackTrace');
|
||||
rethrow;
|
||||
@@ -356,6 +363,7 @@ class CompanyFormController {
|
||||
companyTypes: List.from(selectedCompanyTypes), // 복수 유형 저장
|
||||
isPartner: selectedCompanyTypes.contains(CompanyType.partner),
|
||||
isCustomer: selectedCompanyTypes.contains(CompanyType.customer),
|
||||
parentCompanyId: selectedParentCompanyId, // 부모 회사 ID 추가
|
||||
);
|
||||
|
||||
if (_useApi) {
|
||||
|
||||
Reference in New Issue
Block a user